babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950157951157952157953157954157955157956157957157958157959157960157961157962157963157964157965157966157967157968157969157970157971157972157973157974157975157976157977157978157979157980157981157982157983157984157985157986157987157988157989157990157991157992157993157994157995157996157997157998157999158000158001158002158003158004158005158006158007158008158009158010158011158012158013158014158015158016158017158018158019158020158021158022158023158024158025158026158027158028158029158030158031158032158033158034158035158036158037158038158039158040158041158042158043158044158045158046158047158048158049158050158051158052158053158054158055158056158057158058158059158060158061158062158063158064158065158066158067158068158069158070158071158072158073158074158075158076158077158078158079158080
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. /**
  95. * User defined information that will be sent to observers
  96. */
  97. userInfo?: any;
  98. }
  99. /**
  100. * Represent an Observer registered to a given Observable object.
  101. */
  102. export class Observer<T> {
  103. /**
  104. * Defines the callback to call when the observer is notified
  105. */
  106. callback: (eventData: T, eventState: EventState) => void;
  107. /**
  108. * Defines the mask of the observer (used to filter notifications)
  109. */
  110. mask: number;
  111. /**
  112. * Defines the current scope used to restore the JS context
  113. */
  114. scope: any;
  115. /** @hidden */
  116. _willBeUnregistered: boolean;
  117. /**
  118. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  119. */
  120. unregisterOnNextCall: boolean;
  121. /**
  122. * Creates a new observer
  123. * @param callback defines the callback to call when the observer is notified
  124. * @param mask defines the mask of the observer (used to filter notifications)
  125. * @param scope defines the current scope used to restore the JS context
  126. */
  127. constructor(
  128. /**
  129. * Defines the callback to call when the observer is notified
  130. */
  131. callback: (eventData: T, eventState: EventState) => void,
  132. /**
  133. * Defines the mask of the observer (used to filter notifications)
  134. */
  135. mask: number,
  136. /**
  137. * Defines the current scope used to restore the JS context
  138. */
  139. scope?: any);
  140. }
  141. /**
  142. * Represent a list of observers registered to multiple Observables object.
  143. */
  144. export class MultiObserver<T> {
  145. private _observers;
  146. private _observables;
  147. /**
  148. * Release associated resources
  149. */
  150. dispose(): void;
  151. /**
  152. * Raise a callback when one of the observable will notify
  153. * @param observables defines a list of observables to watch
  154. * @param callback defines the callback to call on notification
  155. * @param mask defines the mask used to filter notifications
  156. * @param scope defines the current scope used to restore the JS context
  157. * @returns the new MultiObserver
  158. */
  159. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  160. }
  161. /**
  162. * The Observable class is a simple implementation of the Observable pattern.
  163. *
  164. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  165. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  166. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  167. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  168. */
  169. export class Observable<T> {
  170. private _observers;
  171. private _eventState;
  172. private _onObserverAdded;
  173. /**
  174. * Gets the list of observers
  175. */
  176. get observers(): Array<Observer<T>>;
  177. /**
  178. * Creates a new observable
  179. * @param onObserverAdded defines a callback to call when a new observer is added
  180. */
  181. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  182. /**
  183. * Create a new Observer with the specified callback
  184. * @param callback the callback that will be executed for that Observer
  185. * @param mask the mask used to filter observers
  186. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  187. * @param scope optional scope for the callback to be called from
  188. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  189. * @returns the new observer created for the callback
  190. */
  191. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  192. /**
  193. * Create a new Observer with the specified callback and unregisters after the next notification
  194. * @param callback the callback that will be executed for that Observer
  195. * @returns the new observer created for the callback
  196. */
  197. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  198. /**
  199. * Remove an Observer from the Observable object
  200. * @param observer the instance of the Observer to remove
  201. * @returns false if it doesn't belong to this Observable
  202. */
  203. remove(observer: Nullable<Observer<T>>): boolean;
  204. /**
  205. * Remove a callback from the Observable object
  206. * @param callback the callback to remove
  207. * @param scope optional scope. If used only the callbacks with this scope will be removed
  208. * @returns false if it doesn't belong to this Observable
  209. */
  210. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  211. private _deferUnregister;
  212. private _remove;
  213. /**
  214. * Moves the observable to the top of the observer list making it get called first when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverTopPriority(observer: Observer<T>): void;
  218. /**
  219. * Moves the observable to the bottom of the observer list making it get called last when notified
  220. * @param observer the observer to move
  221. */
  222. makeObserverBottomPriority(observer: Observer<T>): void;
  223. /**
  224. * Notify all Observers by calling their respective callback with the given data
  225. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  226. * @param eventData defines the data to send to all observers
  227. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  228. * @param target defines the original target of the state
  229. * @param currentTarget defines the current target of the state
  230. * @param userInfo defines any user info to send to observers
  231. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  232. */
  233. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  234. /**
  235. * Calling this will execute each callback, expecting it to be a promise or return a value.
  236. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  237. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  238. * and it is crucial that all callbacks will be executed.
  239. * The order of the callbacks is kept, callbacks are not executed parallel.
  240. *
  241. * @param eventData The data to be sent to each callback
  242. * @param mask is used to filter observers defaults to -1
  243. * @param target defines the callback target (see EventState)
  244. * @param currentTarget defines he current object in the bubbling phase
  245. * @param userInfo defines any user info to send to observers
  246. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  247. */
  248. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  249. /**
  250. * Notify a specific observer
  251. * @param observer defines the observer to notify
  252. * @param eventData defines the data to be sent to each callback
  253. * @param mask is used to filter observers defaults to -1
  254. */
  255. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  256. /**
  257. * Gets a boolean indicating if the observable has at least one observer
  258. * @returns true is the Observable has at least one Observer registered
  259. */
  260. hasObservers(): boolean;
  261. /**
  262. * Clear the list of observers
  263. */
  264. clear(): void;
  265. /**
  266. * Clone the current observable
  267. * @returns a new observable
  268. */
  269. clone(): Observable<T>;
  270. /**
  271. * Does this observable handles observer registered with a given mask
  272. * @param mask defines the mask to be tested
  273. * @return whether or not one observer registered with the given mask is handeled
  274. **/
  275. hasSpecificMask(mask?: number): boolean;
  276. }
  277. }
  278. declare module "babylonjs/Misc/domManagement" {
  279. /**
  280. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  281. * Babylon.js
  282. */
  283. export class DomManagement {
  284. /**
  285. * Checks if the window object exists
  286. * @returns true if the window object exists
  287. */
  288. static IsWindowObjectExist(): boolean;
  289. /**
  290. * Checks if the navigator object exists
  291. * @returns true if the navigator object exists
  292. */
  293. static IsNavigatorAvailable(): boolean;
  294. /**
  295. * Check if the document object exists
  296. * @returns true if the document object exists
  297. */
  298. static IsDocumentAvailable(): boolean;
  299. /**
  300. * Extracts text content from a DOM element hierarchy
  301. * @param element defines the root element
  302. * @returns a string
  303. */
  304. static GetDOMTextContent(element: HTMLElement): string;
  305. }
  306. }
  307. declare module "babylonjs/Misc/logger" {
  308. /**
  309. * Logger used througouht the application to allow configuration of
  310. * the log level required for the messages.
  311. */
  312. export class Logger {
  313. /**
  314. * No log
  315. */
  316. static readonly NoneLogLevel: number;
  317. /**
  318. * Only message logs
  319. */
  320. static readonly MessageLogLevel: number;
  321. /**
  322. * Only warning logs
  323. */
  324. static readonly WarningLogLevel: number;
  325. /**
  326. * Only error logs
  327. */
  328. static readonly ErrorLogLevel: number;
  329. /**
  330. * All logs
  331. */
  332. static readonly AllLogLevel: number;
  333. private static _LogCache;
  334. /**
  335. * Gets a value indicating the number of loading errors
  336. * @ignorenaming
  337. */
  338. static errorsCount: number;
  339. /**
  340. * Callback called when a new log is added
  341. */
  342. static OnNewCacheEntry: (entry: string) => void;
  343. private static _AddLogEntry;
  344. private static _FormatMessage;
  345. private static _LogDisabled;
  346. private static _LogEnabled;
  347. private static _WarnDisabled;
  348. private static _WarnEnabled;
  349. private static _ErrorDisabled;
  350. private static _ErrorEnabled;
  351. /**
  352. * Log a message to the console
  353. */
  354. static Log: (message: string) => void;
  355. /**
  356. * Write a warning message to the console
  357. */
  358. static Warn: (message: string) => void;
  359. /**
  360. * Write an error message to the console
  361. */
  362. static Error: (message: string) => void;
  363. /**
  364. * Gets current log cache (list of logs)
  365. */
  366. static get LogCache(): string;
  367. /**
  368. * Clears the log cache
  369. */
  370. static ClearLogCache(): void;
  371. /**
  372. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  373. */
  374. static set LogLevels(level: number);
  375. }
  376. }
  377. declare module "babylonjs/Misc/typeStore" {
  378. /** @hidden */
  379. export class _TypeStore {
  380. /** @hidden */
  381. static RegisteredTypes: {
  382. [key: string]: Object;
  383. };
  384. /** @hidden */
  385. static GetClass(fqdn: string): any;
  386. }
  387. }
  388. declare module "babylonjs/Misc/stringTools" {
  389. /**
  390. * Helper to manipulate strings
  391. */
  392. export class StringTools {
  393. /**
  394. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static EndsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  402. * @param str Source string
  403. * @param suffix Suffix to search for in the source string
  404. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  405. */
  406. static StartsWith(str: string, suffix: string): boolean;
  407. /**
  408. * Decodes a buffer into a string
  409. * @param buffer The buffer to decode
  410. * @returns The decoded string
  411. */
  412. static Decode(buffer: Uint8Array | Uint16Array): string;
  413. /**
  414. * Encode a buffer to a base64 string
  415. * @param buffer defines the buffer to encode
  416. * @returns the encoded string
  417. */
  418. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  419. /**
  420. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  421. * @param num the number to convert and pad
  422. * @param length the expected length of the string
  423. * @returns the padded string
  424. */
  425. static PadNumber(num: number, length: number): string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/deepCopier" {
  429. /**
  430. * Class containing a set of static utilities functions for deep copy.
  431. */
  432. export class DeepCopier {
  433. /**
  434. * Tries to copy an object by duplicating every property
  435. * @param source defines the source object
  436. * @param destination defines the target object
  437. * @param doNotCopyList defines a list of properties to avoid
  438. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  439. */
  440. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  441. }
  442. }
  443. declare module "babylonjs/Misc/precisionDate" {
  444. /**
  445. * Class containing a set of static utilities functions for precision date
  446. */
  447. export class PrecisionDate {
  448. /**
  449. * Gets either window.performance.now() if supported or Date.now() else
  450. */
  451. static get Now(): number;
  452. }
  453. }
  454. declare module "babylonjs/Misc/devTools" {
  455. /** @hidden */
  456. export class _DevTools {
  457. static WarnImport(name: string): string;
  458. }
  459. }
  460. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  461. /**
  462. * Interface used to define the mechanism to get data from the network
  463. */
  464. export interface IWebRequest {
  465. /**
  466. * Returns client's response url
  467. */
  468. responseURL: string;
  469. /**
  470. * Returns client's status
  471. */
  472. status: number;
  473. /**
  474. * Returns client's status as a text
  475. */
  476. statusText: string;
  477. }
  478. }
  479. declare module "babylonjs/Misc/webRequest" {
  480. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  481. import { Nullable } from "babylonjs/types";
  482. /**
  483. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  484. */
  485. export class WebRequest implements IWebRequest {
  486. private _xhr;
  487. /**
  488. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  489. * i.e. when loading files, where the server/service expects an Authorization header
  490. */
  491. static CustomRequestHeaders: {
  492. [key: string]: string;
  493. };
  494. /**
  495. * Add callback functions in this array to update all the requests before they get sent to the network
  496. */
  497. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  498. private _injectCustomRequestHeaders;
  499. /**
  500. * Gets or sets a function to be called when loading progress changes
  501. */
  502. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  503. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  504. /**
  505. * Returns client's state
  506. */
  507. get readyState(): number;
  508. /**
  509. * Returns client's status
  510. */
  511. get status(): number;
  512. /**
  513. * Returns client's status as a text
  514. */
  515. get statusText(): string;
  516. /**
  517. * Returns client's response
  518. */
  519. get response(): any;
  520. /**
  521. * Returns client's response url
  522. */
  523. get responseURL(): string;
  524. /**
  525. * Returns client's response as text
  526. */
  527. get responseText(): string;
  528. /**
  529. * Gets or sets the expected response type
  530. */
  531. get responseType(): XMLHttpRequestResponseType;
  532. set responseType(value: XMLHttpRequestResponseType);
  533. /** @hidden */
  534. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  535. /** @hidden */
  536. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  537. /**
  538. * Cancels any network activity
  539. */
  540. abort(): void;
  541. /**
  542. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  543. * @param body defines an optional request body
  544. */
  545. send(body?: Document | BodyInit | null): void;
  546. /**
  547. * Sets the request method, request URL
  548. * @param method defines the method to use (GET, POST, etc..)
  549. * @param url defines the url to connect with
  550. */
  551. open(method: string, url: string): void;
  552. /**
  553. * Sets the value of a request header.
  554. * @param name The name of the header whose value is to be set
  555. * @param value The value to set as the body of the header
  556. */
  557. setRequestHeader(name: string, value: string): void;
  558. /**
  559. * Get the string containing the text of a particular header's value.
  560. * @param name The name of the header
  561. * @returns The string containing the text of the given header name
  562. */
  563. getResponseHeader(name: string): Nullable<string>;
  564. }
  565. }
  566. declare module "babylonjs/Misc/fileRequest" {
  567. import { Observable } from "babylonjs/Misc/observable";
  568. /**
  569. * File request interface
  570. */
  571. export interface IFileRequest {
  572. /**
  573. * Raised when the request is complete (success or error).
  574. */
  575. onCompleteObservable: Observable<IFileRequest>;
  576. /**
  577. * Aborts the request for a file.
  578. */
  579. abort: () => void;
  580. }
  581. }
  582. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  583. /**
  584. * Define options used to create a render target texture
  585. */
  586. export class RenderTargetCreationOptions {
  587. /**
  588. * Specifies is mipmaps must be generated
  589. */
  590. generateMipMaps?: boolean;
  591. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  592. generateDepthBuffer?: boolean;
  593. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  594. generateStencilBuffer?: boolean;
  595. /** Defines texture type (int by default) */
  596. type?: number;
  597. /** Defines sampling mode (trilinear by default) */
  598. samplingMode?: number;
  599. /** Defines format (RGBA by default) */
  600. format?: number;
  601. }
  602. }
  603. declare module "babylonjs/Engines/constants" {
  604. /** Defines the cross module used constants to avoid circular dependncies */
  605. export class Constants {
  606. /** Defines that alpha blending is disabled */
  607. static readonly ALPHA_DISABLE: number;
  608. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  609. static readonly ALPHA_ADD: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_COMBINE: number;
  612. /** Defines that alpha blending is DEST - SRC * DEST */
  613. static readonly ALPHA_SUBTRACT: number;
  614. /** Defines that alpha blending is SRC * DEST */
  615. static readonly ALPHA_MULTIPLY: number;
  616. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  617. static readonly ALPHA_MAXIMIZED: number;
  618. /** Defines that alpha blending is SRC + DEST */
  619. static readonly ALPHA_ONEONE: number;
  620. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  621. static readonly ALPHA_PREMULTIPLIED: number;
  622. /**
  623. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  624. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  625. */
  626. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  627. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  628. static readonly ALPHA_INTERPOLATE: number;
  629. /**
  630. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  631. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  632. */
  633. static readonly ALPHA_SCREENMODE: number;
  634. /**
  635. * Defines that alpha blending is SRC + DST
  636. * Alpha will be set to SRC ALPHA + DST ALPHA
  637. */
  638. static readonly ALPHA_ONEONE_ONEONE: number;
  639. /**
  640. * Defines that alpha blending is SRC * DST ALPHA + DST
  641. * Alpha will be set to 0
  642. */
  643. static readonly ALPHA_ALPHATOCOLOR: number;
  644. /**
  645. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  646. */
  647. static readonly ALPHA_REVERSEONEMINUS: number;
  648. /**
  649. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  650. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  651. */
  652. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  653. /**
  654. * Defines that alpha blending is SRC + DST
  655. * Alpha will be set to SRC ALPHA
  656. */
  657. static readonly ALPHA_ONEONE_ONEZERO: number;
  658. /**
  659. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  660. * Alpha will be set to DST ALPHA
  661. */
  662. static readonly ALPHA_EXCLUSION: number;
  663. /** Defines that alpha blending equation a SUM */
  664. static readonly ALPHA_EQUATION_ADD: number;
  665. /** Defines that alpha blending equation a SUBSTRACTION */
  666. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  667. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  668. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  669. /** Defines that alpha blending equation a MAX operation */
  670. static readonly ALPHA_EQUATION_MAX: number;
  671. /** Defines that alpha blending equation a MIN operation */
  672. static readonly ALPHA_EQUATION_MIN: number;
  673. /**
  674. * Defines that alpha blending equation a DARKEN operation:
  675. * It takes the min of the src and sums the alpha channels.
  676. */
  677. static readonly ALPHA_EQUATION_DARKEN: number;
  678. /** Defines that the ressource is not delayed*/
  679. static readonly DELAYLOADSTATE_NONE: number;
  680. /** Defines that the ressource was successfully delay loaded */
  681. static readonly DELAYLOADSTATE_LOADED: number;
  682. /** Defines that the ressource is currently delay loading */
  683. static readonly DELAYLOADSTATE_LOADING: number;
  684. /** Defines that the ressource is delayed and has not started loading */
  685. static readonly DELAYLOADSTATE_NOTLOADED: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  687. static readonly NEVER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  689. static readonly ALWAYS: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  691. static readonly LESS: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  693. static readonly EQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  695. static readonly LEQUAL: number;
  696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  697. static readonly GREATER: number;
  698. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  699. static readonly GEQUAL: number;
  700. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  701. static readonly NOTEQUAL: number;
  702. /** Passed to stencilOperation to specify that stencil value must be kept */
  703. static readonly KEEP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be replaced */
  705. static readonly REPLACE: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented */
  707. static readonly INCR: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented */
  709. static readonly DECR: number;
  710. /** Passed to stencilOperation to specify that stencil value must be inverted */
  711. static readonly INVERT: number;
  712. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  713. static readonly INCR_WRAP: number;
  714. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  715. static readonly DECR_WRAP: number;
  716. /** Texture is not repeating outside of 0..1 UVs */
  717. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  718. /** Texture is repeating outside of 0..1 UVs */
  719. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  720. /** Texture is repeating and mirrored */
  721. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  722. /** ALPHA */
  723. static readonly TEXTUREFORMAT_ALPHA: number;
  724. /** LUMINANCE */
  725. static readonly TEXTUREFORMAT_LUMINANCE: number;
  726. /** LUMINANCE_ALPHA */
  727. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  728. /** RGB */
  729. static readonly TEXTUREFORMAT_RGB: number;
  730. /** RGBA */
  731. static readonly TEXTUREFORMAT_RGBA: number;
  732. /** RED */
  733. static readonly TEXTUREFORMAT_RED: number;
  734. /** RED (2nd reference) */
  735. static readonly TEXTUREFORMAT_R: number;
  736. /** RG */
  737. static readonly TEXTUREFORMAT_RG: number;
  738. /** RED_INTEGER */
  739. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  740. /** RED_INTEGER (2nd reference) */
  741. static readonly TEXTUREFORMAT_R_INTEGER: number;
  742. /** RG_INTEGER */
  743. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  744. /** RGB_INTEGER */
  745. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  746. /** RGBA_INTEGER */
  747. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  748. /** UNSIGNED_BYTE */
  749. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  750. /** UNSIGNED_BYTE (2nd reference) */
  751. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  752. /** FLOAT */
  753. static readonly TEXTURETYPE_FLOAT: number;
  754. /** HALF_FLOAT */
  755. static readonly TEXTURETYPE_HALF_FLOAT: number;
  756. /** BYTE */
  757. static readonly TEXTURETYPE_BYTE: number;
  758. /** SHORT */
  759. static readonly TEXTURETYPE_SHORT: number;
  760. /** UNSIGNED_SHORT */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  762. /** INT */
  763. static readonly TEXTURETYPE_INT: number;
  764. /** UNSIGNED_INT */
  765. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  766. /** UNSIGNED_SHORT_4_4_4_4 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  768. /** UNSIGNED_SHORT_5_5_5_1 */
  769. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  770. /** UNSIGNED_SHORT_5_6_5 */
  771. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  772. /** UNSIGNED_INT_2_10_10_10_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  774. /** UNSIGNED_INT_24_8 */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  776. /** UNSIGNED_INT_10F_11F_11F_REV */
  777. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  778. /** UNSIGNED_INT_5_9_9_9_REV */
  779. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  780. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  781. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  782. /** nearest is mag = nearest and min = nearest and no mip */
  783. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  784. /** mag = nearest and min = nearest and mip = none */
  785. static readonly TEXTURE_NEAREST_NEAREST: number;
  786. /** Bilinear is mag = linear and min = linear and no mip */
  787. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  788. /** mag = linear and min = linear and mip = none */
  789. static readonly TEXTURE_LINEAR_LINEAR: number;
  790. /** Trilinear is mag = linear and min = linear and mip = linear */
  791. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  792. /** Trilinear is mag = linear and min = linear and mip = linear */
  793. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = nearest and mip = nearest */
  795. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  796. /** mag = nearest and min = linear and mip = nearest */
  797. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  798. /** mag = nearest and min = linear and mip = linear */
  799. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  800. /** mag = nearest and min = linear and mip = none */
  801. static readonly TEXTURE_NEAREST_LINEAR: number;
  802. /** nearest is mag = nearest and min = nearest and mip = linear */
  803. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  804. /** mag = linear and min = nearest and mip = nearest */
  805. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = linear */
  807. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  808. /** Bilinear is mag = linear and min = linear and mip = nearest */
  809. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  810. /** mag = linear and min = nearest and mip = none */
  811. static readonly TEXTURE_LINEAR_NEAREST: number;
  812. /** Explicit coordinates mode */
  813. static readonly TEXTURE_EXPLICIT_MODE: number;
  814. /** Spherical coordinates mode */
  815. static readonly TEXTURE_SPHERICAL_MODE: number;
  816. /** Planar coordinates mode */
  817. static readonly TEXTURE_PLANAR_MODE: number;
  818. /** Cubic coordinates mode */
  819. static readonly TEXTURE_CUBIC_MODE: number;
  820. /** Projection coordinates mode */
  821. static readonly TEXTURE_PROJECTION_MODE: number;
  822. /** Skybox coordinates mode */
  823. static readonly TEXTURE_SKYBOX_MODE: number;
  824. /** Inverse Cubic coordinates mode */
  825. static readonly TEXTURE_INVCUBIC_MODE: number;
  826. /** Equirectangular coordinates mode */
  827. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  828. /** Equirectangular Fixed coordinates mode */
  829. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  830. /** Equirectangular Fixed Mirrored coordinates mode */
  831. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  832. /** Offline (baking) quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  834. /** High quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  836. /** Medium quality for texture filtering */
  837. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  838. /** Low quality for texture filtering */
  839. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  840. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  841. static readonly SCALEMODE_FLOOR: number;
  842. /** Defines that texture rescaling will look for the nearest power of 2 size */
  843. static readonly SCALEMODE_NEAREST: number;
  844. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  845. static readonly SCALEMODE_CEILING: number;
  846. /**
  847. * The dirty texture flag value
  848. */
  849. static readonly MATERIAL_TextureDirtyFlag: number;
  850. /**
  851. * The dirty light flag value
  852. */
  853. static readonly MATERIAL_LightDirtyFlag: number;
  854. /**
  855. * The dirty fresnel flag value
  856. */
  857. static readonly MATERIAL_FresnelDirtyFlag: number;
  858. /**
  859. * The dirty attribute flag value
  860. */
  861. static readonly MATERIAL_AttributesDirtyFlag: number;
  862. /**
  863. * The dirty misc flag value
  864. */
  865. static readonly MATERIAL_MiscDirtyFlag: number;
  866. /**
  867. * The dirty prepass flag value
  868. */
  869. static readonly MATERIAL_PrePassDirtyFlag: number;
  870. /**
  871. * The all dirty flag value
  872. */
  873. static readonly MATERIAL_AllDirtyFlag: number;
  874. /**
  875. * Returns the triangle fill mode
  876. */
  877. static readonly MATERIAL_TriangleFillMode: number;
  878. /**
  879. * Returns the wireframe mode
  880. */
  881. static readonly MATERIAL_WireFrameFillMode: number;
  882. /**
  883. * Returns the point fill mode
  884. */
  885. static readonly MATERIAL_PointFillMode: number;
  886. /**
  887. * Returns the point list draw mode
  888. */
  889. static readonly MATERIAL_PointListDrawMode: number;
  890. /**
  891. * Returns the line list draw mode
  892. */
  893. static readonly MATERIAL_LineListDrawMode: number;
  894. /**
  895. * Returns the line loop draw mode
  896. */
  897. static readonly MATERIAL_LineLoopDrawMode: number;
  898. /**
  899. * Returns the line strip draw mode
  900. */
  901. static readonly MATERIAL_LineStripDrawMode: number;
  902. /**
  903. * Returns the triangle strip draw mode
  904. */
  905. static readonly MATERIAL_TriangleStripDrawMode: number;
  906. /**
  907. * Returns the triangle fan draw mode
  908. */
  909. static readonly MATERIAL_TriangleFanDrawMode: number;
  910. /**
  911. * Stores the clock-wise side orientation
  912. */
  913. static readonly MATERIAL_ClockWiseSideOrientation: number;
  914. /**
  915. * Stores the counter clock-wise side orientation
  916. */
  917. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  918. /**
  919. * Nothing
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_NothingTrigger: number;
  923. /**
  924. * On pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickTrigger: number;
  928. /**
  929. * On left pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnLeftPickTrigger: number;
  933. /**
  934. * On right pick
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnRightPickTrigger: number;
  938. /**
  939. * On center pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnCenterPickTrigger: number;
  943. /**
  944. * On pick down
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickDownTrigger: number;
  948. /**
  949. * On double pick
  950. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  951. */
  952. static readonly ACTION_OnDoublePickTrigger: number;
  953. /**
  954. * On pick up
  955. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  956. */
  957. static readonly ACTION_OnPickUpTrigger: number;
  958. /**
  959. * On pick out.
  960. * This trigger will only be raised if you also declared a OnPickDown
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPickOutTrigger: number;
  964. /**
  965. * On long press
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnLongPressTrigger: number;
  969. /**
  970. * On pointer over
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnPointerOverTrigger: number;
  974. /**
  975. * On pointer out
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnPointerOutTrigger: number;
  979. /**
  980. * On every frame
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnEveryFrameTrigger: number;
  984. /**
  985. * On intersection enter
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnIntersectionEnterTrigger: number;
  989. /**
  990. * On intersection exit
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnIntersectionExitTrigger: number;
  994. /**
  995. * On key down
  996. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  997. */
  998. static readonly ACTION_OnKeyDownTrigger: number;
  999. /**
  1000. * On key up
  1001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1002. */
  1003. static readonly ACTION_OnKeyUpTrigger: number;
  1004. /**
  1005. * Billboard mode will only apply to Y axis
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1008. /**
  1009. * Billboard mode will apply to all axes
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1012. /**
  1013. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1014. */
  1015. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1016. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1017. * Test order :
  1018. * Is the bounding sphere outside the frustum ?
  1019. * If not, are the bounding box vertices outside the frustum ?
  1020. * It not, then the cullable object is in the frustum.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1023. /** Culling strategy : Bounding Sphere Only.
  1024. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1025. * It's also less accurate than the standard because some not visible objects can still be selected.
  1026. * Test : is the bounding sphere outside the frustum ?
  1027. * If not, then the cullable object is in the frustum.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1030. /** Culling strategy : Optimistic Inclusion.
  1031. * This in an inclusion test first, then the standard exclusion test.
  1032. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1034. * Anyway, it's as accurate as the standard strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the default culling strategy.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1040. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1041. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1042. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1043. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1044. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1045. * Test :
  1046. * Is the cullable object bounding sphere center in the frustum ?
  1047. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1048. */
  1049. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1050. /**
  1051. * No logging while loading
  1052. */
  1053. static readonly SCENELOADER_NO_LOGGING: number;
  1054. /**
  1055. * Minimal logging while loading
  1056. */
  1057. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1058. /**
  1059. * Summary logging while loading
  1060. */
  1061. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1062. /**
  1063. * Detailled logging while loading
  1064. */
  1065. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1066. /**
  1067. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1068. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1069. */
  1070. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1071. /**
  1072. * Constant used to retrieve the position texture index in the textures array in the prepass
  1073. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1074. */
  1075. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1076. /**
  1077. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1078. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1079. */
  1080. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1081. /**
  1082. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1083. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1084. */
  1085. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1086. /**
  1087. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1088. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1089. */
  1090. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1091. /**
  1092. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1093. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1094. */
  1095. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1096. /**
  1097. * Constant used to retrieve albedo index in the textures array in the prepass
  1098. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1099. */
  1100. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1101. }
  1102. }
  1103. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1104. import { Nullable } from "babylonjs/types";
  1105. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1106. /**
  1107. * This represents the required contract to create a new type of texture loader.
  1108. */
  1109. export interface IInternalTextureLoader {
  1110. /**
  1111. * Defines wether the loader supports cascade loading the different faces.
  1112. */
  1113. supportCascades: boolean;
  1114. /**
  1115. * This returns if the loader support the current file information.
  1116. * @param extension defines the file extension of the file being loaded
  1117. * @param mimeType defines the optional mime type of the file being loaded
  1118. * @returns true if the loader can load the specified file
  1119. */
  1120. canLoad(extension: string, mimeType?: string): boolean;
  1121. /**
  1122. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1123. * @param data contains the texture data
  1124. * @param texture defines the BabylonJS internal texture
  1125. * @param createPolynomials will be true if polynomials have been requested
  1126. * @param onLoad defines the callback to trigger once the texture is ready
  1127. * @param onError defines the callback to trigger in case of error
  1128. * @param options options to be passed to the loader
  1129. */
  1130. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1131. /**
  1132. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1133. * @param data contains the texture data
  1134. * @param texture defines the BabylonJS internal texture
  1135. * @param callback defines the method to call once ready to upload
  1136. * @param options options to be passed to the loader
  1137. */
  1138. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1139. }
  1140. }
  1141. declare module "babylonjs/Engines/IPipelineContext" {
  1142. /**
  1143. * Class used to store and describe the pipeline context associated with an effect
  1144. */
  1145. export interface IPipelineContext {
  1146. /**
  1147. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1148. */
  1149. isAsync: boolean;
  1150. /**
  1151. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1152. */
  1153. isReady: boolean;
  1154. /** @hidden */
  1155. _getVertexShaderCode(): string | null;
  1156. /** @hidden */
  1157. _getFragmentShaderCode(): string | null;
  1158. /** @hidden */
  1159. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1160. }
  1161. }
  1162. declare module "babylonjs/Meshes/dataBuffer" {
  1163. /**
  1164. * Class used to store gfx data (like WebGLBuffer)
  1165. */
  1166. export class DataBuffer {
  1167. /**
  1168. * Gets or sets the number of objects referencing this buffer
  1169. */
  1170. references: number;
  1171. /** Gets or sets the size of the underlying buffer */
  1172. capacity: number;
  1173. /**
  1174. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1175. */
  1176. is32Bits: boolean;
  1177. /**
  1178. * Gets the underlying buffer
  1179. */
  1180. get underlyingResource(): any;
  1181. }
  1182. }
  1183. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1184. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1185. /** @hidden */
  1186. export interface IShaderProcessor {
  1187. attributeProcessor?: (attribute: string) => string;
  1188. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1189. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1190. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1191. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1192. lineProcessor?: (line: string, isFragment: boolean) => string;
  1193. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1194. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  1195. }
  1196. }
  1197. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1198. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1199. /** @hidden */
  1200. export interface ProcessingOptions {
  1201. defines: string[];
  1202. indexParameters: any;
  1203. isFragment: boolean;
  1204. shouldUseHighPrecisionShader: boolean;
  1205. supportsUniformBuffers: boolean;
  1206. shadersRepository: string;
  1207. includesShadersStore: {
  1208. [key: string]: string;
  1209. };
  1210. processor?: IShaderProcessor;
  1211. version: string;
  1212. platformName: string;
  1213. lookForClosingBracketForUniformBuffer?: boolean;
  1214. }
  1215. }
  1216. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1217. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1218. /** @hidden */
  1219. export class ShaderCodeNode {
  1220. line: string;
  1221. children: ShaderCodeNode[];
  1222. additionalDefineKey?: string;
  1223. additionalDefineValue?: string;
  1224. isValid(preprocessors: {
  1225. [key: string]: string;
  1226. }): boolean;
  1227. process(preprocessors: {
  1228. [key: string]: string;
  1229. }, options: ProcessingOptions): string;
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1233. /** @hidden */
  1234. export class ShaderCodeCursor {
  1235. private _lines;
  1236. lineIndex: number;
  1237. get currentLine(): string;
  1238. get canRead(): boolean;
  1239. set lines(value: string[]);
  1240. }
  1241. }
  1242. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1243. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1244. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1245. /** @hidden */
  1246. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1247. process(preprocessors: {
  1248. [key: string]: string;
  1249. }, options: ProcessingOptions): string;
  1250. }
  1251. }
  1252. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1253. /** @hidden */
  1254. export class ShaderDefineExpression {
  1255. isTrue(preprocessors: {
  1256. [key: string]: string;
  1257. }): boolean;
  1258. private static _OperatorPriority;
  1259. private static _Stack;
  1260. static postfixToInfix(postfix: string[]): string;
  1261. static infixToPostfix(infix: string): string[];
  1262. }
  1263. }
  1264. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1265. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1266. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1267. /** @hidden */
  1268. export class ShaderCodeTestNode extends ShaderCodeNode {
  1269. testExpression: ShaderDefineExpression;
  1270. isValid(preprocessors: {
  1271. [key: string]: string;
  1272. }): boolean;
  1273. }
  1274. }
  1275. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1276. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1277. /** @hidden */
  1278. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1279. define: string;
  1280. not: boolean;
  1281. constructor(define: string, not?: boolean);
  1282. isTrue(preprocessors: {
  1283. [key: string]: string;
  1284. }): boolean;
  1285. }
  1286. }
  1287. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1288. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1289. /** @hidden */
  1290. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1291. leftOperand: ShaderDefineExpression;
  1292. rightOperand: ShaderDefineExpression;
  1293. isTrue(preprocessors: {
  1294. [key: string]: string;
  1295. }): boolean;
  1296. }
  1297. }
  1298. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1299. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1300. /** @hidden */
  1301. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1302. leftOperand: ShaderDefineExpression;
  1303. rightOperand: ShaderDefineExpression;
  1304. isTrue(preprocessors: {
  1305. [key: string]: string;
  1306. }): boolean;
  1307. }
  1308. }
  1309. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1310. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1311. /** @hidden */
  1312. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1313. define: string;
  1314. operand: string;
  1315. testValue: string;
  1316. constructor(define: string, operand: string, testValue: string);
  1317. isTrue(preprocessors: {
  1318. [key: string]: string;
  1319. }): boolean;
  1320. }
  1321. }
  1322. declare module "babylonjs/Offline/IOfflineProvider" {
  1323. /**
  1324. * Class used to enable access to offline support
  1325. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1326. */
  1327. export interface IOfflineProvider {
  1328. /**
  1329. * Gets a boolean indicating if scene must be saved in the database
  1330. */
  1331. enableSceneOffline: boolean;
  1332. /**
  1333. * Gets a boolean indicating if textures must be saved in the database
  1334. */
  1335. enableTexturesOffline: boolean;
  1336. /**
  1337. * Open the offline support and make it available
  1338. * @param successCallback defines the callback to call on success
  1339. * @param errorCallback defines the callback to call on error
  1340. */
  1341. open(successCallback: () => void, errorCallback: () => void): void;
  1342. /**
  1343. * Loads an image from the offline support
  1344. * @param url defines the url to load from
  1345. * @param image defines the target DOM image
  1346. */
  1347. loadImage(url: string, image: HTMLImageElement): void;
  1348. /**
  1349. * Loads a file from offline support
  1350. * @param url defines the URL to load from
  1351. * @param sceneLoaded defines a callback to call on success
  1352. * @param progressCallBack defines a callback to call when progress changed
  1353. * @param errorCallback defines a callback to call on error
  1354. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1355. */
  1356. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1357. }
  1358. }
  1359. declare module "babylonjs/Misc/filesInputStore" {
  1360. /**
  1361. * Class used to help managing file picking and drag'n'drop
  1362. * File Storage
  1363. */
  1364. export class FilesInputStore {
  1365. /**
  1366. * List of files ready to be loaded
  1367. */
  1368. static FilesToLoad: {
  1369. [key: string]: File;
  1370. };
  1371. }
  1372. }
  1373. declare module "babylonjs/Misc/retryStrategy" {
  1374. import { WebRequest } from "babylonjs/Misc/webRequest";
  1375. /**
  1376. * Class used to define a retry strategy when error happens while loading assets
  1377. */
  1378. export class RetryStrategy {
  1379. /**
  1380. * Function used to defines an exponential back off strategy
  1381. * @param maxRetries defines the maximum number of retries (3 by default)
  1382. * @param baseInterval defines the interval between retries
  1383. * @returns the strategy function to use
  1384. */
  1385. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1386. }
  1387. }
  1388. declare module "babylonjs/Misc/baseError" {
  1389. /**
  1390. * @ignore
  1391. * Application error to support additional information when loading a file
  1392. */
  1393. export abstract class BaseError extends Error {
  1394. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1395. }
  1396. }
  1397. declare module "babylonjs/Misc/fileTools" {
  1398. import { WebRequest } from "babylonjs/Misc/webRequest";
  1399. import { Nullable } from "babylonjs/types";
  1400. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1401. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1402. import { BaseError } from "babylonjs/Misc/baseError";
  1403. /** @ignore */
  1404. export class LoadFileError extends BaseError {
  1405. request?: WebRequest;
  1406. file?: File;
  1407. /**
  1408. * Creates a new LoadFileError
  1409. * @param message defines the message of the error
  1410. * @param request defines the optional web request
  1411. * @param file defines the optional file
  1412. */
  1413. constructor(message: string, object?: WebRequest | File);
  1414. }
  1415. /** @ignore */
  1416. export class RequestFileError extends BaseError {
  1417. request: WebRequest;
  1418. /**
  1419. * Creates a new LoadFileError
  1420. * @param message defines the message of the error
  1421. * @param request defines the optional web request
  1422. */
  1423. constructor(message: string, request: WebRequest);
  1424. }
  1425. /** @ignore */
  1426. export class ReadFileError extends BaseError {
  1427. file: File;
  1428. /**
  1429. * Creates a new ReadFileError
  1430. * @param message defines the message of the error
  1431. * @param file defines the optional file
  1432. */
  1433. constructor(message: string, file: File);
  1434. }
  1435. /**
  1436. * @hidden
  1437. */
  1438. export class FileTools {
  1439. /**
  1440. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1441. */
  1442. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1443. /**
  1444. * Gets or sets the base URL to use to load assets
  1445. */
  1446. static BaseUrl: string;
  1447. /**
  1448. * Default behaviour for cors in the application.
  1449. * It can be a string if the expected behavior is identical in the entire app.
  1450. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1451. */
  1452. static CorsBehavior: string | ((url: string | string[]) => string);
  1453. /**
  1454. * Gets or sets a function used to pre-process url before using them to load assets
  1455. */
  1456. static PreprocessUrl: (url: string) => string;
  1457. /**
  1458. * Removes unwanted characters from an url
  1459. * @param url defines the url to clean
  1460. * @returns the cleaned url
  1461. */
  1462. private static _CleanUrl;
  1463. /**
  1464. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1465. * @param url define the url we are trying
  1466. * @param element define the dom element where to configure the cors policy
  1467. */
  1468. static SetCorsBehavior(url: string | string[], element: {
  1469. crossOrigin: string | null;
  1470. }): void;
  1471. /**
  1472. * Loads an image as an HTMLImageElement.
  1473. * @param input url string, ArrayBuffer, or Blob to load
  1474. * @param onLoad callback called when the image successfully loads
  1475. * @param onError callback called when the image fails to load
  1476. * @param offlineProvider offline provider for caching
  1477. * @param mimeType optional mime type
  1478. * @returns the HTMLImageElement of the loaded image
  1479. */
  1480. 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>;
  1481. /**
  1482. * Reads a file from a File object
  1483. * @param file defines the file to load
  1484. * @param onSuccess defines the callback to call when data is loaded
  1485. * @param onProgress defines the callback to call during loading process
  1486. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1487. * @param onError defines the callback to call when an error occurs
  1488. * @returns a file request object
  1489. */
  1490. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1491. /**
  1492. * Loads a file from a url
  1493. * @param url url to load
  1494. * @param onSuccess callback called when the file successfully loads
  1495. * @param onProgress callback called while file is loading (if the server supports this mode)
  1496. * @param offlineProvider defines the offline provider for caching
  1497. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1498. * @param onError callback called when the file fails to load
  1499. * @returns a file request object
  1500. */
  1501. 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;
  1502. /**
  1503. * Loads a file
  1504. * @param url url to load
  1505. * @param onSuccess callback called when the file successfully loads
  1506. * @param onProgress callback called while file is loading (if the server supports this mode)
  1507. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1508. * @param onError callback called when the file fails to load
  1509. * @param onOpened callback called when the web request is opened
  1510. * @returns a file request object
  1511. */
  1512. 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;
  1513. /**
  1514. * Checks if the loaded document was accessed via `file:`-Protocol.
  1515. * @returns boolean
  1516. */
  1517. static IsFileURL(): boolean;
  1518. }
  1519. }
  1520. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1521. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1522. import { WebRequest } from "babylonjs/Misc/webRequest";
  1523. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1524. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1525. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1526. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1527. /** @hidden */
  1528. export class ShaderProcessor {
  1529. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1530. private static _ProcessPrecision;
  1531. private static _ExtractOperation;
  1532. private static _BuildSubExpression;
  1533. private static _BuildExpression;
  1534. private static _MoveCursorWithinIf;
  1535. private static _MoveCursor;
  1536. private static _EvaluatePreProcessors;
  1537. private static _PreparePreProcessors;
  1538. private static _ProcessShaderConversion;
  1539. private static _ProcessIncludes;
  1540. /**
  1541. * Loads a file from a url
  1542. * @param url url to load
  1543. * @param onSuccess callback called when the file successfully loads
  1544. * @param onProgress callback called while file is loading (if the server supports this mode)
  1545. * @param offlineProvider defines the offline provider for caching
  1546. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1547. * @param onError callback called when the file fails to load
  1548. * @returns a file request object
  1549. * @hidden
  1550. */
  1551. 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;
  1552. }
  1553. }
  1554. declare module "babylonjs/Maths/math.like" {
  1555. import { float, int, DeepImmutable } from "babylonjs/types";
  1556. /**
  1557. * @hidden
  1558. */
  1559. export interface IColor4Like {
  1560. r: float;
  1561. g: float;
  1562. b: float;
  1563. a: float;
  1564. }
  1565. /**
  1566. * @hidden
  1567. */
  1568. export interface IColor3Like {
  1569. r: float;
  1570. g: float;
  1571. b: float;
  1572. }
  1573. /**
  1574. * @hidden
  1575. */
  1576. export interface IVector4Like {
  1577. x: float;
  1578. y: float;
  1579. z: float;
  1580. w: float;
  1581. }
  1582. /**
  1583. * @hidden
  1584. */
  1585. export interface IVector3Like {
  1586. x: float;
  1587. y: float;
  1588. z: float;
  1589. }
  1590. /**
  1591. * @hidden
  1592. */
  1593. export interface IVector2Like {
  1594. x: float;
  1595. y: float;
  1596. }
  1597. /**
  1598. * @hidden
  1599. */
  1600. export interface IMatrixLike {
  1601. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1602. updateFlag: int;
  1603. }
  1604. /**
  1605. * @hidden
  1606. */
  1607. export interface IViewportLike {
  1608. x: float;
  1609. y: float;
  1610. width: float;
  1611. height: float;
  1612. }
  1613. /**
  1614. * @hidden
  1615. */
  1616. export interface IPlaneLike {
  1617. normal: IVector3Like;
  1618. d: float;
  1619. normalize(): void;
  1620. }
  1621. }
  1622. declare module "babylonjs/Materials/iEffectFallbacks" {
  1623. import { Effect } from "babylonjs/Materials/effect";
  1624. /**
  1625. * Interface used to define common properties for effect fallbacks
  1626. */
  1627. export interface IEffectFallbacks {
  1628. /**
  1629. * Removes the defines that should be removed when falling back.
  1630. * @param currentDefines defines the current define statements for the shader.
  1631. * @param effect defines the current effect we try to compile
  1632. * @returns The resulting defines with defines of the current rank removed.
  1633. */
  1634. reduce(currentDefines: string, effect: Effect): string;
  1635. /**
  1636. * Removes the fallback from the bound mesh.
  1637. */
  1638. unBindMesh(): void;
  1639. /**
  1640. * Checks to see if more fallbacks are still availible.
  1641. */
  1642. hasMoreFallbacks: boolean;
  1643. }
  1644. }
  1645. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1646. /**
  1647. * Class used to evalaute queries containing `and` and `or` operators
  1648. */
  1649. export class AndOrNotEvaluator {
  1650. /**
  1651. * Evaluate a query
  1652. * @param query defines the query to evaluate
  1653. * @param evaluateCallback defines the callback used to filter result
  1654. * @returns true if the query matches
  1655. */
  1656. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1657. private static _HandleParenthesisContent;
  1658. private static _SimplifyNegation;
  1659. }
  1660. }
  1661. declare module "babylonjs/Misc/tags" {
  1662. /**
  1663. * Class used to store custom tags
  1664. */
  1665. export class Tags {
  1666. /**
  1667. * Adds support for tags on the given object
  1668. * @param obj defines the object to use
  1669. */
  1670. static EnableFor(obj: any): void;
  1671. /**
  1672. * Removes tags support
  1673. * @param obj defines the object to use
  1674. */
  1675. static DisableFor(obj: any): void;
  1676. /**
  1677. * Gets a boolean indicating if the given object has tags
  1678. * @param obj defines the object to use
  1679. * @returns a boolean
  1680. */
  1681. static HasTags(obj: any): boolean;
  1682. /**
  1683. * Gets the tags available on a given object
  1684. * @param obj defines the object to use
  1685. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1686. * @returns the tags
  1687. */
  1688. static GetTags(obj: any, asString?: boolean): any;
  1689. /**
  1690. * Adds tags to an object
  1691. * @param obj defines the object to use
  1692. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1693. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1694. */
  1695. static AddTagsTo(obj: any, tagsString: string): void;
  1696. /**
  1697. * @hidden
  1698. */
  1699. static _AddTagTo(obj: any, tag: string): void;
  1700. /**
  1701. * Removes specific tags from a specific object
  1702. * @param obj defines the object to use
  1703. * @param tagsString defines the tags to remove
  1704. */
  1705. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1706. /**
  1707. * @hidden
  1708. */
  1709. static _RemoveTagFrom(obj: any, tag: string): void;
  1710. /**
  1711. * Defines if tags hosted on an object match a given query
  1712. * @param obj defines the object to use
  1713. * @param tagsQuery defines the tag query
  1714. * @returns a boolean
  1715. */
  1716. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1717. }
  1718. }
  1719. declare module "babylonjs/Maths/math.scalar" {
  1720. /**
  1721. * Scalar computation library
  1722. */
  1723. export class Scalar {
  1724. /**
  1725. * Two pi constants convenient for computation.
  1726. */
  1727. static TwoPi: number;
  1728. /**
  1729. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1730. * @param a number
  1731. * @param b number
  1732. * @param epsilon (default = 1.401298E-45)
  1733. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1734. */
  1735. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1736. /**
  1737. * Returns a string : the upper case translation of the number i to hexadecimal.
  1738. * @param i number
  1739. * @returns the upper case translation of the number i to hexadecimal.
  1740. */
  1741. static ToHex(i: number): string;
  1742. /**
  1743. * Returns -1 if value is negative and +1 is value is positive.
  1744. * @param value the value
  1745. * @returns the value itself if it's equal to zero.
  1746. */
  1747. static Sign(value: number): number;
  1748. /**
  1749. * Returns the value itself if it's between min and max.
  1750. * Returns min if the value is lower than min.
  1751. * Returns max if the value is greater than max.
  1752. * @param value the value to clmap
  1753. * @param min the min value to clamp to (default: 0)
  1754. * @param max the max value to clamp to (default: 1)
  1755. * @returns the clamped value
  1756. */
  1757. static Clamp(value: number, min?: number, max?: number): number;
  1758. /**
  1759. * the log2 of value.
  1760. * @param value the value to compute log2 of
  1761. * @returns the log2 of value.
  1762. */
  1763. static Log2(value: number): number;
  1764. /**
  1765. * Loops the value, so that it is never larger than length and never smaller than 0.
  1766. *
  1767. * This is similar to the modulo operator but it works with floating point numbers.
  1768. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1769. * With t = 5 and length = 2.5, the result would be 0.0.
  1770. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1771. * @param value the value
  1772. * @param length the length
  1773. * @returns the looped value
  1774. */
  1775. static Repeat(value: number, length: number): number;
  1776. /**
  1777. * Normalize the value between 0.0 and 1.0 using min and max values
  1778. * @param value value to normalize
  1779. * @param min max to normalize between
  1780. * @param max min to normalize between
  1781. * @returns the normalized value
  1782. */
  1783. static Normalize(value: number, min: number, max: number): number;
  1784. /**
  1785. * Denormalize the value from 0.0 and 1.0 using min and max values
  1786. * @param normalized value to denormalize
  1787. * @param min max to denormalize between
  1788. * @param max min to denormalize between
  1789. * @returns the denormalized value
  1790. */
  1791. static Denormalize(normalized: number, min: number, max: number): number;
  1792. /**
  1793. * Calculates the shortest difference between two given angles given in degrees.
  1794. * @param current current angle in degrees
  1795. * @param target target angle in degrees
  1796. * @returns the delta
  1797. */
  1798. static DeltaAngle(current: number, target: number): number;
  1799. /**
  1800. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1801. * @param tx value
  1802. * @param length length
  1803. * @returns The returned value will move back and forth between 0 and length
  1804. */
  1805. static PingPong(tx: number, length: number): number;
  1806. /**
  1807. * Interpolates between min and max with smoothing at the limits.
  1808. *
  1809. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1810. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1811. * @param from from
  1812. * @param to to
  1813. * @param tx value
  1814. * @returns the smooth stepped value
  1815. */
  1816. static SmoothStep(from: number, to: number, tx: number): number;
  1817. /**
  1818. * Moves a value current towards target.
  1819. *
  1820. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1821. * Negative values of maxDelta pushes the value away from target.
  1822. * @param current current value
  1823. * @param target target value
  1824. * @param maxDelta max distance to move
  1825. * @returns resulting value
  1826. */
  1827. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1828. /**
  1829. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1830. *
  1831. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1832. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1833. * @param current current value
  1834. * @param target target value
  1835. * @param maxDelta max distance to move
  1836. * @returns resulting angle
  1837. */
  1838. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1839. /**
  1840. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1841. * @param start start value
  1842. * @param end target value
  1843. * @param amount amount to lerp between
  1844. * @returns the lerped value
  1845. */
  1846. static Lerp(start: number, end: number, amount: number): number;
  1847. /**
  1848. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1849. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1850. * @param start start value
  1851. * @param end target value
  1852. * @param amount amount to lerp between
  1853. * @returns the lerped value
  1854. */
  1855. static LerpAngle(start: number, end: number, amount: number): number;
  1856. /**
  1857. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1858. * @param a start value
  1859. * @param b target value
  1860. * @param value value between a and b
  1861. * @returns the inverseLerp value
  1862. */
  1863. static InverseLerp(a: number, b: number, value: number): number;
  1864. /**
  1865. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1866. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1867. * @param value1 spline value
  1868. * @param tangent1 spline value
  1869. * @param value2 spline value
  1870. * @param tangent2 spline value
  1871. * @param amount input value
  1872. * @returns hermite result
  1873. */
  1874. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1875. /**
  1876. * Returns a random float number between and min and max values
  1877. * @param min min value of random
  1878. * @param max max value of random
  1879. * @returns random value
  1880. */
  1881. static RandomRange(min: number, max: number): number;
  1882. /**
  1883. * This function returns percentage of a number in a given range.
  1884. *
  1885. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1886. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1887. * @param number to convert to percentage
  1888. * @param min min range
  1889. * @param max max range
  1890. * @returns the percentage
  1891. */
  1892. static RangeToPercent(number: number, min: number, max: number): number;
  1893. /**
  1894. * This function returns number that corresponds to the percentage in a given range.
  1895. *
  1896. * PercentToRange(0.34,0,100) will return 34.
  1897. * @param percent to convert to number
  1898. * @param min min range
  1899. * @param max max range
  1900. * @returns the number
  1901. */
  1902. static PercentToRange(percent: number, min: number, max: number): number;
  1903. /**
  1904. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1905. * @param angle The angle to normalize in radian.
  1906. * @return The converted angle.
  1907. */
  1908. static NormalizeRadians(angle: number): number;
  1909. }
  1910. }
  1911. declare module "babylonjs/Maths/math.constants" {
  1912. /**
  1913. * Constant used to convert a value to gamma space
  1914. * @ignorenaming
  1915. */
  1916. export const ToGammaSpace: number;
  1917. /**
  1918. * Constant used to convert a value to linear space
  1919. * @ignorenaming
  1920. */
  1921. export const ToLinearSpace = 2.2;
  1922. /**
  1923. * Constant used to define the minimal number value in Babylon.js
  1924. * @ignorenaming
  1925. */
  1926. let Epsilon: number;
  1927. export { Epsilon };
  1928. }
  1929. declare module "babylonjs/Maths/math.viewport" {
  1930. /**
  1931. * Class used to represent a viewport on screen
  1932. */
  1933. export class Viewport {
  1934. /** viewport left coordinate */
  1935. x: number;
  1936. /** viewport top coordinate */
  1937. y: number;
  1938. /**viewport width */
  1939. width: number;
  1940. /** viewport height */
  1941. height: number;
  1942. /**
  1943. * Creates a Viewport object located at (x, y) and sized (width, height)
  1944. * @param x defines viewport left coordinate
  1945. * @param y defines viewport top coordinate
  1946. * @param width defines the viewport width
  1947. * @param height defines the viewport height
  1948. */
  1949. constructor(
  1950. /** viewport left coordinate */
  1951. x: number,
  1952. /** viewport top coordinate */
  1953. y: number,
  1954. /**viewport width */
  1955. width: number,
  1956. /** viewport height */
  1957. height: number);
  1958. /**
  1959. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1960. * @param renderWidth defines the rendering width
  1961. * @param renderHeight defines the rendering height
  1962. * @returns a new Viewport
  1963. */
  1964. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1965. /**
  1966. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1967. * @param renderWidth defines the rendering width
  1968. * @param renderHeight defines the rendering height
  1969. * @param ref defines the target viewport
  1970. * @returns the current viewport
  1971. */
  1972. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1973. /**
  1974. * Returns a new Viewport copied from the current one
  1975. * @returns a new Viewport
  1976. */
  1977. clone(): Viewport;
  1978. }
  1979. }
  1980. declare module "babylonjs/Misc/arrayTools" {
  1981. /**
  1982. * Class containing a set of static utilities functions for arrays.
  1983. */
  1984. export class ArrayTools {
  1985. /**
  1986. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1987. * @param size the number of element to construct and put in the array
  1988. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1989. * @returns a new array filled with new objects
  1990. */
  1991. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1992. }
  1993. }
  1994. declare module "babylonjs/Maths/math.plane" {
  1995. import { DeepImmutable } from "babylonjs/types";
  1996. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1997. /**
  1998. * Represents a plane by the equation ax + by + cz + d = 0
  1999. */
  2000. export class Plane {
  2001. private static _TmpMatrix;
  2002. /**
  2003. * Normal of the plane (a,b,c)
  2004. */
  2005. normal: Vector3;
  2006. /**
  2007. * d component of the plane
  2008. */
  2009. d: number;
  2010. /**
  2011. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2012. * @param a a component of the plane
  2013. * @param b b component of the plane
  2014. * @param c c component of the plane
  2015. * @param d d component of the plane
  2016. */
  2017. constructor(a: number, b: number, c: number, d: number);
  2018. /**
  2019. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2020. */
  2021. asArray(): number[];
  2022. /**
  2023. * @returns a new plane copied from the current Plane.
  2024. */
  2025. clone(): Plane;
  2026. /**
  2027. * @returns the string "Plane".
  2028. */
  2029. getClassName(): string;
  2030. /**
  2031. * @returns the Plane hash code.
  2032. */
  2033. getHashCode(): number;
  2034. /**
  2035. * Normalize the current Plane in place.
  2036. * @returns the updated Plane.
  2037. */
  2038. normalize(): Plane;
  2039. /**
  2040. * Applies a transformation the plane and returns the result
  2041. * @param transformation the transformation matrix to be applied to the plane
  2042. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2043. */
  2044. transform(transformation: DeepImmutable<Matrix>): Plane;
  2045. /**
  2046. * Compute the dot product between the point and the plane normal
  2047. * @param point point to calculate the dot product with
  2048. * @returns the dot product (float) of the point coordinates and the plane normal.
  2049. */
  2050. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2051. /**
  2052. * Updates the current Plane from the plane defined by the three given points.
  2053. * @param point1 one of the points used to contruct the plane
  2054. * @param point2 one of the points used to contruct the plane
  2055. * @param point3 one of the points used to contruct the plane
  2056. * @returns the updated Plane.
  2057. */
  2058. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2059. /**
  2060. * Checks if the plane is facing a given direction
  2061. * @param direction the direction to check if the plane is facing
  2062. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2063. * @returns True is the vector "direction" is the same side than the plane normal.
  2064. */
  2065. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2066. /**
  2067. * Calculates the distance to a point
  2068. * @param point point to calculate distance to
  2069. * @returns the signed distance (float) from the given point to the Plane.
  2070. */
  2071. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2072. /**
  2073. * Creates a plane from an array
  2074. * @param array the array to create a plane from
  2075. * @returns a new Plane from the given array.
  2076. */
  2077. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2078. /**
  2079. * Creates a plane from three points
  2080. * @param point1 point used to create the plane
  2081. * @param point2 point used to create the plane
  2082. * @param point3 point used to create the plane
  2083. * @returns a new Plane defined by the three given points.
  2084. */
  2085. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2086. /**
  2087. * Creates a plane from an origin point and a normal
  2088. * @param origin origin of the plane to be constructed
  2089. * @param normal normal of the plane to be constructed
  2090. * @returns a new Plane the normal vector to this plane at the given origin point.
  2091. * Note : the vector "normal" is updated because normalized.
  2092. */
  2093. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2094. /**
  2095. * Calculates the distance from a plane and a point
  2096. * @param origin origin of the plane to be constructed
  2097. * @param normal normal of the plane to be constructed
  2098. * @param point point to calculate distance to
  2099. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2100. */
  2101. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2102. }
  2103. }
  2104. declare module "babylonjs/Engines/performanceConfigurator" {
  2105. /** @hidden */
  2106. export class PerformanceConfigurator {
  2107. /** @hidden */
  2108. static MatrixUse64Bits: boolean;
  2109. /** @hidden */
  2110. static MatrixTrackPrecisionChange: boolean;
  2111. /** @hidden */
  2112. static MatrixCurrentType: any;
  2113. /** @hidden */
  2114. static MatrixTrackedMatrices: Array<any> | null;
  2115. /** @hidden */
  2116. static SetMatrixPrecision(use64bits: boolean): void;
  2117. }
  2118. }
  2119. declare module "babylonjs/Maths/math.vector" {
  2120. import { Viewport } from "babylonjs/Maths/math.viewport";
  2121. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2122. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2123. import { Plane } from "babylonjs/Maths/math.plane";
  2124. /**
  2125. * Class representing a vector containing 2 coordinates
  2126. */
  2127. export class Vector2 {
  2128. /** defines the first coordinate */
  2129. x: number;
  2130. /** defines the second coordinate */
  2131. y: number;
  2132. /**
  2133. * Creates a new Vector2 from the given x and y coordinates
  2134. * @param x defines the first coordinate
  2135. * @param y defines the second coordinate
  2136. */
  2137. constructor(
  2138. /** defines the first coordinate */
  2139. x?: number,
  2140. /** defines the second coordinate */
  2141. y?: number);
  2142. /**
  2143. * Gets a string with the Vector2 coordinates
  2144. * @returns a string with the Vector2 coordinates
  2145. */
  2146. toString(): string;
  2147. /**
  2148. * Gets class name
  2149. * @returns the string "Vector2"
  2150. */
  2151. getClassName(): string;
  2152. /**
  2153. * Gets current vector hash code
  2154. * @returns the Vector2 hash code as a number
  2155. */
  2156. getHashCode(): number;
  2157. /**
  2158. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2159. * @param array defines the source array
  2160. * @param index defines the offset in source array
  2161. * @returns the current Vector2
  2162. */
  2163. toArray(array: FloatArray, index?: number): Vector2;
  2164. /**
  2165. * Update the current vector from an array
  2166. * @param array defines the destination array
  2167. * @param index defines the offset in the destination array
  2168. * @returns the current Vector3
  2169. */
  2170. fromArray(array: FloatArray, index?: number): Vector2;
  2171. /**
  2172. * Copy the current vector to an array
  2173. * @returns a new array with 2 elements: the Vector2 coordinates.
  2174. */
  2175. asArray(): number[];
  2176. /**
  2177. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2178. * @param source defines the source Vector2
  2179. * @returns the current updated Vector2
  2180. */
  2181. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2182. /**
  2183. * Sets the Vector2 coordinates with the given floats
  2184. * @param x defines the first coordinate
  2185. * @param y defines the second coordinate
  2186. * @returns the current updated Vector2
  2187. */
  2188. copyFromFloats(x: number, y: number): Vector2;
  2189. /**
  2190. * Sets the Vector2 coordinates with the given floats
  2191. * @param x defines the first coordinate
  2192. * @param y defines the second coordinate
  2193. * @returns the current updated Vector2
  2194. */
  2195. set(x: number, y: number): Vector2;
  2196. /**
  2197. * Add another vector with the current one
  2198. * @param otherVector defines the other vector
  2199. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2200. */
  2201. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2202. /**
  2203. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2204. * @param otherVector defines the other vector
  2205. * @param result defines the target vector
  2206. * @returns the unmodified current Vector2
  2207. */
  2208. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2209. /**
  2210. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2211. * @param otherVector defines the other vector
  2212. * @returns the current updated Vector2
  2213. */
  2214. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2215. /**
  2216. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2217. * @param otherVector defines the other vector
  2218. * @returns a new Vector2
  2219. */
  2220. addVector3(otherVector: Vector3): Vector2;
  2221. /**
  2222. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2223. * @param otherVector defines the other vector
  2224. * @returns a new Vector2
  2225. */
  2226. subtract(otherVector: Vector2): Vector2;
  2227. /**
  2228. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2229. * @param otherVector defines the other vector
  2230. * @param result defines the target vector
  2231. * @returns the unmodified current Vector2
  2232. */
  2233. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2234. /**
  2235. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2236. * @param otherVector defines the other vector
  2237. * @returns the current updated Vector2
  2238. */
  2239. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2240. /**
  2241. * Multiplies in place the current Vector2 coordinates by the given ones
  2242. * @param otherVector defines the other vector
  2243. * @returns the current updated Vector2
  2244. */
  2245. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2246. /**
  2247. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2248. * @param otherVector defines the other vector
  2249. * @returns a new Vector2
  2250. */
  2251. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2254. * @param otherVector defines the other vector
  2255. * @param result defines the target vector
  2256. * @returns the unmodified current Vector2
  2257. */
  2258. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2259. /**
  2260. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2261. * @param x defines the first coordinate
  2262. * @param y defines the second coordinate
  2263. * @returns a new Vector2
  2264. */
  2265. multiplyByFloats(x: number, y: number): Vector2;
  2266. /**
  2267. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2268. * @param otherVector defines the other vector
  2269. * @returns a new Vector2
  2270. */
  2271. divide(otherVector: Vector2): Vector2;
  2272. /**
  2273. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2274. * @param otherVector defines the other vector
  2275. * @param result defines the target vector
  2276. * @returns the unmodified current Vector2
  2277. */
  2278. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2279. /**
  2280. * Divides the current Vector2 coordinates by the given ones
  2281. * @param otherVector defines the other vector
  2282. * @returns the current updated Vector2
  2283. */
  2284. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2285. /**
  2286. * Gets a new Vector2 with current Vector2 negated coordinates
  2287. * @returns a new Vector2
  2288. */
  2289. negate(): Vector2;
  2290. /**
  2291. * Negate this vector in place
  2292. * @returns this
  2293. */
  2294. negateInPlace(): Vector2;
  2295. /**
  2296. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2297. * @param result defines the Vector3 object where to store the result
  2298. * @returns the current Vector2
  2299. */
  2300. negateToRef(result: Vector2): Vector2;
  2301. /**
  2302. * Multiply the Vector2 coordinates by scale
  2303. * @param scale defines the scaling factor
  2304. * @returns the current updated Vector2
  2305. */
  2306. scaleInPlace(scale: number): Vector2;
  2307. /**
  2308. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2309. * @param scale defines the scaling factor
  2310. * @returns a new Vector2
  2311. */
  2312. scale(scale: number): Vector2;
  2313. /**
  2314. * Scale the current Vector2 values by a factor to a given Vector2
  2315. * @param scale defines the scale factor
  2316. * @param result defines the Vector2 object where to store the result
  2317. * @returns the unmodified current Vector2
  2318. */
  2319. scaleToRef(scale: number, result: Vector2): Vector2;
  2320. /**
  2321. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2322. * @param scale defines the scale factor
  2323. * @param result defines the Vector2 object where to store the result
  2324. * @returns the unmodified current Vector2
  2325. */
  2326. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2327. /**
  2328. * Gets a boolean if two vectors are equals
  2329. * @param otherVector defines the other vector
  2330. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2331. */
  2332. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2333. /**
  2334. * Gets a boolean if two vectors are equals (using an epsilon value)
  2335. * @param otherVector defines the other vector
  2336. * @param epsilon defines the minimal distance to consider equality
  2337. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2338. */
  2339. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2340. /**
  2341. * Gets a new Vector2 from current Vector2 floored values
  2342. * @returns a new Vector2
  2343. */
  2344. floor(): Vector2;
  2345. /**
  2346. * Gets a new Vector2 from current Vector2 floored values
  2347. * @returns a new Vector2
  2348. */
  2349. fract(): Vector2;
  2350. /**
  2351. * Gets the length of the vector
  2352. * @returns the vector length (float)
  2353. */
  2354. length(): number;
  2355. /**
  2356. * Gets the vector squared length
  2357. * @returns the vector squared length (float)
  2358. */
  2359. lengthSquared(): number;
  2360. /**
  2361. * Normalize the vector
  2362. * @returns the current updated Vector2
  2363. */
  2364. normalize(): Vector2;
  2365. /**
  2366. * Gets a new Vector2 copied from the Vector2
  2367. * @returns a new Vector2
  2368. */
  2369. clone(): Vector2;
  2370. /**
  2371. * Gets a new Vector2(0, 0)
  2372. * @returns a new Vector2
  2373. */
  2374. static Zero(): Vector2;
  2375. /**
  2376. * Gets a new Vector2(1, 1)
  2377. * @returns a new Vector2
  2378. */
  2379. static One(): Vector2;
  2380. /**
  2381. * Gets a new Vector2 set from the given index element of the given array
  2382. * @param array defines the data source
  2383. * @param offset defines the offset in the data source
  2384. * @returns a new Vector2
  2385. */
  2386. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2387. /**
  2388. * Sets "result" from the given index element of the given array
  2389. * @param array defines the data source
  2390. * @param offset defines the offset in the data source
  2391. * @param result defines the target vector
  2392. */
  2393. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2394. /**
  2395. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2396. * @param value1 defines 1st point of control
  2397. * @param value2 defines 2nd point of control
  2398. * @param value3 defines 3rd point of control
  2399. * @param value4 defines 4th point of control
  2400. * @param amount defines the interpolation factor
  2401. * @returns a new Vector2
  2402. */
  2403. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2404. /**
  2405. * 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".
  2406. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2407. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2408. * @param value defines the value to clamp
  2409. * @param min defines the lower limit
  2410. * @param max defines the upper limit
  2411. * @returns a new Vector2
  2412. */
  2413. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2414. /**
  2415. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2416. * @param value1 defines the 1st control point
  2417. * @param tangent1 defines the outgoing tangent
  2418. * @param value2 defines the 2nd control point
  2419. * @param tangent2 defines the incoming tangent
  2420. * @param amount defines the interpolation factor
  2421. * @returns a new Vector2
  2422. */
  2423. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2424. /**
  2425. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2426. * @param start defines the start vector
  2427. * @param end defines the end vector
  2428. * @param amount defines the interpolation factor
  2429. * @returns a new Vector2
  2430. */
  2431. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2432. /**
  2433. * Gets the dot product of the vector "left" and the vector "right"
  2434. * @param left defines first vector
  2435. * @param right defines second vector
  2436. * @returns the dot product (float)
  2437. */
  2438. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2439. /**
  2440. * Returns a new Vector2 equal to the normalized given vector
  2441. * @param vector defines the vector to normalize
  2442. * @returns a new Vector2
  2443. */
  2444. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2445. /**
  2446. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2447. * @param left defines 1st vector
  2448. * @param right defines 2nd vector
  2449. * @returns a new Vector2
  2450. */
  2451. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2452. /**
  2453. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2454. * @param left defines 1st vector
  2455. * @param right defines 2nd vector
  2456. * @returns a new Vector2
  2457. */
  2458. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2459. /**
  2460. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2461. * @param vector defines the vector to transform
  2462. * @param transformation defines the matrix to apply
  2463. * @returns a new Vector2
  2464. */
  2465. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2466. /**
  2467. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2468. * @param vector defines the vector to transform
  2469. * @param transformation defines the matrix to apply
  2470. * @param result defines the target vector
  2471. */
  2472. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2473. /**
  2474. * Determines if a given vector is included in a triangle
  2475. * @param p defines the vector to test
  2476. * @param p0 defines 1st triangle point
  2477. * @param p1 defines 2nd triangle point
  2478. * @param p2 defines 3rd triangle point
  2479. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2480. */
  2481. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2482. /**
  2483. * Gets the distance between the vectors "value1" and "value2"
  2484. * @param value1 defines first vector
  2485. * @param value2 defines second vector
  2486. * @returns the distance between vectors
  2487. */
  2488. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2489. /**
  2490. * Returns the squared distance between the vectors "value1" and "value2"
  2491. * @param value1 defines first vector
  2492. * @param value2 defines second vector
  2493. * @returns the squared distance between vectors
  2494. */
  2495. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2496. /**
  2497. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2498. * @param value1 defines first vector
  2499. * @param value2 defines second vector
  2500. * @returns a new Vector2
  2501. */
  2502. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2503. /**
  2504. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2505. * @param p defines the middle point
  2506. * @param segA defines one point of the segment
  2507. * @param segB defines the other point of the segment
  2508. * @returns the shortest distance
  2509. */
  2510. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2511. }
  2512. /**
  2513. * Class used to store (x,y,z) vector representation
  2514. * A Vector3 is the main object used in 3D geometry
  2515. * It can represent etiher the coordinates of a point the space, either a direction
  2516. * Reminder: js uses a left handed forward facing system
  2517. */
  2518. export class Vector3 {
  2519. private static _UpReadOnly;
  2520. private static _ZeroReadOnly;
  2521. /** @hidden */
  2522. _x: number;
  2523. /** @hidden */
  2524. _y: number;
  2525. /** @hidden */
  2526. _z: number;
  2527. /** @hidden */
  2528. _isDirty: boolean;
  2529. /** Gets or sets the x coordinate */
  2530. get x(): number;
  2531. set x(value: number);
  2532. /** Gets or sets the y coordinate */
  2533. get y(): number;
  2534. set y(value: number);
  2535. /** Gets or sets the z coordinate */
  2536. get z(): number;
  2537. set z(value: number);
  2538. /**
  2539. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2540. * @param x defines the first coordinates (on X axis)
  2541. * @param y defines the second coordinates (on Y axis)
  2542. * @param z defines the third coordinates (on Z axis)
  2543. */
  2544. constructor(x?: number, y?: number, z?: number);
  2545. /**
  2546. * Creates a string representation of the Vector3
  2547. * @returns a string with the Vector3 coordinates.
  2548. */
  2549. toString(): string;
  2550. /**
  2551. * Gets the class name
  2552. * @returns the string "Vector3"
  2553. */
  2554. getClassName(): string;
  2555. /**
  2556. * Creates the Vector3 hash code
  2557. * @returns a number which tends to be unique between Vector3 instances
  2558. */
  2559. getHashCode(): number;
  2560. /**
  2561. * Creates an array containing three elements : the coordinates of the Vector3
  2562. * @returns a new array of numbers
  2563. */
  2564. asArray(): number[];
  2565. /**
  2566. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2567. * @param array defines the destination array
  2568. * @param index defines the offset in the destination array
  2569. * @returns the current Vector3
  2570. */
  2571. toArray(array: FloatArray, index?: number): Vector3;
  2572. /**
  2573. * Update the current vector from an array
  2574. * @param array defines the destination array
  2575. * @param index defines the offset in the destination array
  2576. * @returns the current Vector3
  2577. */
  2578. fromArray(array: FloatArray, index?: number): Vector3;
  2579. /**
  2580. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2581. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2582. */
  2583. toQuaternion(): Quaternion;
  2584. /**
  2585. * Adds the given vector to the current Vector3
  2586. * @param otherVector defines the second operand
  2587. * @returns the current updated Vector3
  2588. */
  2589. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Adds the given coordinates to the current Vector3
  2592. * @param x defines the x coordinate of the operand
  2593. * @param y defines the y coordinate of the operand
  2594. * @param z defines the z coordinate of the operand
  2595. * @returns the current updated Vector3
  2596. */
  2597. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2598. /**
  2599. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2600. * @param otherVector defines the second operand
  2601. * @returns the resulting Vector3
  2602. */
  2603. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2604. /**
  2605. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2606. * @param otherVector defines the second operand
  2607. * @param result defines the Vector3 object where to store the result
  2608. * @returns the current Vector3
  2609. */
  2610. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2611. /**
  2612. * Subtract the given vector from the current Vector3
  2613. * @param otherVector defines the second operand
  2614. * @returns the current updated Vector3
  2615. */
  2616. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2617. /**
  2618. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2619. * @param otherVector defines the second operand
  2620. * @returns the resulting Vector3
  2621. */
  2622. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2623. /**
  2624. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2625. * @param otherVector defines the second operand
  2626. * @param result defines the Vector3 object where to store the result
  2627. * @returns the current Vector3
  2628. */
  2629. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2630. /**
  2631. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2632. * @param x defines the x coordinate of the operand
  2633. * @param y defines the y coordinate of the operand
  2634. * @param z defines the z coordinate of the operand
  2635. * @returns the resulting Vector3
  2636. */
  2637. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2638. /**
  2639. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2640. * @param x defines the x coordinate of the operand
  2641. * @param y defines the y coordinate of the operand
  2642. * @param z defines the z coordinate of the operand
  2643. * @param result defines the Vector3 object where to store the result
  2644. * @returns the current Vector3
  2645. */
  2646. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2647. /**
  2648. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2649. * @returns a new Vector3
  2650. */
  2651. negate(): Vector3;
  2652. /**
  2653. * Negate this vector in place
  2654. * @returns this
  2655. */
  2656. negateInPlace(): Vector3;
  2657. /**
  2658. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2659. * @param result defines the Vector3 object where to store the result
  2660. * @returns the current Vector3
  2661. */
  2662. negateToRef(result: Vector3): Vector3;
  2663. /**
  2664. * Multiplies the Vector3 coordinates by the float "scale"
  2665. * @param scale defines the multiplier factor
  2666. * @returns the current updated Vector3
  2667. */
  2668. scaleInPlace(scale: number): Vector3;
  2669. /**
  2670. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2671. * @param scale defines the multiplier factor
  2672. * @returns a new Vector3
  2673. */
  2674. scale(scale: number): Vector3;
  2675. /**
  2676. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2677. * @param scale defines the multiplier factor
  2678. * @param result defines the Vector3 object where to store the result
  2679. * @returns the current Vector3
  2680. */
  2681. scaleToRef(scale: number, result: Vector3): Vector3;
  2682. /**
  2683. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2684. * @param scale defines the scale factor
  2685. * @param result defines the Vector3 object where to store the result
  2686. * @returns the unmodified current Vector3
  2687. */
  2688. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2689. /**
  2690. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2691. * @param origin defines the origin of the projection ray
  2692. * @param plane defines the plane to project to
  2693. * @returns the projected vector3
  2694. */
  2695. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2696. /**
  2697. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2698. * @param origin defines the origin of the projection ray
  2699. * @param plane defines the plane to project to
  2700. * @param result defines the Vector3 where to store the result
  2701. */
  2702. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2703. /**
  2704. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2705. * @param otherVector defines the second operand
  2706. * @returns true if both vectors are equals
  2707. */
  2708. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2709. /**
  2710. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2711. * @param otherVector defines the second operand
  2712. * @param epsilon defines the minimal distance to define values as equals
  2713. * @returns true if both vectors are distant less than epsilon
  2714. */
  2715. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2716. /**
  2717. * Returns true if the current Vector3 coordinates equals the given floats
  2718. * @param x defines the x coordinate of the operand
  2719. * @param y defines the y coordinate of the operand
  2720. * @param z defines the z coordinate of the operand
  2721. * @returns true if both vectors are equals
  2722. */
  2723. equalsToFloats(x: number, y: number, z: number): boolean;
  2724. /**
  2725. * Multiplies the current Vector3 coordinates by the given ones
  2726. * @param otherVector defines the second operand
  2727. * @returns the current updated Vector3
  2728. */
  2729. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2730. /**
  2731. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2732. * @param otherVector defines the second operand
  2733. * @returns the new Vector3
  2734. */
  2735. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2736. /**
  2737. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2738. * @param otherVector defines the second operand
  2739. * @param result defines the Vector3 object where to store the result
  2740. * @returns the current Vector3
  2741. */
  2742. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2743. /**
  2744. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2745. * @param x defines the x coordinate of the operand
  2746. * @param y defines the y coordinate of the operand
  2747. * @param z defines the z coordinate of the operand
  2748. * @returns the new Vector3
  2749. */
  2750. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2751. /**
  2752. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2753. * @param otherVector defines the second operand
  2754. * @returns the new Vector3
  2755. */
  2756. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2757. /**
  2758. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2759. * @param otherVector defines the second operand
  2760. * @param result defines the Vector3 object where to store the result
  2761. * @returns the current Vector3
  2762. */
  2763. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2764. /**
  2765. * Divides the current Vector3 coordinates by the given ones.
  2766. * @param otherVector defines the second operand
  2767. * @returns the current updated Vector3
  2768. */
  2769. divideInPlace(otherVector: Vector3): Vector3;
  2770. /**
  2771. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2772. * @param other defines the second operand
  2773. * @returns the current updated Vector3
  2774. */
  2775. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2776. /**
  2777. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2778. * @param other defines the second operand
  2779. * @returns the current updated Vector3
  2780. */
  2781. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2782. /**
  2783. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2784. * @param x defines the x coordinate of the operand
  2785. * @param y defines the y coordinate of the operand
  2786. * @param z defines the z coordinate of the operand
  2787. * @returns the current updated Vector3
  2788. */
  2789. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2790. /**
  2791. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2792. * @param x defines the x coordinate of the operand
  2793. * @param y defines the y coordinate of the operand
  2794. * @param z defines the z coordinate of the operand
  2795. * @returns the current updated Vector3
  2796. */
  2797. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2798. /**
  2799. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2800. * Check if is non uniform within a certain amount of decimal places to account for this
  2801. * @param epsilon the amount the values can differ
  2802. * @returns if the the vector is non uniform to a certain number of decimal places
  2803. */
  2804. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2805. /**
  2806. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2807. */
  2808. get isNonUniform(): boolean;
  2809. /**
  2810. * Gets a new Vector3 from current Vector3 floored values
  2811. * @returns a new Vector3
  2812. */
  2813. floor(): Vector3;
  2814. /**
  2815. * Gets a new Vector3 from current Vector3 floored values
  2816. * @returns a new Vector3
  2817. */
  2818. fract(): Vector3;
  2819. /**
  2820. * Gets the length of the Vector3
  2821. * @returns the length of the Vector3
  2822. */
  2823. length(): number;
  2824. /**
  2825. * Gets the squared length of the Vector3
  2826. * @returns squared length of the Vector3
  2827. */
  2828. lengthSquared(): number;
  2829. /**
  2830. * Normalize the current Vector3.
  2831. * Please note that this is an in place operation.
  2832. * @returns the current updated Vector3
  2833. */
  2834. normalize(): Vector3;
  2835. /**
  2836. * Reorders the x y z properties of the vector in place
  2837. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2838. * @returns the current updated vector
  2839. */
  2840. reorderInPlace(order: string): this;
  2841. /**
  2842. * Rotates the vector around 0,0,0 by a quaternion
  2843. * @param quaternion the rotation quaternion
  2844. * @param result vector to store the result
  2845. * @returns the resulting vector
  2846. */
  2847. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2848. /**
  2849. * Rotates a vector around a given point
  2850. * @param quaternion the rotation quaternion
  2851. * @param point the point to rotate around
  2852. * @param result vector to store the result
  2853. * @returns the resulting vector
  2854. */
  2855. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2856. /**
  2857. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2858. * The cross product is then orthogonal to both current and "other"
  2859. * @param other defines the right operand
  2860. * @returns the cross product
  2861. */
  2862. cross(other: Vector3): Vector3;
  2863. /**
  2864. * Normalize the current Vector3 with the given input length.
  2865. * Please note that this is an in place operation.
  2866. * @param len the length of the vector
  2867. * @returns the current updated Vector3
  2868. */
  2869. normalizeFromLength(len: number): Vector3;
  2870. /**
  2871. * Normalize the current Vector3 to a new vector
  2872. * @returns the new Vector3
  2873. */
  2874. normalizeToNew(): Vector3;
  2875. /**
  2876. * Normalize the current Vector3 to the reference
  2877. * @param reference define the Vector3 to update
  2878. * @returns the updated Vector3
  2879. */
  2880. normalizeToRef(reference: Vector3): Vector3;
  2881. /**
  2882. * Creates a new Vector3 copied from the current Vector3
  2883. * @returns the new Vector3
  2884. */
  2885. clone(): Vector3;
  2886. /**
  2887. * Copies the given vector coordinates to the current Vector3 ones
  2888. * @param source defines the source Vector3
  2889. * @returns the current updated Vector3
  2890. */
  2891. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2892. /**
  2893. * Copies the given floats to the current Vector3 coordinates
  2894. * @param x defines the x coordinate of the operand
  2895. * @param y defines the y coordinate of the operand
  2896. * @param z defines the z coordinate of the operand
  2897. * @returns the current updated Vector3
  2898. */
  2899. copyFromFloats(x: number, y: number, z: number): Vector3;
  2900. /**
  2901. * Copies the given floats to the current Vector3 coordinates
  2902. * @param x defines the x coordinate of the operand
  2903. * @param y defines the y coordinate of the operand
  2904. * @param z defines the z coordinate of the operand
  2905. * @returns the current updated Vector3
  2906. */
  2907. set(x: number, y: number, z: number): Vector3;
  2908. /**
  2909. * Copies the given float to the current Vector3 coordinates
  2910. * @param v defines the x, y and z coordinates of the operand
  2911. * @returns the current updated Vector3
  2912. */
  2913. setAll(v: number): Vector3;
  2914. /**
  2915. * Get the clip factor between two vectors
  2916. * @param vector0 defines the first operand
  2917. * @param vector1 defines the second operand
  2918. * @param axis defines the axis to use
  2919. * @param size defines the size along the axis
  2920. * @returns the clip factor
  2921. */
  2922. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2923. /**
  2924. * Get angle between two vectors
  2925. * @param vector0 angle between vector0 and vector1
  2926. * @param vector1 angle between vector0 and vector1
  2927. * @param normal direction of the normal
  2928. * @return the angle between vector0 and vector1
  2929. */
  2930. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2931. /**
  2932. * Returns a new Vector3 set from the index "offset" of the given array
  2933. * @param array defines the source array
  2934. * @param offset defines the offset in the source array
  2935. * @returns the new Vector3
  2936. */
  2937. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2938. /**
  2939. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2940. * @param array defines the source array
  2941. * @param offset defines the offset in the source array
  2942. * @returns the new Vector3
  2943. * @deprecated Please use FromArray instead.
  2944. */
  2945. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2946. /**
  2947. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2948. * @param array defines the source array
  2949. * @param offset defines the offset in the source array
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2953. /**
  2954. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2955. * @param array defines the source array
  2956. * @param offset defines the offset in the source array
  2957. * @param result defines the Vector3 where to store the result
  2958. * @deprecated Please use FromArrayToRef instead.
  2959. */
  2960. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2961. /**
  2962. * Sets the given vector "result" with the given floats.
  2963. * @param x defines the x coordinate of the source
  2964. * @param y defines the y coordinate of the source
  2965. * @param z defines the z coordinate of the source
  2966. * @param result defines the Vector3 where to store the result
  2967. */
  2968. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2969. /**
  2970. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2971. * @returns a new empty Vector3
  2972. */
  2973. static Zero(): Vector3;
  2974. /**
  2975. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2976. * @returns a new unit Vector3
  2977. */
  2978. static One(): Vector3;
  2979. /**
  2980. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2981. * @returns a new up Vector3
  2982. */
  2983. static Up(): Vector3;
  2984. /**
  2985. * Gets a up Vector3 that must not be updated
  2986. */
  2987. static get UpReadOnly(): DeepImmutable<Vector3>;
  2988. /**
  2989. * Gets a zero Vector3 that must not be updated
  2990. */
  2991. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2992. /**
  2993. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2994. * @returns a new down Vector3
  2995. */
  2996. static Down(): Vector3;
  2997. /**
  2998. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2999. * @param rightHandedSystem is the scene right-handed (negative z)
  3000. * @returns a new forward Vector3
  3001. */
  3002. static Forward(rightHandedSystem?: boolean): Vector3;
  3003. /**
  3004. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3005. * @param rightHandedSystem is the scene right-handed (negative-z)
  3006. * @returns a new forward Vector3
  3007. */
  3008. static Backward(rightHandedSystem?: boolean): Vector3;
  3009. /**
  3010. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3011. * @returns a new right Vector3
  3012. */
  3013. static Right(): Vector3;
  3014. /**
  3015. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3016. * @returns a new left Vector3
  3017. */
  3018. static Left(): Vector3;
  3019. /**
  3020. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3021. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3022. * @param vector defines the Vector3 to transform
  3023. * @param transformation defines the transformation matrix
  3024. * @returns the transformed Vector3
  3025. */
  3026. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3027. /**
  3028. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3029. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3030. * @param vector defines the Vector3 to transform
  3031. * @param transformation defines the transformation matrix
  3032. * @param result defines the Vector3 where to store the result
  3033. */
  3034. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3035. /**
  3036. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3037. * This method computes tranformed coordinates only, not transformed direction vectors
  3038. * @param x define the x coordinate of the source vector
  3039. * @param y define the y coordinate of the source vector
  3040. * @param z define the z coordinate of the source vector
  3041. * @param transformation defines the transformation matrix
  3042. * @param result defines the Vector3 where to store the result
  3043. */
  3044. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3045. /**
  3046. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3047. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3048. * @param vector defines the Vector3 to transform
  3049. * @param transformation defines the transformation matrix
  3050. * @returns the new Vector3
  3051. */
  3052. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3053. /**
  3054. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3055. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3056. * @param vector defines the Vector3 to transform
  3057. * @param transformation defines the transformation matrix
  3058. * @param result defines the Vector3 where to store the result
  3059. */
  3060. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3061. /**
  3062. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3063. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3064. * @param x define the x coordinate of the source vector
  3065. * @param y define the y coordinate of the source vector
  3066. * @param z define the z coordinate of the source vector
  3067. * @param transformation defines the transformation matrix
  3068. * @param result defines the Vector3 where to store the result
  3069. */
  3070. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3071. /**
  3072. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3073. * @param value1 defines the first control point
  3074. * @param value2 defines the second control point
  3075. * @param value3 defines the third control point
  3076. * @param value4 defines the fourth control point
  3077. * @param amount defines the amount on the spline to use
  3078. * @returns the new Vector3
  3079. */
  3080. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3081. /**
  3082. * 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"
  3083. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3084. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3085. * @param value defines the current value
  3086. * @param min defines the lower range value
  3087. * @param max defines the upper range value
  3088. * @returns the new Vector3
  3089. */
  3090. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3091. /**
  3092. * 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"
  3093. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3094. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3095. * @param value defines the current value
  3096. * @param min defines the lower range value
  3097. * @param max defines the upper range value
  3098. * @param result defines the Vector3 where to store the result
  3099. */
  3100. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3101. /**
  3102. * Checks if a given vector is inside a specific range
  3103. * @param v defines the vector to test
  3104. * @param min defines the minimum range
  3105. * @param max defines the maximum range
  3106. */
  3107. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3108. /**
  3109. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3110. * @param value1 defines the first control point
  3111. * @param tangent1 defines the first tangent vector
  3112. * @param value2 defines the second control point
  3113. * @param tangent2 defines the second tangent vector
  3114. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3115. * @returns the new Vector3
  3116. */
  3117. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3118. /**
  3119. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3120. * @param start defines the start value
  3121. * @param end defines the end value
  3122. * @param amount max defines amount between both (between 0 and 1)
  3123. * @returns the new Vector3
  3124. */
  3125. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3126. /**
  3127. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3128. * @param start defines the start value
  3129. * @param end defines the end value
  3130. * @param amount max defines amount between both (between 0 and 1)
  3131. * @param result defines the Vector3 where to store the result
  3132. */
  3133. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3134. /**
  3135. * Returns the dot product (float) between the vectors "left" and "right"
  3136. * @param left defines the left operand
  3137. * @param right defines the right operand
  3138. * @returns the dot product
  3139. */
  3140. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3141. /**
  3142. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3143. * The cross product is then orthogonal to both "left" and "right"
  3144. * @param left defines the left operand
  3145. * @param right defines the right operand
  3146. * @returns the cross product
  3147. */
  3148. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3149. /**
  3150. * Sets the given vector "result" with the cross product of "left" and "right"
  3151. * The cross product is then orthogonal to both "left" and "right"
  3152. * @param left defines the left operand
  3153. * @param right defines the right operand
  3154. * @param result defines the Vector3 where to store the result
  3155. */
  3156. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3157. /**
  3158. * Returns a new Vector3 as the normalization of the given vector
  3159. * @param vector defines the Vector3 to normalize
  3160. * @returns the new Vector3
  3161. */
  3162. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * Sets the given vector "result" with the normalization of the given first vector
  3165. * @param vector defines the Vector3 to normalize
  3166. * @param result defines the Vector3 where to store the result
  3167. */
  3168. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3169. /**
  3170. * Project a Vector3 onto screen space
  3171. * @param vector defines the Vector3 to project
  3172. * @param world defines the world matrix to use
  3173. * @param transform defines the transform (view x projection) matrix to use
  3174. * @param viewport defines the screen viewport to use
  3175. * @returns the new Vector3
  3176. */
  3177. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3178. /**
  3179. * Project a Vector3 onto screen space to reference
  3180. * @param vector defines the Vector3 to project
  3181. * @param world defines the world matrix to use
  3182. * @param transform defines the transform (view x projection) matrix to use
  3183. * @param viewport defines the screen viewport to use
  3184. * @param result the vector in which the screen space will be stored
  3185. * @returns the new Vector3
  3186. */
  3187. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3188. /** @hidden */
  3189. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3190. /**
  3191. * Unproject from screen space to object space
  3192. * @param source defines the screen space Vector3 to use
  3193. * @param viewportWidth defines the current width of the viewport
  3194. * @param viewportHeight defines the current height of the viewport
  3195. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3196. * @param transform defines the transform (view x projection) matrix to use
  3197. * @returns the new Vector3
  3198. */
  3199. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3200. /**
  3201. * Unproject from screen space to object space
  3202. * @param source defines the screen space Vector3 to use
  3203. * @param viewportWidth defines the current width of the viewport
  3204. * @param viewportHeight defines the current height of the viewport
  3205. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3206. * @param view defines the view matrix to use
  3207. * @param projection defines the projection matrix to use
  3208. * @returns the new Vector3
  3209. */
  3210. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3211. /**
  3212. * Unproject from screen space to object space
  3213. * @param source defines the screen space Vector3 to use
  3214. * @param viewportWidth defines the current width of the viewport
  3215. * @param viewportHeight defines the current height of the viewport
  3216. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3217. * @param view defines the view matrix to use
  3218. * @param projection defines the projection matrix to use
  3219. * @param result defines the Vector3 where to store the result
  3220. */
  3221. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3222. /**
  3223. * Unproject from screen space to object space
  3224. * @param sourceX defines the screen space x coordinate to use
  3225. * @param sourceY defines the screen space y coordinate to use
  3226. * @param sourceZ defines the screen space z coordinate to use
  3227. * @param viewportWidth defines the current width of the viewport
  3228. * @param viewportHeight defines the current height of the viewport
  3229. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3230. * @param view defines the view matrix to use
  3231. * @param projection defines the projection matrix to use
  3232. * @param result defines the Vector3 where to store the result
  3233. */
  3234. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3235. /**
  3236. * Gets the minimal coordinate values between two Vector3
  3237. * @param left defines the first operand
  3238. * @param right defines the second operand
  3239. * @returns the new Vector3
  3240. */
  3241. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3242. /**
  3243. * Gets the maximal coordinate values between two Vector3
  3244. * @param left defines the first operand
  3245. * @param right defines the second operand
  3246. * @returns the new Vector3
  3247. */
  3248. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3249. /**
  3250. * Returns the distance between the vectors "value1" and "value2"
  3251. * @param value1 defines the first operand
  3252. * @param value2 defines the second operand
  3253. * @returns the distance
  3254. */
  3255. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3256. /**
  3257. * Returns the squared distance between the vectors "value1" and "value2"
  3258. * @param value1 defines the first operand
  3259. * @param value2 defines the second operand
  3260. * @returns the squared distance
  3261. */
  3262. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3263. /**
  3264. * Returns a new Vector3 located at the center between "value1" and "value2"
  3265. * @param value1 defines the first operand
  3266. * @param value2 defines the second operand
  3267. * @returns the new Vector3
  3268. */
  3269. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3270. /**
  3271. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3272. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3273. * to something in order to rotate it from its local system to the given target system
  3274. * Note: axis1, axis2 and axis3 are normalized during this operation
  3275. * @param axis1 defines the first axis
  3276. * @param axis2 defines the second axis
  3277. * @param axis3 defines the third axis
  3278. * @returns a new Vector3
  3279. */
  3280. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3281. /**
  3282. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3283. * @param axis1 defines the first axis
  3284. * @param axis2 defines the second axis
  3285. * @param axis3 defines the third axis
  3286. * @param ref defines the Vector3 where to store the result
  3287. */
  3288. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3289. }
  3290. /**
  3291. * Vector4 class created for EulerAngle class conversion to Quaternion
  3292. */
  3293. export class Vector4 {
  3294. /** x value of the vector */
  3295. x: number;
  3296. /** y value of the vector */
  3297. y: number;
  3298. /** z value of the vector */
  3299. z: number;
  3300. /** w value of the vector */
  3301. w: number;
  3302. /**
  3303. * Creates a Vector4 object from the given floats.
  3304. * @param x x value of the vector
  3305. * @param y y value of the vector
  3306. * @param z z value of the vector
  3307. * @param w w value of the vector
  3308. */
  3309. constructor(
  3310. /** x value of the vector */
  3311. x: number,
  3312. /** y value of the vector */
  3313. y: number,
  3314. /** z value of the vector */
  3315. z: number,
  3316. /** w value of the vector */
  3317. w: number);
  3318. /**
  3319. * Returns the string with the Vector4 coordinates.
  3320. * @returns a string containing all the vector values
  3321. */
  3322. toString(): string;
  3323. /**
  3324. * Returns the string "Vector4".
  3325. * @returns "Vector4"
  3326. */
  3327. getClassName(): string;
  3328. /**
  3329. * Returns the Vector4 hash code.
  3330. * @returns a unique hash code
  3331. */
  3332. getHashCode(): number;
  3333. /**
  3334. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3335. * @returns the resulting array
  3336. */
  3337. asArray(): number[];
  3338. /**
  3339. * Populates the given array from the given index with the Vector4 coordinates.
  3340. * @param array array to populate
  3341. * @param index index of the array to start at (default: 0)
  3342. * @returns the Vector4.
  3343. */
  3344. toArray(array: FloatArray, index?: number): Vector4;
  3345. /**
  3346. * Update the current vector from an array
  3347. * @param array defines the destination array
  3348. * @param index defines the offset in the destination array
  3349. * @returns the current Vector3
  3350. */
  3351. fromArray(array: FloatArray, index?: number): Vector4;
  3352. /**
  3353. * Adds the given vector to the current Vector4.
  3354. * @param otherVector the vector to add
  3355. * @returns the updated Vector4.
  3356. */
  3357. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3358. /**
  3359. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3360. * @param otherVector the vector to add
  3361. * @returns the resulting vector
  3362. */
  3363. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3364. /**
  3365. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3366. * @param otherVector the vector to add
  3367. * @param result the vector to store the result
  3368. * @returns the current Vector4.
  3369. */
  3370. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3371. /**
  3372. * Subtract in place the given vector from the current Vector4.
  3373. * @param otherVector the vector to subtract
  3374. * @returns the updated Vector4.
  3375. */
  3376. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3377. /**
  3378. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3379. * @param otherVector the vector to add
  3380. * @returns the new vector with the result
  3381. */
  3382. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3383. /**
  3384. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3385. * @param otherVector the vector to subtract
  3386. * @param result the vector to store the result
  3387. * @returns the current Vector4.
  3388. */
  3389. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3390. /**
  3391. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3392. */
  3393. /**
  3394. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3395. * @param x value to subtract
  3396. * @param y value to subtract
  3397. * @param z value to subtract
  3398. * @param w value to subtract
  3399. * @returns new vector containing the result
  3400. */
  3401. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3402. /**
  3403. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3404. * @param x value to subtract
  3405. * @param y value to subtract
  3406. * @param z value to subtract
  3407. * @param w value to subtract
  3408. * @param result the vector to store the result in
  3409. * @returns the current Vector4.
  3410. */
  3411. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3412. /**
  3413. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3414. * @returns a new vector with the negated values
  3415. */
  3416. negate(): Vector4;
  3417. /**
  3418. * Negate this vector in place
  3419. * @returns this
  3420. */
  3421. negateInPlace(): Vector4;
  3422. /**
  3423. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3424. * @param result defines the Vector3 object where to store the result
  3425. * @returns the current Vector4
  3426. */
  3427. negateToRef(result: Vector4): Vector4;
  3428. /**
  3429. * Multiplies the current Vector4 coordinates by scale (float).
  3430. * @param scale the number to scale with
  3431. * @returns the updated Vector4.
  3432. */
  3433. scaleInPlace(scale: number): Vector4;
  3434. /**
  3435. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3436. * @param scale the number to scale with
  3437. * @returns a new vector with the result
  3438. */
  3439. scale(scale: number): Vector4;
  3440. /**
  3441. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3442. * @param scale the number to scale with
  3443. * @param result a vector to store the result in
  3444. * @returns the current Vector4.
  3445. */
  3446. scaleToRef(scale: number, result: Vector4): Vector4;
  3447. /**
  3448. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3449. * @param scale defines the scale factor
  3450. * @param result defines the Vector4 object where to store the result
  3451. * @returns the unmodified current Vector4
  3452. */
  3453. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3454. /**
  3455. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3456. * @param otherVector the vector to compare against
  3457. * @returns true if they are equal
  3458. */
  3459. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3460. /**
  3461. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3462. * @param otherVector vector to compare against
  3463. * @param epsilon (Default: very small number)
  3464. * @returns true if they are equal
  3465. */
  3466. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3467. /**
  3468. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3469. * @param x x value to compare against
  3470. * @param y y value to compare against
  3471. * @param z z value to compare against
  3472. * @param w w value to compare against
  3473. * @returns true if equal
  3474. */
  3475. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3476. /**
  3477. * Multiplies in place the current Vector4 by the given one.
  3478. * @param otherVector vector to multiple with
  3479. * @returns the updated Vector4.
  3480. */
  3481. multiplyInPlace(otherVector: Vector4): Vector4;
  3482. /**
  3483. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3484. * @param otherVector vector to multiple with
  3485. * @returns resulting new vector
  3486. */
  3487. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3488. /**
  3489. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3490. * @param otherVector vector to multiple with
  3491. * @param result vector to store the result
  3492. * @returns the current Vector4.
  3493. */
  3494. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3495. /**
  3496. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3497. * @param x x value multiply with
  3498. * @param y y value multiply with
  3499. * @param z z value multiply with
  3500. * @param w w value multiply with
  3501. * @returns resulting new vector
  3502. */
  3503. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3504. /**
  3505. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3506. * @param otherVector vector to devide with
  3507. * @returns resulting new vector
  3508. */
  3509. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3510. /**
  3511. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3512. * @param otherVector vector to devide with
  3513. * @param result vector to store the result
  3514. * @returns the current Vector4.
  3515. */
  3516. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3517. /**
  3518. * Divides the current Vector3 coordinates by the given ones.
  3519. * @param otherVector vector to devide with
  3520. * @returns the updated Vector3.
  3521. */
  3522. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3523. /**
  3524. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3525. * @param other defines the second operand
  3526. * @returns the current updated Vector4
  3527. */
  3528. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3529. /**
  3530. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3531. * @param other defines the second operand
  3532. * @returns the current updated Vector4
  3533. */
  3534. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3535. /**
  3536. * Gets a new Vector4 from current Vector4 floored values
  3537. * @returns a new Vector4
  3538. */
  3539. floor(): Vector4;
  3540. /**
  3541. * Gets a new Vector4 from current Vector3 floored values
  3542. * @returns a new Vector4
  3543. */
  3544. fract(): Vector4;
  3545. /**
  3546. * Returns the Vector4 length (float).
  3547. * @returns the length
  3548. */
  3549. length(): number;
  3550. /**
  3551. * Returns the Vector4 squared length (float).
  3552. * @returns the length squared
  3553. */
  3554. lengthSquared(): number;
  3555. /**
  3556. * Normalizes in place the Vector4.
  3557. * @returns the updated Vector4.
  3558. */
  3559. normalize(): Vector4;
  3560. /**
  3561. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3562. * @returns this converted to a new vector3
  3563. */
  3564. toVector3(): Vector3;
  3565. /**
  3566. * Returns a new Vector4 copied from the current one.
  3567. * @returns the new cloned vector
  3568. */
  3569. clone(): Vector4;
  3570. /**
  3571. * Updates the current Vector4 with the given one coordinates.
  3572. * @param source the source vector to copy from
  3573. * @returns the updated Vector4.
  3574. */
  3575. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3576. /**
  3577. * Updates the current Vector4 coordinates with the given floats.
  3578. * @param x float to copy from
  3579. * @param y float to copy from
  3580. * @param z float to copy from
  3581. * @param w float to copy from
  3582. * @returns the updated Vector4.
  3583. */
  3584. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3585. /**
  3586. * Updates the current Vector4 coordinates with the given floats.
  3587. * @param x float to set from
  3588. * @param y float to set from
  3589. * @param z float to set from
  3590. * @param w float to set from
  3591. * @returns the updated Vector4.
  3592. */
  3593. set(x: number, y: number, z: number, w: number): Vector4;
  3594. /**
  3595. * Copies the given float to the current Vector3 coordinates
  3596. * @param v defines the x, y, z and w coordinates of the operand
  3597. * @returns the current updated Vector3
  3598. */
  3599. setAll(v: number): Vector4;
  3600. /**
  3601. * Returns a new Vector4 set from the starting index of the given array.
  3602. * @param array the array to pull values from
  3603. * @param offset the offset into the array to start at
  3604. * @returns the new vector
  3605. */
  3606. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3607. /**
  3608. * Updates the given vector "result" from the starting index of the given array.
  3609. * @param array the array to pull values from
  3610. * @param offset the offset into the array to start at
  3611. * @param result the vector to store the result in
  3612. */
  3613. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3614. /**
  3615. * Updates the given vector "result" from the starting index of the given Float32Array.
  3616. * @param array the array to pull values from
  3617. * @param offset the offset into the array to start at
  3618. * @param result the vector to store the result in
  3619. */
  3620. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3621. /**
  3622. * Updates the given vector "result" coordinates from the given floats.
  3623. * @param x float to set from
  3624. * @param y float to set from
  3625. * @param z float to set from
  3626. * @param w float to set from
  3627. * @param result the vector to the floats in
  3628. */
  3629. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3630. /**
  3631. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3632. * @returns the new vector
  3633. */
  3634. static Zero(): Vector4;
  3635. /**
  3636. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3637. * @returns the new vector
  3638. */
  3639. static One(): Vector4;
  3640. /**
  3641. * Returns a new normalized Vector4 from the given one.
  3642. * @param vector the vector to normalize
  3643. * @returns the vector
  3644. */
  3645. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3646. /**
  3647. * Updates the given vector "result" from the normalization of the given one.
  3648. * @param vector the vector to normalize
  3649. * @param result the vector to store the result in
  3650. */
  3651. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3652. /**
  3653. * Returns a vector with the minimum values from the left and right vectors
  3654. * @param left left vector to minimize
  3655. * @param right right vector to minimize
  3656. * @returns a new vector with the minimum of the left and right vector values
  3657. */
  3658. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3659. /**
  3660. * Returns a vector with the maximum values from the left and right vectors
  3661. * @param left left vector to maximize
  3662. * @param right right vector to maximize
  3663. * @returns a new vector with the maximum of the left and right vector values
  3664. */
  3665. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3666. /**
  3667. * Returns the distance (float) between the vectors "value1" and "value2".
  3668. * @param value1 value to calulate the distance between
  3669. * @param value2 value to calulate the distance between
  3670. * @return the distance between the two vectors
  3671. */
  3672. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3673. /**
  3674. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3675. * @param value1 value to calulate the distance between
  3676. * @param value2 value to calulate the distance between
  3677. * @return the distance between the two vectors squared
  3678. */
  3679. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3680. /**
  3681. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3682. * @param value1 value to calulate the center between
  3683. * @param value2 value to calulate the center between
  3684. * @return the center between the two vectors
  3685. */
  3686. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3687. /**
  3688. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3689. * This methods computes transformed normalized direction vectors only.
  3690. * @param vector the vector to transform
  3691. * @param transformation the transformation matrix to apply
  3692. * @returns the new vector
  3693. */
  3694. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3695. /**
  3696. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3697. * This methods computes transformed normalized direction vectors only.
  3698. * @param vector the vector to transform
  3699. * @param transformation the transformation matrix to apply
  3700. * @param result the vector to store the result in
  3701. */
  3702. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3703. /**
  3704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3705. * This methods computes transformed normalized direction vectors only.
  3706. * @param x value to transform
  3707. * @param y value to transform
  3708. * @param z value to transform
  3709. * @param w value to transform
  3710. * @param transformation the transformation matrix to apply
  3711. * @param result the vector to store the results in
  3712. */
  3713. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3714. /**
  3715. * Creates a new Vector4 from a Vector3
  3716. * @param source defines the source data
  3717. * @param w defines the 4th component (default is 0)
  3718. * @returns a new Vector4
  3719. */
  3720. static FromVector3(source: Vector3, w?: number): Vector4;
  3721. }
  3722. /**
  3723. * Class used to store quaternion data
  3724. * @see https://en.wikipedia.org/wiki/Quaternion
  3725. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3726. */
  3727. export class Quaternion {
  3728. /** @hidden */
  3729. _x: number;
  3730. /** @hidden */
  3731. _y: number;
  3732. /** @hidden */
  3733. _z: number;
  3734. /** @hidden */
  3735. _w: number;
  3736. /** @hidden */
  3737. _isDirty: boolean;
  3738. /** Gets or sets the x coordinate */
  3739. get x(): number;
  3740. set x(value: number);
  3741. /** Gets or sets the y coordinate */
  3742. get y(): number;
  3743. set y(value: number);
  3744. /** Gets or sets the z coordinate */
  3745. get z(): number;
  3746. set z(value: number);
  3747. /** Gets or sets the w coordinate */
  3748. get w(): number;
  3749. set w(value: number);
  3750. /**
  3751. * Creates a new Quaternion from the given floats
  3752. * @param x defines the first component (0 by default)
  3753. * @param y defines the second component (0 by default)
  3754. * @param z defines the third component (0 by default)
  3755. * @param w defines the fourth component (1.0 by default)
  3756. */
  3757. constructor(x?: number, y?: number, z?: number, w?: number);
  3758. /**
  3759. * Gets a string representation for the current quaternion
  3760. * @returns a string with the Quaternion coordinates
  3761. */
  3762. toString(): string;
  3763. /**
  3764. * Gets the class name of the quaternion
  3765. * @returns the string "Quaternion"
  3766. */
  3767. getClassName(): string;
  3768. /**
  3769. * Gets a hash code for this quaternion
  3770. * @returns the quaternion hash code
  3771. */
  3772. getHashCode(): number;
  3773. /**
  3774. * Copy the quaternion to an array
  3775. * @returns a new array populated with 4 elements from the quaternion coordinates
  3776. */
  3777. asArray(): number[];
  3778. /**
  3779. * Check if two quaternions are equals
  3780. * @param otherQuaternion defines the second operand
  3781. * @return true if the current quaternion and the given one coordinates are strictly equals
  3782. */
  3783. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3784. /**
  3785. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3786. * @param otherQuaternion defines the other quaternion
  3787. * @param epsilon defines the minimal distance to consider equality
  3788. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3789. */
  3790. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3791. /**
  3792. * Clone the current quaternion
  3793. * @returns a new quaternion copied from the current one
  3794. */
  3795. clone(): Quaternion;
  3796. /**
  3797. * Copy a quaternion to the current one
  3798. * @param other defines the other quaternion
  3799. * @returns the updated current quaternion
  3800. */
  3801. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3802. /**
  3803. * Updates the current quaternion with the given float coordinates
  3804. * @param x defines the x coordinate
  3805. * @param y defines the y coordinate
  3806. * @param z defines the z coordinate
  3807. * @param w defines the w coordinate
  3808. * @returns the updated current quaternion
  3809. */
  3810. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3811. /**
  3812. * Updates the current quaternion from the given float coordinates
  3813. * @param x defines the x coordinate
  3814. * @param y defines the y coordinate
  3815. * @param z defines the z coordinate
  3816. * @param w defines the w coordinate
  3817. * @returns the updated current quaternion
  3818. */
  3819. set(x: number, y: number, z: number, w: number): Quaternion;
  3820. /**
  3821. * Adds two quaternions
  3822. * @param other defines the second operand
  3823. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3824. */
  3825. add(other: DeepImmutable<Quaternion>): Quaternion;
  3826. /**
  3827. * Add a quaternion to the current one
  3828. * @param other defines the quaternion to add
  3829. * @returns the current quaternion
  3830. */
  3831. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3832. /**
  3833. * Subtract two quaternions
  3834. * @param other defines the second operand
  3835. * @returns a new quaternion as the subtraction result of the given one from the current one
  3836. */
  3837. subtract(other: Quaternion): Quaternion;
  3838. /**
  3839. * Multiplies the current quaternion by a scale factor
  3840. * @param value defines the scale factor
  3841. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3842. */
  3843. scale(value: number): Quaternion;
  3844. /**
  3845. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3846. * @param scale defines the scale factor
  3847. * @param result defines the Quaternion object where to store the result
  3848. * @returns the unmodified current quaternion
  3849. */
  3850. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3851. /**
  3852. * Multiplies in place the current quaternion by a scale factor
  3853. * @param value defines the scale factor
  3854. * @returns the current modified quaternion
  3855. */
  3856. scaleInPlace(value: number): Quaternion;
  3857. /**
  3858. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3859. * @param scale defines the scale factor
  3860. * @param result defines the Quaternion object where to store the result
  3861. * @returns the unmodified current quaternion
  3862. */
  3863. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3864. /**
  3865. * Multiplies two quaternions
  3866. * @param q1 defines the second operand
  3867. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3868. */
  3869. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3870. /**
  3871. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3872. * @param q1 defines the second operand
  3873. * @param result defines the target quaternion
  3874. * @returns the current quaternion
  3875. */
  3876. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3877. /**
  3878. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3879. * @param q1 defines the second operand
  3880. * @returns the currentupdated quaternion
  3881. */
  3882. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3883. /**
  3884. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3885. * @param ref defines the target quaternion
  3886. * @returns the current quaternion
  3887. */
  3888. conjugateToRef(ref: Quaternion): Quaternion;
  3889. /**
  3890. * Conjugates in place (1-q) the current quaternion
  3891. * @returns the current updated quaternion
  3892. */
  3893. conjugateInPlace(): Quaternion;
  3894. /**
  3895. * Conjugates in place (1-q) the current quaternion
  3896. * @returns a new quaternion
  3897. */
  3898. conjugate(): Quaternion;
  3899. /**
  3900. * Gets length of current quaternion
  3901. * @returns the quaternion length (float)
  3902. */
  3903. length(): number;
  3904. /**
  3905. * Normalize in place the current quaternion
  3906. * @returns the current updated quaternion
  3907. */
  3908. normalize(): Quaternion;
  3909. /**
  3910. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3911. * @param order is a reserved parameter and is ignored for now
  3912. * @returns a new Vector3 containing the Euler angles
  3913. */
  3914. toEulerAngles(order?: string): Vector3;
  3915. /**
  3916. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3917. * @param result defines the vector which will be filled with the Euler angles
  3918. * @returns the current unchanged quaternion
  3919. */
  3920. toEulerAnglesToRef(result: Vector3): Quaternion;
  3921. /**
  3922. * Updates the given rotation matrix with the current quaternion values
  3923. * @param result defines the target matrix
  3924. * @returns the current unchanged quaternion
  3925. */
  3926. toRotationMatrix(result: Matrix): Quaternion;
  3927. /**
  3928. * Updates the current quaternion from the given rotation matrix values
  3929. * @param matrix defines the source matrix
  3930. * @returns the current updated quaternion
  3931. */
  3932. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3933. /**
  3934. * Creates a new quaternion from a rotation matrix
  3935. * @param matrix defines the source matrix
  3936. * @returns a new quaternion created from the given rotation matrix values
  3937. */
  3938. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3939. /**
  3940. * Updates the given quaternion with the given rotation matrix values
  3941. * @param matrix defines the source matrix
  3942. * @param result defines the target quaternion
  3943. */
  3944. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3945. /**
  3946. * Returns the dot product (float) between the quaternions "left" and "right"
  3947. * @param left defines the left operand
  3948. * @param right defines the right operand
  3949. * @returns the dot product
  3950. */
  3951. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3952. /**
  3953. * Checks if the two quaternions are close to each other
  3954. * @param quat0 defines the first quaternion to check
  3955. * @param quat1 defines the second quaternion to check
  3956. * @returns true if the two quaternions are close to each other
  3957. */
  3958. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3959. /**
  3960. * Creates an empty quaternion
  3961. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3962. */
  3963. static Zero(): Quaternion;
  3964. /**
  3965. * Inverse a given quaternion
  3966. * @param q defines the source quaternion
  3967. * @returns a new quaternion as the inverted current quaternion
  3968. */
  3969. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3970. /**
  3971. * Inverse a given quaternion
  3972. * @param q defines the source quaternion
  3973. * @param result the quaternion the result will be stored in
  3974. * @returns the result quaternion
  3975. */
  3976. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3977. /**
  3978. * Creates an identity quaternion
  3979. * @returns the identity quaternion
  3980. */
  3981. static Identity(): Quaternion;
  3982. /**
  3983. * Gets a boolean indicating if the given quaternion is identity
  3984. * @param quaternion defines the quaternion to check
  3985. * @returns true if the quaternion is identity
  3986. */
  3987. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3988. /**
  3989. * Creates a quaternion from a rotation around an axis
  3990. * @param axis defines the axis to use
  3991. * @param angle defines the angle to use
  3992. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3993. */
  3994. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3995. /**
  3996. * Creates a rotation around an axis and stores it into the given quaternion
  3997. * @param axis defines the axis to use
  3998. * @param angle defines the angle to use
  3999. * @param result defines the target quaternion
  4000. * @returns the target quaternion
  4001. */
  4002. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4003. /**
  4004. * Creates a new quaternion from data stored into an array
  4005. * @param array defines the data source
  4006. * @param offset defines the offset in the source array where the data starts
  4007. * @returns a new quaternion
  4008. */
  4009. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4010. /**
  4011. * Updates the given quaternion "result" from the starting index of the given array.
  4012. * @param array the array to pull values from
  4013. * @param offset the offset into the array to start at
  4014. * @param result the quaternion to store the result in
  4015. */
  4016. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4017. /**
  4018. * Create a quaternion from Euler rotation angles
  4019. * @param x Pitch
  4020. * @param y Yaw
  4021. * @param z Roll
  4022. * @returns the new Quaternion
  4023. */
  4024. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4025. /**
  4026. * Updates a quaternion from Euler rotation angles
  4027. * @param x Pitch
  4028. * @param y Yaw
  4029. * @param z Roll
  4030. * @param result the quaternion to store the result
  4031. * @returns the updated quaternion
  4032. */
  4033. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4034. /**
  4035. * Create a quaternion from Euler rotation vector
  4036. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4037. * @returns the new Quaternion
  4038. */
  4039. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4040. /**
  4041. * Updates a quaternion from Euler rotation vector
  4042. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4043. * @param result the quaternion to store the result
  4044. * @returns the updated quaternion
  4045. */
  4046. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4047. /**
  4048. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4049. * @param yaw defines the rotation around Y axis
  4050. * @param pitch defines the rotation around X axis
  4051. * @param roll defines the rotation around Z axis
  4052. * @returns the new quaternion
  4053. */
  4054. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4055. /**
  4056. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4057. * @param yaw defines the rotation around Y axis
  4058. * @param pitch defines the rotation around X axis
  4059. * @param roll defines the rotation around Z axis
  4060. * @param result defines the target quaternion
  4061. */
  4062. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4063. /**
  4064. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4065. * @param alpha defines the rotation around first axis
  4066. * @param beta defines the rotation around second axis
  4067. * @param gamma defines the rotation around third axis
  4068. * @returns the new quaternion
  4069. */
  4070. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4071. /**
  4072. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4073. * @param alpha defines the rotation around first axis
  4074. * @param beta defines the rotation around second axis
  4075. * @param gamma defines the rotation around third axis
  4076. * @param result defines the target quaternion
  4077. */
  4078. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4079. /**
  4080. * 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)
  4081. * @param axis1 defines the first axis
  4082. * @param axis2 defines the second axis
  4083. * @param axis3 defines the third axis
  4084. * @returns the new quaternion
  4085. */
  4086. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4087. /**
  4088. * 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
  4089. * @param axis1 defines the first axis
  4090. * @param axis2 defines the second axis
  4091. * @param axis3 defines the third axis
  4092. * @param ref defines the target quaternion
  4093. */
  4094. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4095. /**
  4096. * Interpolates between two quaternions
  4097. * @param left defines first quaternion
  4098. * @param right defines second quaternion
  4099. * @param amount defines the gradient to use
  4100. * @returns the new interpolated quaternion
  4101. */
  4102. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4103. /**
  4104. * Interpolates between two quaternions and stores it into a target quaternion
  4105. * @param left defines first quaternion
  4106. * @param right defines second quaternion
  4107. * @param amount defines the gradient to use
  4108. * @param result defines the target quaternion
  4109. */
  4110. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4111. /**
  4112. * Interpolate between two quaternions using Hermite interpolation
  4113. * @param value1 defines first quaternion
  4114. * @param tangent1 defines the incoming tangent
  4115. * @param value2 defines second quaternion
  4116. * @param tangent2 defines the outgoing tangent
  4117. * @param amount defines the target quaternion
  4118. * @returns the new interpolated quaternion
  4119. */
  4120. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4121. }
  4122. /**
  4123. * Class used to store matrix data (4x4)
  4124. */
  4125. export class Matrix {
  4126. /**
  4127. * Gets the precision of matrix computations
  4128. */
  4129. static get Use64Bits(): boolean;
  4130. private static _updateFlagSeed;
  4131. private static _identityReadOnly;
  4132. private _isIdentity;
  4133. private _isIdentityDirty;
  4134. private _isIdentity3x2;
  4135. private _isIdentity3x2Dirty;
  4136. /**
  4137. * Gets the update flag of the matrix which is an unique number for the matrix.
  4138. * It will be incremented every time the matrix data change.
  4139. * You can use it to speed the comparison between two versions of the same matrix.
  4140. */
  4141. updateFlag: number;
  4142. private readonly _m;
  4143. /**
  4144. * Gets the internal data of the matrix
  4145. */
  4146. get m(): DeepImmutable<Float32Array | Array<number>>;
  4147. /** @hidden */
  4148. _markAsUpdated(): void;
  4149. /** @hidden */
  4150. private _updateIdentityStatus;
  4151. /**
  4152. * Creates an empty matrix (filled with zeros)
  4153. */
  4154. constructor();
  4155. /**
  4156. * Check if the current matrix is identity
  4157. * @returns true is the matrix is the identity matrix
  4158. */
  4159. isIdentity(): boolean;
  4160. /**
  4161. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4162. * @returns true is the matrix is the identity matrix
  4163. */
  4164. isIdentityAs3x2(): boolean;
  4165. /**
  4166. * Gets the determinant of the matrix
  4167. * @returns the matrix determinant
  4168. */
  4169. determinant(): number;
  4170. /**
  4171. * Returns the matrix as a Float32Array or Array<number>
  4172. * @returns the matrix underlying array
  4173. */
  4174. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4175. /**
  4176. * Returns the matrix as a Float32Array or Array<number>
  4177. * @returns the matrix underlying array.
  4178. */
  4179. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4180. /**
  4181. * Inverts the current matrix in place
  4182. * @returns the current inverted matrix
  4183. */
  4184. invert(): Matrix;
  4185. /**
  4186. * Sets all the matrix elements to zero
  4187. * @returns the current matrix
  4188. */
  4189. reset(): Matrix;
  4190. /**
  4191. * Adds the current matrix with a second one
  4192. * @param other defines the matrix to add
  4193. * @returns a new matrix as the addition of the current matrix and the given one
  4194. */
  4195. add(other: DeepImmutable<Matrix>): Matrix;
  4196. /**
  4197. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4198. * @param other defines the matrix to add
  4199. * @param result defines the target matrix
  4200. * @returns the current matrix
  4201. */
  4202. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4203. /**
  4204. * Adds in place the given matrix to the current matrix
  4205. * @param other defines the second operand
  4206. * @returns the current updated matrix
  4207. */
  4208. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4209. /**
  4210. * Sets the given matrix to the current inverted Matrix
  4211. * @param other defines the target matrix
  4212. * @returns the unmodified current matrix
  4213. */
  4214. invertToRef(other: Matrix): Matrix;
  4215. /**
  4216. * add a value at the specified position in the current Matrix
  4217. * @param index the index of the value within the matrix. between 0 and 15.
  4218. * @param value the value to be added
  4219. * @returns the current updated matrix
  4220. */
  4221. addAtIndex(index: number, value: number): Matrix;
  4222. /**
  4223. * mutiply the specified position in the current Matrix by a value
  4224. * @param index the index of the value within the matrix. between 0 and 15.
  4225. * @param value the value to be added
  4226. * @returns the current updated matrix
  4227. */
  4228. multiplyAtIndex(index: number, value: number): Matrix;
  4229. /**
  4230. * Inserts the translation vector (using 3 floats) in the current matrix
  4231. * @param x defines the 1st component of the translation
  4232. * @param y defines the 2nd component of the translation
  4233. * @param z defines the 3rd component of the translation
  4234. * @returns the current updated matrix
  4235. */
  4236. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4237. /**
  4238. * Adds the translation vector (using 3 floats) in the current matrix
  4239. * @param x defines the 1st component of the translation
  4240. * @param y defines the 2nd component of the translation
  4241. * @param z defines the 3rd component of the translation
  4242. * @returns the current updated matrix
  4243. */
  4244. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4245. /**
  4246. * Inserts the translation vector in the current matrix
  4247. * @param vector3 defines the translation to insert
  4248. * @returns the current updated matrix
  4249. */
  4250. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4251. /**
  4252. * Gets the translation value of the current matrix
  4253. * @returns a new Vector3 as the extracted translation from the matrix
  4254. */
  4255. getTranslation(): Vector3;
  4256. /**
  4257. * Fill a Vector3 with the extracted translation from the matrix
  4258. * @param result defines the Vector3 where to store the translation
  4259. * @returns the current matrix
  4260. */
  4261. getTranslationToRef(result: Vector3): Matrix;
  4262. /**
  4263. * Remove rotation and scaling part from the matrix
  4264. * @returns the updated matrix
  4265. */
  4266. removeRotationAndScaling(): Matrix;
  4267. /**
  4268. * Multiply two matrices
  4269. * @param other defines the second operand
  4270. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4271. */
  4272. multiply(other: DeepImmutable<Matrix>): Matrix;
  4273. /**
  4274. * Copy the current matrix from the given one
  4275. * @param other defines the source matrix
  4276. * @returns the current updated matrix
  4277. */
  4278. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4279. /**
  4280. * Populates the given array from the starting index with the current matrix values
  4281. * @param array defines the target array
  4282. * @param offset defines the offset in the target array where to start storing values
  4283. * @returns the current matrix
  4284. */
  4285. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4286. /**
  4287. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4288. * @param other defines the second operand
  4289. * @param result defines the matrix where to store the multiplication
  4290. * @returns the current matrix
  4291. */
  4292. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4293. /**
  4294. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4295. * @param other defines the second operand
  4296. * @param result defines the array where to store the multiplication
  4297. * @param offset defines the offset in the target array where to start storing values
  4298. * @returns the current matrix
  4299. */
  4300. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4301. /**
  4302. * Check equality between this matrix and a second one
  4303. * @param value defines the second matrix to compare
  4304. * @returns true is the current matrix and the given one values are strictly equal
  4305. */
  4306. equals(value: DeepImmutable<Matrix>): boolean;
  4307. /**
  4308. * Clone the current matrix
  4309. * @returns a new matrix from the current matrix
  4310. */
  4311. clone(): Matrix;
  4312. /**
  4313. * Returns the name of the current matrix class
  4314. * @returns the string "Matrix"
  4315. */
  4316. getClassName(): string;
  4317. /**
  4318. * Gets the hash code of the current matrix
  4319. * @returns the hash code
  4320. */
  4321. getHashCode(): number;
  4322. /**
  4323. * Decomposes the current Matrix into a translation, rotation and scaling components
  4324. * @param scale defines the scale vector3 given as a reference to update
  4325. * @param rotation defines the rotation quaternion given as a reference to update
  4326. * @param translation defines the translation vector3 given as a reference to update
  4327. * @returns true if operation was successful
  4328. */
  4329. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4330. /**
  4331. * Gets specific row of the matrix
  4332. * @param index defines the number of the row to get
  4333. * @returns the index-th row of the current matrix as a new Vector4
  4334. */
  4335. getRow(index: number): Nullable<Vector4>;
  4336. /**
  4337. * Sets the index-th row of the current matrix to the vector4 values
  4338. * @param index defines the number of the row to set
  4339. * @param row defines the target vector4
  4340. * @returns the updated current matrix
  4341. */
  4342. setRow(index: number, row: Vector4): Matrix;
  4343. /**
  4344. * Compute the transpose of the matrix
  4345. * @returns the new transposed matrix
  4346. */
  4347. transpose(): Matrix;
  4348. /**
  4349. * Compute the transpose of the matrix and store it in a given matrix
  4350. * @param result defines the target matrix
  4351. * @returns the current matrix
  4352. */
  4353. transposeToRef(result: Matrix): Matrix;
  4354. /**
  4355. * Sets the index-th row of the current matrix with the given 4 x float values
  4356. * @param index defines the row index
  4357. * @param x defines the x component to set
  4358. * @param y defines the y component to set
  4359. * @param z defines the z component to set
  4360. * @param w defines the w component to set
  4361. * @returns the updated current matrix
  4362. */
  4363. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4364. /**
  4365. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4366. * @param scale defines the scale factor
  4367. * @returns a new matrix
  4368. */
  4369. scale(scale: number): Matrix;
  4370. /**
  4371. * Scale the current matrix values by a factor to a given result matrix
  4372. * @param scale defines the scale factor
  4373. * @param result defines the matrix to store the result
  4374. * @returns the current matrix
  4375. */
  4376. scaleToRef(scale: number, result: Matrix): Matrix;
  4377. /**
  4378. * Scale the current matrix values by a factor and add the result to a given matrix
  4379. * @param scale defines the scale factor
  4380. * @param result defines the Matrix to store the result
  4381. * @returns the current matrix
  4382. */
  4383. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4384. /**
  4385. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4386. * @param ref matrix to store the result
  4387. */
  4388. toNormalMatrix(ref: Matrix): void;
  4389. /**
  4390. * Gets only rotation part of the current matrix
  4391. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4392. */
  4393. getRotationMatrix(): Matrix;
  4394. /**
  4395. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4396. * @param result defines the target matrix to store data to
  4397. * @returns the current matrix
  4398. */
  4399. getRotationMatrixToRef(result: Matrix): Matrix;
  4400. /**
  4401. * Toggles model matrix from being right handed to left handed in place and vice versa
  4402. */
  4403. toggleModelMatrixHandInPlace(): void;
  4404. /**
  4405. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4406. */
  4407. toggleProjectionMatrixHandInPlace(): void;
  4408. /**
  4409. * Creates a matrix from an array
  4410. * @param array defines the source array
  4411. * @param offset defines an offset in the source array
  4412. * @returns a new Matrix set from the starting index of the given array
  4413. */
  4414. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4415. /**
  4416. * Copy the content of an array into a given matrix
  4417. * @param array defines the source array
  4418. * @param offset defines an offset in the source array
  4419. * @param result defines the target matrix
  4420. */
  4421. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4422. /**
  4423. * Stores an array into a matrix after having multiplied each component by a given factor
  4424. * @param array defines the source array
  4425. * @param offset defines the offset in the source array
  4426. * @param scale defines the scaling factor
  4427. * @param result defines the target matrix
  4428. */
  4429. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4430. /**
  4431. * Gets an identity matrix that must not be updated
  4432. */
  4433. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4434. /**
  4435. * Stores a list of values (16) inside a given matrix
  4436. * @param initialM11 defines 1st value of 1st row
  4437. * @param initialM12 defines 2nd value of 1st row
  4438. * @param initialM13 defines 3rd value of 1st row
  4439. * @param initialM14 defines 4th value of 1st row
  4440. * @param initialM21 defines 1st value of 2nd row
  4441. * @param initialM22 defines 2nd value of 2nd row
  4442. * @param initialM23 defines 3rd value of 2nd row
  4443. * @param initialM24 defines 4th value of 2nd row
  4444. * @param initialM31 defines 1st value of 3rd row
  4445. * @param initialM32 defines 2nd value of 3rd row
  4446. * @param initialM33 defines 3rd value of 3rd row
  4447. * @param initialM34 defines 4th value of 3rd row
  4448. * @param initialM41 defines 1st value of 4th row
  4449. * @param initialM42 defines 2nd value of 4th row
  4450. * @param initialM43 defines 3rd value of 4th row
  4451. * @param initialM44 defines 4th value of 4th row
  4452. * @param result defines the target matrix
  4453. */
  4454. 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;
  4455. /**
  4456. * Creates new matrix from a list of values (16)
  4457. * @param initialM11 defines 1st value of 1st row
  4458. * @param initialM12 defines 2nd value of 1st row
  4459. * @param initialM13 defines 3rd value of 1st row
  4460. * @param initialM14 defines 4th value of 1st row
  4461. * @param initialM21 defines 1st value of 2nd row
  4462. * @param initialM22 defines 2nd value of 2nd row
  4463. * @param initialM23 defines 3rd value of 2nd row
  4464. * @param initialM24 defines 4th value of 2nd row
  4465. * @param initialM31 defines 1st value of 3rd row
  4466. * @param initialM32 defines 2nd value of 3rd row
  4467. * @param initialM33 defines 3rd value of 3rd row
  4468. * @param initialM34 defines 4th value of 3rd row
  4469. * @param initialM41 defines 1st value of 4th row
  4470. * @param initialM42 defines 2nd value of 4th row
  4471. * @param initialM43 defines 3rd value of 4th row
  4472. * @param initialM44 defines 4th value of 4th row
  4473. * @returns the new matrix
  4474. */
  4475. 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;
  4476. /**
  4477. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4478. * @param scale defines the scale vector3
  4479. * @param rotation defines the rotation quaternion
  4480. * @param translation defines the translation vector3
  4481. * @returns a new matrix
  4482. */
  4483. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4484. /**
  4485. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4486. * @param scale defines the scale vector3
  4487. * @param rotation defines the rotation quaternion
  4488. * @param translation defines the translation vector3
  4489. * @param result defines the target matrix
  4490. */
  4491. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4492. /**
  4493. * Creates a new identity matrix
  4494. * @returns a new identity matrix
  4495. */
  4496. static Identity(): Matrix;
  4497. /**
  4498. * Creates a new identity matrix and stores the result in a given matrix
  4499. * @param result defines the target matrix
  4500. */
  4501. static IdentityToRef(result: Matrix): void;
  4502. /**
  4503. * Creates a new zero matrix
  4504. * @returns a new zero matrix
  4505. */
  4506. static Zero(): Matrix;
  4507. /**
  4508. * Creates a new rotation matrix for "angle" radians around the X axis
  4509. * @param angle defines the angle (in radians) to use
  4510. * @return the new matrix
  4511. */
  4512. static RotationX(angle: number): Matrix;
  4513. /**
  4514. * Creates a new matrix as the invert of a given matrix
  4515. * @param source defines the source matrix
  4516. * @returns the new matrix
  4517. */
  4518. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4519. /**
  4520. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4521. * @param angle defines the angle (in radians) to use
  4522. * @param result defines the target matrix
  4523. */
  4524. static RotationXToRef(angle: number, result: Matrix): void;
  4525. /**
  4526. * Creates a new rotation matrix for "angle" radians around the Y axis
  4527. * @param angle defines the angle (in radians) to use
  4528. * @return the new matrix
  4529. */
  4530. static RotationY(angle: number): Matrix;
  4531. /**
  4532. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4533. * @param angle defines the angle (in radians) to use
  4534. * @param result defines the target matrix
  4535. */
  4536. static RotationYToRef(angle: number, result: Matrix): void;
  4537. /**
  4538. * Creates a new rotation matrix for "angle" radians around the Z axis
  4539. * @param angle defines the angle (in radians) to use
  4540. * @return the new matrix
  4541. */
  4542. static RotationZ(angle: number): Matrix;
  4543. /**
  4544. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4545. * @param angle defines the angle (in radians) to use
  4546. * @param result defines the target matrix
  4547. */
  4548. static RotationZToRef(angle: number, result: Matrix): void;
  4549. /**
  4550. * Creates a new rotation matrix for "angle" radians around the given axis
  4551. * @param axis defines the axis to use
  4552. * @param angle defines the angle (in radians) to use
  4553. * @return the new matrix
  4554. */
  4555. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4556. /**
  4557. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4558. * @param axis defines the axis to use
  4559. * @param angle defines the angle (in radians) to use
  4560. * @param result defines the target matrix
  4561. */
  4562. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4563. /**
  4564. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4565. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4566. * @param from defines the vector to align
  4567. * @param to defines the vector to align to
  4568. * @param result defines the target matrix
  4569. */
  4570. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4571. /**
  4572. * Creates a rotation matrix
  4573. * @param yaw defines the yaw angle in radians (Y axis)
  4574. * @param pitch defines the pitch angle in radians (X axis)
  4575. * @param roll defines the roll angle in radians (Z axis)
  4576. * @returns the new rotation matrix
  4577. */
  4578. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4579. /**
  4580. * Creates a rotation matrix and stores it in a given matrix
  4581. * @param yaw defines the yaw angle in radians (Y axis)
  4582. * @param pitch defines the pitch angle in radians (X axis)
  4583. * @param roll defines the roll angle in radians (Z axis)
  4584. * @param result defines the target matrix
  4585. */
  4586. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4587. /**
  4588. * Creates a scaling matrix
  4589. * @param x defines the scale factor on X axis
  4590. * @param y defines the scale factor on Y axis
  4591. * @param z defines the scale factor on Z axis
  4592. * @returns the new matrix
  4593. */
  4594. static Scaling(x: number, y: number, z: number): Matrix;
  4595. /**
  4596. * Creates a scaling matrix and stores it in a given matrix
  4597. * @param x defines the scale factor on X axis
  4598. * @param y defines the scale factor on Y axis
  4599. * @param z defines the scale factor on Z axis
  4600. * @param result defines the target matrix
  4601. */
  4602. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4603. /**
  4604. * Creates a translation matrix
  4605. * @param x defines the translation on X axis
  4606. * @param y defines the translation on Y axis
  4607. * @param z defines the translationon Z axis
  4608. * @returns the new matrix
  4609. */
  4610. static Translation(x: number, y: number, z: number): Matrix;
  4611. /**
  4612. * Creates a translation matrix and stores it in a given matrix
  4613. * @param x defines the translation on X axis
  4614. * @param y defines the translation on Y axis
  4615. * @param z defines the translationon Z axis
  4616. * @param result defines the target matrix
  4617. */
  4618. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4619. /**
  4620. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4621. * @param startValue defines the start value
  4622. * @param endValue defines the end value
  4623. * @param gradient defines the gradient factor
  4624. * @returns the new matrix
  4625. */
  4626. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4627. /**
  4628. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4629. * @param startValue defines the start value
  4630. * @param endValue defines the end value
  4631. * @param gradient defines the gradient factor
  4632. * @param result defines the Matrix object where to store data
  4633. */
  4634. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4635. /**
  4636. * Builds a new matrix whose values are computed by:
  4637. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4638. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4639. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4640. * @param startValue defines the first matrix
  4641. * @param endValue defines the second matrix
  4642. * @param gradient defines the gradient between the two matrices
  4643. * @returns the new matrix
  4644. */
  4645. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4646. /**
  4647. * Update a matrix to values which are computed by:
  4648. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4649. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4650. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4651. * @param startValue defines the first matrix
  4652. * @param endValue defines the second matrix
  4653. * @param gradient defines the gradient between the two matrices
  4654. * @param result defines the target matrix
  4655. */
  4656. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4657. /**
  4658. * 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"
  4659. * This function works in left handed mode
  4660. * @param eye defines the final position of the entity
  4661. * @param target defines where the entity should look at
  4662. * @param up defines the up vector for the entity
  4663. * @returns the new matrix
  4664. */
  4665. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4666. /**
  4667. * 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".
  4668. * This function works in left handed mode
  4669. * @param eye defines the final position of the entity
  4670. * @param target defines where the entity should look at
  4671. * @param up defines the up vector for the entity
  4672. * @param result defines the target matrix
  4673. */
  4674. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4675. /**
  4676. * 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"
  4677. * This function works in right handed mode
  4678. * @param eye defines the final position of the entity
  4679. * @param target defines where the entity should look at
  4680. * @param up defines the up vector for the entity
  4681. * @returns the new matrix
  4682. */
  4683. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4684. /**
  4685. * 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".
  4686. * This function works in right handed mode
  4687. * @param eye defines the final position of the entity
  4688. * @param target defines where the entity should look at
  4689. * @param up defines the up vector for the entity
  4690. * @param result defines the target matrix
  4691. */
  4692. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4693. /**
  4694. * Create a left-handed orthographic projection matrix
  4695. * @param width defines the viewport width
  4696. * @param height defines the viewport height
  4697. * @param znear defines the near clip plane
  4698. * @param zfar defines the far clip plane
  4699. * @returns a new matrix as a left-handed orthographic projection matrix
  4700. */
  4701. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4702. /**
  4703. * Store a left-handed orthographic projection to a given matrix
  4704. * @param width defines the viewport width
  4705. * @param height defines the viewport height
  4706. * @param znear defines the near clip plane
  4707. * @param zfar defines the far clip plane
  4708. * @param result defines the target matrix
  4709. */
  4710. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4711. /**
  4712. * Create a left-handed orthographic projection matrix
  4713. * @param left defines the viewport left coordinate
  4714. * @param right defines the viewport right coordinate
  4715. * @param bottom defines the viewport bottom coordinate
  4716. * @param top defines the viewport top coordinate
  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 orthographic projection matrix
  4720. */
  4721. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4722. /**
  4723. * Stores a left-handed orthographic projection into a given matrix
  4724. * @param left defines the viewport left coordinate
  4725. * @param right defines the viewport right coordinate
  4726. * @param bottom defines the viewport bottom coordinate
  4727. * @param top defines the viewport top coordinate
  4728. * @param znear defines the near clip plane
  4729. * @param zfar defines the far clip plane
  4730. * @param result defines the target matrix
  4731. */
  4732. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4733. /**
  4734. * Creates a right-handed orthographic projection matrix
  4735. * @param left defines the viewport left coordinate
  4736. * @param right defines the viewport right coordinate
  4737. * @param bottom defines the viewport bottom coordinate
  4738. * @param top defines the viewport top coordinate
  4739. * @param znear defines the near clip plane
  4740. * @param zfar defines the far clip plane
  4741. * @returns a new matrix as a right-handed orthographic projection matrix
  4742. */
  4743. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4744. /**
  4745. * Stores a right-handed orthographic projection into a given matrix
  4746. * @param left defines the viewport left coordinate
  4747. * @param right defines the viewport right coordinate
  4748. * @param bottom defines the viewport bottom coordinate
  4749. * @param top defines the viewport top coordinate
  4750. * @param znear defines the near clip plane
  4751. * @param zfar defines the far clip plane
  4752. * @param result defines the target matrix
  4753. */
  4754. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4755. /**
  4756. * Creates a left-handed perspective projection matrix
  4757. * @param width defines the viewport width
  4758. * @param height defines the viewport height
  4759. * @param znear defines the near clip plane
  4760. * @param zfar defines the far clip plane
  4761. * @returns a new matrix as a left-handed perspective projection matrix
  4762. */
  4763. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4764. /**
  4765. * Creates a left-handed perspective projection matrix
  4766. * @param fov defines the horizontal field of view
  4767. * @param aspect defines the aspect ratio
  4768. * @param znear defines the near clip plane
  4769. * @param zfar defines the far clip plane
  4770. * @returns a new matrix as a left-handed perspective projection matrix
  4771. */
  4772. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4773. /**
  4774. * Stores a left-handed perspective projection into a given matrix
  4775. * @param fov defines the horizontal field of view
  4776. * @param aspect defines the aspect ratio
  4777. * @param znear defines the near clip plane
  4778. * @param zfar defines the far clip plane
  4779. * @param result defines the target matrix
  4780. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4781. */
  4782. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4783. /**
  4784. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4785. * @param fov defines the horizontal field of view
  4786. * @param aspect defines the aspect ratio
  4787. * @param znear defines the near clip plane
  4788. * @param zfar not used as infinity is used as far clip
  4789. * @param result defines the target matrix
  4790. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4791. */
  4792. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4793. /**
  4794. * Creates a right-handed perspective projection matrix
  4795. * @param fov defines the horizontal field of view
  4796. * @param aspect defines the aspect ratio
  4797. * @param znear defines the near clip plane
  4798. * @param zfar defines the far clip plane
  4799. * @returns a new matrix as a right-handed perspective projection matrix
  4800. */
  4801. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4802. /**
  4803. * Stores a right-handed perspective projection into a given matrix
  4804. * @param fov defines the horizontal field of view
  4805. * @param aspect defines the aspect ratio
  4806. * @param znear defines the near clip plane
  4807. * @param zfar defines the far clip plane
  4808. * @param result defines the target matrix
  4809. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4810. */
  4811. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4812. /**
  4813. * Stores a right-handed perspective projection into a given matrix
  4814. * @param fov defines the horizontal field of view
  4815. * @param aspect defines the aspect ratio
  4816. * @param znear defines the near clip plane
  4817. * @param zfar not used as infinity is used as far clip
  4818. * @param result defines the target matrix
  4819. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4820. */
  4821. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4822. /**
  4823. * Stores a perspective projection for WebVR info a given matrix
  4824. * @param fov defines the field of view
  4825. * @param znear defines the near clip plane
  4826. * @param zfar defines the far clip plane
  4827. * @param result defines the target matrix
  4828. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4829. */
  4830. static PerspectiveFovWebVRToRef(fov: {
  4831. upDegrees: number;
  4832. downDegrees: number;
  4833. leftDegrees: number;
  4834. rightDegrees: number;
  4835. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4836. /**
  4837. * Computes a complete transformation matrix
  4838. * @param viewport defines the viewport to use
  4839. * @param world defines the world matrix
  4840. * @param view defines the view matrix
  4841. * @param projection defines the projection matrix
  4842. * @param zmin defines the near clip plane
  4843. * @param zmax defines the far clip plane
  4844. * @returns the transformation matrix
  4845. */
  4846. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4847. /**
  4848. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4849. * @param matrix defines the matrix to use
  4850. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4851. */
  4852. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4853. /**
  4854. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4855. * @param matrix defines the matrix to use
  4856. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4857. */
  4858. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4859. /**
  4860. * Compute the transpose of a given matrix
  4861. * @param matrix defines the matrix to transpose
  4862. * @returns the new matrix
  4863. */
  4864. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4865. /**
  4866. * Compute the transpose of a matrix and store it in a target matrix
  4867. * @param matrix defines the matrix to transpose
  4868. * @param result defines the target matrix
  4869. */
  4870. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4871. /**
  4872. * Computes a reflection matrix from a plane
  4873. * @param plane defines the reflection plane
  4874. * @returns a new matrix
  4875. */
  4876. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4877. /**
  4878. * Computes a reflection matrix from a plane
  4879. * @param plane defines the reflection plane
  4880. * @param result defines the target matrix
  4881. */
  4882. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4883. /**
  4884. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4885. * @param xaxis defines the value of the 1st axis
  4886. * @param yaxis defines the value of the 2nd axis
  4887. * @param zaxis defines the value of the 3rd axis
  4888. * @param result defines the target matrix
  4889. */
  4890. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4891. /**
  4892. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4893. * @param quat defines the quaternion to use
  4894. * @param result defines the target matrix
  4895. */
  4896. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4897. }
  4898. /**
  4899. * @hidden
  4900. */
  4901. export class TmpVectors {
  4902. static Vector2: Vector2[];
  4903. static Vector3: Vector3[];
  4904. static Vector4: Vector4[];
  4905. static Quaternion: Quaternion[];
  4906. static Matrix: Matrix[];
  4907. }
  4908. }
  4909. declare module "babylonjs/Maths/math.path" {
  4910. import { DeepImmutable, Nullable } from "babylonjs/types";
  4911. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4912. /**
  4913. * Defines potential orientation for back face culling
  4914. */
  4915. export enum Orientation {
  4916. /**
  4917. * Clockwise
  4918. */
  4919. CW = 0,
  4920. /** Counter clockwise */
  4921. CCW = 1
  4922. }
  4923. /** Class used to represent a Bezier curve */
  4924. export class BezierCurve {
  4925. /**
  4926. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4927. * @param t defines the time
  4928. * @param x1 defines the left coordinate on X axis
  4929. * @param y1 defines the left coordinate on Y axis
  4930. * @param x2 defines the right coordinate on X axis
  4931. * @param y2 defines the right coordinate on Y axis
  4932. * @returns the interpolated value
  4933. */
  4934. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4935. }
  4936. /**
  4937. * Defines angle representation
  4938. */
  4939. export class Angle {
  4940. private _radians;
  4941. /**
  4942. * Creates an Angle object of "radians" radians (float).
  4943. * @param radians the angle in radians
  4944. */
  4945. constructor(radians: number);
  4946. /**
  4947. * Get value in degrees
  4948. * @returns the Angle value in degrees (float)
  4949. */
  4950. degrees(): number;
  4951. /**
  4952. * Get value in radians
  4953. * @returns the Angle value in radians (float)
  4954. */
  4955. radians(): number;
  4956. /**
  4957. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4958. * @param a defines first point as the origin
  4959. * @param b defines point
  4960. * @returns a new Angle
  4961. */
  4962. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4963. /**
  4964. * Gets a new Angle object from the given float in radians
  4965. * @param radians defines the angle value in radians
  4966. * @returns a new Angle
  4967. */
  4968. static FromRadians(radians: number): Angle;
  4969. /**
  4970. * Gets a new Angle object from the given float in degrees
  4971. * @param degrees defines the angle value in degrees
  4972. * @returns a new Angle
  4973. */
  4974. static FromDegrees(degrees: number): Angle;
  4975. }
  4976. /**
  4977. * This represents an arc in a 2d space.
  4978. */
  4979. export class Arc2 {
  4980. /** Defines the start point of the arc */
  4981. startPoint: Vector2;
  4982. /** Defines the mid point of the arc */
  4983. midPoint: Vector2;
  4984. /** Defines the end point of the arc */
  4985. endPoint: Vector2;
  4986. /**
  4987. * Defines the center point of the arc.
  4988. */
  4989. centerPoint: Vector2;
  4990. /**
  4991. * Defines the radius of the arc.
  4992. */
  4993. radius: number;
  4994. /**
  4995. * Defines the angle of the arc (from mid point to end point).
  4996. */
  4997. angle: Angle;
  4998. /**
  4999. * Defines the start angle of the arc (from start point to middle point).
  5000. */
  5001. startAngle: Angle;
  5002. /**
  5003. * Defines the orientation of the arc (clock wise/counter clock wise).
  5004. */
  5005. orientation: Orientation;
  5006. /**
  5007. * Creates an Arc object from the three given points : start, middle and end.
  5008. * @param startPoint Defines the start point of the arc
  5009. * @param midPoint Defines the midlle point of the arc
  5010. * @param endPoint Defines the end point of the arc
  5011. */
  5012. constructor(
  5013. /** Defines the start point of the arc */
  5014. startPoint: Vector2,
  5015. /** Defines the mid point of the arc */
  5016. midPoint: Vector2,
  5017. /** Defines the end point of the arc */
  5018. endPoint: Vector2);
  5019. }
  5020. /**
  5021. * Represents a 2D path made up of multiple 2D points
  5022. */
  5023. export class Path2 {
  5024. private _points;
  5025. private _length;
  5026. /**
  5027. * If the path start and end point are the same
  5028. */
  5029. closed: boolean;
  5030. /**
  5031. * Creates a Path2 object from the starting 2D coordinates x and y.
  5032. * @param x the starting points x value
  5033. * @param y the starting points y value
  5034. */
  5035. constructor(x: number, y: number);
  5036. /**
  5037. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5038. * @param x the added points x value
  5039. * @param y the added points y value
  5040. * @returns the updated Path2.
  5041. */
  5042. addLineTo(x: number, y: number): Path2;
  5043. /**
  5044. * 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.
  5045. * @param midX middle point x value
  5046. * @param midY middle point y value
  5047. * @param endX end point x value
  5048. * @param endY end point y value
  5049. * @param numberOfSegments (default: 36)
  5050. * @returns the updated Path2.
  5051. */
  5052. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5053. /**
  5054. * Closes the Path2.
  5055. * @returns the Path2.
  5056. */
  5057. close(): Path2;
  5058. /**
  5059. * Gets the sum of the distance between each sequential point in the path
  5060. * @returns the Path2 total length (float).
  5061. */
  5062. length(): number;
  5063. /**
  5064. * Gets the points which construct the path
  5065. * @returns the Path2 internal array of points.
  5066. */
  5067. getPoints(): Vector2[];
  5068. /**
  5069. * Retreives the point at the distance aways from the starting point
  5070. * @param normalizedLengthPosition the length along the path to retreive the point from
  5071. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5072. */
  5073. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5074. /**
  5075. * Creates a new path starting from an x and y position
  5076. * @param x starting x value
  5077. * @param y starting y value
  5078. * @returns a new Path2 starting at the coordinates (x, y).
  5079. */
  5080. static StartingAt(x: number, y: number): Path2;
  5081. }
  5082. /**
  5083. * Represents a 3D path made up of multiple 3D points
  5084. */
  5085. export class Path3D {
  5086. /**
  5087. * an array of Vector3, the curve axis of the Path3D
  5088. */
  5089. path: Vector3[];
  5090. private _curve;
  5091. private _distances;
  5092. private _tangents;
  5093. private _normals;
  5094. private _binormals;
  5095. private _raw;
  5096. private _alignTangentsWithPath;
  5097. private readonly _pointAtData;
  5098. /**
  5099. * new Path3D(path, normal, raw)
  5100. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5101. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5102. * @param path an array of Vector3, the curve axis of the Path3D
  5103. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5104. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5105. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5106. */
  5107. constructor(
  5108. /**
  5109. * an array of Vector3, the curve axis of the Path3D
  5110. */
  5111. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5112. /**
  5113. * Returns the Path3D array of successive Vector3 designing its curve.
  5114. * @returns the Path3D array of successive Vector3 designing its curve.
  5115. */
  5116. getCurve(): Vector3[];
  5117. /**
  5118. * Returns the Path3D array of successive Vector3 designing its curve.
  5119. * @returns the Path3D array of successive Vector3 designing its curve.
  5120. */
  5121. getPoints(): Vector3[];
  5122. /**
  5123. * @returns the computed length (float) of the path.
  5124. */
  5125. length(): number;
  5126. /**
  5127. * Returns an array populated with tangent vectors on each Path3D curve point.
  5128. * @returns an array populated with tangent vectors on each Path3D curve point.
  5129. */
  5130. getTangents(): Vector3[];
  5131. /**
  5132. * Returns an array populated with normal vectors on each Path3D curve point.
  5133. * @returns an array populated with normal vectors on each Path3D curve point.
  5134. */
  5135. getNormals(): Vector3[];
  5136. /**
  5137. * Returns an array populated with binormal vectors on each Path3D curve point.
  5138. * @returns an array populated with binormal vectors on each Path3D curve point.
  5139. */
  5140. getBinormals(): Vector3[];
  5141. /**
  5142. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5143. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5144. */
  5145. getDistances(): number[];
  5146. /**
  5147. * Returns an interpolated point along this path
  5148. * @param position the position of the point along this path, from 0.0 to 1.0
  5149. * @returns a new Vector3 as the point
  5150. */
  5151. getPointAt(position: number): Vector3;
  5152. /**
  5153. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5154. * @param position the position of the point along this path, from 0.0 to 1.0
  5155. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5156. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5157. */
  5158. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5159. /**
  5160. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5161. * @param position the position of the point along this path, from 0.0 to 1.0
  5162. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5163. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5164. */
  5165. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5166. /**
  5167. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5168. * @param position the position of the point along this path, from 0.0 to 1.0
  5169. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5170. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5171. */
  5172. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5173. /**
  5174. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5175. * @param position the position of the point along this path, from 0.0 to 1.0
  5176. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5177. */
  5178. getDistanceAt(position: number): number;
  5179. /**
  5180. * Returns the array index of the previous point of an interpolated point along this path
  5181. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5182. * @returns the array index
  5183. */
  5184. getPreviousPointIndexAt(position: number): number;
  5185. /**
  5186. * 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)
  5187. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5188. * @returns the sub position
  5189. */
  5190. getSubPositionAt(position: number): number;
  5191. /**
  5192. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5193. * @param target the vector of which to get the closest position to
  5194. * @returns the position of the closest virtual point on this path to the target vector
  5195. */
  5196. getClosestPositionTo(target: Vector3): number;
  5197. /**
  5198. * Returns a sub path (slice) of this path
  5199. * @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
  5200. * @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
  5201. * @returns a sub path (slice) of this path
  5202. */
  5203. slice(start?: number, end?: number): Path3D;
  5204. /**
  5205. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5206. * @param path path which all values are copied into the curves points
  5207. * @param firstNormal which should be projected onto the curve
  5208. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5209. * @returns the same object updated.
  5210. */
  5211. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5212. private _compute;
  5213. private _getFirstNonNullVector;
  5214. private _getLastNonNullVector;
  5215. private _normalVector;
  5216. /**
  5217. * Updates the point at data for an interpolated point along this curve
  5218. * @param position the position of the point along this curve, from 0.0 to 1.0
  5219. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5220. * @returns the (updated) point at data
  5221. */
  5222. private _updatePointAtData;
  5223. /**
  5224. * Updates the point at data from the specified parameters
  5225. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5226. * @param point the interpolated point
  5227. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5228. */
  5229. private _setPointAtData;
  5230. /**
  5231. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5232. */
  5233. private _updateInterpolationMatrix;
  5234. }
  5235. /**
  5236. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5237. * A Curve3 is designed from a series of successive Vector3.
  5238. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5239. */
  5240. export class Curve3 {
  5241. private _points;
  5242. private _length;
  5243. /**
  5244. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5245. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5246. * @param v1 (Vector3) the control point
  5247. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5248. * @param nbPoints (integer) the wanted number of points in the curve
  5249. * @returns the created Curve3
  5250. */
  5251. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5252. /**
  5253. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5254. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5255. * @param v1 (Vector3) the first control point
  5256. * @param v2 (Vector3) the second control point
  5257. * @param v3 (Vector3) the end point of the Cubic Bezier
  5258. * @param nbPoints (integer) the wanted number of points in the curve
  5259. * @returns the created Curve3
  5260. */
  5261. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5262. /**
  5263. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5264. * @param p1 (Vector3) the origin point of the Hermite Spline
  5265. * @param t1 (Vector3) the tangent vector at the origin point
  5266. * @param p2 (Vector3) the end point of the Hermite Spline
  5267. * @param t2 (Vector3) the tangent vector at the end point
  5268. * @param nbPoints (integer) the wanted number of points in the curve
  5269. * @returns the created Curve3
  5270. */
  5271. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5272. /**
  5273. * Returns a Curve3 object along a CatmullRom Spline curve :
  5274. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5275. * @param nbPoints (integer) the wanted number of points between each curve control points
  5276. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5277. * @returns the created Curve3
  5278. */
  5279. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5280. /**
  5281. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5282. * A Curve3 is designed from a series of successive Vector3.
  5283. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5284. * @param points points which make up the curve
  5285. */
  5286. constructor(points: Vector3[]);
  5287. /**
  5288. * @returns the Curve3 stored array of successive Vector3
  5289. */
  5290. getPoints(): Vector3[];
  5291. /**
  5292. * @returns the computed length (float) of the curve.
  5293. */
  5294. length(): number;
  5295. /**
  5296. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5297. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5298. * curveA and curveB keep unchanged.
  5299. * @param curve the curve to continue from this curve
  5300. * @returns the newly constructed curve
  5301. */
  5302. continue(curve: DeepImmutable<Curve3>): Curve3;
  5303. private _computeLength;
  5304. }
  5305. }
  5306. declare module "babylonjs/Animations/easing" {
  5307. /**
  5308. * This represents the main contract an easing function should follow.
  5309. * Easing functions are used throughout the animation system.
  5310. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5311. */
  5312. export interface IEasingFunction {
  5313. /**
  5314. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5315. * of the easing function.
  5316. * The link below provides some of the most common examples of easing functions.
  5317. * @see https://easings.net/
  5318. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5319. * @returns the corresponding value on the curve defined by the easing function
  5320. */
  5321. ease(gradient: number): number;
  5322. }
  5323. /**
  5324. * Base class used for every default easing function.
  5325. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5326. */
  5327. export class EasingFunction implements IEasingFunction {
  5328. /**
  5329. * Interpolation follows the mathematical formula associated with the easing function.
  5330. */
  5331. static readonly EASINGMODE_EASEIN: number;
  5332. /**
  5333. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5334. */
  5335. static readonly EASINGMODE_EASEOUT: number;
  5336. /**
  5337. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5338. */
  5339. static readonly EASINGMODE_EASEINOUT: number;
  5340. private _easingMode;
  5341. /**
  5342. * Sets the easing mode of the current function.
  5343. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5344. */
  5345. setEasingMode(easingMode: number): void;
  5346. /**
  5347. * Gets the current easing mode.
  5348. * @returns the easing mode
  5349. */
  5350. getEasingMode(): number;
  5351. /**
  5352. * @hidden
  5353. */
  5354. easeInCore(gradient: number): number;
  5355. /**
  5356. * Given an input gradient between 0 and 1, this returns the corresponding value
  5357. * of the easing function.
  5358. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5359. * @returns the corresponding value on the curve defined by the easing function
  5360. */
  5361. ease(gradient: number): number;
  5362. }
  5363. /**
  5364. * Easing function with a circle shape (see link below).
  5365. * @see https://easings.net/#easeInCirc
  5366. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5367. */
  5368. export class CircleEase extends EasingFunction implements IEasingFunction {
  5369. /** @hidden */
  5370. easeInCore(gradient: number): number;
  5371. }
  5372. /**
  5373. * Easing function with a ease back shape (see link below).
  5374. * @see https://easings.net/#easeInBack
  5375. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5376. */
  5377. export class BackEase extends EasingFunction implements IEasingFunction {
  5378. /** Defines the amplitude of the function */
  5379. amplitude: number;
  5380. /**
  5381. * Instantiates a back ease easing
  5382. * @see https://easings.net/#easeInBack
  5383. * @param amplitude Defines the amplitude of the function
  5384. */
  5385. constructor(
  5386. /** Defines the amplitude of the function */
  5387. amplitude?: number);
  5388. /** @hidden */
  5389. easeInCore(gradient: number): number;
  5390. }
  5391. /**
  5392. * Easing function with a bouncing shape (see link below).
  5393. * @see https://easings.net/#easeInBounce
  5394. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5395. */
  5396. export class BounceEase extends EasingFunction implements IEasingFunction {
  5397. /** Defines the number of bounces */
  5398. bounces: number;
  5399. /** Defines the amplitude of the bounce */
  5400. bounciness: number;
  5401. /**
  5402. * Instantiates a bounce easing
  5403. * @see https://easings.net/#easeInBounce
  5404. * @param bounces Defines the number of bounces
  5405. * @param bounciness Defines the amplitude of the bounce
  5406. */
  5407. constructor(
  5408. /** Defines the number of bounces */
  5409. bounces?: number,
  5410. /** Defines the amplitude of the bounce */
  5411. bounciness?: number);
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a power of 3 shape (see link below).
  5417. * @see https://easings.net/#easeInCubic
  5418. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class CubicEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with an elastic shape (see link below).
  5426. * @see https://easings.net/#easeInElastic
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5430. /** Defines the number of oscillations*/
  5431. oscillations: number;
  5432. /** Defines the amplitude of the oscillations*/
  5433. springiness: number;
  5434. /**
  5435. * Instantiates an elastic easing function
  5436. * @see https://easings.net/#easeInElastic
  5437. * @param oscillations Defines the number of oscillations
  5438. * @param springiness Defines the amplitude of the oscillations
  5439. */
  5440. constructor(
  5441. /** Defines the number of oscillations*/
  5442. oscillations?: number,
  5443. /** Defines the amplitude of the oscillations*/
  5444. springiness?: number);
  5445. /** @hidden */
  5446. easeInCore(gradient: number): number;
  5447. }
  5448. /**
  5449. * Easing function with an exponential shape (see link below).
  5450. * @see https://easings.net/#easeInExpo
  5451. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5452. */
  5453. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5454. /** Defines the exponent of the function */
  5455. exponent: number;
  5456. /**
  5457. * Instantiates an exponential easing function
  5458. * @see https://easings.net/#easeInExpo
  5459. * @param exponent Defines the exponent of the function
  5460. */
  5461. constructor(
  5462. /** Defines the exponent of the function */
  5463. exponent?: number);
  5464. /** @hidden */
  5465. easeInCore(gradient: number): number;
  5466. }
  5467. /**
  5468. * Easing function with a power shape (see link below).
  5469. * @see https://easings.net/#easeInQuad
  5470. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5471. */
  5472. export class PowerEase extends EasingFunction implements IEasingFunction {
  5473. /** Defines the power of the function */
  5474. power: number;
  5475. /**
  5476. * Instantiates an power base easing function
  5477. * @see https://easings.net/#easeInQuad
  5478. * @param power Defines the power of the function
  5479. */
  5480. constructor(
  5481. /** Defines the power of the function */
  5482. power?: number);
  5483. /** @hidden */
  5484. easeInCore(gradient: number): number;
  5485. }
  5486. /**
  5487. * Easing function with a power of 2 shape (see link below).
  5488. * @see https://easings.net/#easeInQuad
  5489. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5490. */
  5491. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5492. /** @hidden */
  5493. easeInCore(gradient: number): number;
  5494. }
  5495. /**
  5496. * Easing function with a power of 4 shape (see link below).
  5497. * @see https://easings.net/#easeInQuart
  5498. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5499. */
  5500. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5501. /** @hidden */
  5502. easeInCore(gradient: number): number;
  5503. }
  5504. /**
  5505. * Easing function with a power of 5 shape (see link below).
  5506. * @see https://easings.net/#easeInQuint
  5507. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5508. */
  5509. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5510. /** @hidden */
  5511. easeInCore(gradient: number): number;
  5512. }
  5513. /**
  5514. * Easing function with a sin shape (see link below).
  5515. * @see https://easings.net/#easeInSine
  5516. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5517. */
  5518. export class SineEase extends EasingFunction implements IEasingFunction {
  5519. /** @hidden */
  5520. easeInCore(gradient: number): number;
  5521. }
  5522. /**
  5523. * Easing function with a bezier shape (see link below).
  5524. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5525. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5526. */
  5527. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5528. /** Defines the x component of the start tangent in the bezier curve */
  5529. x1: number;
  5530. /** Defines the y component of the start tangent in the bezier curve */
  5531. y1: number;
  5532. /** Defines the x component of the end tangent in the bezier curve */
  5533. x2: number;
  5534. /** Defines the y component of the end tangent in the bezier curve */
  5535. y2: number;
  5536. /**
  5537. * Instantiates a bezier function
  5538. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5539. * @param x1 Defines the x component of the start tangent in the bezier curve
  5540. * @param y1 Defines the y component of the start tangent in the bezier curve
  5541. * @param x2 Defines the x component of the end tangent in the bezier curve
  5542. * @param y2 Defines the y component of the end tangent in the bezier curve
  5543. */
  5544. constructor(
  5545. /** Defines the x component of the start tangent in the bezier curve */
  5546. x1?: number,
  5547. /** Defines the y component of the start tangent in the bezier curve */
  5548. y1?: number,
  5549. /** Defines the x component of the end tangent in the bezier curve */
  5550. x2?: number,
  5551. /** Defines the y component of the end tangent in the bezier curve */
  5552. y2?: number);
  5553. /** @hidden */
  5554. easeInCore(gradient: number): number;
  5555. }
  5556. }
  5557. declare module "babylonjs/Maths/math.color" {
  5558. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5559. /**
  5560. * Class used to hold a RBG color
  5561. */
  5562. export class Color3 {
  5563. /**
  5564. * Defines the red component (between 0 and 1, default is 0)
  5565. */
  5566. r: number;
  5567. /**
  5568. * Defines the green component (between 0 and 1, default is 0)
  5569. */
  5570. g: number;
  5571. /**
  5572. * Defines the blue component (between 0 and 1, default is 0)
  5573. */
  5574. b: number;
  5575. /**
  5576. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5577. * @param r defines the red component (between 0 and 1, default is 0)
  5578. * @param g defines the green component (between 0 and 1, default is 0)
  5579. * @param b defines the blue component (between 0 and 1, default is 0)
  5580. */
  5581. constructor(
  5582. /**
  5583. * Defines the red component (between 0 and 1, default is 0)
  5584. */
  5585. r?: number,
  5586. /**
  5587. * Defines the green component (between 0 and 1, default is 0)
  5588. */
  5589. g?: number,
  5590. /**
  5591. * Defines the blue component (between 0 and 1, default is 0)
  5592. */
  5593. b?: number);
  5594. /**
  5595. * Creates a string with the Color3 current values
  5596. * @returns the string representation of the Color3 object
  5597. */
  5598. toString(): string;
  5599. /**
  5600. * Returns the string "Color3"
  5601. * @returns "Color3"
  5602. */
  5603. getClassName(): string;
  5604. /**
  5605. * Compute the Color3 hash code
  5606. * @returns an unique number that can be used to hash Color3 objects
  5607. */
  5608. getHashCode(): number;
  5609. /**
  5610. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5611. * @param array defines the array where to store the r,g,b components
  5612. * @param index defines an optional index in the target array to define where to start storing values
  5613. * @returns the current Color3 object
  5614. */
  5615. toArray(array: FloatArray, index?: number): Color3;
  5616. /**
  5617. * Update the current color with values stored in an array from the starting index of the given array
  5618. * @param array defines the source array
  5619. * @param offset defines an offset in the source array
  5620. * @returns the current Color3 object
  5621. */
  5622. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5623. /**
  5624. * Returns a new Color4 object from the current Color3 and the given alpha
  5625. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5626. * @returns a new Color4 object
  5627. */
  5628. toColor4(alpha?: number): Color4;
  5629. /**
  5630. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5631. * @returns the new array
  5632. */
  5633. asArray(): number[];
  5634. /**
  5635. * Returns the luminance value
  5636. * @returns a float value
  5637. */
  5638. toLuminance(): number;
  5639. /**
  5640. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5641. * @param otherColor defines the second operand
  5642. * @returns the new Color3 object
  5643. */
  5644. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5645. /**
  5646. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5647. * @param otherColor defines the second operand
  5648. * @param result defines the Color3 object where to store the result
  5649. * @returns the current Color3
  5650. */
  5651. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5652. /**
  5653. * Determines equality between Color3 objects
  5654. * @param otherColor defines the second operand
  5655. * @returns true if the rgb values are equal to the given ones
  5656. */
  5657. equals(otherColor: DeepImmutable<Color3>): boolean;
  5658. /**
  5659. * Determines equality between the current Color3 object and a set of r,b,g values
  5660. * @param r defines the red component to check
  5661. * @param g defines the green component to check
  5662. * @param b defines the blue component to check
  5663. * @returns true if the rgb values are equal to the given ones
  5664. */
  5665. equalsFloats(r: number, g: number, b: number): boolean;
  5666. /**
  5667. * Multiplies in place each rgb value by scale
  5668. * @param scale defines the scaling factor
  5669. * @returns the updated Color3
  5670. */
  5671. scale(scale: number): Color3;
  5672. /**
  5673. * Multiplies the rgb values by scale and stores the result into "result"
  5674. * @param scale defines the scaling factor
  5675. * @param result defines the Color3 object where to store the result
  5676. * @returns the unmodified current Color3
  5677. */
  5678. scaleToRef(scale: number, result: Color3): Color3;
  5679. /**
  5680. * Scale the current Color3 values by a factor and add the result to a given Color3
  5681. * @param scale defines the scale factor
  5682. * @param result defines color to store the result into
  5683. * @returns the unmodified current Color3
  5684. */
  5685. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5686. /**
  5687. * Clamps the rgb values by the min and max values and stores the result into "result"
  5688. * @param min defines minimum clamping value (default is 0)
  5689. * @param max defines maximum clamping value (default is 1)
  5690. * @param result defines color to store the result into
  5691. * @returns the original Color3
  5692. */
  5693. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5694. /**
  5695. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5696. * @param otherColor defines the second operand
  5697. * @returns the new Color3
  5698. */
  5699. add(otherColor: DeepImmutable<Color3>): Color3;
  5700. /**
  5701. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5702. * @param otherColor defines the second operand
  5703. * @param result defines Color3 object to store the result into
  5704. * @returns the unmodified current Color3
  5705. */
  5706. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5707. /**
  5708. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5709. * @param otherColor defines the second operand
  5710. * @returns the new Color3
  5711. */
  5712. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5713. /**
  5714. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5715. * @param otherColor defines the second operand
  5716. * @param result defines Color3 object to store the result into
  5717. * @returns the unmodified current Color3
  5718. */
  5719. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5720. /**
  5721. * Copy the current object
  5722. * @returns a new Color3 copied the current one
  5723. */
  5724. clone(): Color3;
  5725. /**
  5726. * Copies the rgb values from the source in the current Color3
  5727. * @param source defines the source Color3 object
  5728. * @returns the updated Color3 object
  5729. */
  5730. copyFrom(source: DeepImmutable<Color3>): Color3;
  5731. /**
  5732. * Updates the Color3 rgb values from the given floats
  5733. * @param r defines the red component to read from
  5734. * @param g defines the green component to read from
  5735. * @param b defines the blue component to read from
  5736. * @returns the current Color3 object
  5737. */
  5738. copyFromFloats(r: number, g: number, b: number): Color3;
  5739. /**
  5740. * Updates the Color3 rgb values from the given floats
  5741. * @param r defines the red component to read from
  5742. * @param g defines the green component to read from
  5743. * @param b defines the blue component to read from
  5744. * @returns the current Color3 object
  5745. */
  5746. set(r: number, g: number, b: number): Color3;
  5747. /**
  5748. * Compute the Color3 hexadecimal code as a string
  5749. * @returns a string containing the hexadecimal representation of the Color3 object
  5750. */
  5751. toHexString(): string;
  5752. /**
  5753. * Computes a new Color3 converted from the current one to linear space
  5754. * @returns a new Color3 object
  5755. */
  5756. toLinearSpace(): Color3;
  5757. /**
  5758. * Converts current color in rgb space to HSV values
  5759. * @returns a new color3 representing the HSV values
  5760. */
  5761. toHSV(): Color3;
  5762. /**
  5763. * Converts current color in rgb space to HSV values
  5764. * @param result defines the Color3 where to store the HSV values
  5765. */
  5766. toHSVToRef(result: Color3): void;
  5767. /**
  5768. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5769. * @param convertedColor defines the Color3 object where to store the linear space version
  5770. * @returns the unmodified Color3
  5771. */
  5772. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5773. /**
  5774. * Computes a new Color3 converted from the current one to gamma space
  5775. * @returns a new Color3 object
  5776. */
  5777. toGammaSpace(): Color3;
  5778. /**
  5779. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5780. * @param convertedColor defines the Color3 object where to store the gamma space version
  5781. * @returns the unmodified Color3
  5782. */
  5783. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5784. private static _BlackReadOnly;
  5785. /**
  5786. * Convert Hue, saturation and value to a Color3 (RGB)
  5787. * @param hue defines the hue
  5788. * @param saturation defines the saturation
  5789. * @param value defines the value
  5790. * @param result defines the Color3 where to store the RGB values
  5791. */
  5792. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5793. /**
  5794. * Creates a new Color3 from the string containing valid hexadecimal values
  5795. * @param hex defines a string containing valid hexadecimal values
  5796. * @returns a new Color3 object
  5797. */
  5798. static FromHexString(hex: string): Color3;
  5799. /**
  5800. * Creates a new Color3 from the starting index of the given array
  5801. * @param array defines the source array
  5802. * @param offset defines an offset in the source array
  5803. * @returns a new Color3 object
  5804. */
  5805. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5806. /**
  5807. * Creates a new Color3 from the starting index element of the given array
  5808. * @param array defines the source array to read from
  5809. * @param offset defines the offset in the source array
  5810. * @param result defines the target Color3 object
  5811. */
  5812. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5813. /**
  5814. * Creates a new Color3 from integer values (< 256)
  5815. * @param r defines the red component to read from (value between 0 and 255)
  5816. * @param g defines the green component to read from (value between 0 and 255)
  5817. * @param b defines the blue component to read from (value between 0 and 255)
  5818. * @returns a new Color3 object
  5819. */
  5820. static FromInts(r: number, g: number, b: number): Color3;
  5821. /**
  5822. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5823. * @param start defines the start Color3 value
  5824. * @param end defines the end Color3 value
  5825. * @param amount defines the gradient value between start and end
  5826. * @returns a new Color3 object
  5827. */
  5828. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5829. /**
  5830. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5831. * @param left defines the start value
  5832. * @param right defines the end value
  5833. * @param amount defines the gradient factor
  5834. * @param result defines the Color3 object where to store the result
  5835. */
  5836. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5837. /**
  5838. * Returns a Color3 value containing a red color
  5839. * @returns a new Color3 object
  5840. */
  5841. static Red(): Color3;
  5842. /**
  5843. * Returns a Color3 value containing a green color
  5844. * @returns a new Color3 object
  5845. */
  5846. static Green(): Color3;
  5847. /**
  5848. * Returns a Color3 value containing a blue color
  5849. * @returns a new Color3 object
  5850. */
  5851. static Blue(): Color3;
  5852. /**
  5853. * Returns a Color3 value containing a black color
  5854. * @returns a new Color3 object
  5855. */
  5856. static Black(): Color3;
  5857. /**
  5858. * Gets a Color3 value containing a black color that must not be updated
  5859. */
  5860. static get BlackReadOnly(): DeepImmutable<Color3>;
  5861. /**
  5862. * Returns a Color3 value containing a white color
  5863. * @returns a new Color3 object
  5864. */
  5865. static White(): Color3;
  5866. /**
  5867. * Returns a Color3 value containing a purple color
  5868. * @returns a new Color3 object
  5869. */
  5870. static Purple(): Color3;
  5871. /**
  5872. * Returns a Color3 value containing a magenta color
  5873. * @returns a new Color3 object
  5874. */
  5875. static Magenta(): Color3;
  5876. /**
  5877. * Returns a Color3 value containing a yellow color
  5878. * @returns a new Color3 object
  5879. */
  5880. static Yellow(): Color3;
  5881. /**
  5882. * Returns a Color3 value containing a gray color
  5883. * @returns a new Color3 object
  5884. */
  5885. static Gray(): Color3;
  5886. /**
  5887. * Returns a Color3 value containing a teal color
  5888. * @returns a new Color3 object
  5889. */
  5890. static Teal(): Color3;
  5891. /**
  5892. * Returns a Color3 value containing a random color
  5893. * @returns a new Color3 object
  5894. */
  5895. static Random(): Color3;
  5896. }
  5897. /**
  5898. * Class used to hold a RBGA color
  5899. */
  5900. export class Color4 {
  5901. /**
  5902. * Defines the red component (between 0 and 1, default is 0)
  5903. */
  5904. r: number;
  5905. /**
  5906. * Defines the green component (between 0 and 1, default is 0)
  5907. */
  5908. g: number;
  5909. /**
  5910. * Defines the blue component (between 0 and 1, default is 0)
  5911. */
  5912. b: number;
  5913. /**
  5914. * Defines the alpha component (between 0 and 1, default is 1)
  5915. */
  5916. a: number;
  5917. /**
  5918. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5919. * @param r defines the red component (between 0 and 1, default is 0)
  5920. * @param g defines the green component (between 0 and 1, default is 0)
  5921. * @param b defines the blue component (between 0 and 1, default is 0)
  5922. * @param a defines the alpha component (between 0 and 1, default is 1)
  5923. */
  5924. constructor(
  5925. /**
  5926. * Defines the red component (between 0 and 1, default is 0)
  5927. */
  5928. r?: number,
  5929. /**
  5930. * Defines the green component (between 0 and 1, default is 0)
  5931. */
  5932. g?: number,
  5933. /**
  5934. * Defines the blue component (between 0 and 1, default is 0)
  5935. */
  5936. b?: number,
  5937. /**
  5938. * Defines the alpha component (between 0 and 1, default is 1)
  5939. */
  5940. a?: number);
  5941. /**
  5942. * Adds in place the given Color4 values to the current Color4 object
  5943. * @param right defines the second operand
  5944. * @returns the current updated Color4 object
  5945. */
  5946. addInPlace(right: DeepImmutable<Color4>): Color4;
  5947. /**
  5948. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5949. * @returns the new array
  5950. */
  5951. asArray(): number[];
  5952. /**
  5953. * Stores from the starting index in the given array the Color4 successive values
  5954. * @param array defines the array where to store the r,g,b components
  5955. * @param index defines an optional index in the target array to define where to start storing values
  5956. * @returns the current Color4 object
  5957. */
  5958. toArray(array: number[], index?: number): Color4;
  5959. /**
  5960. * Update the current color with values stored in an array from the starting index of the given array
  5961. * @param array defines the source array
  5962. * @param offset defines an offset in the source array
  5963. * @returns the current Color4 object
  5964. */
  5965. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5966. /**
  5967. * Determines equality between Color4 objects
  5968. * @param otherColor defines the second operand
  5969. * @returns true if the rgba values are equal to the given ones
  5970. */
  5971. equals(otherColor: DeepImmutable<Color4>): boolean;
  5972. /**
  5973. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5974. * @param right defines the second operand
  5975. * @returns a new Color4 object
  5976. */
  5977. add(right: DeepImmutable<Color4>): Color4;
  5978. /**
  5979. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5980. * @param right defines the second operand
  5981. * @returns a new Color4 object
  5982. */
  5983. subtract(right: DeepImmutable<Color4>): Color4;
  5984. /**
  5985. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5986. * @param right defines the second operand
  5987. * @param result defines the Color4 object where to store the result
  5988. * @returns the current Color4 object
  5989. */
  5990. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5991. /**
  5992. * Creates a new Color4 with the current Color4 values multiplied by scale
  5993. * @param scale defines the scaling factor to apply
  5994. * @returns a new Color4 object
  5995. */
  5996. scale(scale: number): Color4;
  5997. /**
  5998. * Multiplies the current Color4 values by scale and stores the result in "result"
  5999. * @param scale defines the scaling factor to apply
  6000. * @param result defines the Color4 object where to store the result
  6001. * @returns the current unmodified Color4
  6002. */
  6003. scaleToRef(scale: number, result: Color4): Color4;
  6004. /**
  6005. * Scale the current Color4 values by a factor and add the result to a given Color4
  6006. * @param scale defines the scale factor
  6007. * @param result defines the Color4 object where to store the result
  6008. * @returns the unmodified current Color4
  6009. */
  6010. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6011. /**
  6012. * Clamps the rgb values by the min and max values and stores the result into "result"
  6013. * @param min defines minimum clamping value (default is 0)
  6014. * @param max defines maximum clamping value (default is 1)
  6015. * @param result defines color to store the result into.
  6016. * @returns the cuurent Color4
  6017. */
  6018. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6019. /**
  6020. * Multipy an Color4 value by another and return a new Color4 object
  6021. * @param color defines the Color4 value to multiply by
  6022. * @returns a new Color4 object
  6023. */
  6024. multiply(color: Color4): Color4;
  6025. /**
  6026. * Multipy a Color4 value by another and push the result in a reference value
  6027. * @param color defines the Color4 value to multiply by
  6028. * @param result defines the Color4 to fill the result in
  6029. * @returns the result Color4
  6030. */
  6031. multiplyToRef(color: Color4, result: Color4): Color4;
  6032. /**
  6033. * Creates a string with the Color4 current values
  6034. * @returns the string representation of the Color4 object
  6035. */
  6036. toString(): string;
  6037. /**
  6038. * Returns the string "Color4"
  6039. * @returns "Color4"
  6040. */
  6041. getClassName(): string;
  6042. /**
  6043. * Compute the Color4 hash code
  6044. * @returns an unique number that can be used to hash Color4 objects
  6045. */
  6046. getHashCode(): number;
  6047. /**
  6048. * Creates a new Color4 copied from the current one
  6049. * @returns a new Color4 object
  6050. */
  6051. clone(): Color4;
  6052. /**
  6053. * Copies the given Color4 values into the current one
  6054. * @param source defines the source Color4 object
  6055. * @returns the current updated Color4 object
  6056. */
  6057. copyFrom(source: Color4): Color4;
  6058. /**
  6059. * Copies the given float values into the current one
  6060. * @param r defines the red component to read from
  6061. * @param g defines the green component to read from
  6062. * @param b defines the blue component to read from
  6063. * @param a defines the alpha component to read from
  6064. * @returns the current updated Color4 object
  6065. */
  6066. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6067. /**
  6068. * Copies the given float values into the current one
  6069. * @param r defines the red component to read from
  6070. * @param g defines the green component to read from
  6071. * @param b defines the blue component to read from
  6072. * @param a defines the alpha component to read from
  6073. * @returns the current updated Color4 object
  6074. */
  6075. set(r: number, g: number, b: number, a: number): Color4;
  6076. /**
  6077. * Compute the Color4 hexadecimal code as a string
  6078. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6079. * @returns a string containing the hexadecimal representation of the Color4 object
  6080. */
  6081. toHexString(returnAsColor3?: boolean): string;
  6082. /**
  6083. * Computes a new Color4 converted from the current one to linear space
  6084. * @returns a new Color4 object
  6085. */
  6086. toLinearSpace(): Color4;
  6087. /**
  6088. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6089. * @param convertedColor defines the Color4 object where to store the linear space version
  6090. * @returns the unmodified Color4
  6091. */
  6092. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6093. /**
  6094. * Computes a new Color4 converted from the current one to gamma space
  6095. * @returns a new Color4 object
  6096. */
  6097. toGammaSpace(): Color4;
  6098. /**
  6099. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6100. * @param convertedColor defines the Color4 object where to store the gamma space version
  6101. * @returns the unmodified Color4
  6102. */
  6103. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6104. /**
  6105. * Creates a new Color4 from the string containing valid hexadecimal values
  6106. * @param hex defines a string containing valid hexadecimal values
  6107. * @returns a new Color4 object
  6108. */
  6109. static FromHexString(hex: string): Color4;
  6110. /**
  6111. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6112. * @param left defines the start value
  6113. * @param right defines the end value
  6114. * @param amount defines the gradient factor
  6115. * @returns a new Color4 object
  6116. */
  6117. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6118. /**
  6119. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6120. * @param left defines the start value
  6121. * @param right defines the end value
  6122. * @param amount defines the gradient factor
  6123. * @param result defines the Color4 object where to store data
  6124. */
  6125. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6126. /**
  6127. * Creates a new Color4 from a Color3 and an alpha value
  6128. * @param color3 defines the source Color3 to read from
  6129. * @param alpha defines the alpha component (1.0 by default)
  6130. * @returns a new Color4 object
  6131. */
  6132. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6133. /**
  6134. * Creates a new Color4 from the starting index element of the given array
  6135. * @param array defines the source array to read from
  6136. * @param offset defines the offset in the source array
  6137. * @returns a new Color4 object
  6138. */
  6139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6140. /**
  6141. * Creates a new Color4 from the starting index element of the given array
  6142. * @param array defines the source array to read from
  6143. * @param offset defines the offset in the source array
  6144. * @param result defines the target Color4 object
  6145. */
  6146. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6147. /**
  6148. * Creates a new Color3 from integer values (< 256)
  6149. * @param r defines the red component to read from (value between 0 and 255)
  6150. * @param g defines the green component to read from (value between 0 and 255)
  6151. * @param b defines the blue component to read from (value between 0 and 255)
  6152. * @param a defines the alpha component to read from (value between 0 and 255)
  6153. * @returns a new Color3 object
  6154. */
  6155. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6156. /**
  6157. * Check the content of a given array and convert it to an array containing RGBA data
  6158. * If the original array was already containing count * 4 values then it is returned directly
  6159. * @param colors defines the array to check
  6160. * @param count defines the number of RGBA data to expect
  6161. * @returns an array containing count * 4 values (RGBA)
  6162. */
  6163. static CheckColors4(colors: number[], count: number): number[];
  6164. }
  6165. /**
  6166. * @hidden
  6167. */
  6168. export class TmpColors {
  6169. static Color3: Color3[];
  6170. static Color4: Color4[];
  6171. }
  6172. }
  6173. declare module "babylonjs/Animations/animationKey" {
  6174. /**
  6175. * Defines an interface which represents an animation key frame
  6176. */
  6177. export interface IAnimationKey {
  6178. /**
  6179. * Frame of the key frame
  6180. */
  6181. frame: number;
  6182. /**
  6183. * Value at the specifies key frame
  6184. */
  6185. value: any;
  6186. /**
  6187. * The input tangent for the cubic hermite spline
  6188. */
  6189. inTangent?: any;
  6190. /**
  6191. * The output tangent for the cubic hermite spline
  6192. */
  6193. outTangent?: any;
  6194. /**
  6195. * The animation interpolation type
  6196. */
  6197. interpolation?: AnimationKeyInterpolation;
  6198. }
  6199. /**
  6200. * Enum for the animation key frame interpolation type
  6201. */
  6202. export enum AnimationKeyInterpolation {
  6203. /**
  6204. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6205. */
  6206. STEP = 1
  6207. }
  6208. }
  6209. declare module "babylonjs/Animations/animationRange" {
  6210. /**
  6211. * Represents the range of an animation
  6212. */
  6213. export class AnimationRange {
  6214. /**The name of the animation range**/
  6215. name: string;
  6216. /**The starting frame of the animation */
  6217. from: number;
  6218. /**The ending frame of the animation*/
  6219. to: number;
  6220. /**
  6221. * Initializes the range of an animation
  6222. * @param name The name of the animation range
  6223. * @param from The starting frame of the animation
  6224. * @param to The ending frame of the animation
  6225. */
  6226. constructor(
  6227. /**The name of the animation range**/
  6228. name: string,
  6229. /**The starting frame of the animation */
  6230. from: number,
  6231. /**The ending frame of the animation*/
  6232. to: number);
  6233. /**
  6234. * Makes a copy of the animation range
  6235. * @returns A copy of the animation range
  6236. */
  6237. clone(): AnimationRange;
  6238. }
  6239. }
  6240. declare module "babylonjs/Animations/animationEvent" {
  6241. /**
  6242. * Composed of a frame, and an action function
  6243. */
  6244. export class AnimationEvent {
  6245. /** The frame for which the event is triggered **/
  6246. frame: number;
  6247. /** The event to perform when triggered **/
  6248. action: (currentFrame: number) => void;
  6249. /** Specifies if the event should be triggered only once**/
  6250. onlyOnce?: boolean | undefined;
  6251. /**
  6252. * Specifies if the animation event is done
  6253. */
  6254. isDone: boolean;
  6255. /**
  6256. * Initializes the animation event
  6257. * @param frame The frame for which the event is triggered
  6258. * @param action The event to perform when triggered
  6259. * @param onlyOnce Specifies if the event should be triggered only once
  6260. */
  6261. constructor(
  6262. /** The frame for which the event is triggered **/
  6263. frame: number,
  6264. /** The event to perform when triggered **/
  6265. action: (currentFrame: number) => void,
  6266. /** Specifies if the event should be triggered only once**/
  6267. onlyOnce?: boolean | undefined);
  6268. /** @hidden */
  6269. _clone(): AnimationEvent;
  6270. }
  6271. }
  6272. declare module "babylonjs/Behaviors/behavior" {
  6273. import { Nullable } from "babylonjs/types";
  6274. /**
  6275. * Interface used to define a behavior
  6276. */
  6277. export interface Behavior<T> {
  6278. /** gets or sets behavior's name */
  6279. name: string;
  6280. /**
  6281. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6282. */
  6283. init(): void;
  6284. /**
  6285. * Called when the behavior is attached to a target
  6286. * @param target defines the target where the behavior is attached to
  6287. */
  6288. attach(target: T): void;
  6289. /**
  6290. * Called when the behavior is detached from its target
  6291. */
  6292. detach(): void;
  6293. }
  6294. /**
  6295. * Interface implemented by classes supporting behaviors
  6296. */
  6297. export interface IBehaviorAware<T> {
  6298. /**
  6299. * Attach a behavior
  6300. * @param behavior defines the behavior to attach
  6301. * @returns the current host
  6302. */
  6303. addBehavior(behavior: Behavior<T>): T;
  6304. /**
  6305. * Remove a behavior from the current object
  6306. * @param behavior defines the behavior to detach
  6307. * @returns the current host
  6308. */
  6309. removeBehavior(behavior: Behavior<T>): T;
  6310. /**
  6311. * Gets a behavior using its name to search
  6312. * @param name defines the name to search
  6313. * @returns the behavior or null if not found
  6314. */
  6315. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6316. }
  6317. }
  6318. declare module "babylonjs/Misc/smartArray" {
  6319. /**
  6320. * Defines an array and its length.
  6321. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6322. */
  6323. export interface ISmartArrayLike<T> {
  6324. /**
  6325. * The data of the array.
  6326. */
  6327. data: Array<T>;
  6328. /**
  6329. * The active length of the array.
  6330. */
  6331. length: number;
  6332. }
  6333. /**
  6334. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6335. */
  6336. export class SmartArray<T> implements ISmartArrayLike<T> {
  6337. /**
  6338. * The full set of data from the array.
  6339. */
  6340. data: Array<T>;
  6341. /**
  6342. * The active length of the array.
  6343. */
  6344. length: number;
  6345. protected _id: number;
  6346. /**
  6347. * Instantiates a Smart Array.
  6348. * @param capacity defines the default capacity of the array.
  6349. */
  6350. constructor(capacity: number);
  6351. /**
  6352. * Pushes a value at the end of the active data.
  6353. * @param value defines the object to push in the array.
  6354. */
  6355. push(value: T): void;
  6356. /**
  6357. * Iterates over the active data and apply the lambda to them.
  6358. * @param func defines the action to apply on each value.
  6359. */
  6360. forEach(func: (content: T) => void): void;
  6361. /**
  6362. * Sorts the full sets of data.
  6363. * @param compareFn defines the comparison function to apply.
  6364. */
  6365. sort(compareFn: (a: T, b: T) => number): void;
  6366. /**
  6367. * Resets the active data to an empty array.
  6368. */
  6369. reset(): void;
  6370. /**
  6371. * Releases all the data from the array as well as the array.
  6372. */
  6373. dispose(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * @param array defines the data to concatenate with.
  6377. */
  6378. concat(array: any): void;
  6379. /**
  6380. * Returns the position of a value in the active data.
  6381. * @param value defines the value to find the index for
  6382. * @returns the index if found in the active data otherwise -1
  6383. */
  6384. indexOf(value: T): number;
  6385. /**
  6386. * Returns whether an element is part of the active data.
  6387. * @param value defines the value to look for
  6388. * @returns true if found in the active data otherwise false
  6389. */
  6390. contains(value: T): boolean;
  6391. private static _GlobalId;
  6392. }
  6393. /**
  6394. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6395. * The data in this array can only be present once
  6396. */
  6397. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6398. private _duplicateId;
  6399. /**
  6400. * Pushes a value at the end of the active data.
  6401. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6402. * @param value defines the object to push in the array.
  6403. */
  6404. push(value: T): void;
  6405. /**
  6406. * Pushes a value at the end of the active data.
  6407. * If the data is already present, it won t be added again
  6408. * @param value defines the object to push in the array.
  6409. * @returns true if added false if it was already present
  6410. */
  6411. pushNoDuplicate(value: T): boolean;
  6412. /**
  6413. * Resets the active data to an empty array.
  6414. */
  6415. reset(): void;
  6416. /**
  6417. * Concats the active data with a given array.
  6418. * This ensures no dupplicate will be present in the result.
  6419. * @param array defines the data to concatenate with.
  6420. */
  6421. concatWithNoDuplicate(array: any): void;
  6422. }
  6423. }
  6424. declare module "babylonjs/Cameras/cameraInputsManager" {
  6425. import { Nullable } from "babylonjs/types";
  6426. import { Camera } from "babylonjs/Cameras/camera";
  6427. /**
  6428. * @ignore
  6429. * This is a list of all the different input types that are available in the application.
  6430. * Fo instance: ArcRotateCameraGamepadInput...
  6431. */
  6432. export var CameraInputTypes: {};
  6433. /**
  6434. * This is the contract to implement in order to create a new input class.
  6435. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6436. */
  6437. export interface ICameraInput<TCamera extends Camera> {
  6438. /**
  6439. * Defines the camera the input is attached to.
  6440. */
  6441. camera: Nullable<TCamera>;
  6442. /**
  6443. * Gets the class name of the current intput.
  6444. * @returns the class name
  6445. */
  6446. getClassName(): string;
  6447. /**
  6448. * Get the friendly name associated with the input class.
  6449. * @returns the input friendly name
  6450. */
  6451. getSimpleName(): string;
  6452. /**
  6453. * Attach the input controls to a specific dom element to get the input from.
  6454. * @param element Defines the element the controls should be listened from
  6455. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6456. */
  6457. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6458. /**
  6459. * Detach the current controls from the specified dom element.
  6460. * @param element Defines the element to stop listening the inputs from
  6461. */
  6462. detachControl(element: Nullable<HTMLElement>): void;
  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. /**
  6470. * Represents a map of input types to input instance or input index to input instance.
  6471. */
  6472. export interface CameraInputsMap<TCamera extends Camera> {
  6473. /**
  6474. * Accessor to the input by input type.
  6475. */
  6476. [name: string]: ICameraInput<TCamera>;
  6477. /**
  6478. * Accessor to the input by input index.
  6479. */
  6480. [idx: number]: ICameraInput<TCamera>;
  6481. }
  6482. /**
  6483. * This represents the input manager used within a camera.
  6484. * It helps dealing with all the different kind of input attached to a camera.
  6485. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6486. */
  6487. export class CameraInputsManager<TCamera extends Camera> {
  6488. /**
  6489. * Defines the list of inputs attahed to the camera.
  6490. */
  6491. attached: CameraInputsMap<TCamera>;
  6492. /**
  6493. * Defines the dom element the camera is collecting inputs from.
  6494. * This is null if the controls have not been attached.
  6495. */
  6496. attachedElement: Nullable<HTMLElement>;
  6497. /**
  6498. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6499. */
  6500. noPreventDefault: boolean;
  6501. /**
  6502. * Defined the camera the input manager belongs to.
  6503. */
  6504. camera: TCamera;
  6505. /**
  6506. * Update the current camera state depending on the inputs that have been used this frame.
  6507. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6508. */
  6509. checkInputs: () => void;
  6510. /**
  6511. * Instantiate a new Camera Input Manager.
  6512. * @param camera Defines the camera the input manager blongs to
  6513. */
  6514. constructor(camera: TCamera);
  6515. /**
  6516. * Add an input method to a camera
  6517. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6518. * @param input camera input method
  6519. */
  6520. add(input: ICameraInput<TCamera>): void;
  6521. /**
  6522. * Remove a specific input method from a camera
  6523. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6524. * @param inputToRemove camera input method
  6525. */
  6526. remove(inputToRemove: ICameraInput<TCamera>): void;
  6527. /**
  6528. * Remove a specific input type from a camera
  6529. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6530. * @param inputType the type of the input to remove
  6531. */
  6532. removeByType(inputType: string): void;
  6533. private _addCheckInputs;
  6534. /**
  6535. * Attach the input controls to the currently attached dom element to listen the events from.
  6536. * @param input Defines the input to attach
  6537. */
  6538. attachInput(input: ICameraInput<TCamera>): void;
  6539. /**
  6540. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6541. * @param element Defines the dom element to collect the events from
  6542. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6543. */
  6544. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6545. /**
  6546. * Detach the current manager inputs controls from a specific dom element.
  6547. * @param element Defines the dom element to collect the events from
  6548. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6549. */
  6550. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6551. /**
  6552. * Rebuild the dynamic inputCheck function from the current list of
  6553. * defined inputs in the manager.
  6554. */
  6555. rebuildInputCheck(): void;
  6556. /**
  6557. * Remove all attached input methods from a camera
  6558. */
  6559. clear(): void;
  6560. /**
  6561. * Serialize the current input manager attached to a camera.
  6562. * This ensures than once parsed,
  6563. * the input associated to the camera will be identical to the current ones
  6564. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6565. */
  6566. serialize(serializedCamera: any): void;
  6567. /**
  6568. * Parses an input manager serialized JSON to restore the previous list of inputs
  6569. * and states associated to a camera.
  6570. * @param parsedCamera Defines the JSON to parse
  6571. */
  6572. parse(parsedCamera: any): void;
  6573. }
  6574. }
  6575. declare module "babylonjs/Meshes/buffer" {
  6576. import { Nullable, DataArray } from "babylonjs/types";
  6577. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6578. /**
  6579. * Class used to store data that will be store in GPU memory
  6580. */
  6581. export class Buffer {
  6582. private _engine;
  6583. private _buffer;
  6584. /** @hidden */
  6585. _data: Nullable<DataArray>;
  6586. private _updatable;
  6587. private _instanced;
  6588. private _divisor;
  6589. /**
  6590. * Gets the byte stride.
  6591. */
  6592. readonly byteStride: number;
  6593. /**
  6594. * Constructor
  6595. * @param engine the engine
  6596. * @param data the data to use for this buffer
  6597. * @param updatable whether the data is updatable
  6598. * @param stride the stride (optional)
  6599. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6600. * @param instanced whether the buffer is instanced (optional)
  6601. * @param useBytes set to true if the stride in in bytes (optional)
  6602. * @param divisor sets an optional divisor for instances (1 by default)
  6603. */
  6604. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6605. /**
  6606. * Create a new VertexBuffer based on the current buffer
  6607. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6608. * @param offset defines offset in the buffer (0 by default)
  6609. * @param size defines the size in floats of attributes (position is 3 for instance)
  6610. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6611. * @param instanced defines if the vertex buffer contains indexed data
  6612. * @param useBytes defines if the offset and stride are in bytes *
  6613. * @param divisor sets an optional divisor for instances (1 by default)
  6614. * @returns the new vertex buffer
  6615. */
  6616. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6617. /**
  6618. * Gets a boolean indicating if the Buffer is updatable?
  6619. * @returns true if the buffer is updatable
  6620. */
  6621. isUpdatable(): boolean;
  6622. /**
  6623. * Gets current buffer's data
  6624. * @returns a DataArray or null
  6625. */
  6626. getData(): Nullable<DataArray>;
  6627. /**
  6628. * Gets underlying native buffer
  6629. * @returns underlying native buffer
  6630. */
  6631. getBuffer(): Nullable<DataBuffer>;
  6632. /**
  6633. * Gets the stride in float32 units (i.e. byte stride / 4).
  6634. * May not be an integer if the byte stride is not divisible by 4.
  6635. * @returns the stride in float32 units
  6636. * @deprecated Please use byteStride instead.
  6637. */
  6638. getStrideSize(): number;
  6639. /**
  6640. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6641. * @param data defines the data to store
  6642. */
  6643. create(data?: Nullable<DataArray>): void;
  6644. /** @hidden */
  6645. _rebuild(): void;
  6646. /**
  6647. * Update current buffer data
  6648. * @param data defines the data to store
  6649. */
  6650. update(data: DataArray): void;
  6651. /**
  6652. * Updates the data directly.
  6653. * @param data the new data
  6654. * @param offset the new offset
  6655. * @param vertexCount the vertex count (optional)
  6656. * @param useBytes set to true if the offset is in bytes
  6657. */
  6658. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6659. /**
  6660. * Release all resources
  6661. */
  6662. dispose(): void;
  6663. }
  6664. /**
  6665. * Specialized buffer used to store vertex data
  6666. */
  6667. export class VertexBuffer {
  6668. /** @hidden */
  6669. _buffer: Buffer;
  6670. private _kind;
  6671. private _size;
  6672. private _ownsBuffer;
  6673. private _instanced;
  6674. private _instanceDivisor;
  6675. /**
  6676. * The byte type.
  6677. */
  6678. static readonly BYTE: number;
  6679. /**
  6680. * The unsigned byte type.
  6681. */
  6682. static readonly UNSIGNED_BYTE: number;
  6683. /**
  6684. * The short type.
  6685. */
  6686. static readonly SHORT: number;
  6687. /**
  6688. * The unsigned short type.
  6689. */
  6690. static readonly UNSIGNED_SHORT: number;
  6691. /**
  6692. * The integer type.
  6693. */
  6694. static readonly INT: number;
  6695. /**
  6696. * The unsigned integer type.
  6697. */
  6698. static readonly UNSIGNED_INT: number;
  6699. /**
  6700. * The float type.
  6701. */
  6702. static readonly FLOAT: number;
  6703. /**
  6704. * Gets or sets the instance divisor when in instanced mode
  6705. */
  6706. get instanceDivisor(): number;
  6707. set instanceDivisor(value: number);
  6708. /**
  6709. * Gets the byte stride.
  6710. */
  6711. readonly byteStride: number;
  6712. /**
  6713. * Gets the byte offset.
  6714. */
  6715. readonly byteOffset: number;
  6716. /**
  6717. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6718. */
  6719. readonly normalized: boolean;
  6720. /**
  6721. * Gets the data type of each component in the array.
  6722. */
  6723. readonly type: number;
  6724. /**
  6725. * Constructor
  6726. * @param engine the engine
  6727. * @param data the data to use for this vertex buffer
  6728. * @param kind the vertex buffer kind
  6729. * @param updatable whether the data is updatable
  6730. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6731. * @param stride the stride (optional)
  6732. * @param instanced whether the buffer is instanced (optional)
  6733. * @param offset the offset of the data (optional)
  6734. * @param size the number of components (optional)
  6735. * @param type the type of the component (optional)
  6736. * @param normalized whether the data contains normalized data (optional)
  6737. * @param useBytes set to true if stride and offset are in bytes (optional)
  6738. * @param divisor defines the instance divisor to use (1 by default)
  6739. */
  6740. 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);
  6741. /** @hidden */
  6742. _rebuild(): void;
  6743. /**
  6744. * Returns the kind of the VertexBuffer (string)
  6745. * @returns a string
  6746. */
  6747. getKind(): string;
  6748. /**
  6749. * Gets a boolean indicating if the VertexBuffer is updatable?
  6750. * @returns true if the buffer is updatable
  6751. */
  6752. isUpdatable(): boolean;
  6753. /**
  6754. * Gets current buffer's data
  6755. * @returns a DataArray or null
  6756. */
  6757. getData(): Nullable<DataArray>;
  6758. /**
  6759. * Gets underlying native buffer
  6760. * @returns underlying native buffer
  6761. */
  6762. getBuffer(): Nullable<DataBuffer>;
  6763. /**
  6764. * Gets the stride in float32 units (i.e. byte stride / 4).
  6765. * May not be an integer if the byte stride is not divisible by 4.
  6766. * @returns the stride in float32 units
  6767. * @deprecated Please use byteStride instead.
  6768. */
  6769. getStrideSize(): number;
  6770. /**
  6771. * Returns the offset as a multiple of the type byte length.
  6772. * @returns the offset in bytes
  6773. * @deprecated Please use byteOffset instead.
  6774. */
  6775. getOffset(): number;
  6776. /**
  6777. * Returns the number of components per vertex attribute (integer)
  6778. * @returns the size in float
  6779. */
  6780. getSize(): number;
  6781. /**
  6782. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6783. * @returns true if this buffer is instanced
  6784. */
  6785. getIsInstanced(): boolean;
  6786. /**
  6787. * Returns the instancing divisor, zero for non-instanced (integer).
  6788. * @returns a number
  6789. */
  6790. getInstanceDivisor(): number;
  6791. /**
  6792. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6793. * @param data defines the data to store
  6794. */
  6795. create(data?: DataArray): void;
  6796. /**
  6797. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6798. * This function will create a new buffer if the current one is not updatable
  6799. * @param data defines the data to store
  6800. */
  6801. update(data: DataArray): void;
  6802. /**
  6803. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6804. * Returns the directly updated WebGLBuffer.
  6805. * @param data the new data
  6806. * @param offset the new offset
  6807. * @param useBytes set to true if the offset is in bytes
  6808. */
  6809. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6810. /**
  6811. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6812. */
  6813. dispose(): void;
  6814. /**
  6815. * Enumerates each value of this vertex buffer as numbers.
  6816. * @param count the number of values to enumerate
  6817. * @param callback the callback function called for each value
  6818. */
  6819. forEach(count: number, callback: (value: number, index: number) => void): void;
  6820. /**
  6821. * Positions
  6822. */
  6823. static readonly PositionKind: string;
  6824. /**
  6825. * Normals
  6826. */
  6827. static readonly NormalKind: string;
  6828. /**
  6829. * Tangents
  6830. */
  6831. static readonly TangentKind: string;
  6832. /**
  6833. * Texture coordinates
  6834. */
  6835. static readonly UVKind: string;
  6836. /**
  6837. * Texture coordinates 2
  6838. */
  6839. static readonly UV2Kind: string;
  6840. /**
  6841. * Texture coordinates 3
  6842. */
  6843. static readonly UV3Kind: string;
  6844. /**
  6845. * Texture coordinates 4
  6846. */
  6847. static readonly UV4Kind: string;
  6848. /**
  6849. * Texture coordinates 5
  6850. */
  6851. static readonly UV5Kind: string;
  6852. /**
  6853. * Texture coordinates 6
  6854. */
  6855. static readonly UV6Kind: string;
  6856. /**
  6857. * Colors
  6858. */
  6859. static readonly ColorKind: string;
  6860. /**
  6861. * Matrix indices (for bones)
  6862. */
  6863. static readonly MatricesIndicesKind: string;
  6864. /**
  6865. * Matrix weights (for bones)
  6866. */
  6867. static readonly MatricesWeightsKind: string;
  6868. /**
  6869. * Additional matrix indices (for bones)
  6870. */
  6871. static readonly MatricesIndicesExtraKind: string;
  6872. /**
  6873. * Additional matrix weights (for bones)
  6874. */
  6875. static readonly MatricesWeightsExtraKind: string;
  6876. /**
  6877. * Deduces the stride given a kind.
  6878. * @param kind The kind string to deduce
  6879. * @returns The deduced stride
  6880. */
  6881. static DeduceStride(kind: string): number;
  6882. /**
  6883. * Gets the byte length of the given type.
  6884. * @param type the type
  6885. * @returns the number of bytes
  6886. */
  6887. static GetTypeByteLength(type: number): number;
  6888. /**
  6889. * Enumerates each value of the given parameters as numbers.
  6890. * @param data the data to enumerate
  6891. * @param byteOffset the byte offset of the data
  6892. * @param byteStride the byte stride of the data
  6893. * @param componentCount the number of components per element
  6894. * @param componentType the type of the component
  6895. * @param count the number of values to enumerate
  6896. * @param normalized whether the data is normalized
  6897. * @param callback the callback function called for each value
  6898. */
  6899. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6900. private static _GetFloatValue;
  6901. }
  6902. }
  6903. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6904. import { Vector3 } from "babylonjs/Maths/math.vector";
  6905. import { Mesh } from "babylonjs/Meshes/mesh";
  6906. /**
  6907. * The options Interface for creating a Capsule Mesh
  6908. */
  6909. export interface ICreateCapsuleOptions {
  6910. /** The Orientation of the capsule. Default : Vector3.Up() */
  6911. orientation?: Vector3;
  6912. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6913. subdivisions: number;
  6914. /** Number of cylindrical segments on the capsule. */
  6915. tessellation: number;
  6916. /** Height or Length of the capsule. */
  6917. height: number;
  6918. /** Radius of the capsule. */
  6919. radius: number;
  6920. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6921. capSubdivisions: number;
  6922. /** Overwrite for the top radius. */
  6923. radiusTop?: number;
  6924. /** Overwrite for the bottom radius. */
  6925. radiusBottom?: number;
  6926. /** Overwrite for the top capSubdivisions. */
  6927. topCapSubdivisions?: number;
  6928. /** Overwrite for the bottom capSubdivisions. */
  6929. bottomCapSubdivisions?: number;
  6930. }
  6931. /**
  6932. * Class containing static functions to help procedurally build meshes
  6933. */
  6934. export class CapsuleBuilder {
  6935. /**
  6936. * Creates a capsule or a pill mesh
  6937. * @param name defines the name of the mesh
  6938. * @param options The constructors options.
  6939. * @param scene The scene the mesh is scoped to.
  6940. * @returns Capsule Mesh
  6941. */
  6942. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6943. }
  6944. }
  6945. declare module "babylonjs/Collisions/intersectionInfo" {
  6946. import { Nullable } from "babylonjs/types";
  6947. /**
  6948. * @hidden
  6949. */
  6950. export class IntersectionInfo {
  6951. bu: Nullable<number>;
  6952. bv: Nullable<number>;
  6953. distance: number;
  6954. faceId: number;
  6955. subMeshId: number;
  6956. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6957. }
  6958. }
  6959. declare module "babylonjs/Culling/boundingSphere" {
  6960. import { DeepImmutable } from "babylonjs/types";
  6961. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6962. import { Plane } from "babylonjs/Maths/math.plane";
  6963. /**
  6964. * Class used to store bounding sphere information
  6965. */
  6966. export class BoundingSphere {
  6967. /**
  6968. * Gets the center of the bounding sphere in local space
  6969. */
  6970. readonly center: Vector3;
  6971. /**
  6972. * Radius of the bounding sphere in local space
  6973. */
  6974. radius: number;
  6975. /**
  6976. * Gets the center of the bounding sphere in world space
  6977. */
  6978. readonly centerWorld: Vector3;
  6979. /**
  6980. * Radius of the bounding sphere in world space
  6981. */
  6982. radiusWorld: number;
  6983. /**
  6984. * Gets the minimum vector in local space
  6985. */
  6986. readonly minimum: Vector3;
  6987. /**
  6988. * Gets the maximum vector in local space
  6989. */
  6990. readonly maximum: Vector3;
  6991. private _worldMatrix;
  6992. private static readonly TmpVector3;
  6993. /**
  6994. * Creates a new bounding sphere
  6995. * @param min defines the minimum vector (in local space)
  6996. * @param max defines the maximum vector (in local space)
  6997. * @param worldMatrix defines the new world matrix
  6998. */
  6999. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7000. /**
  7001. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7002. * @param min defines the new minimum vector (in local space)
  7003. * @param max defines the new maximum vector (in local space)
  7004. * @param worldMatrix defines the new world matrix
  7005. */
  7006. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7007. /**
  7008. * Scale the current bounding sphere by applying a scale factor
  7009. * @param factor defines the scale factor to apply
  7010. * @returns the current bounding box
  7011. */
  7012. scale(factor: number): BoundingSphere;
  7013. /**
  7014. * Gets the world matrix of the bounding box
  7015. * @returns a matrix
  7016. */
  7017. getWorldMatrix(): DeepImmutable<Matrix>;
  7018. /** @hidden */
  7019. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7020. /**
  7021. * Tests if the bounding sphere is intersecting the frustum planes
  7022. * @param frustumPlanes defines the frustum planes to test
  7023. * @returns true if there is an intersection
  7024. */
  7025. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7026. /**
  7027. * Tests if the bounding sphere center is in between the frustum planes.
  7028. * Used for optimistic fast inclusion.
  7029. * @param frustumPlanes defines the frustum planes to test
  7030. * @returns true if the sphere center is in between the frustum planes
  7031. */
  7032. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7033. /**
  7034. * Tests if a point is inside the bounding sphere
  7035. * @param point defines the point to test
  7036. * @returns true if the point is inside the bounding sphere
  7037. */
  7038. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7039. /**
  7040. * Checks if two sphere intersct
  7041. * @param sphere0 sphere 0
  7042. * @param sphere1 sphere 1
  7043. * @returns true if the speres intersect
  7044. */
  7045. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7046. }
  7047. }
  7048. declare module "babylonjs/Culling/boundingBox" {
  7049. import { DeepImmutable } from "babylonjs/types";
  7050. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7051. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7052. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7053. import { Plane } from "babylonjs/Maths/math.plane";
  7054. /**
  7055. * Class used to store bounding box information
  7056. */
  7057. export class BoundingBox implements ICullable {
  7058. /**
  7059. * Gets the 8 vectors representing the bounding box in local space
  7060. */
  7061. readonly vectors: Vector3[];
  7062. /**
  7063. * Gets the center of the bounding box in local space
  7064. */
  7065. readonly center: Vector3;
  7066. /**
  7067. * Gets the center of the bounding box in world space
  7068. */
  7069. readonly centerWorld: Vector3;
  7070. /**
  7071. * Gets the extend size in local space
  7072. */
  7073. readonly extendSize: Vector3;
  7074. /**
  7075. * Gets the extend size in world space
  7076. */
  7077. readonly extendSizeWorld: Vector3;
  7078. /**
  7079. * Gets the OBB (object bounding box) directions
  7080. */
  7081. readonly directions: Vector3[];
  7082. /**
  7083. * Gets the 8 vectors representing the bounding box in world space
  7084. */
  7085. readonly vectorsWorld: Vector3[];
  7086. /**
  7087. * Gets the minimum vector in world space
  7088. */
  7089. readonly minimumWorld: Vector3;
  7090. /**
  7091. * Gets the maximum vector in world space
  7092. */
  7093. readonly maximumWorld: Vector3;
  7094. /**
  7095. * Gets the minimum vector in local space
  7096. */
  7097. readonly minimum: Vector3;
  7098. /**
  7099. * Gets the maximum vector in local space
  7100. */
  7101. readonly maximum: Vector3;
  7102. private _worldMatrix;
  7103. private static readonly TmpVector3;
  7104. /**
  7105. * @hidden
  7106. */
  7107. _tag: number;
  7108. /**
  7109. * Creates a new bounding box
  7110. * @param min defines the minimum vector (in local space)
  7111. * @param max defines the maximum vector (in local space)
  7112. * @param worldMatrix defines the new world matrix
  7113. */
  7114. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7115. /**
  7116. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7117. * @param min defines the new minimum vector (in local space)
  7118. * @param max defines the new maximum vector (in local space)
  7119. * @param worldMatrix defines the new world matrix
  7120. */
  7121. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7122. /**
  7123. * Scale the current bounding box by applying a scale factor
  7124. * @param factor defines the scale factor to apply
  7125. * @returns the current bounding box
  7126. */
  7127. scale(factor: number): BoundingBox;
  7128. /**
  7129. * Gets the world matrix of the bounding box
  7130. * @returns a matrix
  7131. */
  7132. getWorldMatrix(): DeepImmutable<Matrix>;
  7133. /** @hidden */
  7134. _update(world: DeepImmutable<Matrix>): void;
  7135. /**
  7136. * Tests if the bounding box is intersecting the frustum planes
  7137. * @param frustumPlanes defines the frustum planes to test
  7138. * @returns true if there is an intersection
  7139. */
  7140. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7141. /**
  7142. * Tests if the bounding box is entirely inside the frustum planes
  7143. * @param frustumPlanes defines the frustum planes to test
  7144. * @returns true if there is an inclusion
  7145. */
  7146. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7147. /**
  7148. * Tests if a point is inside the bounding box
  7149. * @param point defines the point to test
  7150. * @returns true if the point is inside the bounding box
  7151. */
  7152. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7153. /**
  7154. * Tests if the bounding box intersects with a bounding sphere
  7155. * @param sphere defines the sphere to test
  7156. * @returns true if there is an intersection
  7157. */
  7158. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7159. /**
  7160. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7161. * @param min defines the min vector to use
  7162. * @param max defines the max vector to use
  7163. * @returns true if there is an intersection
  7164. */
  7165. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7166. /**
  7167. * Tests if two bounding boxes are intersections
  7168. * @param box0 defines the first box to test
  7169. * @param box1 defines the second box to test
  7170. * @returns true if there is an intersection
  7171. */
  7172. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7173. /**
  7174. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7175. * @param minPoint defines the minimum vector of the bounding box
  7176. * @param maxPoint defines the maximum vector of the bounding box
  7177. * @param sphereCenter defines the sphere center
  7178. * @param sphereRadius defines the sphere radius
  7179. * @returns true if there is an intersection
  7180. */
  7181. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7182. /**
  7183. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7184. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7185. * @param frustumPlanes defines the frustum planes to test
  7186. * @return true if there is an inclusion
  7187. */
  7188. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7189. /**
  7190. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7191. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7192. * @param frustumPlanes defines the frustum planes to test
  7193. * @return true if there is an intersection
  7194. */
  7195. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7196. }
  7197. }
  7198. declare module "babylonjs/Collisions/collider" {
  7199. import { Nullable, IndicesArray } from "babylonjs/types";
  7200. import { Vector3 } from "babylonjs/Maths/math.vector";
  7201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7202. import { Plane } from "babylonjs/Maths/math.plane";
  7203. /** @hidden */
  7204. export class Collider {
  7205. /** Define if a collision was found */
  7206. collisionFound: boolean;
  7207. /**
  7208. * Define last intersection point in local space
  7209. */
  7210. intersectionPoint: Vector3;
  7211. /**
  7212. * Define last collided mesh
  7213. */
  7214. collidedMesh: Nullable<AbstractMesh>;
  7215. private _collisionPoint;
  7216. private _planeIntersectionPoint;
  7217. private _tempVector;
  7218. private _tempVector2;
  7219. private _tempVector3;
  7220. private _tempVector4;
  7221. private _edge;
  7222. private _baseToVertex;
  7223. private _destinationPoint;
  7224. private _slidePlaneNormal;
  7225. private _displacementVector;
  7226. /** @hidden */
  7227. _radius: Vector3;
  7228. /** @hidden */
  7229. _retry: number;
  7230. private _velocity;
  7231. private _basePoint;
  7232. private _epsilon;
  7233. /** @hidden */
  7234. _velocityWorldLength: number;
  7235. /** @hidden */
  7236. _basePointWorld: Vector3;
  7237. private _velocityWorld;
  7238. private _normalizedVelocity;
  7239. /** @hidden */
  7240. _initialVelocity: Vector3;
  7241. /** @hidden */
  7242. _initialPosition: Vector3;
  7243. private _nearestDistance;
  7244. private _collisionMask;
  7245. get collisionMask(): number;
  7246. set collisionMask(mask: number);
  7247. /**
  7248. * Gets the plane normal used to compute the sliding response (in local space)
  7249. */
  7250. get slidePlaneNormal(): Vector3;
  7251. /** @hidden */
  7252. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7253. /** @hidden */
  7254. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7255. /** @hidden */
  7256. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7257. /** @hidden */
  7258. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7259. /** @hidden */
  7260. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7261. /** @hidden */
  7262. _getResponse(pos: Vector3, vel: Vector3): void;
  7263. }
  7264. }
  7265. declare module "babylonjs/Culling/boundingInfo" {
  7266. import { DeepImmutable } from "babylonjs/types";
  7267. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7268. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7269. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7270. import { Plane } from "babylonjs/Maths/math.plane";
  7271. import { Collider } from "babylonjs/Collisions/collider";
  7272. /**
  7273. * Interface for cullable objects
  7274. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7275. */
  7276. export interface ICullable {
  7277. /**
  7278. * Checks if the object or part of the object is in the frustum
  7279. * @param frustumPlanes Camera near/planes
  7280. * @returns true if the object is in frustum otherwise false
  7281. */
  7282. isInFrustum(frustumPlanes: Plane[]): boolean;
  7283. /**
  7284. * Checks if a cullable object (mesh...) is in the camera frustum
  7285. * Unlike isInFrustum this cheks the full bounding box
  7286. * @param frustumPlanes Camera near/planes
  7287. * @returns true if the object is in frustum otherwise false
  7288. */
  7289. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7290. }
  7291. /**
  7292. * Info for a bounding data of a mesh
  7293. */
  7294. export class BoundingInfo implements ICullable {
  7295. /**
  7296. * Bounding box for the mesh
  7297. */
  7298. readonly boundingBox: BoundingBox;
  7299. /**
  7300. * Bounding sphere for the mesh
  7301. */
  7302. readonly boundingSphere: BoundingSphere;
  7303. private _isLocked;
  7304. private static readonly TmpVector3;
  7305. /**
  7306. * Constructs bounding info
  7307. * @param minimum min vector of the bounding box/sphere
  7308. * @param maximum max vector of the bounding box/sphere
  7309. * @param worldMatrix defines the new world matrix
  7310. */
  7311. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7312. /**
  7313. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7314. * @param min defines the new minimum vector (in local space)
  7315. * @param max defines the new maximum vector (in local space)
  7316. * @param worldMatrix defines the new world matrix
  7317. */
  7318. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7319. /**
  7320. * min vector of the bounding box/sphere
  7321. */
  7322. get minimum(): Vector3;
  7323. /**
  7324. * max vector of the bounding box/sphere
  7325. */
  7326. get maximum(): Vector3;
  7327. /**
  7328. * If the info is locked and won't be updated to avoid perf overhead
  7329. */
  7330. get isLocked(): boolean;
  7331. set isLocked(value: boolean);
  7332. /**
  7333. * Updates the bounding sphere and box
  7334. * @param world world matrix to be used to update
  7335. */
  7336. update(world: DeepImmutable<Matrix>): void;
  7337. /**
  7338. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7339. * @param center New center of the bounding info
  7340. * @param extend New extend of the bounding info
  7341. * @returns the current bounding info
  7342. */
  7343. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7344. /**
  7345. * Scale the current bounding info by applying a scale factor
  7346. * @param factor defines the scale factor to apply
  7347. * @returns the current bounding info
  7348. */
  7349. scale(factor: number): BoundingInfo;
  7350. /**
  7351. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7352. * @param frustumPlanes defines the frustum to test
  7353. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7354. * @returns true if the bounding info is in the frustum planes
  7355. */
  7356. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7357. /**
  7358. * Gets the world distance between the min and max points of the bounding box
  7359. */
  7360. get diagonalLength(): number;
  7361. /**
  7362. * Checks if a cullable object (mesh...) is in the camera frustum
  7363. * Unlike isInFrustum this cheks the full bounding box
  7364. * @param frustumPlanes Camera near/planes
  7365. * @returns true if the object is in frustum otherwise false
  7366. */
  7367. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7368. /** @hidden */
  7369. _checkCollision(collider: Collider): boolean;
  7370. /**
  7371. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7372. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7373. * @param point the point to check intersection with
  7374. * @returns if the point intersects
  7375. */
  7376. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7377. /**
  7378. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7379. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7380. * @param boundingInfo the bounding info to check intersection with
  7381. * @param precise if the intersection should be done using OBB
  7382. * @returns if the bounding info intersects
  7383. */
  7384. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7385. }
  7386. }
  7387. declare module "babylonjs/Maths/math.functions" {
  7388. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7389. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7390. /**
  7391. * Extracts minimum and maximum values from a list of indexed positions
  7392. * @param positions defines the positions to use
  7393. * @param indices defines the indices to the positions
  7394. * @param indexStart defines the start index
  7395. * @param indexCount defines the end index
  7396. * @param bias defines bias value to add to the result
  7397. * @return minimum and maximum values
  7398. */
  7399. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7400. minimum: Vector3;
  7401. maximum: Vector3;
  7402. };
  7403. /**
  7404. * Extracts minimum and maximum values from a list of positions
  7405. * @param positions defines the positions to use
  7406. * @param start defines the start index in the positions array
  7407. * @param count defines the number of positions to handle
  7408. * @param bias defines bias value to add to the result
  7409. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7410. * @return minimum and maximum values
  7411. */
  7412. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7413. minimum: Vector3;
  7414. maximum: Vector3;
  7415. };
  7416. }
  7417. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7418. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7419. /** @hidden */
  7420. export class WebGLDataBuffer extends DataBuffer {
  7421. private _buffer;
  7422. constructor(resource: WebGLBuffer);
  7423. get underlyingResource(): any;
  7424. }
  7425. }
  7426. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7427. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7428. import { Nullable } from "babylonjs/types";
  7429. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7430. /** @hidden */
  7431. export class WebGLPipelineContext implements IPipelineContext {
  7432. engine: ThinEngine;
  7433. program: Nullable<WebGLProgram>;
  7434. context?: WebGLRenderingContext;
  7435. vertexShader?: WebGLShader;
  7436. fragmentShader?: WebGLShader;
  7437. isParallelCompiled: boolean;
  7438. onCompiled?: () => void;
  7439. transformFeedback?: WebGLTransformFeedback | null;
  7440. vertexCompilationError: Nullable<string>;
  7441. fragmentCompilationError: Nullable<string>;
  7442. programLinkError: Nullable<string>;
  7443. programValidationError: Nullable<string>;
  7444. get isAsync(): boolean;
  7445. get isReady(): boolean;
  7446. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7447. _getVertexShaderCode(): string | null;
  7448. _getFragmentShaderCode(): string | null;
  7449. }
  7450. }
  7451. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7452. import { FloatArray, Nullable } from "babylonjs/types";
  7453. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7454. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7455. module "babylonjs/Engines/thinEngine" {
  7456. interface ThinEngine {
  7457. /**
  7458. * Create an uniform buffer
  7459. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7460. * @param elements defines the content of the uniform buffer
  7461. * @returns the webGL uniform buffer
  7462. */
  7463. createUniformBuffer(elements: FloatArray): DataBuffer;
  7464. /**
  7465. * Create a dynamic uniform buffer
  7466. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7467. * @param elements defines the content of the uniform buffer
  7468. * @returns the webGL uniform buffer
  7469. */
  7470. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7471. /**
  7472. * Update an existing uniform buffer
  7473. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7474. * @param uniformBuffer defines the target uniform buffer
  7475. * @param elements defines the content to update
  7476. * @param offset defines the offset in the uniform buffer where update should start
  7477. * @param count defines the size of the data to update
  7478. */
  7479. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7480. /**
  7481. * Bind an uniform buffer to the current webGL context
  7482. * @param buffer defines the buffer to bind
  7483. */
  7484. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7485. /**
  7486. * Bind a buffer to the current webGL context at a given location
  7487. * @param buffer defines the buffer to bind
  7488. * @param location defines the index where to bind the buffer
  7489. */
  7490. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7491. /**
  7492. * Bind a specific block at a given index in a specific shader program
  7493. * @param pipelineContext defines the pipeline context to use
  7494. * @param blockName defines the block name
  7495. * @param index defines the index where to bind the block
  7496. */
  7497. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7498. }
  7499. }
  7500. }
  7501. declare module "babylonjs/Materials/uniformBuffer" {
  7502. import { Nullable, FloatArray } from "babylonjs/types";
  7503. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7504. import { Engine } from "babylonjs/Engines/engine";
  7505. import { Effect } from "babylonjs/Materials/effect";
  7506. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7507. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7508. import { Color3 } from "babylonjs/Maths/math.color";
  7509. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7510. /**
  7511. * Uniform buffer objects.
  7512. *
  7513. * Handles blocks of uniform on the GPU.
  7514. *
  7515. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7516. *
  7517. * For more information, please refer to :
  7518. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7519. */
  7520. export class UniformBuffer {
  7521. private _engine;
  7522. private _buffer;
  7523. private _data;
  7524. private _bufferData;
  7525. private _dynamic?;
  7526. private _uniformLocations;
  7527. private _uniformSizes;
  7528. private _uniformLocationPointer;
  7529. private _needSync;
  7530. private _noUBO;
  7531. private _currentEffect;
  7532. /** @hidden */
  7533. _alreadyBound: boolean;
  7534. private static _MAX_UNIFORM_SIZE;
  7535. private static _tempBuffer;
  7536. /**
  7537. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7538. * This is dynamic to allow compat with webgl 1 and 2.
  7539. * You will need to pass the name of the uniform as well as the value.
  7540. */
  7541. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7542. /**
  7543. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7544. * This is dynamic to allow compat with webgl 1 and 2.
  7545. * You will need to pass the name of the uniform as well as the value.
  7546. */
  7547. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7548. /**
  7549. * Lambda to Update a single float in a uniform buffer.
  7550. * This is dynamic to allow compat with webgl 1 and 2.
  7551. * You will need to pass the name of the uniform as well as the value.
  7552. */
  7553. updateFloat: (name: string, x: number) => void;
  7554. /**
  7555. * Lambda to Update a vec2 of float in a uniform buffer.
  7556. * This is dynamic to allow compat with webgl 1 and 2.
  7557. * You will need to pass the name of the uniform as well as the value.
  7558. */
  7559. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7560. /**
  7561. * Lambda to Update a vec3 of float in a uniform buffer.
  7562. * This is dynamic to allow compat with webgl 1 and 2.
  7563. * You will need to pass the name of the uniform as well as the value.
  7564. */
  7565. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7566. /**
  7567. * Lambda to Update a vec4 of float in a uniform buffer.
  7568. * This is dynamic to allow compat with webgl 1 and 2.
  7569. * You will need to pass the name of the uniform as well as the value.
  7570. */
  7571. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7572. /**
  7573. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7574. * This is dynamic to allow compat with webgl 1 and 2.
  7575. * You will need to pass the name of the uniform as well as the value.
  7576. */
  7577. updateMatrix: (name: string, mat: Matrix) => void;
  7578. /**
  7579. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7580. * This is dynamic to allow compat with webgl 1 and 2.
  7581. * You will need to pass the name of the uniform as well as the value.
  7582. */
  7583. updateVector3: (name: string, vector: Vector3) => void;
  7584. /**
  7585. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7586. * This is dynamic to allow compat with webgl 1 and 2.
  7587. * You will need to pass the name of the uniform as well as the value.
  7588. */
  7589. updateVector4: (name: string, vector: Vector4) => void;
  7590. /**
  7591. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7592. * This is dynamic to allow compat with webgl 1 and 2.
  7593. * You will need to pass the name of the uniform as well as the value.
  7594. */
  7595. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7596. /**
  7597. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7598. * This is dynamic to allow compat with webgl 1 and 2.
  7599. * You will need to pass the name of the uniform as well as the value.
  7600. */
  7601. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7602. /**
  7603. * Instantiates a new Uniform buffer objects.
  7604. *
  7605. * Handles blocks of uniform on the GPU.
  7606. *
  7607. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7608. *
  7609. * For more information, please refer to :
  7610. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7611. * @param engine Define the engine the buffer is associated with
  7612. * @param data Define the data contained in the buffer
  7613. * @param dynamic Define if the buffer is updatable
  7614. */
  7615. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7616. /**
  7617. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7618. * or just falling back on setUniformXXX calls.
  7619. */
  7620. get useUbo(): boolean;
  7621. /**
  7622. * Indicates if the WebGL underlying uniform buffer is in sync
  7623. * with the javascript cache data.
  7624. */
  7625. get isSync(): boolean;
  7626. /**
  7627. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7628. * Also, a dynamic UniformBuffer will disable cache verification and always
  7629. * update the underlying WebGL uniform buffer to the GPU.
  7630. * @returns if Dynamic, otherwise false
  7631. */
  7632. isDynamic(): boolean;
  7633. /**
  7634. * The data cache on JS side.
  7635. * @returns the underlying data as a float array
  7636. */
  7637. getData(): Float32Array;
  7638. /**
  7639. * The underlying WebGL Uniform buffer.
  7640. * @returns the webgl buffer
  7641. */
  7642. getBuffer(): Nullable<DataBuffer>;
  7643. /**
  7644. * std140 layout specifies how to align data within an UBO structure.
  7645. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7646. * for specs.
  7647. */
  7648. private _fillAlignment;
  7649. /**
  7650. * Adds an uniform in the buffer.
  7651. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7652. * for the layout to be correct !
  7653. * @param name Name of the uniform, as used in the uniform block in the shader.
  7654. * @param size Data size, or data directly.
  7655. */
  7656. addUniform(name: string, size: number | number[]): void;
  7657. /**
  7658. * Adds a Matrix 4x4 to the uniform buffer.
  7659. * @param name Name of the uniform, as used in the uniform block in the shader.
  7660. * @param mat A 4x4 matrix.
  7661. */
  7662. addMatrix(name: string, mat: Matrix): void;
  7663. /**
  7664. * Adds a vec2 to the uniform buffer.
  7665. * @param name Name of the uniform, as used in the uniform block in the shader.
  7666. * @param x Define the x component value of the vec2
  7667. * @param y Define the y component value of the vec2
  7668. */
  7669. addFloat2(name: string, x: number, y: number): void;
  7670. /**
  7671. * Adds a vec3 to the uniform buffer.
  7672. * @param name Name of the uniform, as used in the uniform block in the shader.
  7673. * @param x Define the x component value of the vec3
  7674. * @param y Define the y component value of the vec3
  7675. * @param z Define the z component value of the vec3
  7676. */
  7677. addFloat3(name: string, x: number, y: number, z: number): void;
  7678. /**
  7679. * Adds a vec3 to the uniform buffer.
  7680. * @param name Name of the uniform, as used in the uniform block in the shader.
  7681. * @param color Define the vec3 from a Color
  7682. */
  7683. addColor3(name: string, color: Color3): void;
  7684. /**
  7685. * Adds a vec4 to the uniform buffer.
  7686. * @param name Name of the uniform, as used in the uniform block in the shader.
  7687. * @param color Define the rgb components from a Color
  7688. * @param alpha Define the a component of the vec4
  7689. */
  7690. addColor4(name: string, color: Color3, alpha: number): void;
  7691. /**
  7692. * Adds a vec3 to the uniform buffer.
  7693. * @param name Name of the uniform, as used in the uniform block in the shader.
  7694. * @param vector Define the vec3 components from a Vector
  7695. */
  7696. addVector3(name: string, vector: Vector3): void;
  7697. /**
  7698. * Adds a Matrix 3x3 to the uniform buffer.
  7699. * @param name Name of the uniform, as used in the uniform block in the shader.
  7700. */
  7701. addMatrix3x3(name: string): void;
  7702. /**
  7703. * Adds a Matrix 2x2 to the uniform buffer.
  7704. * @param name Name of the uniform, as used in the uniform block in the shader.
  7705. */
  7706. addMatrix2x2(name: string): void;
  7707. /**
  7708. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7709. */
  7710. create(): void;
  7711. /** @hidden */
  7712. _rebuild(): void;
  7713. /**
  7714. * Updates the WebGL Uniform Buffer on the GPU.
  7715. * If the `dynamic` flag is set to true, no cache comparison is done.
  7716. * Otherwise, the buffer will be updated only if the cache differs.
  7717. */
  7718. update(): void;
  7719. /**
  7720. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7721. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7722. * @param data Define the flattened data
  7723. * @param size Define the size of the data.
  7724. */
  7725. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7726. private _valueCache;
  7727. private _cacheMatrix;
  7728. private _updateMatrix3x3ForUniform;
  7729. private _updateMatrix3x3ForEffect;
  7730. private _updateMatrix2x2ForEffect;
  7731. private _updateMatrix2x2ForUniform;
  7732. private _updateFloatForEffect;
  7733. private _updateFloatForUniform;
  7734. private _updateFloat2ForEffect;
  7735. private _updateFloat2ForUniform;
  7736. private _updateFloat3ForEffect;
  7737. private _updateFloat3ForUniform;
  7738. private _updateFloat4ForEffect;
  7739. private _updateFloat4ForUniform;
  7740. private _updateMatrixForEffect;
  7741. private _updateMatrixForUniform;
  7742. private _updateVector3ForEffect;
  7743. private _updateVector3ForUniform;
  7744. private _updateVector4ForEffect;
  7745. private _updateVector4ForUniform;
  7746. private _updateColor3ForEffect;
  7747. private _updateColor3ForUniform;
  7748. private _updateColor4ForEffect;
  7749. private _updateColor4ForUniform;
  7750. /**
  7751. * Sets a sampler uniform on the effect.
  7752. * @param name Define the name of the sampler.
  7753. * @param texture Define the texture to set in the sampler
  7754. */
  7755. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7756. /**
  7757. * Directly updates the value of the uniform in the cache AND on the GPU.
  7758. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7759. * @param data Define the flattened data
  7760. */
  7761. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7762. /**
  7763. * Binds this uniform buffer to an effect.
  7764. * @param effect Define the effect to bind the buffer to
  7765. * @param name Name of the uniform block in the shader.
  7766. */
  7767. bindToEffect(effect: Effect, name: string): void;
  7768. /**
  7769. * Disposes the uniform buffer.
  7770. */
  7771. dispose(): void;
  7772. }
  7773. }
  7774. declare module "babylonjs/Misc/iInspectable" {
  7775. /**
  7776. * Enum that determines the text-wrapping mode to use.
  7777. */
  7778. export enum InspectableType {
  7779. /**
  7780. * Checkbox for booleans
  7781. */
  7782. Checkbox = 0,
  7783. /**
  7784. * Sliders for numbers
  7785. */
  7786. Slider = 1,
  7787. /**
  7788. * Vector3
  7789. */
  7790. Vector3 = 2,
  7791. /**
  7792. * Quaternions
  7793. */
  7794. Quaternion = 3,
  7795. /**
  7796. * Color3
  7797. */
  7798. Color3 = 4,
  7799. /**
  7800. * String
  7801. */
  7802. String = 5
  7803. }
  7804. /**
  7805. * Interface used to define custom inspectable properties.
  7806. * This interface is used by the inspector to display custom property grids
  7807. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7808. */
  7809. export interface IInspectable {
  7810. /**
  7811. * Gets the label to display
  7812. */
  7813. label: string;
  7814. /**
  7815. * Gets the name of the property to edit
  7816. */
  7817. propertyName: string;
  7818. /**
  7819. * Gets the type of the editor to use
  7820. */
  7821. type: InspectableType;
  7822. /**
  7823. * Gets the minimum value of the property when using in "slider" mode
  7824. */
  7825. min?: number;
  7826. /**
  7827. * Gets the maximum value of the property when using in "slider" mode
  7828. */
  7829. max?: number;
  7830. /**
  7831. * Gets the setp to use when using in "slider" mode
  7832. */
  7833. step?: number;
  7834. }
  7835. }
  7836. declare module "babylonjs/Misc/timingTools" {
  7837. /**
  7838. * Class used to provide helper for timing
  7839. */
  7840. export class TimingTools {
  7841. /**
  7842. * Polyfill for setImmediate
  7843. * @param action defines the action to execute after the current execution block
  7844. */
  7845. static SetImmediate(action: () => void): void;
  7846. }
  7847. }
  7848. declare module "babylonjs/Misc/instantiationTools" {
  7849. /**
  7850. * Class used to enable instatition of objects by class name
  7851. */
  7852. export class InstantiationTools {
  7853. /**
  7854. * Use this object to register external classes like custom textures or material
  7855. * to allow the laoders to instantiate them
  7856. */
  7857. static RegisteredExternalClasses: {
  7858. [key: string]: Object;
  7859. };
  7860. /**
  7861. * Tries to instantiate a new object from a given class name
  7862. * @param className defines the class name to instantiate
  7863. * @returns the new object or null if the system was not able to do the instantiation
  7864. */
  7865. static Instantiate(className: string): any;
  7866. }
  7867. }
  7868. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7869. /**
  7870. * Define options used to create a depth texture
  7871. */
  7872. export class DepthTextureCreationOptions {
  7873. /** Specifies whether or not a stencil should be allocated in the texture */
  7874. generateStencil?: boolean;
  7875. /** Specifies whether or not bilinear filtering is enable on the texture */
  7876. bilinearFiltering?: boolean;
  7877. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7878. comparisonFunction?: number;
  7879. /** Specifies if the created texture is a cube texture */
  7880. isCube?: boolean;
  7881. }
  7882. }
  7883. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7884. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7885. import { Nullable } from "babylonjs/types";
  7886. import { Scene } from "babylonjs/scene";
  7887. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7888. module "babylonjs/Engines/thinEngine" {
  7889. interface ThinEngine {
  7890. /**
  7891. * Creates a depth stencil cube texture.
  7892. * This is only available in WebGL 2.
  7893. * @param size The size of face edge in the cube texture.
  7894. * @param options The options defining the cube texture.
  7895. * @returns The cube texture
  7896. */
  7897. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7898. /**
  7899. * Creates a cube texture
  7900. * @param rootUrl defines the url where the files to load is located
  7901. * @param scene defines the current scene
  7902. * @param files defines the list of files to load (1 per face)
  7903. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7904. * @param onLoad defines an optional callback raised when the texture is loaded
  7905. * @param onError defines an optional callback raised if there is an issue to load the texture
  7906. * @param format defines the format of the data
  7907. * @param forcedExtension defines the extension to use to pick the right loader
  7908. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7909. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7910. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7911. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7912. * @param loaderOptions options to be passed to the loader
  7913. * @returns the cube texture as an InternalTexture
  7914. */
  7915. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  7916. /**
  7917. * Creates a cube texture
  7918. * @param rootUrl defines the url where the files to load is located
  7919. * @param scene defines the current scene
  7920. * @param files defines the list of files to load (1 per face)
  7921. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7922. * @param onLoad defines an optional callback raised when the texture is loaded
  7923. * @param onError defines an optional callback raised if there is an issue to load the texture
  7924. * @param format defines the format of the data
  7925. * @param forcedExtension defines the extension to use to pick the right loader
  7926. * @returns the cube texture as an InternalTexture
  7927. */
  7928. 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;
  7929. /**
  7930. * Creates a cube texture
  7931. * @param rootUrl defines the url where the files to load is located
  7932. * @param scene defines the current scene
  7933. * @param files defines the list of files to load (1 per face)
  7934. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7935. * @param onLoad defines an optional callback raised when the texture is loaded
  7936. * @param onError defines an optional callback raised if there is an issue to load the texture
  7937. * @param format defines the format of the data
  7938. * @param forcedExtension defines the extension to use to pick the right loader
  7939. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7940. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7941. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7942. * @returns the cube texture as an InternalTexture
  7943. */
  7944. 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;
  7945. /** @hidden */
  7946. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7947. /** @hidden */
  7948. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7949. /** @hidden */
  7950. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7951. /** @hidden */
  7952. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7953. /**
  7954. * @hidden
  7955. */
  7956. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  7957. }
  7958. }
  7959. }
  7960. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7961. import { Nullable } from "babylonjs/types";
  7962. import { Scene } from "babylonjs/scene";
  7963. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7964. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7965. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7966. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7967. import { Observable } from "babylonjs/Misc/observable";
  7968. /**
  7969. * Class for creating a cube texture
  7970. */
  7971. export class CubeTexture extends BaseTexture {
  7972. private _delayedOnLoad;
  7973. /**
  7974. * Observable triggered once the texture has been loaded.
  7975. */
  7976. onLoadObservable: Observable<CubeTexture>;
  7977. /**
  7978. * The url of the texture
  7979. */
  7980. url: string;
  7981. /**
  7982. * Gets or sets the center of the bounding box associated with the cube texture.
  7983. * It must define where the camera used to render the texture was set
  7984. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7985. */
  7986. boundingBoxPosition: Vector3;
  7987. private _boundingBoxSize;
  7988. /**
  7989. * Gets or sets the size of the bounding box associated with the cube texture
  7990. * When defined, the cubemap will switch to local mode
  7991. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7992. * @example https://www.babylonjs-playground.com/#RNASML
  7993. */
  7994. set boundingBoxSize(value: Vector3);
  7995. /**
  7996. * Returns the bounding box size
  7997. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7998. */
  7999. get boundingBoxSize(): Vector3;
  8000. protected _rotationY: number;
  8001. /**
  8002. * Sets texture matrix rotation angle around Y axis in radians.
  8003. */
  8004. set rotationY(value: number);
  8005. /**
  8006. * Gets texture matrix rotation angle around Y axis radians.
  8007. */
  8008. get rotationY(): number;
  8009. /**
  8010. * Are mip maps generated for this texture or not.
  8011. */
  8012. get noMipmap(): boolean;
  8013. private _noMipmap;
  8014. private _files;
  8015. protected _forcedExtension: Nullable<string>;
  8016. private _extensions;
  8017. private _textureMatrix;
  8018. private _format;
  8019. private _createPolynomials;
  8020. private _loaderOptions;
  8021. /**
  8022. * Creates a cube texture from an array of image urls
  8023. * @param files defines an array of image urls
  8024. * @param scene defines the hosting scene
  8025. * @param noMipmap specifies if mip maps are not used
  8026. * @returns a cube texture
  8027. */
  8028. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8029. /**
  8030. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8031. * @param url defines the url of the prefiltered texture
  8032. * @param scene defines the scene the texture is attached to
  8033. * @param forcedExtension defines the extension of the file if different from the url
  8034. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8035. * @return the prefiltered texture
  8036. */
  8037. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8038. /**
  8039. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8040. * as prefiltered data.
  8041. * @param rootUrl defines the url of the texture or the root name of the six images
  8042. * @param null defines the scene or engine the texture is attached to
  8043. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8044. * @param noMipmap defines if mipmaps should be created or not
  8045. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8046. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8047. * @param onError defines a callback triggered in case of error during load
  8048. * @param format defines the internal format to use for the texture once loaded
  8049. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8050. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8051. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8052. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8053. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8054. * @param loaderOptions options to be passed to the loader
  8055. * @return the cube texture
  8056. */
  8057. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  8058. /**
  8059. * Get the current class name of the texture useful for serialization or dynamic coding.
  8060. * @returns "CubeTexture"
  8061. */
  8062. getClassName(): string;
  8063. /**
  8064. * Update the url (and optional buffer) of this texture if url was null during construction.
  8065. * @param url the url of the texture
  8066. * @param forcedExtension defines the extension to use
  8067. * @param onLoad callback called when the texture is loaded (defaults to null)
  8068. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8069. */
  8070. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8071. /**
  8072. * Delays loading of the cube texture
  8073. * @param forcedExtension defines the extension to use
  8074. */
  8075. delayLoad(forcedExtension?: string): void;
  8076. /**
  8077. * Returns the reflection texture matrix
  8078. * @returns the reflection texture matrix
  8079. */
  8080. getReflectionTextureMatrix(): Matrix;
  8081. /**
  8082. * Sets the reflection texture matrix
  8083. * @param value Reflection texture matrix
  8084. */
  8085. setReflectionTextureMatrix(value: Matrix): void;
  8086. /**
  8087. * Parses text to create a cube texture
  8088. * @param parsedTexture define the serialized text to read from
  8089. * @param scene defines the hosting scene
  8090. * @param rootUrl defines the root url of the cube texture
  8091. * @returns a cube texture
  8092. */
  8093. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8094. /**
  8095. * Makes a clone, or deep copy, of the cube texture
  8096. * @returns a new cube texture
  8097. */
  8098. clone(): CubeTexture;
  8099. }
  8100. }
  8101. declare module "babylonjs/Materials/materialDefines" {
  8102. /**
  8103. * Manages the defines for the Material
  8104. */
  8105. export class MaterialDefines {
  8106. /** @hidden */
  8107. protected _keys: string[];
  8108. private _isDirty;
  8109. /** @hidden */
  8110. _renderId: number;
  8111. /** @hidden */
  8112. _areLightsDirty: boolean;
  8113. /** @hidden */
  8114. _areLightsDisposed: boolean;
  8115. /** @hidden */
  8116. _areAttributesDirty: boolean;
  8117. /** @hidden */
  8118. _areTexturesDirty: boolean;
  8119. /** @hidden */
  8120. _areFresnelDirty: boolean;
  8121. /** @hidden */
  8122. _areMiscDirty: boolean;
  8123. /** @hidden */
  8124. _arePrePassDirty: boolean;
  8125. /** @hidden */
  8126. _areImageProcessingDirty: boolean;
  8127. /** @hidden */
  8128. _normals: boolean;
  8129. /** @hidden */
  8130. _uvs: boolean;
  8131. /** @hidden */
  8132. _needNormals: boolean;
  8133. /** @hidden */
  8134. _needUVs: boolean;
  8135. [id: string]: any;
  8136. /**
  8137. * Specifies if the material needs to be re-calculated
  8138. */
  8139. get isDirty(): boolean;
  8140. /**
  8141. * Marks the material to indicate that it has been re-calculated
  8142. */
  8143. markAsProcessed(): void;
  8144. /**
  8145. * Marks the material to indicate that it needs to be re-calculated
  8146. */
  8147. markAsUnprocessed(): void;
  8148. /**
  8149. * Marks the material to indicate all of its defines need to be re-calculated
  8150. */
  8151. markAllAsDirty(): void;
  8152. /**
  8153. * Marks the material to indicate that image processing needs to be re-calculated
  8154. */
  8155. markAsImageProcessingDirty(): void;
  8156. /**
  8157. * Marks the material to indicate the lights need to be re-calculated
  8158. * @param disposed Defines whether the light is dirty due to dispose or not
  8159. */
  8160. markAsLightDirty(disposed?: boolean): void;
  8161. /**
  8162. * Marks the attribute state as changed
  8163. */
  8164. markAsAttributesDirty(): void;
  8165. /**
  8166. * Marks the texture state as changed
  8167. */
  8168. markAsTexturesDirty(): void;
  8169. /**
  8170. * Marks the fresnel state as changed
  8171. */
  8172. markAsFresnelDirty(): void;
  8173. /**
  8174. * Marks the misc state as changed
  8175. */
  8176. markAsMiscDirty(): void;
  8177. /**
  8178. * Marks the prepass state as changed
  8179. */
  8180. markAsPrePassDirty(): void;
  8181. /**
  8182. * Rebuilds the material defines
  8183. */
  8184. rebuild(): void;
  8185. /**
  8186. * Specifies if two material defines are equal
  8187. * @param other - A material define instance to compare to
  8188. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8189. */
  8190. isEqual(other: MaterialDefines): boolean;
  8191. /**
  8192. * Clones this instance's defines to another instance
  8193. * @param other - material defines to clone values to
  8194. */
  8195. cloneTo(other: MaterialDefines): void;
  8196. /**
  8197. * Resets the material define values
  8198. */
  8199. reset(): void;
  8200. /**
  8201. * Converts the material define values to a string
  8202. * @returns - String of material define information
  8203. */
  8204. toString(): string;
  8205. }
  8206. }
  8207. declare module "babylonjs/Materials/colorCurves" {
  8208. import { Effect } from "babylonjs/Materials/effect";
  8209. /**
  8210. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8211. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8212. * 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;
  8213. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8214. */
  8215. export class ColorCurves {
  8216. private _dirty;
  8217. private _tempColor;
  8218. private _globalCurve;
  8219. private _highlightsCurve;
  8220. private _midtonesCurve;
  8221. private _shadowsCurve;
  8222. private _positiveCurve;
  8223. private _negativeCurve;
  8224. private _globalHue;
  8225. private _globalDensity;
  8226. private _globalSaturation;
  8227. private _globalExposure;
  8228. /**
  8229. * Gets the global Hue value.
  8230. * 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).
  8231. */
  8232. get globalHue(): number;
  8233. /**
  8234. * Sets the global Hue value.
  8235. * 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).
  8236. */
  8237. set globalHue(value: number);
  8238. /**
  8239. * Gets the global Density value.
  8240. * 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.
  8241. * Values less than zero provide a filter of opposite hue.
  8242. */
  8243. get globalDensity(): number;
  8244. /**
  8245. * Sets the global Density value.
  8246. * 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.
  8247. * Values less than zero provide a filter of opposite hue.
  8248. */
  8249. set globalDensity(value: number);
  8250. /**
  8251. * Gets the global Saturation value.
  8252. * 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.
  8253. */
  8254. get globalSaturation(): number;
  8255. /**
  8256. * Sets the global Saturation value.
  8257. * 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.
  8258. */
  8259. set globalSaturation(value: number);
  8260. /**
  8261. * Gets the global Exposure value.
  8262. * 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.
  8263. */
  8264. get globalExposure(): number;
  8265. /**
  8266. * Sets the global Exposure value.
  8267. * 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.
  8268. */
  8269. set globalExposure(value: number);
  8270. private _highlightsHue;
  8271. private _highlightsDensity;
  8272. private _highlightsSaturation;
  8273. private _highlightsExposure;
  8274. /**
  8275. * Gets the highlights Hue value.
  8276. * 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).
  8277. */
  8278. get highlightsHue(): number;
  8279. /**
  8280. * Sets the highlights Hue value.
  8281. * 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).
  8282. */
  8283. set highlightsHue(value: number);
  8284. /**
  8285. * Gets the highlights Density value.
  8286. * 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.
  8287. * Values less than zero provide a filter of opposite hue.
  8288. */
  8289. get highlightsDensity(): number;
  8290. /**
  8291. * Sets the highlights Density value.
  8292. * 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.
  8293. * Values less than zero provide a filter of opposite hue.
  8294. */
  8295. set highlightsDensity(value: number);
  8296. /**
  8297. * Gets the highlights Saturation value.
  8298. * 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.
  8299. */
  8300. get highlightsSaturation(): number;
  8301. /**
  8302. * Sets the highlights Saturation value.
  8303. * 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.
  8304. */
  8305. set highlightsSaturation(value: number);
  8306. /**
  8307. * Gets the highlights Exposure value.
  8308. * 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.
  8309. */
  8310. get highlightsExposure(): number;
  8311. /**
  8312. * Sets the highlights Exposure value.
  8313. * 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.
  8314. */
  8315. set highlightsExposure(value: number);
  8316. private _midtonesHue;
  8317. private _midtonesDensity;
  8318. private _midtonesSaturation;
  8319. private _midtonesExposure;
  8320. /**
  8321. * Gets the midtones Hue value.
  8322. * 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).
  8323. */
  8324. get midtonesHue(): number;
  8325. /**
  8326. * Sets the midtones Hue value.
  8327. * 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).
  8328. */
  8329. set midtonesHue(value: number);
  8330. /**
  8331. * Gets the midtones Density value.
  8332. * 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.
  8333. * Values less than zero provide a filter of opposite hue.
  8334. */
  8335. get midtonesDensity(): number;
  8336. /**
  8337. * Sets the midtones Density value.
  8338. * 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.
  8339. * Values less than zero provide a filter of opposite hue.
  8340. */
  8341. set midtonesDensity(value: number);
  8342. /**
  8343. * Gets the midtones Saturation value.
  8344. * 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.
  8345. */
  8346. get midtonesSaturation(): number;
  8347. /**
  8348. * Sets the midtones Saturation value.
  8349. * 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.
  8350. */
  8351. set midtonesSaturation(value: number);
  8352. /**
  8353. * Gets the midtones Exposure value.
  8354. * 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.
  8355. */
  8356. get midtonesExposure(): number;
  8357. /**
  8358. * Sets the midtones Exposure value.
  8359. * 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.
  8360. */
  8361. set midtonesExposure(value: number);
  8362. private _shadowsHue;
  8363. private _shadowsDensity;
  8364. private _shadowsSaturation;
  8365. private _shadowsExposure;
  8366. /**
  8367. * Gets the shadows Hue value.
  8368. * 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).
  8369. */
  8370. get shadowsHue(): number;
  8371. /**
  8372. * Sets the shadows Hue value.
  8373. * 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).
  8374. */
  8375. set shadowsHue(value: number);
  8376. /**
  8377. * Gets the shadows Density value.
  8378. * 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.
  8379. * Values less than zero provide a filter of opposite hue.
  8380. */
  8381. get shadowsDensity(): number;
  8382. /**
  8383. * Sets the shadows Density value.
  8384. * 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.
  8385. * Values less than zero provide a filter of opposite hue.
  8386. */
  8387. set shadowsDensity(value: number);
  8388. /**
  8389. * Gets the shadows Saturation value.
  8390. * 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.
  8391. */
  8392. get shadowsSaturation(): number;
  8393. /**
  8394. * Sets the shadows Saturation value.
  8395. * 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.
  8396. */
  8397. set shadowsSaturation(value: number);
  8398. /**
  8399. * Gets the shadows Exposure value.
  8400. * 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.
  8401. */
  8402. get shadowsExposure(): number;
  8403. /**
  8404. * Sets the shadows Exposure value.
  8405. * 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.
  8406. */
  8407. set shadowsExposure(value: number);
  8408. /**
  8409. * Returns the class name
  8410. * @returns The class name
  8411. */
  8412. getClassName(): string;
  8413. /**
  8414. * Binds the color curves to the shader.
  8415. * @param colorCurves The color curve to bind
  8416. * @param effect The effect to bind to
  8417. * @param positiveUniform The positive uniform shader parameter
  8418. * @param neutralUniform The neutral uniform shader parameter
  8419. * @param negativeUniform The negative uniform shader parameter
  8420. */
  8421. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8422. /**
  8423. * Prepare the list of uniforms associated with the ColorCurves effects.
  8424. * @param uniformsList The list of uniforms used in the effect
  8425. */
  8426. static PrepareUniforms(uniformsList: string[]): void;
  8427. /**
  8428. * Returns color grading data based on a hue, density, saturation and exposure value.
  8429. * @param filterHue The hue of the color filter.
  8430. * @param filterDensity The density of the color filter.
  8431. * @param saturation The saturation.
  8432. * @param exposure The exposure.
  8433. * @param result The result data container.
  8434. */
  8435. private getColorGradingDataToRef;
  8436. /**
  8437. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8438. * @param value The input slider value in range [-100,100].
  8439. * @returns Adjusted value.
  8440. */
  8441. private static applyColorGradingSliderNonlinear;
  8442. /**
  8443. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8444. * @param hue The hue (H) input.
  8445. * @param saturation The saturation (S) input.
  8446. * @param brightness The brightness (B) input.
  8447. * @result An RGBA color represented as Vector4.
  8448. */
  8449. private static fromHSBToRef;
  8450. /**
  8451. * Returns a value clamped between min and max
  8452. * @param value The value to clamp
  8453. * @param min The minimum of value
  8454. * @param max The maximum of value
  8455. * @returns The clamped value.
  8456. */
  8457. private static clamp;
  8458. /**
  8459. * Clones the current color curve instance.
  8460. * @return The cloned curves
  8461. */
  8462. clone(): ColorCurves;
  8463. /**
  8464. * Serializes the current color curve instance to a json representation.
  8465. * @return a JSON representation
  8466. */
  8467. serialize(): any;
  8468. /**
  8469. * Parses the color curve from a json representation.
  8470. * @param source the JSON source to parse
  8471. * @return The parsed curves
  8472. */
  8473. static Parse(source: any): ColorCurves;
  8474. }
  8475. }
  8476. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8477. import { Observable } from "babylonjs/Misc/observable";
  8478. import { Nullable } from "babylonjs/types";
  8479. import { Color4 } from "babylonjs/Maths/math.color";
  8480. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8481. import { Effect } from "babylonjs/Materials/effect";
  8482. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8483. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8484. /**
  8485. * Interface to follow in your material defines to integrate easily the
  8486. * Image proccessing functions.
  8487. * @hidden
  8488. */
  8489. export interface IImageProcessingConfigurationDefines {
  8490. IMAGEPROCESSING: boolean;
  8491. VIGNETTE: boolean;
  8492. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8493. VIGNETTEBLENDMODEOPAQUE: boolean;
  8494. TONEMAPPING: boolean;
  8495. TONEMAPPING_ACES: boolean;
  8496. CONTRAST: boolean;
  8497. EXPOSURE: boolean;
  8498. COLORCURVES: boolean;
  8499. COLORGRADING: boolean;
  8500. COLORGRADING3D: boolean;
  8501. SAMPLER3DGREENDEPTH: boolean;
  8502. SAMPLER3DBGRMAP: boolean;
  8503. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8504. }
  8505. /**
  8506. * @hidden
  8507. */
  8508. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8509. IMAGEPROCESSING: boolean;
  8510. VIGNETTE: boolean;
  8511. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8512. VIGNETTEBLENDMODEOPAQUE: boolean;
  8513. TONEMAPPING: boolean;
  8514. TONEMAPPING_ACES: boolean;
  8515. CONTRAST: boolean;
  8516. COLORCURVES: boolean;
  8517. COLORGRADING: boolean;
  8518. COLORGRADING3D: boolean;
  8519. SAMPLER3DGREENDEPTH: boolean;
  8520. SAMPLER3DBGRMAP: boolean;
  8521. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8522. EXPOSURE: boolean;
  8523. constructor();
  8524. }
  8525. /**
  8526. * This groups together the common properties used for image processing either in direct forward pass
  8527. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8528. * or not.
  8529. */
  8530. export class ImageProcessingConfiguration {
  8531. /**
  8532. * Default tone mapping applied in BabylonJS.
  8533. */
  8534. static readonly TONEMAPPING_STANDARD: number;
  8535. /**
  8536. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8537. * to other engines rendering to increase portability.
  8538. */
  8539. static readonly TONEMAPPING_ACES: number;
  8540. /**
  8541. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8542. */
  8543. colorCurves: Nullable<ColorCurves>;
  8544. private _colorCurvesEnabled;
  8545. /**
  8546. * Gets wether the color curves effect is enabled.
  8547. */
  8548. get colorCurvesEnabled(): boolean;
  8549. /**
  8550. * Sets wether the color curves effect is enabled.
  8551. */
  8552. set colorCurvesEnabled(value: boolean);
  8553. private _colorGradingTexture;
  8554. /**
  8555. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8556. */
  8557. get colorGradingTexture(): Nullable<BaseTexture>;
  8558. /**
  8559. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8560. */
  8561. set colorGradingTexture(value: Nullable<BaseTexture>);
  8562. private _colorGradingEnabled;
  8563. /**
  8564. * Gets wether the color grading effect is enabled.
  8565. */
  8566. get colorGradingEnabled(): boolean;
  8567. /**
  8568. * Sets wether the color grading effect is enabled.
  8569. */
  8570. set colorGradingEnabled(value: boolean);
  8571. private _colorGradingWithGreenDepth;
  8572. /**
  8573. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8574. */
  8575. get colorGradingWithGreenDepth(): boolean;
  8576. /**
  8577. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8578. */
  8579. set colorGradingWithGreenDepth(value: boolean);
  8580. private _colorGradingBGR;
  8581. /**
  8582. * Gets wether the color grading texture contains BGR values.
  8583. */
  8584. get colorGradingBGR(): boolean;
  8585. /**
  8586. * Sets wether the color grading texture contains BGR values.
  8587. */
  8588. set colorGradingBGR(value: boolean);
  8589. /** @hidden */
  8590. _exposure: number;
  8591. /**
  8592. * Gets the Exposure used in the effect.
  8593. */
  8594. get exposure(): number;
  8595. /**
  8596. * Sets the Exposure used in the effect.
  8597. */
  8598. set exposure(value: number);
  8599. private _toneMappingEnabled;
  8600. /**
  8601. * Gets wether the tone mapping effect is enabled.
  8602. */
  8603. get toneMappingEnabled(): boolean;
  8604. /**
  8605. * Sets wether the tone mapping effect is enabled.
  8606. */
  8607. set toneMappingEnabled(value: boolean);
  8608. private _toneMappingType;
  8609. /**
  8610. * Gets the type of tone mapping effect.
  8611. */
  8612. get toneMappingType(): number;
  8613. /**
  8614. * Sets the type of tone mapping effect used in BabylonJS.
  8615. */
  8616. set toneMappingType(value: number);
  8617. protected _contrast: number;
  8618. /**
  8619. * Gets the contrast used in the effect.
  8620. */
  8621. get contrast(): number;
  8622. /**
  8623. * Sets the contrast used in the effect.
  8624. */
  8625. set contrast(value: number);
  8626. /**
  8627. * Vignette stretch size.
  8628. */
  8629. vignetteStretch: number;
  8630. /**
  8631. * Vignette centre X Offset.
  8632. */
  8633. vignetteCentreX: number;
  8634. /**
  8635. * Vignette centre Y Offset.
  8636. */
  8637. vignetteCentreY: number;
  8638. /**
  8639. * Vignette weight or intensity of the vignette effect.
  8640. */
  8641. vignetteWeight: number;
  8642. /**
  8643. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8644. * if vignetteEnabled is set to true.
  8645. */
  8646. vignetteColor: Color4;
  8647. /**
  8648. * Camera field of view used by the Vignette effect.
  8649. */
  8650. vignetteCameraFov: number;
  8651. private _vignetteBlendMode;
  8652. /**
  8653. * Gets the vignette blend mode allowing different kind of effect.
  8654. */
  8655. get vignetteBlendMode(): number;
  8656. /**
  8657. * Sets the vignette blend mode allowing different kind of effect.
  8658. */
  8659. set vignetteBlendMode(value: number);
  8660. private _vignetteEnabled;
  8661. /**
  8662. * Gets wether the vignette effect is enabled.
  8663. */
  8664. get vignetteEnabled(): boolean;
  8665. /**
  8666. * Sets wether the vignette effect is enabled.
  8667. */
  8668. set vignetteEnabled(value: boolean);
  8669. private _applyByPostProcess;
  8670. /**
  8671. * Gets wether the image processing is applied through a post process or not.
  8672. */
  8673. get applyByPostProcess(): boolean;
  8674. /**
  8675. * Sets wether the image processing is applied through a post process or not.
  8676. */
  8677. set applyByPostProcess(value: boolean);
  8678. private _isEnabled;
  8679. /**
  8680. * Gets wether the image processing is enabled or not.
  8681. */
  8682. get isEnabled(): boolean;
  8683. /**
  8684. * Sets wether the image processing is enabled or not.
  8685. */
  8686. set isEnabled(value: boolean);
  8687. /**
  8688. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8689. */
  8690. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8691. /**
  8692. * Method called each time the image processing information changes requires to recompile the effect.
  8693. */
  8694. protected _updateParameters(): void;
  8695. /**
  8696. * Gets the current class name.
  8697. * @return "ImageProcessingConfiguration"
  8698. */
  8699. getClassName(): string;
  8700. /**
  8701. * Prepare the list of uniforms associated with the Image Processing effects.
  8702. * @param uniforms The list of uniforms used in the effect
  8703. * @param defines the list of defines currently in use
  8704. */
  8705. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8706. /**
  8707. * Prepare the list of samplers associated with the Image Processing effects.
  8708. * @param samplersList The list of uniforms used in the effect
  8709. * @param defines the list of defines currently in use
  8710. */
  8711. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8712. /**
  8713. * Prepare the list of defines associated to the shader.
  8714. * @param defines the list of defines to complete
  8715. * @param forPostProcess Define if we are currently in post process mode or not
  8716. */
  8717. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8718. /**
  8719. * Returns true if all the image processing information are ready.
  8720. * @returns True if ready, otherwise, false
  8721. */
  8722. isReady(): boolean;
  8723. /**
  8724. * Binds the image processing to the shader.
  8725. * @param effect The effect to bind to
  8726. * @param overrideAspectRatio Override the aspect ratio of the effect
  8727. */
  8728. bind(effect: Effect, overrideAspectRatio?: number): void;
  8729. /**
  8730. * Clones the current image processing instance.
  8731. * @return The cloned image processing
  8732. */
  8733. clone(): ImageProcessingConfiguration;
  8734. /**
  8735. * Serializes the current image processing instance to a json representation.
  8736. * @return a JSON representation
  8737. */
  8738. serialize(): any;
  8739. /**
  8740. * Parses the image processing from a json representation.
  8741. * @param source the JSON source to parse
  8742. * @return The parsed image processing
  8743. */
  8744. static Parse(source: any): ImageProcessingConfiguration;
  8745. private static _VIGNETTEMODE_MULTIPLY;
  8746. private static _VIGNETTEMODE_OPAQUE;
  8747. /**
  8748. * Used to apply the vignette as a mix with the pixel color.
  8749. */
  8750. static get VIGNETTEMODE_MULTIPLY(): number;
  8751. /**
  8752. * Used to apply the vignette as a replacement of the pixel color.
  8753. */
  8754. static get VIGNETTEMODE_OPAQUE(): number;
  8755. }
  8756. }
  8757. declare module "babylonjs/Shaders/postprocess.vertex" {
  8758. /** @hidden */
  8759. export var postprocessVertexShader: {
  8760. name: string;
  8761. shader: string;
  8762. };
  8763. }
  8764. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8765. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8766. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8767. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8768. /**
  8769. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8770. */
  8771. export type RenderTargetTextureSize = number | {
  8772. width: number;
  8773. height: number;
  8774. layers?: number;
  8775. };
  8776. module "babylonjs/Engines/thinEngine" {
  8777. interface ThinEngine {
  8778. /**
  8779. * Creates a new render target texture
  8780. * @param size defines the size of the texture
  8781. * @param options defines the options used to create the texture
  8782. * @returns a new render target texture stored in an InternalTexture
  8783. */
  8784. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8785. /**
  8786. * Creates a depth stencil texture.
  8787. * This is only available in WebGL 2 or with the depth texture extension available.
  8788. * @param size The size of face edge in the texture.
  8789. * @param options The options defining the texture.
  8790. * @returns The texture
  8791. */
  8792. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8793. /** @hidden */
  8794. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8795. }
  8796. }
  8797. }
  8798. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8799. /**
  8800. * Defines the kind of connection point for node based material
  8801. */
  8802. export enum NodeMaterialBlockConnectionPointTypes {
  8803. /** Float */
  8804. Float = 1,
  8805. /** Int */
  8806. Int = 2,
  8807. /** Vector2 */
  8808. Vector2 = 4,
  8809. /** Vector3 */
  8810. Vector3 = 8,
  8811. /** Vector4 */
  8812. Vector4 = 16,
  8813. /** Color3 */
  8814. Color3 = 32,
  8815. /** Color4 */
  8816. Color4 = 64,
  8817. /** Matrix */
  8818. Matrix = 128,
  8819. /** Custom object */
  8820. Object = 256,
  8821. /** Detect type based on connection */
  8822. AutoDetect = 1024,
  8823. /** Output type that will be defined by input type */
  8824. BasedOnInput = 2048
  8825. }
  8826. }
  8827. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8828. /**
  8829. * Enum used to define the target of a block
  8830. */
  8831. export enum NodeMaterialBlockTargets {
  8832. /** Vertex shader */
  8833. Vertex = 1,
  8834. /** Fragment shader */
  8835. Fragment = 2,
  8836. /** Neutral */
  8837. Neutral = 4,
  8838. /** Vertex and Fragment */
  8839. VertexAndFragment = 3
  8840. }
  8841. }
  8842. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8843. /**
  8844. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8845. */
  8846. export enum NodeMaterialBlockConnectionPointMode {
  8847. /** Value is an uniform */
  8848. Uniform = 0,
  8849. /** Value is a mesh attribute */
  8850. Attribute = 1,
  8851. /** Value is a varying between vertex and fragment shaders */
  8852. Varying = 2,
  8853. /** Mode is undefined */
  8854. Undefined = 3
  8855. }
  8856. }
  8857. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8858. /**
  8859. * Enum used to define system values e.g. values automatically provided by the system
  8860. */
  8861. export enum NodeMaterialSystemValues {
  8862. /** World */
  8863. World = 1,
  8864. /** View */
  8865. View = 2,
  8866. /** Projection */
  8867. Projection = 3,
  8868. /** ViewProjection */
  8869. ViewProjection = 4,
  8870. /** WorldView */
  8871. WorldView = 5,
  8872. /** WorldViewProjection */
  8873. WorldViewProjection = 6,
  8874. /** CameraPosition */
  8875. CameraPosition = 7,
  8876. /** Fog Color */
  8877. FogColor = 8,
  8878. /** Delta time */
  8879. DeltaTime = 9
  8880. }
  8881. }
  8882. declare module "babylonjs/Maths/math.axis" {
  8883. import { Vector3 } from "babylonjs/Maths/math.vector";
  8884. /** Defines supported spaces */
  8885. export enum Space {
  8886. /** Local (object) space */
  8887. LOCAL = 0,
  8888. /** World space */
  8889. WORLD = 1,
  8890. /** Bone space */
  8891. BONE = 2
  8892. }
  8893. /** Defines the 3 main axes */
  8894. export class Axis {
  8895. /** X axis */
  8896. static X: Vector3;
  8897. /** Y axis */
  8898. static Y: Vector3;
  8899. /** Z axis */
  8900. static Z: Vector3;
  8901. }
  8902. }
  8903. declare module "babylonjs/Maths/math.frustum" {
  8904. import { Matrix } from "babylonjs/Maths/math.vector";
  8905. import { DeepImmutable } from "babylonjs/types";
  8906. import { Plane } from "babylonjs/Maths/math.plane";
  8907. /**
  8908. * Represents a camera frustum
  8909. */
  8910. export class Frustum {
  8911. /**
  8912. * Gets the planes representing the frustum
  8913. * @param transform matrix to be applied to the returned planes
  8914. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8915. */
  8916. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8917. /**
  8918. * Gets the near frustum plane transformed by the transform matrix
  8919. * @param transform transformation matrix to be applied to the resulting frustum plane
  8920. * @param frustumPlane the resuling frustum plane
  8921. */
  8922. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8923. /**
  8924. * Gets the far frustum plane transformed by the transform matrix
  8925. * @param transform transformation matrix to be applied to the resulting frustum plane
  8926. * @param frustumPlane the resuling frustum plane
  8927. */
  8928. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8929. /**
  8930. * Gets the left frustum plane transformed by the transform matrix
  8931. * @param transform transformation matrix to be applied to the resulting frustum plane
  8932. * @param frustumPlane the resuling frustum plane
  8933. */
  8934. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8935. /**
  8936. * Gets the right frustum plane transformed by the transform matrix
  8937. * @param transform transformation matrix to be applied to the resulting frustum plane
  8938. * @param frustumPlane the resuling frustum plane
  8939. */
  8940. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8941. /**
  8942. * Gets the top frustum plane transformed by the transform matrix
  8943. * @param transform transformation matrix to be applied to the resulting frustum plane
  8944. * @param frustumPlane the resuling frustum plane
  8945. */
  8946. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8947. /**
  8948. * Gets the bottom frustum plane transformed by the transform matrix
  8949. * @param transform transformation matrix to be applied to the resulting frustum plane
  8950. * @param frustumPlane the resuling frustum plane
  8951. */
  8952. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8953. /**
  8954. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8955. * @param transform transformation matrix to be applied to the resulting frustum planes
  8956. * @param frustumPlanes the resuling frustum planes
  8957. */
  8958. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8959. }
  8960. }
  8961. declare module "babylonjs/Maths/math.size" {
  8962. /**
  8963. * Interface for the size containing width and height
  8964. */
  8965. export interface ISize {
  8966. /**
  8967. * Width
  8968. */
  8969. width: number;
  8970. /**
  8971. * Heighht
  8972. */
  8973. height: number;
  8974. }
  8975. /**
  8976. * Size containing widht and height
  8977. */
  8978. export class Size implements ISize {
  8979. /**
  8980. * Width
  8981. */
  8982. width: number;
  8983. /**
  8984. * Height
  8985. */
  8986. height: number;
  8987. /**
  8988. * Creates a Size object from the given width and height (floats).
  8989. * @param width width of the new size
  8990. * @param height height of the new size
  8991. */
  8992. constructor(width: number, height: number);
  8993. /**
  8994. * Returns a string with the Size width and height
  8995. * @returns a string with the Size width and height
  8996. */
  8997. toString(): string;
  8998. /**
  8999. * "Size"
  9000. * @returns the string "Size"
  9001. */
  9002. getClassName(): string;
  9003. /**
  9004. * Returns the Size hash code.
  9005. * @returns a hash code for a unique width and height
  9006. */
  9007. getHashCode(): number;
  9008. /**
  9009. * Updates the current size from the given one.
  9010. * @param src the given size
  9011. */
  9012. copyFrom(src: Size): void;
  9013. /**
  9014. * Updates in place the current Size from the given floats.
  9015. * @param width width of the new size
  9016. * @param height height of the new size
  9017. * @returns the updated Size.
  9018. */
  9019. copyFromFloats(width: number, height: number): Size;
  9020. /**
  9021. * Updates in place the current Size from the given floats.
  9022. * @param width width to set
  9023. * @param height height to set
  9024. * @returns the updated Size.
  9025. */
  9026. set(width: number, height: number): Size;
  9027. /**
  9028. * Multiplies the width and height by numbers
  9029. * @param w factor to multiple the width by
  9030. * @param h factor to multiple the height by
  9031. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  9032. */
  9033. multiplyByFloats(w: number, h: number): Size;
  9034. /**
  9035. * Clones the size
  9036. * @returns a new Size copied from the given one.
  9037. */
  9038. clone(): Size;
  9039. /**
  9040. * True if the current Size and the given one width and height are strictly equal.
  9041. * @param other the other size to compare against
  9042. * @returns True if the current Size and the given one width and height are strictly equal.
  9043. */
  9044. equals(other: Size): boolean;
  9045. /**
  9046. * The surface of the Size : width * height (float).
  9047. */
  9048. get surface(): number;
  9049. /**
  9050. * Create a new size of zero
  9051. * @returns a new Size set to (0.0, 0.0)
  9052. */
  9053. static Zero(): Size;
  9054. /**
  9055. * Sums the width and height of two sizes
  9056. * @param otherSize size to add to this size
  9057. * @returns a new Size set as the addition result of the current Size and the given one.
  9058. */
  9059. add(otherSize: Size): Size;
  9060. /**
  9061. * Subtracts the width and height of two
  9062. * @param otherSize size to subtract to this size
  9063. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9064. */
  9065. subtract(otherSize: Size): Size;
  9066. /**
  9067. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9068. * @param start starting size to lerp between
  9069. * @param end end size to lerp between
  9070. * @param amount amount to lerp between the start and end values
  9071. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9072. */
  9073. static Lerp(start: Size, end: Size, amount: number): Size;
  9074. }
  9075. }
  9076. declare module "babylonjs/Maths/math.vertexFormat" {
  9077. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9078. /**
  9079. * Contains position and normal vectors for a vertex
  9080. */
  9081. export class PositionNormalVertex {
  9082. /** the position of the vertex (defaut: 0,0,0) */
  9083. position: Vector3;
  9084. /** the normal of the vertex (defaut: 0,1,0) */
  9085. normal: Vector3;
  9086. /**
  9087. * Creates a PositionNormalVertex
  9088. * @param position the position of the vertex (defaut: 0,0,0)
  9089. * @param normal the normal of the vertex (defaut: 0,1,0)
  9090. */
  9091. constructor(
  9092. /** the position of the vertex (defaut: 0,0,0) */
  9093. position?: Vector3,
  9094. /** the normal of the vertex (defaut: 0,1,0) */
  9095. normal?: Vector3);
  9096. /**
  9097. * Clones the PositionNormalVertex
  9098. * @returns the cloned PositionNormalVertex
  9099. */
  9100. clone(): PositionNormalVertex;
  9101. }
  9102. /**
  9103. * Contains position, normal and uv vectors for a vertex
  9104. */
  9105. export class PositionNormalTextureVertex {
  9106. /** the position of the vertex (defaut: 0,0,0) */
  9107. position: Vector3;
  9108. /** the normal of the vertex (defaut: 0,1,0) */
  9109. normal: Vector3;
  9110. /** the uv of the vertex (default: 0,0) */
  9111. uv: Vector2;
  9112. /**
  9113. * Creates a PositionNormalTextureVertex
  9114. * @param position the position of the vertex (defaut: 0,0,0)
  9115. * @param normal the normal of the vertex (defaut: 0,1,0)
  9116. * @param uv the uv of the vertex (default: 0,0)
  9117. */
  9118. constructor(
  9119. /** the position of the vertex (defaut: 0,0,0) */
  9120. position?: Vector3,
  9121. /** the normal of the vertex (defaut: 0,1,0) */
  9122. normal?: Vector3,
  9123. /** the uv of the vertex (default: 0,0) */
  9124. uv?: Vector2);
  9125. /**
  9126. * Clones the PositionNormalTextureVertex
  9127. * @returns the cloned PositionNormalTextureVertex
  9128. */
  9129. clone(): PositionNormalTextureVertex;
  9130. }
  9131. }
  9132. declare module "babylonjs/Maths/math" {
  9133. export * from "babylonjs/Maths/math.axis";
  9134. export * from "babylonjs/Maths/math.color";
  9135. export * from "babylonjs/Maths/math.constants";
  9136. export * from "babylonjs/Maths/math.frustum";
  9137. export * from "babylonjs/Maths/math.path";
  9138. export * from "babylonjs/Maths/math.plane";
  9139. export * from "babylonjs/Maths/math.size";
  9140. export * from "babylonjs/Maths/math.vector";
  9141. export * from "babylonjs/Maths/math.vertexFormat";
  9142. export * from "babylonjs/Maths/math.viewport";
  9143. }
  9144. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9145. /**
  9146. * Enum defining the type of animations supported by InputBlock
  9147. */
  9148. export enum AnimatedInputBlockTypes {
  9149. /** No animation */
  9150. None = 0,
  9151. /** Time based animation. Will only work for floats */
  9152. Time = 1
  9153. }
  9154. }
  9155. declare module "babylonjs/Lights/shadowLight" {
  9156. import { Camera } from "babylonjs/Cameras/camera";
  9157. import { Scene } from "babylonjs/scene";
  9158. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9160. import { Light } from "babylonjs/Lights/light";
  9161. /**
  9162. * Interface describing all the common properties and methods a shadow light needs to implement.
  9163. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9164. * as well as binding the different shadow properties to the effects.
  9165. */
  9166. export interface IShadowLight extends Light {
  9167. /**
  9168. * The light id in the scene (used in scene.findLighById for instance)
  9169. */
  9170. id: string;
  9171. /**
  9172. * The position the shdow will be casted from.
  9173. */
  9174. position: Vector3;
  9175. /**
  9176. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9177. */
  9178. direction: Vector3;
  9179. /**
  9180. * The transformed position. Position of the light in world space taking parenting in account.
  9181. */
  9182. transformedPosition: Vector3;
  9183. /**
  9184. * The transformed direction. Direction of the light in world space taking parenting in account.
  9185. */
  9186. transformedDirection: Vector3;
  9187. /**
  9188. * The friendly name of the light in the scene.
  9189. */
  9190. name: string;
  9191. /**
  9192. * Defines the shadow projection clipping minimum z value.
  9193. */
  9194. shadowMinZ: number;
  9195. /**
  9196. * Defines the shadow projection clipping maximum z value.
  9197. */
  9198. shadowMaxZ: number;
  9199. /**
  9200. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9201. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9202. */
  9203. computeTransformedInformation(): boolean;
  9204. /**
  9205. * Gets the scene the light belongs to.
  9206. * @returns The scene
  9207. */
  9208. getScene(): Scene;
  9209. /**
  9210. * Callback defining a custom Projection Matrix Builder.
  9211. * This can be used to override the default projection matrix computation.
  9212. */
  9213. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9214. /**
  9215. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9216. * @param matrix The materix to updated with the projection information
  9217. * @param viewMatrix The transform matrix of the light
  9218. * @param renderList The list of mesh to render in the map
  9219. * @returns The current light
  9220. */
  9221. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9222. /**
  9223. * Gets the current depth scale used in ESM.
  9224. * @returns The scale
  9225. */
  9226. getDepthScale(): number;
  9227. /**
  9228. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9229. * @returns true if a cube texture needs to be use
  9230. */
  9231. needCube(): boolean;
  9232. /**
  9233. * Detects if the projection matrix requires to be recomputed this frame.
  9234. * @returns true if it requires to be recomputed otherwise, false.
  9235. */
  9236. needProjectionMatrixCompute(): boolean;
  9237. /**
  9238. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9239. */
  9240. forceProjectionMatrixCompute(): void;
  9241. /**
  9242. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9243. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9244. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9245. */
  9246. getShadowDirection(faceIndex?: number): Vector3;
  9247. /**
  9248. * Gets the minZ used for shadow according to both the scene and the light.
  9249. * @param activeCamera The camera we are returning the min for
  9250. * @returns the depth min z
  9251. */
  9252. getDepthMinZ(activeCamera: Camera): number;
  9253. /**
  9254. * Gets the maxZ used for shadow according to both the scene and the light.
  9255. * @param activeCamera The camera we are returning the max for
  9256. * @returns the depth max z
  9257. */
  9258. getDepthMaxZ(activeCamera: Camera): number;
  9259. }
  9260. /**
  9261. * Base implementation IShadowLight
  9262. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9263. */
  9264. export abstract class ShadowLight extends Light implements IShadowLight {
  9265. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9266. protected _position: Vector3;
  9267. protected _setPosition(value: Vector3): void;
  9268. /**
  9269. * Sets the position the shadow will be casted from. Also use as the light position for both
  9270. * point and spot lights.
  9271. */
  9272. get position(): Vector3;
  9273. /**
  9274. * Sets the position the shadow will be casted from. Also use as the light position for both
  9275. * point and spot lights.
  9276. */
  9277. set position(value: Vector3);
  9278. protected _direction: Vector3;
  9279. protected _setDirection(value: Vector3): void;
  9280. /**
  9281. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9282. * Also use as the light direction on spot and directional lights.
  9283. */
  9284. get direction(): Vector3;
  9285. /**
  9286. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9287. * Also use as the light direction on spot and directional lights.
  9288. */
  9289. set direction(value: Vector3);
  9290. protected _shadowMinZ: number;
  9291. /**
  9292. * Gets the shadow projection clipping minimum z value.
  9293. */
  9294. get shadowMinZ(): number;
  9295. /**
  9296. * Sets the shadow projection clipping minimum z value.
  9297. */
  9298. set shadowMinZ(value: number);
  9299. protected _shadowMaxZ: number;
  9300. /**
  9301. * Sets the shadow projection clipping maximum z value.
  9302. */
  9303. get shadowMaxZ(): number;
  9304. /**
  9305. * Gets the shadow projection clipping maximum z value.
  9306. */
  9307. set shadowMaxZ(value: number);
  9308. /**
  9309. * Callback defining a custom Projection Matrix Builder.
  9310. * This can be used to override the default projection matrix computation.
  9311. */
  9312. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9313. /**
  9314. * The transformed position. Position of the light in world space taking parenting in account.
  9315. */
  9316. transformedPosition: Vector3;
  9317. /**
  9318. * The transformed direction. Direction of the light in world space taking parenting in account.
  9319. */
  9320. transformedDirection: Vector3;
  9321. private _needProjectionMatrixCompute;
  9322. /**
  9323. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9324. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9325. */
  9326. computeTransformedInformation(): boolean;
  9327. /**
  9328. * Return the depth scale used for the shadow map.
  9329. * @returns the depth scale.
  9330. */
  9331. getDepthScale(): number;
  9332. /**
  9333. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9334. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9335. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9336. */
  9337. getShadowDirection(faceIndex?: number): Vector3;
  9338. /**
  9339. * Returns the ShadowLight absolute position in the World.
  9340. * @returns the position vector in world space
  9341. */
  9342. getAbsolutePosition(): Vector3;
  9343. /**
  9344. * Sets the ShadowLight direction toward the passed target.
  9345. * @param target The point to target in local space
  9346. * @returns the updated ShadowLight direction
  9347. */
  9348. setDirectionToTarget(target: Vector3): Vector3;
  9349. /**
  9350. * Returns the light rotation in euler definition.
  9351. * @returns the x y z rotation in local space.
  9352. */
  9353. getRotation(): Vector3;
  9354. /**
  9355. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9356. * @returns true if a cube texture needs to be use
  9357. */
  9358. needCube(): boolean;
  9359. /**
  9360. * Detects if the projection matrix requires to be recomputed this frame.
  9361. * @returns true if it requires to be recomputed otherwise, false.
  9362. */
  9363. needProjectionMatrixCompute(): boolean;
  9364. /**
  9365. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9366. */
  9367. forceProjectionMatrixCompute(): void;
  9368. /** @hidden */
  9369. _initCache(): void;
  9370. /** @hidden */
  9371. _isSynchronized(): boolean;
  9372. /**
  9373. * Computes the world matrix of the node
  9374. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9375. * @returns the world matrix
  9376. */
  9377. computeWorldMatrix(force?: boolean): Matrix;
  9378. /**
  9379. * Gets the minZ used for shadow according to both the scene and the light.
  9380. * @param activeCamera The camera we are returning the min for
  9381. * @returns the depth min z
  9382. */
  9383. getDepthMinZ(activeCamera: Camera): number;
  9384. /**
  9385. * Gets the maxZ used for shadow according to both the scene and the light.
  9386. * @param activeCamera The camera we are returning the max for
  9387. * @returns the depth max z
  9388. */
  9389. getDepthMaxZ(activeCamera: Camera): number;
  9390. /**
  9391. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9392. * @param matrix The materix to updated with the projection information
  9393. * @param viewMatrix The transform matrix of the light
  9394. * @param renderList The list of mesh to render in the map
  9395. * @returns The current light
  9396. */
  9397. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9398. }
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9401. /** @hidden */
  9402. export var packingFunctions: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9408. /** @hidden */
  9409. export var bayerDitherFunctions: {
  9410. name: string;
  9411. shader: string;
  9412. };
  9413. }
  9414. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9415. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9416. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9417. /** @hidden */
  9418. export var shadowMapFragmentDeclaration: {
  9419. name: string;
  9420. shader: string;
  9421. };
  9422. }
  9423. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9424. /** @hidden */
  9425. export var clipPlaneFragmentDeclaration: {
  9426. name: string;
  9427. shader: string;
  9428. };
  9429. }
  9430. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9431. /** @hidden */
  9432. export var clipPlaneFragment: {
  9433. name: string;
  9434. shader: string;
  9435. };
  9436. }
  9437. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9438. /** @hidden */
  9439. export var shadowMapFragment: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9445. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9446. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9447. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9448. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9449. /** @hidden */
  9450. export var shadowMapPixelShader: {
  9451. name: string;
  9452. shader: string;
  9453. };
  9454. }
  9455. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9456. /** @hidden */
  9457. export var bonesDeclaration: {
  9458. name: string;
  9459. shader: string;
  9460. };
  9461. }
  9462. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9463. /** @hidden */
  9464. export var morphTargetsVertexGlobalDeclaration: {
  9465. name: string;
  9466. shader: string;
  9467. };
  9468. }
  9469. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9470. /** @hidden */
  9471. export var morphTargetsVertexDeclaration: {
  9472. name: string;
  9473. shader: string;
  9474. };
  9475. }
  9476. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9477. /** @hidden */
  9478. export var instancesDeclaration: {
  9479. name: string;
  9480. shader: string;
  9481. };
  9482. }
  9483. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9484. /** @hidden */
  9485. export var helperFunctions: {
  9486. name: string;
  9487. shader: string;
  9488. };
  9489. }
  9490. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9491. /** @hidden */
  9492. export var shadowMapVertexDeclaration: {
  9493. name: string;
  9494. shader: string;
  9495. };
  9496. }
  9497. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9498. /** @hidden */
  9499. export var clipPlaneVertexDeclaration: {
  9500. name: string;
  9501. shader: string;
  9502. };
  9503. }
  9504. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9505. /** @hidden */
  9506. export var morphTargetsVertex: {
  9507. name: string;
  9508. shader: string;
  9509. };
  9510. }
  9511. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9512. /** @hidden */
  9513. export var instancesVertex: {
  9514. name: string;
  9515. shader: string;
  9516. };
  9517. }
  9518. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9519. /** @hidden */
  9520. export var bonesVertex: {
  9521. name: string;
  9522. shader: string;
  9523. };
  9524. }
  9525. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9526. /** @hidden */
  9527. export var shadowMapVertexNormalBias: {
  9528. name: string;
  9529. shader: string;
  9530. };
  9531. }
  9532. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9533. /** @hidden */
  9534. export var shadowMapVertexMetric: {
  9535. name: string;
  9536. shader: string;
  9537. };
  9538. }
  9539. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9540. /** @hidden */
  9541. export var clipPlaneVertex: {
  9542. name: string;
  9543. shader: string;
  9544. };
  9545. }
  9546. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9547. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9548. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9549. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9550. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9551. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9552. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9553. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9554. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9555. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9556. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9557. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9558. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9559. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9560. /** @hidden */
  9561. export var shadowMapVertexShader: {
  9562. name: string;
  9563. shader: string;
  9564. };
  9565. }
  9566. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9567. /** @hidden */
  9568. export var depthBoxBlurPixelShader: {
  9569. name: string;
  9570. shader: string;
  9571. };
  9572. }
  9573. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9574. /** @hidden */
  9575. export var shadowMapFragmentSoftTransparentShadow: {
  9576. name: string;
  9577. shader: string;
  9578. };
  9579. }
  9580. declare module "babylonjs/Materials/effectFallbacks" {
  9581. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9582. import { Effect } from "babylonjs/Materials/effect";
  9583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9584. /**
  9585. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9586. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9587. */
  9588. export class EffectFallbacks implements IEffectFallbacks {
  9589. private _defines;
  9590. private _currentRank;
  9591. private _maxRank;
  9592. private _mesh;
  9593. /**
  9594. * Removes the fallback from the bound mesh.
  9595. */
  9596. unBindMesh(): void;
  9597. /**
  9598. * Adds a fallback on the specified property.
  9599. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9600. * @param define The name of the define in the shader
  9601. */
  9602. addFallback(rank: number, define: string): void;
  9603. /**
  9604. * Sets the mesh to use CPU skinning when needing to fallback.
  9605. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9606. * @param mesh The mesh to use the fallbacks.
  9607. */
  9608. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9609. /**
  9610. * Checks to see if more fallbacks are still availible.
  9611. */
  9612. get hasMoreFallbacks(): boolean;
  9613. /**
  9614. * Removes the defines that should be removed when falling back.
  9615. * @param currentDefines defines the current define statements for the shader.
  9616. * @param effect defines the current effect we try to compile
  9617. * @returns The resulting defines with defines of the current rank removed.
  9618. */
  9619. reduce(currentDefines: string, effect: Effect): string;
  9620. }
  9621. }
  9622. declare module "babylonjs/Actions/action" {
  9623. import { Observable } from "babylonjs/Misc/observable";
  9624. import { Condition } from "babylonjs/Actions/condition";
  9625. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9626. import { Nullable } from "babylonjs/types";
  9627. import { Scene } from "babylonjs/scene";
  9628. import { ActionManager } from "babylonjs/Actions/actionManager";
  9629. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9630. import { Node } from "babylonjs/node";
  9631. /**
  9632. * Interface used to define Action
  9633. */
  9634. export interface IAction {
  9635. /**
  9636. * Trigger for the action
  9637. */
  9638. trigger: number;
  9639. /** Options of the trigger */
  9640. triggerOptions: any;
  9641. /**
  9642. * Gets the trigger parameters
  9643. * @returns the trigger parameters
  9644. */
  9645. getTriggerParameter(): any;
  9646. /**
  9647. * Internal only - executes current action event
  9648. * @hidden
  9649. */
  9650. _executeCurrent(evt?: ActionEvent): void;
  9651. /**
  9652. * Serialize placeholder for child classes
  9653. * @param parent of child
  9654. * @returns the serialized object
  9655. */
  9656. serialize(parent: any): any;
  9657. /**
  9658. * Internal only
  9659. * @hidden
  9660. */
  9661. _prepare(): void;
  9662. /**
  9663. * Internal only - manager for action
  9664. * @hidden
  9665. */
  9666. _actionManager: Nullable<AbstractActionManager>;
  9667. /**
  9668. * Adds action to chain of actions, may be a DoNothingAction
  9669. * @param action defines the next action to execute
  9670. * @returns The action passed in
  9671. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9672. */
  9673. then(action: IAction): IAction;
  9674. }
  9675. /**
  9676. * The action to be carried out following a trigger
  9677. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9678. */
  9679. export class Action implements IAction {
  9680. /** the trigger, with or without parameters, for the action */
  9681. triggerOptions: any;
  9682. /**
  9683. * Trigger for the action
  9684. */
  9685. trigger: number;
  9686. /**
  9687. * Internal only - manager for action
  9688. * @hidden
  9689. */
  9690. _actionManager: ActionManager;
  9691. private _nextActiveAction;
  9692. private _child;
  9693. private _condition?;
  9694. private _triggerParameter;
  9695. /**
  9696. * An event triggered prior to action being executed.
  9697. */
  9698. onBeforeExecuteObservable: Observable<Action>;
  9699. /**
  9700. * Creates a new Action
  9701. * @param triggerOptions the trigger, with or without parameters, for the action
  9702. * @param condition an optional determinant of action
  9703. */
  9704. constructor(
  9705. /** the trigger, with or without parameters, for the action */
  9706. triggerOptions: any, condition?: Condition);
  9707. /**
  9708. * Internal only
  9709. * @hidden
  9710. */
  9711. _prepare(): void;
  9712. /**
  9713. * Gets the trigger parameters
  9714. * @returns the trigger parameters
  9715. */
  9716. getTriggerParameter(): any;
  9717. /**
  9718. * Internal only - executes current action event
  9719. * @hidden
  9720. */
  9721. _executeCurrent(evt?: ActionEvent): void;
  9722. /**
  9723. * Execute placeholder for child classes
  9724. * @param evt optional action event
  9725. */
  9726. execute(evt?: ActionEvent): void;
  9727. /**
  9728. * Skips to next active action
  9729. */
  9730. skipToNextActiveAction(): void;
  9731. /**
  9732. * Adds action to chain of actions, may be a DoNothingAction
  9733. * @param action defines the next action to execute
  9734. * @returns The action passed in
  9735. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9736. */
  9737. then(action: Action): Action;
  9738. /**
  9739. * Internal only
  9740. * @hidden
  9741. */
  9742. _getProperty(propertyPath: string): string;
  9743. /**
  9744. * Internal only
  9745. * @hidden
  9746. */
  9747. _getEffectiveTarget(target: any, propertyPath: string): any;
  9748. /**
  9749. * Serialize placeholder for child classes
  9750. * @param parent of child
  9751. * @returns the serialized object
  9752. */
  9753. serialize(parent: any): any;
  9754. /**
  9755. * Internal only called by serialize
  9756. * @hidden
  9757. */
  9758. protected _serialize(serializedAction: any, parent?: any): any;
  9759. /**
  9760. * Internal only
  9761. * @hidden
  9762. */
  9763. static _SerializeValueAsString: (value: any) => string;
  9764. /**
  9765. * Internal only
  9766. * @hidden
  9767. */
  9768. static _GetTargetProperty: (target: Scene | Node) => {
  9769. name: string;
  9770. targetType: string;
  9771. value: string;
  9772. };
  9773. }
  9774. }
  9775. declare module "babylonjs/Actions/condition" {
  9776. import { ActionManager } from "babylonjs/Actions/actionManager";
  9777. /**
  9778. * A Condition applied to an Action
  9779. */
  9780. export class Condition {
  9781. /**
  9782. * Internal only - manager for action
  9783. * @hidden
  9784. */
  9785. _actionManager: ActionManager;
  9786. /**
  9787. * Internal only
  9788. * @hidden
  9789. */
  9790. _evaluationId: number;
  9791. /**
  9792. * Internal only
  9793. * @hidden
  9794. */
  9795. _currentResult: boolean;
  9796. /**
  9797. * Creates a new Condition
  9798. * @param actionManager the manager of the action the condition is applied to
  9799. */
  9800. constructor(actionManager: ActionManager);
  9801. /**
  9802. * Check if the current condition is valid
  9803. * @returns a boolean
  9804. */
  9805. isValid(): boolean;
  9806. /**
  9807. * Internal only
  9808. * @hidden
  9809. */
  9810. _getProperty(propertyPath: string): string;
  9811. /**
  9812. * Internal only
  9813. * @hidden
  9814. */
  9815. _getEffectiveTarget(target: any, propertyPath: string): any;
  9816. /**
  9817. * Serialize placeholder for child classes
  9818. * @returns the serialized object
  9819. */
  9820. serialize(): any;
  9821. /**
  9822. * Internal only
  9823. * @hidden
  9824. */
  9825. protected _serialize(serializedCondition: any): any;
  9826. }
  9827. /**
  9828. * Defines specific conditional operators as extensions of Condition
  9829. */
  9830. export class ValueCondition extends Condition {
  9831. /** path to specify the property of the target the conditional operator uses */
  9832. propertyPath: string;
  9833. /** the value compared by the conditional operator against the current value of the property */
  9834. value: any;
  9835. /** the conditional operator, default ValueCondition.IsEqual */
  9836. operator: number;
  9837. /**
  9838. * Internal only
  9839. * @hidden
  9840. */
  9841. private static _IsEqual;
  9842. /**
  9843. * Internal only
  9844. * @hidden
  9845. */
  9846. private static _IsDifferent;
  9847. /**
  9848. * Internal only
  9849. * @hidden
  9850. */
  9851. private static _IsGreater;
  9852. /**
  9853. * Internal only
  9854. * @hidden
  9855. */
  9856. private static _IsLesser;
  9857. /**
  9858. * returns the number for IsEqual
  9859. */
  9860. static get IsEqual(): number;
  9861. /**
  9862. * Returns the number for IsDifferent
  9863. */
  9864. static get IsDifferent(): number;
  9865. /**
  9866. * Returns the number for IsGreater
  9867. */
  9868. static get IsGreater(): number;
  9869. /**
  9870. * Returns the number for IsLesser
  9871. */
  9872. static get IsLesser(): number;
  9873. /**
  9874. * Internal only The action manager for the condition
  9875. * @hidden
  9876. */
  9877. _actionManager: ActionManager;
  9878. /**
  9879. * Internal only
  9880. * @hidden
  9881. */
  9882. private _target;
  9883. /**
  9884. * Internal only
  9885. * @hidden
  9886. */
  9887. private _effectiveTarget;
  9888. /**
  9889. * Internal only
  9890. * @hidden
  9891. */
  9892. private _property;
  9893. /**
  9894. * Creates a new ValueCondition
  9895. * @param actionManager manager for the action the condition applies to
  9896. * @param target for the action
  9897. * @param propertyPath path to specify the property of the target the conditional operator uses
  9898. * @param value the value compared by the conditional operator against the current value of the property
  9899. * @param operator the conditional operator, default ValueCondition.IsEqual
  9900. */
  9901. constructor(actionManager: ActionManager, target: any,
  9902. /** path to specify the property of the target the conditional operator uses */
  9903. propertyPath: string,
  9904. /** the value compared by the conditional operator against the current value of the property */
  9905. value: any,
  9906. /** the conditional operator, default ValueCondition.IsEqual */
  9907. operator?: number);
  9908. /**
  9909. * Compares the given value with the property value for the specified conditional operator
  9910. * @returns the result of the comparison
  9911. */
  9912. isValid(): boolean;
  9913. /**
  9914. * Serialize the ValueCondition into a JSON compatible object
  9915. * @returns serialization object
  9916. */
  9917. serialize(): any;
  9918. /**
  9919. * Gets the name of the conditional operator for the ValueCondition
  9920. * @param operator the conditional operator
  9921. * @returns the name
  9922. */
  9923. static GetOperatorName(operator: number): string;
  9924. }
  9925. /**
  9926. * Defines a predicate condition as an extension of Condition
  9927. */
  9928. export class PredicateCondition extends Condition {
  9929. /** defines the predicate function used to validate the condition */
  9930. predicate: () => boolean;
  9931. /**
  9932. * Internal only - manager for action
  9933. * @hidden
  9934. */
  9935. _actionManager: ActionManager;
  9936. /**
  9937. * Creates a new PredicateCondition
  9938. * @param actionManager manager for the action the condition applies to
  9939. * @param predicate defines the predicate function used to validate the condition
  9940. */
  9941. constructor(actionManager: ActionManager,
  9942. /** defines the predicate function used to validate the condition */
  9943. predicate: () => boolean);
  9944. /**
  9945. * @returns the validity of the predicate condition
  9946. */
  9947. isValid(): boolean;
  9948. }
  9949. /**
  9950. * Defines a state condition as an extension of Condition
  9951. */
  9952. export class StateCondition extends Condition {
  9953. /** Value to compare with target state */
  9954. value: string;
  9955. /**
  9956. * Internal only - manager for action
  9957. * @hidden
  9958. */
  9959. _actionManager: ActionManager;
  9960. /**
  9961. * Internal only
  9962. * @hidden
  9963. */
  9964. private _target;
  9965. /**
  9966. * Creates a new StateCondition
  9967. * @param actionManager manager for the action the condition applies to
  9968. * @param target of the condition
  9969. * @param value to compare with target state
  9970. */
  9971. constructor(actionManager: ActionManager, target: any,
  9972. /** Value to compare with target state */
  9973. value: string);
  9974. /**
  9975. * Gets a boolean indicating if the current condition is met
  9976. * @returns the validity of the state
  9977. */
  9978. isValid(): boolean;
  9979. /**
  9980. * Serialize the StateCondition into a JSON compatible object
  9981. * @returns serialization object
  9982. */
  9983. serialize(): any;
  9984. }
  9985. }
  9986. declare module "babylonjs/Actions/directActions" {
  9987. import { Action } from "babylonjs/Actions/action";
  9988. import { Condition } from "babylonjs/Actions/condition";
  9989. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9990. /**
  9991. * This defines an action responsible to toggle a boolean once triggered.
  9992. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9993. */
  9994. export class SwitchBooleanAction extends Action {
  9995. /**
  9996. * The path to the boolean property in the target object
  9997. */
  9998. propertyPath: string;
  9999. private _target;
  10000. private _effectiveTarget;
  10001. private _property;
  10002. /**
  10003. * Instantiate the action
  10004. * @param triggerOptions defines the trigger options
  10005. * @param target defines the object containing the boolean
  10006. * @param propertyPath defines the path to the boolean property in the target object
  10007. * @param condition defines the trigger related conditions
  10008. */
  10009. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10010. /** @hidden */
  10011. _prepare(): void;
  10012. /**
  10013. * Execute the action toggle the boolean value.
  10014. */
  10015. execute(): void;
  10016. /**
  10017. * Serializes the actions and its related information.
  10018. * @param parent defines the object to serialize in
  10019. * @returns the serialized object
  10020. */
  10021. serialize(parent: any): any;
  10022. }
  10023. /**
  10024. * This defines an action responsible to set a the state field of the target
  10025. * to a desired value once triggered.
  10026. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10027. */
  10028. export class SetStateAction extends Action {
  10029. /**
  10030. * The value to store in the state field.
  10031. */
  10032. value: string;
  10033. private _target;
  10034. /**
  10035. * Instantiate the action
  10036. * @param triggerOptions defines the trigger options
  10037. * @param target defines the object containing the state property
  10038. * @param value defines the value to store in the state field
  10039. * @param condition defines the trigger related conditions
  10040. */
  10041. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10042. /**
  10043. * Execute the action and store the value on the target state property.
  10044. */
  10045. execute(): void;
  10046. /**
  10047. * Serializes the actions and its related information.
  10048. * @param parent defines the object to serialize in
  10049. * @returns the serialized object
  10050. */
  10051. serialize(parent: any): any;
  10052. }
  10053. /**
  10054. * This defines an action responsible to set a property of the target
  10055. * to a desired value once triggered.
  10056. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10057. */
  10058. export class SetValueAction extends Action {
  10059. /**
  10060. * The path of the property to set in the target.
  10061. */
  10062. propertyPath: string;
  10063. /**
  10064. * The value to set in the property
  10065. */
  10066. value: any;
  10067. private _target;
  10068. private _effectiveTarget;
  10069. private _property;
  10070. /**
  10071. * Instantiate the action
  10072. * @param triggerOptions defines the trigger options
  10073. * @param target defines the object containing the property
  10074. * @param propertyPath defines the path of the property to set in the target
  10075. * @param value defines the value to set in the property
  10076. * @param condition defines the trigger related conditions
  10077. */
  10078. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10079. /** @hidden */
  10080. _prepare(): void;
  10081. /**
  10082. * Execute the action and set the targetted property to the desired value.
  10083. */
  10084. execute(): void;
  10085. /**
  10086. * Serializes the actions and its related information.
  10087. * @param parent defines the object to serialize in
  10088. * @returns the serialized object
  10089. */
  10090. serialize(parent: any): any;
  10091. }
  10092. /**
  10093. * This defines an action responsible to increment the target value
  10094. * to a desired value once triggered.
  10095. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10096. */
  10097. export class IncrementValueAction extends Action {
  10098. /**
  10099. * The path of the property to increment in the target.
  10100. */
  10101. propertyPath: string;
  10102. /**
  10103. * The value we should increment the property by.
  10104. */
  10105. value: any;
  10106. private _target;
  10107. private _effectiveTarget;
  10108. private _property;
  10109. /**
  10110. * Instantiate the action
  10111. * @param triggerOptions defines the trigger options
  10112. * @param target defines the object containing the property
  10113. * @param propertyPath defines the path of the property to increment in the target
  10114. * @param value defines the value value we should increment the property by
  10115. * @param condition defines the trigger related conditions
  10116. */
  10117. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10118. /** @hidden */
  10119. _prepare(): void;
  10120. /**
  10121. * Execute the action and increment the target of the value amount.
  10122. */
  10123. execute(): void;
  10124. /**
  10125. * Serializes the actions and its related information.
  10126. * @param parent defines the object to serialize in
  10127. * @returns the serialized object
  10128. */
  10129. serialize(parent: any): any;
  10130. }
  10131. /**
  10132. * This defines an action responsible to start an animation once triggered.
  10133. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10134. */
  10135. export class PlayAnimationAction extends Action {
  10136. /**
  10137. * Where the animation should start (animation frame)
  10138. */
  10139. from: number;
  10140. /**
  10141. * Where the animation should stop (animation frame)
  10142. */
  10143. to: number;
  10144. /**
  10145. * Define if the animation should loop or stop after the first play.
  10146. */
  10147. loop?: boolean;
  10148. private _target;
  10149. /**
  10150. * Instantiate the action
  10151. * @param triggerOptions defines the trigger options
  10152. * @param target defines the target animation or animation name
  10153. * @param from defines from where the animation should start (animation frame)
  10154. * @param end defines where the animation should stop (animation frame)
  10155. * @param loop defines if the animation should loop or stop after the first play
  10156. * @param condition defines the trigger related conditions
  10157. */
  10158. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10159. /** @hidden */
  10160. _prepare(): void;
  10161. /**
  10162. * Execute the action and play the animation.
  10163. */
  10164. execute(): void;
  10165. /**
  10166. * Serializes the actions and its related information.
  10167. * @param parent defines the object to serialize in
  10168. * @returns the serialized object
  10169. */
  10170. serialize(parent: any): any;
  10171. }
  10172. /**
  10173. * This defines an action responsible to stop an animation once triggered.
  10174. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10175. */
  10176. export class StopAnimationAction extends Action {
  10177. private _target;
  10178. /**
  10179. * Instantiate the action
  10180. * @param triggerOptions defines the trigger options
  10181. * @param target defines the target animation or animation name
  10182. * @param condition defines the trigger related conditions
  10183. */
  10184. constructor(triggerOptions: any, target: any, condition?: Condition);
  10185. /** @hidden */
  10186. _prepare(): void;
  10187. /**
  10188. * Execute the action and stop the animation.
  10189. */
  10190. execute(): void;
  10191. /**
  10192. * Serializes the actions and its related information.
  10193. * @param parent defines the object to serialize in
  10194. * @returns the serialized object
  10195. */
  10196. serialize(parent: any): any;
  10197. }
  10198. /**
  10199. * This defines an action responsible that does nothing once triggered.
  10200. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10201. */
  10202. export class DoNothingAction extends Action {
  10203. /**
  10204. * Instantiate the action
  10205. * @param triggerOptions defines the trigger options
  10206. * @param condition defines the trigger related conditions
  10207. */
  10208. constructor(triggerOptions?: any, condition?: Condition);
  10209. /**
  10210. * Execute the action and do nothing.
  10211. */
  10212. execute(): void;
  10213. /**
  10214. * Serializes the actions and its related information.
  10215. * @param parent defines the object to serialize in
  10216. * @returns the serialized object
  10217. */
  10218. serialize(parent: any): any;
  10219. }
  10220. /**
  10221. * This defines an action responsible to trigger several actions once triggered.
  10222. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10223. */
  10224. export class CombineAction extends Action {
  10225. /**
  10226. * The list of aggregated animations to run.
  10227. */
  10228. children: Action[];
  10229. /**
  10230. * Instantiate the action
  10231. * @param triggerOptions defines the trigger options
  10232. * @param children defines the list of aggregated animations to run
  10233. * @param condition defines the trigger related conditions
  10234. */
  10235. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10236. /** @hidden */
  10237. _prepare(): void;
  10238. /**
  10239. * Execute the action and executes all the aggregated actions.
  10240. */
  10241. execute(evt: ActionEvent): void;
  10242. /**
  10243. * Serializes the actions and its related information.
  10244. * @param parent defines the object to serialize in
  10245. * @returns the serialized object
  10246. */
  10247. serialize(parent: any): any;
  10248. }
  10249. /**
  10250. * This defines an action responsible to run code (external event) once triggered.
  10251. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10252. */
  10253. export class ExecuteCodeAction extends Action {
  10254. /**
  10255. * The callback function to run.
  10256. */
  10257. func: (evt: ActionEvent) => void;
  10258. /**
  10259. * Instantiate the action
  10260. * @param triggerOptions defines the trigger options
  10261. * @param func defines the callback function to run
  10262. * @param condition defines the trigger related conditions
  10263. */
  10264. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10265. /**
  10266. * Execute the action and run the attached code.
  10267. */
  10268. execute(evt: ActionEvent): void;
  10269. }
  10270. /**
  10271. * This defines an action responsible to set the parent property of the target once triggered.
  10272. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10273. */
  10274. export class SetParentAction extends Action {
  10275. private _parent;
  10276. private _target;
  10277. /**
  10278. * Instantiate the action
  10279. * @param triggerOptions defines the trigger options
  10280. * @param target defines the target containing the parent property
  10281. * @param parent defines from where the animation should start (animation frame)
  10282. * @param condition defines the trigger related conditions
  10283. */
  10284. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10285. /** @hidden */
  10286. _prepare(): void;
  10287. /**
  10288. * Execute the action and set the parent property.
  10289. */
  10290. execute(): void;
  10291. /**
  10292. * Serializes the actions and its related information.
  10293. * @param parent defines the object to serialize in
  10294. * @returns the serialized object
  10295. */
  10296. serialize(parent: any): any;
  10297. }
  10298. }
  10299. declare module "babylonjs/Actions/actionManager" {
  10300. import { Nullable } from "babylonjs/types";
  10301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10302. import { Scene } from "babylonjs/scene";
  10303. import { IAction } from "babylonjs/Actions/action";
  10304. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10305. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10306. /**
  10307. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10308. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10309. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10310. */
  10311. export class ActionManager extends AbstractActionManager {
  10312. /**
  10313. * Nothing
  10314. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10315. */
  10316. static readonly NothingTrigger: number;
  10317. /**
  10318. * On pick
  10319. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10320. */
  10321. static readonly OnPickTrigger: number;
  10322. /**
  10323. * On left pick
  10324. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10325. */
  10326. static readonly OnLeftPickTrigger: number;
  10327. /**
  10328. * On right pick
  10329. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10330. */
  10331. static readonly OnRightPickTrigger: number;
  10332. /**
  10333. * On center pick
  10334. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10335. */
  10336. static readonly OnCenterPickTrigger: number;
  10337. /**
  10338. * On pick down
  10339. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10340. */
  10341. static readonly OnPickDownTrigger: number;
  10342. /**
  10343. * On double pick
  10344. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10345. */
  10346. static readonly OnDoublePickTrigger: number;
  10347. /**
  10348. * On pick up
  10349. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10350. */
  10351. static readonly OnPickUpTrigger: number;
  10352. /**
  10353. * On pick out.
  10354. * This trigger will only be raised if you also declared a OnPickDown
  10355. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10356. */
  10357. static readonly OnPickOutTrigger: number;
  10358. /**
  10359. * On long press
  10360. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10361. */
  10362. static readonly OnLongPressTrigger: number;
  10363. /**
  10364. * On pointer over
  10365. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10366. */
  10367. static readonly OnPointerOverTrigger: number;
  10368. /**
  10369. * On pointer out
  10370. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10371. */
  10372. static readonly OnPointerOutTrigger: number;
  10373. /**
  10374. * On every frame
  10375. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10376. */
  10377. static readonly OnEveryFrameTrigger: number;
  10378. /**
  10379. * On intersection enter
  10380. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10381. */
  10382. static readonly OnIntersectionEnterTrigger: number;
  10383. /**
  10384. * On intersection exit
  10385. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10386. */
  10387. static readonly OnIntersectionExitTrigger: number;
  10388. /**
  10389. * On key down
  10390. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10391. */
  10392. static readonly OnKeyDownTrigger: number;
  10393. /**
  10394. * On key up
  10395. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10396. */
  10397. static readonly OnKeyUpTrigger: number;
  10398. private _scene;
  10399. /**
  10400. * Creates a new action manager
  10401. * @param scene defines the hosting scene
  10402. */
  10403. constructor(scene: Scene);
  10404. /**
  10405. * Releases all associated resources
  10406. */
  10407. dispose(): void;
  10408. /**
  10409. * Gets hosting scene
  10410. * @returns the hosting scene
  10411. */
  10412. getScene(): Scene;
  10413. /**
  10414. * Does this action manager handles actions of any of the given triggers
  10415. * @param triggers defines the triggers to be tested
  10416. * @return a boolean indicating whether one (or more) of the triggers is handled
  10417. */
  10418. hasSpecificTriggers(triggers: number[]): boolean;
  10419. /**
  10420. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10421. * speed.
  10422. * @param triggerA defines the trigger to be tested
  10423. * @param triggerB defines the trigger to be tested
  10424. * @return a boolean indicating whether one (or more) of the triggers is handled
  10425. */
  10426. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10427. /**
  10428. * Does this action manager handles actions of a given trigger
  10429. * @param trigger defines the trigger to be tested
  10430. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10431. * @return whether the trigger is handled
  10432. */
  10433. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10434. /**
  10435. * Does this action manager has pointer triggers
  10436. */
  10437. get hasPointerTriggers(): boolean;
  10438. /**
  10439. * Does this action manager has pick triggers
  10440. */
  10441. get hasPickTriggers(): boolean;
  10442. /**
  10443. * Registers an action to this action manager
  10444. * @param action defines the action to be registered
  10445. * @return the action amended (prepared) after registration
  10446. */
  10447. registerAction(action: IAction): Nullable<IAction>;
  10448. /**
  10449. * Unregisters an action to this action manager
  10450. * @param action defines the action to be unregistered
  10451. * @return a boolean indicating whether the action has been unregistered
  10452. */
  10453. unregisterAction(action: IAction): Boolean;
  10454. /**
  10455. * Process a specific trigger
  10456. * @param trigger defines the trigger to process
  10457. * @param evt defines the event details to be processed
  10458. */
  10459. processTrigger(trigger: number, evt?: IActionEvent): void;
  10460. /** @hidden */
  10461. _getEffectiveTarget(target: any, propertyPath: string): any;
  10462. /** @hidden */
  10463. _getProperty(propertyPath: string): string;
  10464. /**
  10465. * Serialize this manager to a JSON object
  10466. * @param name defines the property name to store this manager
  10467. * @returns a JSON representation of this manager
  10468. */
  10469. serialize(name: string): any;
  10470. /**
  10471. * Creates a new ActionManager from a JSON data
  10472. * @param parsedActions defines the JSON data to read from
  10473. * @param object defines the hosting mesh
  10474. * @param scene defines the hosting scene
  10475. */
  10476. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10477. /**
  10478. * Get a trigger name by index
  10479. * @param trigger defines the trigger index
  10480. * @returns a trigger name
  10481. */
  10482. static GetTriggerName(trigger: number): string;
  10483. }
  10484. }
  10485. declare module "babylonjs/Sprites/sprite" {
  10486. import { Vector3 } from "babylonjs/Maths/math.vector";
  10487. import { Nullable } from "babylonjs/types";
  10488. import { ActionManager } from "babylonjs/Actions/actionManager";
  10489. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10490. import { Color4 } from "babylonjs/Maths/math.color";
  10491. import { Observable } from "babylonjs/Misc/observable";
  10492. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10493. import { Animation } from "babylonjs/Animations/animation";
  10494. /**
  10495. * Class used to represent a sprite
  10496. * @see https://doc.babylonjs.com/babylon101/sprites
  10497. */
  10498. export class Sprite implements IAnimatable {
  10499. /** defines the name */
  10500. name: string;
  10501. /** Gets or sets the current world position */
  10502. position: Vector3;
  10503. /** Gets or sets the main color */
  10504. color: Color4;
  10505. /** Gets or sets the width */
  10506. width: number;
  10507. /** Gets or sets the height */
  10508. height: number;
  10509. /** Gets or sets rotation angle */
  10510. angle: number;
  10511. /** Gets or sets the cell index in the sprite sheet */
  10512. cellIndex: number;
  10513. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10514. cellRef: string;
  10515. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10516. invertU: boolean;
  10517. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10518. invertV: boolean;
  10519. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10520. disposeWhenFinishedAnimating: boolean;
  10521. /** Gets the list of attached animations */
  10522. animations: Nullable<Array<Animation>>;
  10523. /** Gets or sets a boolean indicating if the sprite can be picked */
  10524. isPickable: boolean;
  10525. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10526. useAlphaForPicking: boolean;
  10527. /** @hidden */
  10528. _xOffset: number;
  10529. /** @hidden */
  10530. _yOffset: number;
  10531. /** @hidden */
  10532. _xSize: number;
  10533. /** @hidden */
  10534. _ySize: number;
  10535. /**
  10536. * Gets or sets the associated action manager
  10537. */
  10538. actionManager: Nullable<ActionManager>;
  10539. /**
  10540. * An event triggered when the control has been disposed
  10541. */
  10542. onDisposeObservable: Observable<Sprite>;
  10543. private _animationStarted;
  10544. private _loopAnimation;
  10545. private _fromIndex;
  10546. private _toIndex;
  10547. private _delay;
  10548. private _direction;
  10549. private _manager;
  10550. private _time;
  10551. private _onAnimationEnd;
  10552. /**
  10553. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10554. */
  10555. isVisible: boolean;
  10556. /**
  10557. * Gets or sets the sprite size
  10558. */
  10559. get size(): number;
  10560. set size(value: number);
  10561. /**
  10562. * Returns a boolean indicating if the animation is started
  10563. */
  10564. get animationStarted(): boolean;
  10565. /**
  10566. * Gets or sets the unique id of the sprite
  10567. */
  10568. uniqueId: number;
  10569. /**
  10570. * Gets the manager of this sprite
  10571. */
  10572. get manager(): ISpriteManager;
  10573. /**
  10574. * Creates a new Sprite
  10575. * @param name defines the name
  10576. * @param manager defines the manager
  10577. */
  10578. constructor(
  10579. /** defines the name */
  10580. name: string, manager: ISpriteManager);
  10581. /**
  10582. * Returns the string "Sprite"
  10583. * @returns "Sprite"
  10584. */
  10585. getClassName(): string;
  10586. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10587. get fromIndex(): number;
  10588. set fromIndex(value: number);
  10589. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10590. get toIndex(): number;
  10591. set toIndex(value: number);
  10592. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10593. get loopAnimation(): boolean;
  10594. set loopAnimation(value: boolean);
  10595. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10596. get delay(): number;
  10597. set delay(value: number);
  10598. /**
  10599. * Starts an animation
  10600. * @param from defines the initial key
  10601. * @param to defines the end key
  10602. * @param loop defines if the animation must loop
  10603. * @param delay defines the start delay (in ms)
  10604. * @param onAnimationEnd defines a callback to call when animation ends
  10605. */
  10606. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10607. /** Stops current animation (if any) */
  10608. stopAnimation(): void;
  10609. /** @hidden */
  10610. _animate(deltaTime: number): void;
  10611. /** Release associated resources */
  10612. dispose(): void;
  10613. /**
  10614. * Serializes the sprite to a JSON object
  10615. * @returns the JSON object
  10616. */
  10617. serialize(): any;
  10618. /**
  10619. * Parses a JSON object to create a new sprite
  10620. * @param parsedSprite The JSON object to parse
  10621. * @param manager defines the hosting manager
  10622. * @returns the new sprite
  10623. */
  10624. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10625. }
  10626. }
  10627. declare module "babylonjs/Collisions/pickingInfo" {
  10628. import { Nullable } from "babylonjs/types";
  10629. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10631. import { Sprite } from "babylonjs/Sprites/sprite";
  10632. import { Ray } from "babylonjs/Culling/ray";
  10633. /**
  10634. * Information about the result of picking within a scene
  10635. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10636. */
  10637. export class PickingInfo {
  10638. /** @hidden */
  10639. _pickingUnavailable: boolean;
  10640. /**
  10641. * If the pick collided with an object
  10642. */
  10643. hit: boolean;
  10644. /**
  10645. * Distance away where the pick collided
  10646. */
  10647. distance: number;
  10648. /**
  10649. * The location of pick collision
  10650. */
  10651. pickedPoint: Nullable<Vector3>;
  10652. /**
  10653. * The mesh corresponding the the pick collision
  10654. */
  10655. pickedMesh: Nullable<AbstractMesh>;
  10656. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10657. bu: number;
  10658. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10659. bv: number;
  10660. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10661. faceId: number;
  10662. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10663. subMeshFaceId: number;
  10664. /** Id of the the submesh that was picked */
  10665. subMeshId: number;
  10666. /** If a sprite was picked, this will be the sprite the pick collided with */
  10667. pickedSprite: Nullable<Sprite>;
  10668. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10669. thinInstanceIndex: number;
  10670. /**
  10671. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10672. */
  10673. originMesh: Nullable<AbstractMesh>;
  10674. /**
  10675. * The ray that was used to perform the picking.
  10676. */
  10677. ray: Nullable<Ray>;
  10678. /**
  10679. * Gets the normal correspodning to the face the pick collided with
  10680. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10681. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10682. * @returns The normal correspodning to the face the pick collided with
  10683. */
  10684. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10685. /**
  10686. * Gets the texture coordinates of where the pick occured
  10687. * @returns the vector containing the coordnates of the texture
  10688. */
  10689. getTextureCoordinates(): Nullable<Vector2>;
  10690. }
  10691. }
  10692. declare module "babylonjs/Culling/ray" {
  10693. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10694. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10696. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10697. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10698. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10699. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10700. import { Plane } from "babylonjs/Maths/math.plane";
  10701. /**
  10702. * Class representing a ray with position and direction
  10703. */
  10704. export class Ray {
  10705. /** origin point */
  10706. origin: Vector3;
  10707. /** direction */
  10708. direction: Vector3;
  10709. /** length of the ray */
  10710. length: number;
  10711. private static readonly _TmpVector3;
  10712. private _tmpRay;
  10713. /**
  10714. * Creates a new ray
  10715. * @param origin origin point
  10716. * @param direction direction
  10717. * @param length length of the ray
  10718. */
  10719. constructor(
  10720. /** origin point */
  10721. origin: Vector3,
  10722. /** direction */
  10723. direction: Vector3,
  10724. /** length of the ray */
  10725. length?: number);
  10726. /**
  10727. * Checks if the ray intersects a box
  10728. * This does not account for the ray lenght by design to improve perfs.
  10729. * @param minimum bound of the box
  10730. * @param maximum bound of the box
  10731. * @param intersectionTreshold extra extend to be added to the box in all direction
  10732. * @returns if the box was hit
  10733. */
  10734. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10735. /**
  10736. * Checks if the ray intersects a box
  10737. * This does not account for the ray lenght by design to improve perfs.
  10738. * @param box the bounding box to check
  10739. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10740. * @returns if the box was hit
  10741. */
  10742. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10743. /**
  10744. * If the ray hits a sphere
  10745. * @param sphere the bounding sphere to check
  10746. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10747. * @returns true if it hits the sphere
  10748. */
  10749. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10750. /**
  10751. * If the ray hits a triange
  10752. * @param vertex0 triangle vertex
  10753. * @param vertex1 triangle vertex
  10754. * @param vertex2 triangle vertex
  10755. * @returns intersection information if hit
  10756. */
  10757. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10758. /**
  10759. * Checks if ray intersects a plane
  10760. * @param plane the plane to check
  10761. * @returns the distance away it was hit
  10762. */
  10763. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10764. /**
  10765. * Calculate the intercept of a ray on a given axis
  10766. * @param axis to check 'x' | 'y' | 'z'
  10767. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10768. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10769. */
  10770. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10771. /**
  10772. * Checks if ray intersects a mesh
  10773. * @param mesh the mesh to check
  10774. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10775. * @returns picking info of the intersecton
  10776. */
  10777. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10778. /**
  10779. * Checks if ray intersects a mesh
  10780. * @param meshes the meshes to check
  10781. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10782. * @param results array to store result in
  10783. * @returns Array of picking infos
  10784. */
  10785. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10786. private _comparePickingInfo;
  10787. private static smallnum;
  10788. private static rayl;
  10789. /**
  10790. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10791. * @param sega the first point of the segment to test the intersection against
  10792. * @param segb the second point of the segment to test the intersection against
  10793. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10794. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10795. */
  10796. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10797. /**
  10798. * Update the ray from viewport position
  10799. * @param x position
  10800. * @param y y position
  10801. * @param viewportWidth viewport width
  10802. * @param viewportHeight viewport height
  10803. * @param world world matrix
  10804. * @param view view matrix
  10805. * @param projection projection matrix
  10806. * @returns this ray updated
  10807. */
  10808. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10809. /**
  10810. * Creates a ray with origin and direction of 0,0,0
  10811. * @returns the new ray
  10812. */
  10813. static Zero(): Ray;
  10814. /**
  10815. * Creates a new ray from screen space and viewport
  10816. * @param x position
  10817. * @param y y position
  10818. * @param viewportWidth viewport width
  10819. * @param viewportHeight viewport height
  10820. * @param world world matrix
  10821. * @param view view matrix
  10822. * @param projection projection matrix
  10823. * @returns new ray
  10824. */
  10825. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10826. /**
  10827. * 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
  10828. * transformed to the given world matrix.
  10829. * @param origin The origin point
  10830. * @param end The end point
  10831. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10832. * @returns the new ray
  10833. */
  10834. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10835. /**
  10836. * Transforms a ray by a matrix
  10837. * @param ray ray to transform
  10838. * @param matrix matrix to apply
  10839. * @returns the resulting new ray
  10840. */
  10841. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10842. /**
  10843. * Transforms a ray by a matrix
  10844. * @param ray ray to transform
  10845. * @param matrix matrix to apply
  10846. * @param result ray to store result in
  10847. */
  10848. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10849. /**
  10850. * Unproject a ray from screen space to object space
  10851. * @param sourceX defines the screen space x coordinate to use
  10852. * @param sourceY defines the screen space y coordinate to use
  10853. * @param viewportWidth defines the current width of the viewport
  10854. * @param viewportHeight defines the current height of the viewport
  10855. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10856. * @param view defines the view matrix to use
  10857. * @param projection defines the projection matrix to use
  10858. */
  10859. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10860. }
  10861. /**
  10862. * Type used to define predicate used to select faces when a mesh intersection is detected
  10863. */
  10864. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10865. module "babylonjs/scene" {
  10866. interface Scene {
  10867. /** @hidden */
  10868. _tempPickingRay: Nullable<Ray>;
  10869. /** @hidden */
  10870. _cachedRayForTransform: Ray;
  10871. /** @hidden */
  10872. _pickWithRayInverseMatrix: Matrix;
  10873. /** @hidden */
  10874. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10875. /** @hidden */
  10876. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10877. /** @hidden */
  10878. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10879. }
  10880. }
  10881. }
  10882. declare module "babylonjs/sceneComponent" {
  10883. import { Scene } from "babylonjs/scene";
  10884. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10885. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10886. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10887. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10888. import { Nullable } from "babylonjs/types";
  10889. import { Camera } from "babylonjs/Cameras/camera";
  10890. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10891. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10892. import { AbstractScene } from "babylonjs/abstractScene";
  10893. import { Mesh } from "babylonjs/Meshes/mesh";
  10894. /**
  10895. * Groups all the scene component constants in one place to ease maintenance.
  10896. * @hidden
  10897. */
  10898. export class SceneComponentConstants {
  10899. static readonly NAME_EFFECTLAYER: string;
  10900. static readonly NAME_LAYER: string;
  10901. static readonly NAME_LENSFLARESYSTEM: string;
  10902. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10903. static readonly NAME_PARTICLESYSTEM: string;
  10904. static readonly NAME_GAMEPAD: string;
  10905. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10906. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10907. static readonly NAME_PREPASSRENDERER: string;
  10908. static readonly NAME_DEPTHRENDERER: string;
  10909. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10910. static readonly NAME_SPRITE: string;
  10911. static readonly NAME_SUBSURFACE: string;
  10912. static readonly NAME_OUTLINERENDERER: string;
  10913. static readonly NAME_PROCEDURALTEXTURE: string;
  10914. static readonly NAME_SHADOWGENERATOR: string;
  10915. static readonly NAME_OCTREE: string;
  10916. static readonly NAME_PHYSICSENGINE: string;
  10917. static readonly NAME_AUDIO: string;
  10918. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10919. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10920. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10921. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10922. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10923. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10924. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10925. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10926. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10927. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10928. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10929. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10930. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10931. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10932. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10933. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10934. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10935. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10936. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10937. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10938. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10939. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10940. static readonly STEP_AFTERRENDER_AUDIO: number;
  10941. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10942. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10943. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10944. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10945. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10946. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10947. static readonly STEP_POINTERMOVE_SPRITE: number;
  10948. static readonly STEP_POINTERDOWN_SPRITE: number;
  10949. static readonly STEP_POINTERUP_SPRITE: number;
  10950. }
  10951. /**
  10952. * This represents a scene component.
  10953. *
  10954. * This is used to decouple the dependency the scene is having on the different workloads like
  10955. * layers, post processes...
  10956. */
  10957. export interface ISceneComponent {
  10958. /**
  10959. * The name of the component. Each component must have a unique name.
  10960. */
  10961. name: string;
  10962. /**
  10963. * The scene the component belongs to.
  10964. */
  10965. scene: Scene;
  10966. /**
  10967. * Register the component to one instance of a scene.
  10968. */
  10969. register(): void;
  10970. /**
  10971. * Rebuilds the elements related to this component in case of
  10972. * context lost for instance.
  10973. */
  10974. rebuild(): void;
  10975. /**
  10976. * Disposes the component and the associated ressources.
  10977. */
  10978. dispose(): void;
  10979. }
  10980. /**
  10981. * This represents a SERIALIZABLE scene component.
  10982. *
  10983. * This extends Scene Component to add Serialization methods on top.
  10984. */
  10985. export interface ISceneSerializableComponent extends ISceneComponent {
  10986. /**
  10987. * Adds all the elements from the container to the scene
  10988. * @param container the container holding the elements
  10989. */
  10990. addFromContainer(container: AbstractScene): void;
  10991. /**
  10992. * Removes all the elements in the container from the scene
  10993. * @param container contains the elements to remove
  10994. * @param dispose if the removed element should be disposed (default: false)
  10995. */
  10996. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10997. /**
  10998. * Serializes the component data to the specified json object
  10999. * @param serializationObject The object to serialize to
  11000. */
  11001. serialize(serializationObject: any): void;
  11002. }
  11003. /**
  11004. * Strong typing of a Mesh related stage step action
  11005. */
  11006. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11007. /**
  11008. * Strong typing of a Evaluate Sub Mesh related stage step action
  11009. */
  11010. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11011. /**
  11012. * Strong typing of a pre active Mesh related stage step action
  11013. */
  11014. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11015. /**
  11016. * Strong typing of a Camera related stage step action
  11017. */
  11018. export type CameraStageAction = (camera: Camera) => void;
  11019. /**
  11020. * Strong typing of a Camera Frame buffer related stage step action
  11021. */
  11022. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11023. /**
  11024. * Strong typing of a Render Target related stage step action
  11025. */
  11026. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11027. /**
  11028. * Strong typing of a RenderingGroup related stage step action
  11029. */
  11030. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11031. /**
  11032. * Strong typing of a Mesh Render related stage step action
  11033. */
  11034. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11035. /**
  11036. * Strong typing of a simple stage step action
  11037. */
  11038. export type SimpleStageAction = () => void;
  11039. /**
  11040. * Strong typing of a render target action.
  11041. */
  11042. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11043. /**
  11044. * Strong typing of a pointer move action.
  11045. */
  11046. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11047. /**
  11048. * Strong typing of a pointer up/down action.
  11049. */
  11050. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11051. /**
  11052. * Representation of a stage in the scene (Basically a list of ordered steps)
  11053. * @hidden
  11054. */
  11055. export class Stage<T extends Function> extends Array<{
  11056. index: number;
  11057. component: ISceneComponent;
  11058. action: T;
  11059. }> {
  11060. /**
  11061. * Hide ctor from the rest of the world.
  11062. * @param items The items to add.
  11063. */
  11064. private constructor();
  11065. /**
  11066. * Creates a new Stage.
  11067. * @returns A new instance of a Stage
  11068. */
  11069. static Create<T extends Function>(): Stage<T>;
  11070. /**
  11071. * Registers a step in an ordered way in the targeted stage.
  11072. * @param index Defines the position to register the step in
  11073. * @param component Defines the component attached to the step
  11074. * @param action Defines the action to launch during the step
  11075. */
  11076. registerStep(index: number, component: ISceneComponent, action: T): void;
  11077. /**
  11078. * Clears all the steps from the stage.
  11079. */
  11080. clear(): void;
  11081. }
  11082. }
  11083. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11084. import { Nullable } from "babylonjs/types";
  11085. import { Observable } from "babylonjs/Misc/observable";
  11086. import { Scene } from "babylonjs/scene";
  11087. import { Sprite } from "babylonjs/Sprites/sprite";
  11088. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11089. import { Ray } from "babylonjs/Culling/ray";
  11090. import { Camera } from "babylonjs/Cameras/camera";
  11091. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11092. import { ISceneComponent } from "babylonjs/sceneComponent";
  11093. module "babylonjs/scene" {
  11094. interface Scene {
  11095. /** @hidden */
  11096. _pointerOverSprite: Nullable<Sprite>;
  11097. /** @hidden */
  11098. _pickedDownSprite: Nullable<Sprite>;
  11099. /** @hidden */
  11100. _tempSpritePickingRay: Nullable<Ray>;
  11101. /**
  11102. * All of the sprite managers added to this scene
  11103. * @see https://doc.babylonjs.com/babylon101/sprites
  11104. */
  11105. spriteManagers: Array<ISpriteManager>;
  11106. /**
  11107. * An event triggered when sprites rendering is about to start
  11108. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11109. */
  11110. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11111. /**
  11112. * An event triggered when sprites rendering is done
  11113. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11114. */
  11115. onAfterSpritesRenderingObservable: Observable<Scene>;
  11116. /** @hidden */
  11117. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11118. /** Launch a ray to try to pick a sprite in the scene
  11119. * @param x position on screen
  11120. * @param y position on screen
  11121. * @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
  11122. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11123. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11124. * @returns a PickingInfo
  11125. */
  11126. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11127. /** Use the given ray to pick a sprite in the scene
  11128. * @param ray The ray (in world space) to use to pick meshes
  11129. * @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
  11130. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11131. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11132. * @returns a PickingInfo
  11133. */
  11134. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11135. /** @hidden */
  11136. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11137. /** Launch a ray to try to pick sprites in the scene
  11138. * @param x position on screen
  11139. * @param y position on screen
  11140. * @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
  11141. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11142. * @returns a PickingInfo array
  11143. */
  11144. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11145. /** Use the given ray to pick sprites in the scene
  11146. * @param ray The ray (in world space) to use to pick meshes
  11147. * @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
  11148. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11149. * @returns a PickingInfo array
  11150. */
  11151. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11152. /**
  11153. * Force the sprite under the pointer
  11154. * @param sprite defines the sprite to use
  11155. */
  11156. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11157. /**
  11158. * Gets the sprite under the pointer
  11159. * @returns a Sprite or null if no sprite is under the pointer
  11160. */
  11161. getPointerOverSprite(): Nullable<Sprite>;
  11162. }
  11163. }
  11164. /**
  11165. * Defines the sprite scene component responsible to manage sprites
  11166. * in a given scene.
  11167. */
  11168. export class SpriteSceneComponent implements ISceneComponent {
  11169. /**
  11170. * The component name helpfull to identify the component in the list of scene components.
  11171. */
  11172. readonly name: string;
  11173. /**
  11174. * The scene the component belongs to.
  11175. */
  11176. scene: Scene;
  11177. /** @hidden */
  11178. private _spritePredicate;
  11179. /**
  11180. * Creates a new instance of the component for the given scene
  11181. * @param scene Defines the scene to register the component in
  11182. */
  11183. constructor(scene: Scene);
  11184. /**
  11185. * Registers the component in a given scene
  11186. */
  11187. register(): void;
  11188. /**
  11189. * Rebuilds the elements related to this component in case of
  11190. * context lost for instance.
  11191. */
  11192. rebuild(): void;
  11193. /**
  11194. * Disposes the component and the associated ressources.
  11195. */
  11196. dispose(): void;
  11197. private _pickSpriteButKeepRay;
  11198. private _pointerMove;
  11199. private _pointerDown;
  11200. private _pointerUp;
  11201. }
  11202. }
  11203. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11204. /** @hidden */
  11205. export var fogFragmentDeclaration: {
  11206. name: string;
  11207. shader: string;
  11208. };
  11209. }
  11210. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11211. /** @hidden */
  11212. export var fogFragment: {
  11213. name: string;
  11214. shader: string;
  11215. };
  11216. }
  11217. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  11218. /** @hidden */
  11219. export var imageProcessingCompatibility: {
  11220. name: string;
  11221. shader: string;
  11222. };
  11223. }
  11224. declare module "babylonjs/Shaders/sprites.fragment" {
  11225. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11226. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11227. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  11228. /** @hidden */
  11229. export var spritesPixelShader: {
  11230. name: string;
  11231. shader: string;
  11232. };
  11233. }
  11234. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11235. /** @hidden */
  11236. export var fogVertexDeclaration: {
  11237. name: string;
  11238. shader: string;
  11239. };
  11240. }
  11241. declare module "babylonjs/Shaders/sprites.vertex" {
  11242. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11243. /** @hidden */
  11244. export var spritesVertexShader: {
  11245. name: string;
  11246. shader: string;
  11247. };
  11248. }
  11249. declare module "babylonjs/Sprites/spriteManager" {
  11250. import { IDisposable, Scene } from "babylonjs/scene";
  11251. import { Nullable } from "babylonjs/types";
  11252. import { Observable } from "babylonjs/Misc/observable";
  11253. import { Sprite } from "babylonjs/Sprites/sprite";
  11254. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11255. import { Camera } from "babylonjs/Cameras/camera";
  11256. import { Texture } from "babylonjs/Materials/Textures/texture";
  11257. import "babylonjs/Shaders/sprites.fragment";
  11258. import "babylonjs/Shaders/sprites.vertex";
  11259. import { Ray } from "babylonjs/Culling/ray";
  11260. /**
  11261. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11262. */
  11263. export interface ISpriteManager extends IDisposable {
  11264. /**
  11265. * Gets manager's name
  11266. */
  11267. name: string;
  11268. /**
  11269. * Restricts the camera to viewing objects with the same layerMask.
  11270. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11271. */
  11272. layerMask: number;
  11273. /**
  11274. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11275. */
  11276. isPickable: boolean;
  11277. /**
  11278. * Gets the hosting scene
  11279. */
  11280. scene: Scene;
  11281. /**
  11282. * Specifies the rendering group id for this mesh (0 by default)
  11283. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11284. */
  11285. renderingGroupId: number;
  11286. /**
  11287. * Defines the list of sprites managed by the manager.
  11288. */
  11289. sprites: Array<Sprite>;
  11290. /**
  11291. * Gets or sets the spritesheet texture
  11292. */
  11293. texture: Texture;
  11294. /** Defines the default width of a cell in the spritesheet */
  11295. cellWidth: number;
  11296. /** Defines the default height of a cell in the spritesheet */
  11297. cellHeight: number;
  11298. /**
  11299. * Tests the intersection of a sprite with a specific ray.
  11300. * @param ray The ray we are sending to test the collision
  11301. * @param camera The camera space we are sending rays in
  11302. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11303. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11304. * @returns picking info or null.
  11305. */
  11306. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11307. /**
  11308. * Intersects the sprites with a ray
  11309. * @param ray defines the ray to intersect with
  11310. * @param camera defines the current active camera
  11311. * @param predicate defines a predicate used to select candidate sprites
  11312. * @returns null if no hit or a PickingInfo array
  11313. */
  11314. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11315. /**
  11316. * Renders the list of sprites on screen.
  11317. */
  11318. render(): void;
  11319. }
  11320. /**
  11321. * Class used to manage multiple sprites on the same spritesheet
  11322. * @see https://doc.babylonjs.com/babylon101/sprites
  11323. */
  11324. export class SpriteManager implements ISpriteManager {
  11325. /** defines the manager's name */
  11326. name: string;
  11327. /** Define the Url to load snippets */
  11328. static SnippetUrl: string;
  11329. /** Snippet ID if the manager was created from the snippet server */
  11330. snippetId: string;
  11331. /** Gets the list of sprites */
  11332. sprites: Sprite[];
  11333. /** Gets or sets the rendering group id (0 by default) */
  11334. renderingGroupId: number;
  11335. /** Gets or sets camera layer mask */
  11336. layerMask: number;
  11337. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11338. fogEnabled: boolean;
  11339. /** Gets or sets a boolean indicating if the sprites are pickable */
  11340. isPickable: boolean;
  11341. /** Defines the default width of a cell in the spritesheet */
  11342. cellWidth: number;
  11343. /** Defines the default height of a cell in the spritesheet */
  11344. cellHeight: number;
  11345. /** Associative array from JSON sprite data file */
  11346. private _cellData;
  11347. /** Array of sprite names from JSON sprite data file */
  11348. private _spriteMap;
  11349. /** True when packed cell data from JSON file is ready*/
  11350. private _packedAndReady;
  11351. private _textureContent;
  11352. private _useInstancing;
  11353. /**
  11354. * An event triggered when the manager is disposed.
  11355. */
  11356. onDisposeObservable: Observable<SpriteManager>;
  11357. private _onDisposeObserver;
  11358. /**
  11359. * Callback called when the manager is disposed
  11360. */
  11361. set onDispose(callback: () => void);
  11362. private _capacity;
  11363. private _fromPacked;
  11364. private _spriteTexture;
  11365. private _epsilon;
  11366. private _scene;
  11367. private _vertexData;
  11368. private _buffer;
  11369. private _vertexBuffers;
  11370. private _spriteBuffer;
  11371. private _indexBuffer;
  11372. private _effectBase;
  11373. private _effectFog;
  11374. private _vertexBufferSize;
  11375. /**
  11376. * Gets or sets the unique id of the sprite
  11377. */
  11378. uniqueId: number;
  11379. /**
  11380. * Gets the array of sprites
  11381. */
  11382. get children(): Sprite[];
  11383. /**
  11384. * Gets the hosting scene
  11385. */
  11386. get scene(): Scene;
  11387. /**
  11388. * Gets the capacity of the manager
  11389. */
  11390. get capacity(): number;
  11391. /**
  11392. * Gets or sets the spritesheet texture
  11393. */
  11394. get texture(): Texture;
  11395. set texture(value: Texture);
  11396. private _blendMode;
  11397. /**
  11398. * Blend mode use to render the particle, it can be any of
  11399. * the static Constants.ALPHA_x properties provided in this class.
  11400. * Default value is Constants.ALPHA_COMBINE
  11401. */
  11402. get blendMode(): number;
  11403. set blendMode(blendMode: number);
  11404. /** Disables writing to the depth buffer when rendering the sprites.
  11405. * It can be handy to disable depth writing when using textures without alpha channel
  11406. * and setting some specific blend modes.
  11407. */
  11408. disableDepthWrite: boolean;
  11409. /**
  11410. * Creates a new sprite manager
  11411. * @param name defines the manager's name
  11412. * @param imgUrl defines the sprite sheet url
  11413. * @param capacity defines the maximum allowed number of sprites
  11414. * @param cellSize defines the size of a sprite cell
  11415. * @param scene defines the hosting scene
  11416. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11417. * @param samplingMode defines the smapling mode to use with spritesheet
  11418. * @param fromPacked set to false; do not alter
  11419. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11420. */
  11421. constructor(
  11422. /** defines the manager's name */
  11423. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11424. /**
  11425. * Returns the string "SpriteManager"
  11426. * @returns "SpriteManager"
  11427. */
  11428. getClassName(): string;
  11429. private _makePacked;
  11430. private _appendSpriteVertex;
  11431. private _checkTextureAlpha;
  11432. /**
  11433. * Intersects the sprites with a ray
  11434. * @param ray defines the ray to intersect with
  11435. * @param camera defines the current active camera
  11436. * @param predicate defines a predicate used to select candidate sprites
  11437. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11438. * @returns null if no hit or a PickingInfo
  11439. */
  11440. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11441. /**
  11442. * Intersects the sprites with a ray
  11443. * @param ray defines the ray to intersect with
  11444. * @param camera defines the current active camera
  11445. * @param predicate defines a predicate used to select candidate sprites
  11446. * @returns null if no hit or a PickingInfo array
  11447. */
  11448. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11449. /**
  11450. * Render all child sprites
  11451. */
  11452. render(): void;
  11453. /**
  11454. * Release associated resources
  11455. */
  11456. dispose(): void;
  11457. /**
  11458. * Serializes the sprite manager to a JSON object
  11459. * @param serializeTexture defines if the texture must be serialized as well
  11460. * @returns the JSON object
  11461. */
  11462. serialize(serializeTexture?: boolean): any;
  11463. /**
  11464. * Parses a JSON object to create a new sprite manager.
  11465. * @param parsedManager The JSON object to parse
  11466. * @param scene The scene to create the sprite managerin
  11467. * @param rootUrl The root url to use to load external dependencies like texture
  11468. * @returns the new sprite manager
  11469. */
  11470. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11471. /**
  11472. * Creates a sprite manager from a snippet saved in a remote file
  11473. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11474. * @param url defines the url to load from
  11475. * @param scene defines the hosting scene
  11476. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11477. * @returns a promise that will resolve to the new sprite manager
  11478. */
  11479. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11480. /**
  11481. * Creates a sprite manager from a snippet saved by the sprite editor
  11482. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11483. * @param scene defines the hosting scene
  11484. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11485. * @returns a promise that will resolve to the new sprite manager
  11486. */
  11487. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11488. }
  11489. }
  11490. declare module "babylonjs/Misc/gradients" {
  11491. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11492. /** Interface used by value gradients (color, factor, ...) */
  11493. export interface IValueGradient {
  11494. /**
  11495. * Gets or sets the gradient value (between 0 and 1)
  11496. */
  11497. gradient: number;
  11498. }
  11499. /** Class used to store color4 gradient */
  11500. export class ColorGradient implements IValueGradient {
  11501. /**
  11502. * Gets or sets the gradient value (between 0 and 1)
  11503. */
  11504. gradient: number;
  11505. /**
  11506. * Gets or sets first associated color
  11507. */
  11508. color1: Color4;
  11509. /**
  11510. * Gets or sets second associated color
  11511. */
  11512. color2?: Color4 | undefined;
  11513. /**
  11514. * Creates a new color4 gradient
  11515. * @param gradient gets or sets the gradient value (between 0 and 1)
  11516. * @param color1 gets or sets first associated color
  11517. * @param color2 gets or sets first second color
  11518. */
  11519. constructor(
  11520. /**
  11521. * Gets or sets the gradient value (between 0 and 1)
  11522. */
  11523. gradient: number,
  11524. /**
  11525. * Gets or sets first associated color
  11526. */
  11527. color1: Color4,
  11528. /**
  11529. * Gets or sets second associated color
  11530. */
  11531. color2?: Color4 | undefined);
  11532. /**
  11533. * Will get a color picked randomly between color1 and color2.
  11534. * If color2 is undefined then color1 will be used
  11535. * @param result defines the target Color4 to store the result in
  11536. */
  11537. getColorToRef(result: Color4): void;
  11538. }
  11539. /** Class used to store color 3 gradient */
  11540. export class Color3Gradient implements IValueGradient {
  11541. /**
  11542. * Gets or sets the gradient value (between 0 and 1)
  11543. */
  11544. gradient: number;
  11545. /**
  11546. * Gets or sets the associated color
  11547. */
  11548. color: Color3;
  11549. /**
  11550. * Creates a new color3 gradient
  11551. * @param gradient gets or sets the gradient value (between 0 and 1)
  11552. * @param color gets or sets associated color
  11553. */
  11554. constructor(
  11555. /**
  11556. * Gets or sets the gradient value (between 0 and 1)
  11557. */
  11558. gradient: number,
  11559. /**
  11560. * Gets or sets the associated color
  11561. */
  11562. color: Color3);
  11563. }
  11564. /** Class used to store factor gradient */
  11565. export class FactorGradient implements IValueGradient {
  11566. /**
  11567. * Gets or sets the gradient value (between 0 and 1)
  11568. */
  11569. gradient: number;
  11570. /**
  11571. * Gets or sets first associated factor
  11572. */
  11573. factor1: number;
  11574. /**
  11575. * Gets or sets second associated factor
  11576. */
  11577. factor2?: number | undefined;
  11578. /**
  11579. * Creates a new factor gradient
  11580. * @param gradient gets or sets the gradient value (between 0 and 1)
  11581. * @param factor1 gets or sets first associated factor
  11582. * @param factor2 gets or sets second associated factor
  11583. */
  11584. constructor(
  11585. /**
  11586. * Gets or sets the gradient value (between 0 and 1)
  11587. */
  11588. gradient: number,
  11589. /**
  11590. * Gets or sets first associated factor
  11591. */
  11592. factor1: number,
  11593. /**
  11594. * Gets or sets second associated factor
  11595. */
  11596. factor2?: number | undefined);
  11597. /**
  11598. * Will get a number picked randomly between factor1 and factor2.
  11599. * If factor2 is undefined then factor1 will be used
  11600. * @returns the picked number
  11601. */
  11602. getFactor(): number;
  11603. }
  11604. /**
  11605. * Helper used to simplify some generic gradient tasks
  11606. */
  11607. export class GradientHelper {
  11608. /**
  11609. * Gets the current gradient from an array of IValueGradient
  11610. * @param ratio defines the current ratio to get
  11611. * @param gradients defines the array of IValueGradient
  11612. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11613. */
  11614. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11615. }
  11616. }
  11617. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11618. import { Nullable } from "babylonjs/types";
  11619. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11620. import { Scene } from "babylonjs/scene";
  11621. module "babylonjs/Engines/thinEngine" {
  11622. interface ThinEngine {
  11623. /**
  11624. * Creates a raw texture
  11625. * @param data defines the data to store in the texture
  11626. * @param width defines the width of the texture
  11627. * @param height defines the height of the texture
  11628. * @param format defines the format of the data
  11629. * @param generateMipMaps defines if the engine should generate the mip levels
  11630. * @param invertY defines if data must be stored with Y axis inverted
  11631. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11632. * @param compression defines the compression used (null by default)
  11633. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11634. * @returns the raw texture inside an InternalTexture
  11635. */
  11636. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11637. /**
  11638. * Update a raw texture
  11639. * @param texture defines the texture to update
  11640. * @param data defines the data to store in the texture
  11641. * @param format defines the format of the data
  11642. * @param invertY defines if data must be stored with Y axis inverted
  11643. */
  11644. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11645. /**
  11646. * Update a raw texture
  11647. * @param texture defines the texture to update
  11648. * @param data defines the data to store in the texture
  11649. * @param format defines the format of the data
  11650. * @param invertY defines if data must be stored with Y axis inverted
  11651. * @param compression defines the compression used (null by default)
  11652. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11653. */
  11654. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11655. /**
  11656. * Creates a new raw cube texture
  11657. * @param data defines the array of data to use to create each face
  11658. * @param size defines the size of the textures
  11659. * @param format defines the format of the data
  11660. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11661. * @param generateMipMaps defines if the engine should generate the mip levels
  11662. * @param invertY defines if data must be stored with Y axis inverted
  11663. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11664. * @param compression defines the compression used (null by default)
  11665. * @returns the cube texture as an InternalTexture
  11666. */
  11667. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11668. /**
  11669. * Update a raw cube texture
  11670. * @param texture defines the texture to udpdate
  11671. * @param data defines the data to store
  11672. * @param format defines the data format
  11673. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11674. * @param invertY defines if data must be stored with Y axis inverted
  11675. */
  11676. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11677. /**
  11678. * Update a raw cube texture
  11679. * @param texture defines the texture to udpdate
  11680. * @param data defines the data to store
  11681. * @param format defines the data format
  11682. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11683. * @param invertY defines if data must be stored with Y axis inverted
  11684. * @param compression defines the compression used (null by default)
  11685. */
  11686. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11687. /**
  11688. * Update a raw cube texture
  11689. * @param texture defines the texture to udpdate
  11690. * @param data defines the data to store
  11691. * @param format defines the data format
  11692. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11693. * @param invertY defines if data must be stored with Y axis inverted
  11694. * @param compression defines the compression used (null by default)
  11695. * @param level defines which level of the texture to update
  11696. */
  11697. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11698. /**
  11699. * Creates a new raw cube texture from a specified url
  11700. * @param url defines the url where the data is located
  11701. * @param scene defines the current scene
  11702. * @param size defines the size of the textures
  11703. * @param format defines the format of the data
  11704. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11705. * @param noMipmap defines if the engine should avoid generating the mip levels
  11706. * @param callback defines a callback used to extract texture data from loaded data
  11707. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11708. * @param onLoad defines a callback called when texture is loaded
  11709. * @param onError defines a callback called if there is an error
  11710. * @returns the cube texture as an InternalTexture
  11711. */
  11712. 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;
  11713. /**
  11714. * Creates a new raw cube texture from a specified url
  11715. * @param url defines the url where the data is located
  11716. * @param scene defines the current scene
  11717. * @param size defines the size of the textures
  11718. * @param format defines the format of the data
  11719. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11720. * @param noMipmap defines if the engine should avoid generating the mip levels
  11721. * @param callback defines a callback used to extract texture data from loaded data
  11722. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11723. * @param onLoad defines a callback called when texture is loaded
  11724. * @param onError defines a callback called if there is an error
  11725. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11726. * @param invertY defines if data must be stored with Y axis inverted
  11727. * @returns the cube texture as an InternalTexture
  11728. */
  11729. 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;
  11730. /**
  11731. * Creates a new raw 3D texture
  11732. * @param data defines the data used to create the texture
  11733. * @param width defines the width of the texture
  11734. * @param height defines the height of the texture
  11735. * @param depth defines the depth of the texture
  11736. * @param format defines the format of the texture
  11737. * @param generateMipMaps defines if the engine must generate mip levels
  11738. * @param invertY defines if data must be stored with Y axis inverted
  11739. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11740. * @param compression defines the compressed used (can be null)
  11741. * @param textureType defines the compressed used (can be null)
  11742. * @returns a new raw 3D texture (stored in an InternalTexture)
  11743. */
  11744. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11745. /**
  11746. * Update a raw 3D texture
  11747. * @param texture defines the texture to update
  11748. * @param data defines the data to store
  11749. * @param format defines the data format
  11750. * @param invertY defines if data must be stored with Y axis inverted
  11751. */
  11752. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11753. /**
  11754. * Update a raw 3D texture
  11755. * @param texture defines the texture to update
  11756. * @param data defines the data to store
  11757. * @param format defines the data format
  11758. * @param invertY defines if data must be stored with Y axis inverted
  11759. * @param compression defines the used compression (can be null)
  11760. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11761. */
  11762. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11763. /**
  11764. * Creates a new raw 2D array texture
  11765. * @param data defines the data used to create the texture
  11766. * @param width defines the width of the texture
  11767. * @param height defines the height of the texture
  11768. * @param depth defines the number of layers of the texture
  11769. * @param format defines the format of the texture
  11770. * @param generateMipMaps defines if the engine must generate mip levels
  11771. * @param invertY defines if data must be stored with Y axis inverted
  11772. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11773. * @param compression defines the compressed used (can be null)
  11774. * @param textureType defines the compressed used (can be null)
  11775. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11776. */
  11777. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11778. /**
  11779. * Update a raw 2D array texture
  11780. * @param texture defines the texture to update
  11781. * @param data defines the data to store
  11782. * @param format defines the data format
  11783. * @param invertY defines if data must be stored with Y axis inverted
  11784. */
  11785. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11786. /**
  11787. * Update a raw 2D array texture
  11788. * @param texture defines the texture to update
  11789. * @param data defines the data to store
  11790. * @param format defines the data format
  11791. * @param invertY defines if data must be stored with Y axis inverted
  11792. * @param compression defines the used compression (can be null)
  11793. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11794. */
  11795. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11796. }
  11797. }
  11798. }
  11799. declare module "babylonjs/Materials/Textures/rawTexture" {
  11800. import { Texture } from "babylonjs/Materials/Textures/texture";
  11801. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11802. import { Nullable } from "babylonjs/types";
  11803. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11804. import { Scene } from "babylonjs/scene";
  11805. /**
  11806. * Raw texture can help creating a texture directly from an array of data.
  11807. * This can be super useful if you either get the data from an uncompressed source or
  11808. * if you wish to create your texture pixel by pixel.
  11809. */
  11810. export class RawTexture extends Texture {
  11811. /**
  11812. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11813. */
  11814. format: number;
  11815. /**
  11816. * Instantiates a new RawTexture.
  11817. * Raw texture can help creating a texture directly from an array of data.
  11818. * This can be super useful if you either get the data from an uncompressed source or
  11819. * if you wish to create your texture pixel by pixel.
  11820. * @param data define the array of data to use to create the texture
  11821. * @param width define the width of the texture
  11822. * @param height define the height of the texture
  11823. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11824. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11825. * @param generateMipMaps define whether mip maps should be generated or not
  11826. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11827. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11828. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11829. */
  11830. constructor(data: ArrayBufferView, width: number, height: number,
  11831. /**
  11832. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11833. */
  11834. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11835. /**
  11836. * Updates the texture underlying data.
  11837. * @param data Define the new data of the texture
  11838. */
  11839. update(data: ArrayBufferView): void;
  11840. /**
  11841. * Creates a luminance texture from some data.
  11842. * @param data Define the texture data
  11843. * @param width Define the width of the texture
  11844. * @param height Define the height of the texture
  11845. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11846. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11847. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11848. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11849. * @returns the luminance texture
  11850. */
  11851. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11852. /**
  11853. * Creates a luminance alpha texture from some data.
  11854. * @param data Define the texture data
  11855. * @param width Define the width of the texture
  11856. * @param height Define the height of the texture
  11857. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11858. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11859. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11860. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11861. * @returns the luminance alpha texture
  11862. */
  11863. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11864. /**
  11865. * Creates an alpha texture from some data.
  11866. * @param data Define the texture data
  11867. * @param width Define the width of the texture
  11868. * @param height Define the height of the texture
  11869. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11870. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11871. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11872. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11873. * @returns the alpha texture
  11874. */
  11875. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11876. /**
  11877. * Creates a RGB texture from some data.
  11878. * @param data Define the texture data
  11879. * @param width Define the width of the texture
  11880. * @param height Define the height of the texture
  11881. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11882. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11883. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11884. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11885. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11886. * @returns the RGB alpha texture
  11887. */
  11888. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11889. /**
  11890. * Creates a RGBA texture from some data.
  11891. * @param data Define the texture data
  11892. * @param width Define the width of the texture
  11893. * @param height Define the height of the texture
  11894. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11895. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11896. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11897. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11898. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11899. * @returns the RGBA texture
  11900. */
  11901. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11902. /**
  11903. * Creates a R texture from some data.
  11904. * @param data Define the texture data
  11905. * @param width Define the width of the texture
  11906. * @param height Define the height of the texture
  11907. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11908. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11909. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11910. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11911. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11912. * @returns the R texture
  11913. */
  11914. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11915. }
  11916. }
  11917. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11918. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11919. import { IndicesArray, DataArray } from "babylonjs/types";
  11920. module "babylonjs/Engines/thinEngine" {
  11921. interface ThinEngine {
  11922. /**
  11923. * Update a dynamic index buffer
  11924. * @param indexBuffer defines the target index buffer
  11925. * @param indices defines the data to update
  11926. * @param offset defines the offset in the target index buffer where update should start
  11927. */
  11928. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11929. /**
  11930. * Updates a dynamic vertex buffer.
  11931. * @param vertexBuffer the vertex buffer to update
  11932. * @param data the data used to update the vertex buffer
  11933. * @param byteOffset the byte offset of the data
  11934. * @param byteLength the byte length of the data
  11935. */
  11936. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11937. }
  11938. }
  11939. }
  11940. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11941. import { Scene } from "babylonjs/scene";
  11942. import { ISceneComponent } from "babylonjs/sceneComponent";
  11943. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11944. module "babylonjs/abstractScene" {
  11945. interface AbstractScene {
  11946. /**
  11947. * The list of procedural textures added to the scene
  11948. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11949. */
  11950. proceduralTextures: Array<ProceduralTexture>;
  11951. }
  11952. }
  11953. /**
  11954. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11955. * in a given scene.
  11956. */
  11957. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11958. /**
  11959. * The component name helpfull to identify the component in the list of scene components.
  11960. */
  11961. readonly name: string;
  11962. /**
  11963. * The scene the component belongs to.
  11964. */
  11965. scene: Scene;
  11966. /**
  11967. * Creates a new instance of the component for the given scene
  11968. * @param scene Defines the scene to register the component in
  11969. */
  11970. constructor(scene: Scene);
  11971. /**
  11972. * Registers the component in a given scene
  11973. */
  11974. register(): void;
  11975. /**
  11976. * Rebuilds the elements related to this component in case of
  11977. * context lost for instance.
  11978. */
  11979. rebuild(): void;
  11980. /**
  11981. * Disposes the component and the associated ressources.
  11982. */
  11983. dispose(): void;
  11984. private _beforeClear;
  11985. }
  11986. }
  11987. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11988. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11989. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11990. module "babylonjs/Engines/thinEngine" {
  11991. interface ThinEngine {
  11992. /**
  11993. * Creates a new render target cube texture
  11994. * @param size defines the size of the texture
  11995. * @param options defines the options used to create the texture
  11996. * @returns a new render target cube texture stored in an InternalTexture
  11997. */
  11998. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11999. }
  12000. }
  12001. }
  12002. declare module "babylonjs/Shaders/procedural.vertex" {
  12003. /** @hidden */
  12004. export var proceduralVertexShader: {
  12005. name: string;
  12006. shader: string;
  12007. };
  12008. }
  12009. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  12010. import { Observable } from "babylonjs/Misc/observable";
  12011. import { Nullable } from "babylonjs/types";
  12012. import { Scene } from "babylonjs/scene";
  12013. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12014. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12015. import { Effect } from "babylonjs/Materials/effect";
  12016. import { Texture } from "babylonjs/Materials/Textures/texture";
  12017. import "babylonjs/Engines/Extensions/engine.renderTarget";
  12018. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  12019. import "babylonjs/Shaders/procedural.vertex";
  12020. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12021. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  12022. /**
  12023. * 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.
  12024. * This is the base class of any Procedural texture and contains most of the shareable code.
  12025. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12026. */
  12027. export class ProceduralTexture extends Texture {
  12028. /**
  12029. * Define if the texture is enabled or not (disabled texture will not render)
  12030. */
  12031. isEnabled: boolean;
  12032. /**
  12033. * Define if the texture must be cleared before rendering (default is true)
  12034. */
  12035. autoClear: boolean;
  12036. /**
  12037. * Callback called when the texture is generated
  12038. */
  12039. onGenerated: () => void;
  12040. /**
  12041. * Event raised when the texture is generated
  12042. */
  12043. onGeneratedObservable: Observable<ProceduralTexture>;
  12044. /**
  12045. * Event raised before the texture is generated
  12046. */
  12047. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12048. /**
  12049. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12050. */
  12051. nodeMaterialSource: Nullable<NodeMaterial>;
  12052. /** @hidden */
  12053. _generateMipMaps: boolean;
  12054. /** @hidden **/
  12055. _effect: Effect;
  12056. /** @hidden */
  12057. _textures: {
  12058. [key: string]: Texture;
  12059. };
  12060. /** @hidden */
  12061. protected _fallbackTexture: Nullable<Texture>;
  12062. private _size;
  12063. private _currentRefreshId;
  12064. private _frameId;
  12065. private _refreshRate;
  12066. private _vertexBuffers;
  12067. private _indexBuffer;
  12068. private _uniforms;
  12069. private _samplers;
  12070. private _fragment;
  12071. private _floats;
  12072. private _ints;
  12073. private _floatsArrays;
  12074. private _colors3;
  12075. private _colors4;
  12076. private _vectors2;
  12077. private _vectors3;
  12078. private _matrices;
  12079. private _fallbackTextureUsed;
  12080. private _fullEngine;
  12081. private _cachedDefines;
  12082. private _contentUpdateId;
  12083. private _contentData;
  12084. /**
  12085. * Instantiates a new procedural texture.
  12086. * 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.
  12087. * This is the base class of any Procedural texture and contains most of the shareable code.
  12088. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12089. * @param name Define the name of the texture
  12090. * @param size Define the size of the texture to create
  12091. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12092. * @param scene Define the scene the texture belongs to
  12093. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12094. * @param generateMipMaps Define if the texture should creates mip maps or not
  12095. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12096. * @param textureType The FBO internal texture type
  12097. */
  12098. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  12099. /**
  12100. * The effect that is created when initializing the post process.
  12101. * @returns The created effect corresponding the the postprocess.
  12102. */
  12103. getEffect(): Effect;
  12104. /**
  12105. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12106. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12107. */
  12108. getContent(): Nullable<ArrayBufferView>;
  12109. private _createIndexBuffer;
  12110. /** @hidden */
  12111. _rebuild(): void;
  12112. /**
  12113. * Resets the texture in order to recreate its associated resources.
  12114. * This can be called in case of context loss
  12115. */
  12116. reset(): void;
  12117. protected _getDefines(): string;
  12118. /**
  12119. * Is the texture ready to be used ? (rendered at least once)
  12120. * @returns true if ready, otherwise, false.
  12121. */
  12122. isReady(): boolean;
  12123. /**
  12124. * Resets the refresh counter of the texture and start bak from scratch.
  12125. * Could be useful to regenerate the texture if it is setup to render only once.
  12126. */
  12127. resetRefreshCounter(): void;
  12128. /**
  12129. * Set the fragment shader to use in order to render the texture.
  12130. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12131. */
  12132. setFragment(fragment: any): void;
  12133. /**
  12134. * Define the refresh rate of the texture or the rendering frequency.
  12135. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12136. */
  12137. get refreshRate(): number;
  12138. set refreshRate(value: number);
  12139. /** @hidden */
  12140. _shouldRender(): boolean;
  12141. /**
  12142. * Get the size the texture is rendering at.
  12143. * @returns the size (on cube texture it is always squared)
  12144. */
  12145. getRenderSize(): RenderTargetTextureSize;
  12146. /**
  12147. * Resize the texture to new value.
  12148. * @param size Define the new size the texture should have
  12149. * @param generateMipMaps Define whether the new texture should create mip maps
  12150. */
  12151. resize(size: number, generateMipMaps: boolean): void;
  12152. private _checkUniform;
  12153. /**
  12154. * Set a texture in the shader program used to render.
  12155. * @param name Define the name of the uniform samplers as defined in the shader
  12156. * @param texture Define the texture to bind to this sampler
  12157. * @return the texture itself allowing "fluent" like uniform updates
  12158. */
  12159. setTexture(name: string, texture: Texture): ProceduralTexture;
  12160. /**
  12161. * Set a float in the shader.
  12162. * @param name Define the name of the uniform as defined in the shader
  12163. * @param value Define the value to give to the uniform
  12164. * @return the texture itself allowing "fluent" like uniform updates
  12165. */
  12166. setFloat(name: string, value: number): ProceduralTexture;
  12167. /**
  12168. * Set a int in the shader.
  12169. * @param name Define the name of the uniform as defined in the shader
  12170. * @param value Define the value to give to the uniform
  12171. * @return the texture itself allowing "fluent" like uniform updates
  12172. */
  12173. setInt(name: string, value: number): ProceduralTexture;
  12174. /**
  12175. * Set an array of floats in the shader.
  12176. * @param name Define the name of the uniform as defined in the shader
  12177. * @param value Define the value to give to the uniform
  12178. * @return the texture itself allowing "fluent" like uniform updates
  12179. */
  12180. setFloats(name: string, value: number[]): ProceduralTexture;
  12181. /**
  12182. * Set a vec3 in the shader from a Color3.
  12183. * @param name Define the name of the uniform as defined in the shader
  12184. * @param value Define the value to give to the uniform
  12185. * @return the texture itself allowing "fluent" like uniform updates
  12186. */
  12187. setColor3(name: string, value: Color3): ProceduralTexture;
  12188. /**
  12189. * Set a vec4 in the shader from a Color4.
  12190. * @param name Define the name of the uniform as defined in the shader
  12191. * @param value Define the value to give to the uniform
  12192. * @return the texture itself allowing "fluent" like uniform updates
  12193. */
  12194. setColor4(name: string, value: Color4): ProceduralTexture;
  12195. /**
  12196. * Set a vec2 in the shader from a Vector2.
  12197. * @param name Define the name of the uniform as defined in the shader
  12198. * @param value Define the value to give to the uniform
  12199. * @return the texture itself allowing "fluent" like uniform updates
  12200. */
  12201. setVector2(name: string, value: Vector2): ProceduralTexture;
  12202. /**
  12203. * Set a vec3 in the shader from a Vector3.
  12204. * @param name Define the name of the uniform as defined in the shader
  12205. * @param value Define the value to give to the uniform
  12206. * @return the texture itself allowing "fluent" like uniform updates
  12207. */
  12208. setVector3(name: string, value: Vector3): ProceduralTexture;
  12209. /**
  12210. * Set a mat4 in the shader from a MAtrix.
  12211. * @param name Define the name of the uniform as defined in the shader
  12212. * @param value Define the value to give to the uniform
  12213. * @return the texture itself allowing "fluent" like uniform updates
  12214. */
  12215. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12216. /**
  12217. * Render the texture to its associated render target.
  12218. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12219. */
  12220. render(useCameraPostProcess?: boolean): void;
  12221. /**
  12222. * Clone the texture.
  12223. * @returns the cloned texture
  12224. */
  12225. clone(): ProceduralTexture;
  12226. /**
  12227. * Dispose the texture and release its asoociated resources.
  12228. */
  12229. dispose(): void;
  12230. }
  12231. }
  12232. declare module "babylonjs/Particles/baseParticleSystem" {
  12233. import { Nullable } from "babylonjs/types";
  12234. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12236. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12237. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12238. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12239. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12240. import { Color4 } from "babylonjs/Maths/math.color";
  12241. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12242. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12243. import { Animation } from "babylonjs/Animations/animation";
  12244. import { Scene } from "babylonjs/scene";
  12245. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12246. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12247. /**
  12248. * This represents the base class for particle system in Babylon.
  12249. * 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.
  12250. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12251. * @example https://doc.babylonjs.com/babylon101/particles
  12252. */
  12253. export class BaseParticleSystem {
  12254. /**
  12255. * Source color is added to the destination color without alpha affecting the result
  12256. */
  12257. static BLENDMODE_ONEONE: number;
  12258. /**
  12259. * Blend current color and particle color using particle’s alpha
  12260. */
  12261. static BLENDMODE_STANDARD: number;
  12262. /**
  12263. * Add current color and particle color multiplied by particle’s alpha
  12264. */
  12265. static BLENDMODE_ADD: number;
  12266. /**
  12267. * Multiply current color with particle color
  12268. */
  12269. static BLENDMODE_MULTIPLY: number;
  12270. /**
  12271. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12272. */
  12273. static BLENDMODE_MULTIPLYADD: number;
  12274. /**
  12275. * List of animations used by the particle system.
  12276. */
  12277. animations: Animation[];
  12278. /**
  12279. * Gets or sets the unique id of the particle system
  12280. */
  12281. uniqueId: number;
  12282. /**
  12283. * The id of the Particle system.
  12284. */
  12285. id: string;
  12286. /**
  12287. * The friendly name of the Particle system.
  12288. */
  12289. name: string;
  12290. /**
  12291. * Snippet ID if the particle system was created from the snippet server
  12292. */
  12293. snippetId: string;
  12294. /**
  12295. * The rendering group used by the Particle system to chose when to render.
  12296. */
  12297. renderingGroupId: number;
  12298. /**
  12299. * The emitter represents the Mesh or position we are attaching the particle system to.
  12300. */
  12301. emitter: Nullable<AbstractMesh | Vector3>;
  12302. /**
  12303. * The maximum number of particles to emit per frame
  12304. */
  12305. emitRate: number;
  12306. /**
  12307. * If you want to launch only a few particles at once, that can be done, as well.
  12308. */
  12309. manualEmitCount: number;
  12310. /**
  12311. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12312. */
  12313. updateSpeed: number;
  12314. /**
  12315. * The amount of time the particle system is running (depends of the overall update speed).
  12316. */
  12317. targetStopDuration: number;
  12318. /**
  12319. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12320. */
  12321. disposeOnStop: boolean;
  12322. /**
  12323. * Minimum power of emitting particles.
  12324. */
  12325. minEmitPower: number;
  12326. /**
  12327. * Maximum power of emitting particles.
  12328. */
  12329. maxEmitPower: number;
  12330. /**
  12331. * Minimum life time of emitting particles.
  12332. */
  12333. minLifeTime: number;
  12334. /**
  12335. * Maximum life time of emitting particles.
  12336. */
  12337. maxLifeTime: number;
  12338. /**
  12339. * Minimum Size of emitting particles.
  12340. */
  12341. minSize: number;
  12342. /**
  12343. * Maximum Size of emitting particles.
  12344. */
  12345. maxSize: number;
  12346. /**
  12347. * Minimum scale of emitting particles on X axis.
  12348. */
  12349. minScaleX: number;
  12350. /**
  12351. * Maximum scale of emitting particles on X axis.
  12352. */
  12353. maxScaleX: number;
  12354. /**
  12355. * Minimum scale of emitting particles on Y axis.
  12356. */
  12357. minScaleY: number;
  12358. /**
  12359. * Maximum scale of emitting particles on Y axis.
  12360. */
  12361. maxScaleY: number;
  12362. /**
  12363. * Gets or sets the minimal initial rotation in radians.
  12364. */
  12365. minInitialRotation: number;
  12366. /**
  12367. * Gets or sets the maximal initial rotation in radians.
  12368. */
  12369. maxInitialRotation: number;
  12370. /**
  12371. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12372. */
  12373. minAngularSpeed: number;
  12374. /**
  12375. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12376. */
  12377. maxAngularSpeed: number;
  12378. /**
  12379. * The texture used to render each particle. (this can be a spritesheet)
  12380. */
  12381. particleTexture: Nullable<BaseTexture>;
  12382. /**
  12383. * The layer mask we are rendering the particles through.
  12384. */
  12385. layerMask: number;
  12386. /**
  12387. * This can help using your own shader to render the particle system.
  12388. * The according effect will be created
  12389. */
  12390. customShader: any;
  12391. /**
  12392. * By default particle system starts as soon as they are created. This prevents the
  12393. * automatic start to happen and let you decide when to start emitting particles.
  12394. */
  12395. preventAutoStart: boolean;
  12396. private _noiseTexture;
  12397. /**
  12398. * Gets or sets a texture used to add random noise to particle positions
  12399. */
  12400. get noiseTexture(): Nullable<ProceduralTexture>;
  12401. set noiseTexture(value: Nullable<ProceduralTexture>);
  12402. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12403. noiseStrength: Vector3;
  12404. /**
  12405. * Callback triggered when the particle animation is ending.
  12406. */
  12407. onAnimationEnd: Nullable<() => void>;
  12408. /**
  12409. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12410. */
  12411. blendMode: number;
  12412. /**
  12413. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12414. * to override the particles.
  12415. */
  12416. forceDepthWrite: boolean;
  12417. /** 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 */
  12418. preWarmCycles: number;
  12419. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12420. preWarmStepOffset: number;
  12421. /**
  12422. * 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)
  12423. */
  12424. spriteCellChangeSpeed: number;
  12425. /**
  12426. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12427. */
  12428. startSpriteCellID: number;
  12429. /**
  12430. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12431. */
  12432. endSpriteCellID: number;
  12433. /**
  12434. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12435. */
  12436. spriteCellWidth: number;
  12437. /**
  12438. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12439. */
  12440. spriteCellHeight: number;
  12441. /**
  12442. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12443. */
  12444. spriteRandomStartCell: boolean;
  12445. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12446. translationPivot: Vector2;
  12447. /** @hidden */
  12448. protected _isAnimationSheetEnabled: boolean;
  12449. /**
  12450. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12451. */
  12452. beginAnimationOnStart: boolean;
  12453. /**
  12454. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12455. */
  12456. beginAnimationFrom: number;
  12457. /**
  12458. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12459. */
  12460. beginAnimationTo: number;
  12461. /**
  12462. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12463. */
  12464. beginAnimationLoop: boolean;
  12465. /**
  12466. * Gets or sets a world offset applied to all particles
  12467. */
  12468. worldOffset: Vector3;
  12469. /**
  12470. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12471. */
  12472. get isAnimationSheetEnabled(): boolean;
  12473. set isAnimationSheetEnabled(value: boolean);
  12474. /**
  12475. * Get hosting scene
  12476. * @returns the scene
  12477. */
  12478. getScene(): Nullable<Scene>;
  12479. /**
  12480. * You can use gravity if you want to give an orientation to your particles.
  12481. */
  12482. gravity: Vector3;
  12483. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12484. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12485. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12486. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12487. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12488. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12489. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12490. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12491. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12492. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12493. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12494. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12495. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12496. /**
  12497. * Defines the delay in milliseconds before starting the system (0 by default)
  12498. */
  12499. startDelay: number;
  12500. /**
  12501. * Gets the current list of drag gradients.
  12502. * You must use addDragGradient and removeDragGradient to udpate this list
  12503. * @returns the list of drag gradients
  12504. */
  12505. getDragGradients(): Nullable<Array<FactorGradient>>;
  12506. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12507. limitVelocityDamping: number;
  12508. /**
  12509. * Gets the current list of limit velocity gradients.
  12510. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12511. * @returns the list of limit velocity gradients
  12512. */
  12513. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12514. /**
  12515. * Gets the current list of color gradients.
  12516. * You must use addColorGradient and removeColorGradient to udpate this list
  12517. * @returns the list of color gradients
  12518. */
  12519. getColorGradients(): Nullable<Array<ColorGradient>>;
  12520. /**
  12521. * Gets the current list of size gradients.
  12522. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12523. * @returns the list of size gradients
  12524. */
  12525. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12526. /**
  12527. * Gets the current list of color remap gradients.
  12528. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12529. * @returns the list of color remap gradients
  12530. */
  12531. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12532. /**
  12533. * Gets the current list of alpha remap gradients.
  12534. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12535. * @returns the list of alpha remap gradients
  12536. */
  12537. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12538. /**
  12539. * Gets the current list of life time gradients.
  12540. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12541. * @returns the list of life time gradients
  12542. */
  12543. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12544. /**
  12545. * Gets the current list of angular speed gradients.
  12546. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12547. * @returns the list of angular speed gradients
  12548. */
  12549. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12550. /**
  12551. * Gets the current list of velocity gradients.
  12552. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12553. * @returns the list of velocity gradients
  12554. */
  12555. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12556. /**
  12557. * Gets the current list of start size gradients.
  12558. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12559. * @returns the list of start size gradients
  12560. */
  12561. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12562. /**
  12563. * Gets the current list of emit rate gradients.
  12564. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12565. * @returns the list of emit rate gradients
  12566. */
  12567. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12568. /**
  12569. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12570. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12571. */
  12572. get direction1(): Vector3;
  12573. set direction1(value: Vector3);
  12574. /**
  12575. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12576. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12577. */
  12578. get direction2(): Vector3;
  12579. set direction2(value: Vector3);
  12580. /**
  12581. * 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.
  12582. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12583. */
  12584. get minEmitBox(): Vector3;
  12585. set minEmitBox(value: Vector3);
  12586. /**
  12587. * 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.
  12588. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12589. */
  12590. get maxEmitBox(): Vector3;
  12591. set maxEmitBox(value: Vector3);
  12592. /**
  12593. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12594. */
  12595. color1: Color4;
  12596. /**
  12597. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12598. */
  12599. color2: Color4;
  12600. /**
  12601. * Color the particle will have at the end of its lifetime
  12602. */
  12603. colorDead: Color4;
  12604. /**
  12605. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12606. */
  12607. textureMask: Color4;
  12608. /**
  12609. * The particle emitter type defines the emitter used by the particle system.
  12610. * It can be for example box, sphere, or cone...
  12611. */
  12612. particleEmitterType: IParticleEmitterType;
  12613. /** @hidden */
  12614. _isSubEmitter: boolean;
  12615. /**
  12616. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12617. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12618. */
  12619. billboardMode: number;
  12620. protected _isBillboardBased: boolean;
  12621. /**
  12622. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12623. */
  12624. get isBillboardBased(): boolean;
  12625. set isBillboardBased(value: boolean);
  12626. /**
  12627. * The scene the particle system belongs to.
  12628. */
  12629. protected _scene: Nullable<Scene>;
  12630. /**
  12631. * The engine the particle system belongs to.
  12632. */
  12633. protected _engine: ThinEngine;
  12634. /**
  12635. * Local cache of defines for image processing.
  12636. */
  12637. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12638. /**
  12639. * Default configuration related to image processing available in the standard Material.
  12640. */
  12641. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12642. /**
  12643. * Gets the image processing configuration used either in this material.
  12644. */
  12645. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12646. /**
  12647. * Sets the Default image processing configuration used either in the this material.
  12648. *
  12649. * If sets to null, the scene one is in use.
  12650. */
  12651. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12652. /**
  12653. * Attaches a new image processing configuration to the Standard Material.
  12654. * @param configuration
  12655. */
  12656. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12657. /** @hidden */
  12658. protected _reset(): void;
  12659. /** @hidden */
  12660. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12661. /**
  12662. * Instantiates a particle system.
  12663. * 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.
  12664. * @param name The name of the particle system
  12665. */
  12666. constructor(name: string);
  12667. /**
  12668. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12669. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12670. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12671. * @returns the emitter
  12672. */
  12673. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12674. /**
  12675. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12676. * @param radius The radius of the hemisphere to emit from
  12677. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12678. * @returns the emitter
  12679. */
  12680. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12681. /**
  12682. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12683. * @param radius The radius of the sphere to emit from
  12684. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12685. * @returns the emitter
  12686. */
  12687. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12688. /**
  12689. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12690. * @param radius The radius of the sphere to emit from
  12691. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12692. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12693. * @returns the emitter
  12694. */
  12695. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12696. /**
  12697. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12698. * @param radius The radius of the emission cylinder
  12699. * @param height The height of the emission cylinder
  12700. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12701. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12702. * @returns the emitter
  12703. */
  12704. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12705. /**
  12706. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12707. * @param radius The radius of the cylinder to emit from
  12708. * @param height The height of the emission cylinder
  12709. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12710. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12711. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12712. * @returns the emitter
  12713. */
  12714. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12715. /**
  12716. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12717. * @param radius The radius of the cone to emit from
  12718. * @param angle The base angle of the cone
  12719. * @returns the emitter
  12720. */
  12721. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12722. /**
  12723. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12724. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12725. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12726. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12727. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12728. * @returns the emitter
  12729. */
  12730. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12731. }
  12732. }
  12733. declare module "babylonjs/Particles/subEmitter" {
  12734. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12735. import { Scene } from "babylonjs/scene";
  12736. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12737. /**
  12738. * Type of sub emitter
  12739. */
  12740. export enum SubEmitterType {
  12741. /**
  12742. * Attached to the particle over it's lifetime
  12743. */
  12744. ATTACHED = 0,
  12745. /**
  12746. * Created when the particle dies
  12747. */
  12748. END = 1
  12749. }
  12750. /**
  12751. * Sub emitter class used to emit particles from an existing particle
  12752. */
  12753. export class SubEmitter {
  12754. /**
  12755. * the particle system to be used by the sub emitter
  12756. */
  12757. particleSystem: ParticleSystem;
  12758. /**
  12759. * Type of the submitter (Default: END)
  12760. */
  12761. type: SubEmitterType;
  12762. /**
  12763. * 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)
  12764. * Note: This only is supported when using an emitter of type Mesh
  12765. */
  12766. inheritDirection: boolean;
  12767. /**
  12768. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12769. */
  12770. inheritedVelocityAmount: number;
  12771. /**
  12772. * Creates a sub emitter
  12773. * @param particleSystem the particle system to be used by the sub emitter
  12774. */
  12775. constructor(
  12776. /**
  12777. * the particle system to be used by the sub emitter
  12778. */
  12779. particleSystem: ParticleSystem);
  12780. /**
  12781. * Clones the sub emitter
  12782. * @returns the cloned sub emitter
  12783. */
  12784. clone(): SubEmitter;
  12785. /**
  12786. * Serialize current object to a JSON object
  12787. * @returns the serialized object
  12788. */
  12789. serialize(): any;
  12790. /** @hidden */
  12791. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12792. /**
  12793. * Creates a new SubEmitter from a serialized JSON version
  12794. * @param serializationObject defines the JSON object to read from
  12795. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12796. * @param rootUrl defines the rootUrl for data loading
  12797. * @returns a new SubEmitter
  12798. */
  12799. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12800. /** Release associated resources */
  12801. dispose(): void;
  12802. }
  12803. }
  12804. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12805. /** @hidden */
  12806. export var imageProcessingDeclaration: {
  12807. name: string;
  12808. shader: string;
  12809. };
  12810. }
  12811. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12812. /** @hidden */
  12813. export var imageProcessingFunctions: {
  12814. name: string;
  12815. shader: string;
  12816. };
  12817. }
  12818. declare module "babylonjs/Shaders/particles.fragment" {
  12819. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12820. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12821. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12822. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12823. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12824. /** @hidden */
  12825. export var particlesPixelShader: {
  12826. name: string;
  12827. shader: string;
  12828. };
  12829. }
  12830. declare module "babylonjs/Shaders/particles.vertex" {
  12831. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12832. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12833. /** @hidden */
  12834. export var particlesVertexShader: {
  12835. name: string;
  12836. shader: string;
  12837. };
  12838. }
  12839. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12840. import { Nullable } from "babylonjs/types";
  12841. import { Plane } from "babylonjs/Maths/math";
  12842. /**
  12843. * Interface used to define entities containing multiple clip planes
  12844. */
  12845. export interface IClipPlanesHolder {
  12846. /**
  12847. * Gets or sets the active clipplane 1
  12848. */
  12849. clipPlane: Nullable<Plane>;
  12850. /**
  12851. * Gets or sets the active clipplane 2
  12852. */
  12853. clipPlane2: Nullable<Plane>;
  12854. /**
  12855. * Gets or sets the active clipplane 3
  12856. */
  12857. clipPlane3: Nullable<Plane>;
  12858. /**
  12859. * Gets or sets the active clipplane 4
  12860. */
  12861. clipPlane4: Nullable<Plane>;
  12862. /**
  12863. * Gets or sets the active clipplane 5
  12864. */
  12865. clipPlane5: Nullable<Plane>;
  12866. /**
  12867. * Gets or sets the active clipplane 6
  12868. */
  12869. clipPlane6: Nullable<Plane>;
  12870. }
  12871. }
  12872. declare module "babylonjs/Materials/thinMaterialHelper" {
  12873. import { Effect } from "babylonjs/Materials/effect";
  12874. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12875. /**
  12876. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12877. *
  12878. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12879. *
  12880. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12881. */
  12882. export class ThinMaterialHelper {
  12883. /**
  12884. * Binds the clip plane information from the holder to the effect.
  12885. * @param effect The effect we are binding the data to
  12886. * @param holder The entity containing the clip plane information
  12887. */
  12888. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12889. }
  12890. }
  12891. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12892. module "babylonjs/Engines/thinEngine" {
  12893. interface ThinEngine {
  12894. /**
  12895. * Sets alpha constants used by some alpha blending modes
  12896. * @param r defines the red component
  12897. * @param g defines the green component
  12898. * @param b defines the blue component
  12899. * @param a defines the alpha component
  12900. */
  12901. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12902. /**
  12903. * Sets the current alpha mode
  12904. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12905. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12906. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12907. */
  12908. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12909. /**
  12910. * Gets the current alpha mode
  12911. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12912. * @returns the current alpha mode
  12913. */
  12914. getAlphaMode(): number;
  12915. /**
  12916. * Sets the current alpha equation
  12917. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12918. */
  12919. setAlphaEquation(equation: number): void;
  12920. /**
  12921. * Gets the current alpha equation.
  12922. * @returns the current alpha equation
  12923. */
  12924. getAlphaEquation(): number;
  12925. }
  12926. }
  12927. }
  12928. declare module "babylonjs/Particles/particleSystem" {
  12929. import { Nullable } from "babylonjs/types";
  12930. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12931. import { Observable } from "babylonjs/Misc/observable";
  12932. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12933. import { Effect } from "babylonjs/Materials/effect";
  12934. import { IDisposable } from "babylonjs/scene";
  12935. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12936. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12937. import { Particle } from "babylonjs/Particles/particle";
  12938. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12939. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12940. import "babylonjs/Shaders/particles.fragment";
  12941. import "babylonjs/Shaders/particles.vertex";
  12942. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12943. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12944. import "babylonjs/Engines/Extensions/engine.alpha";
  12945. import { Scene } from "babylonjs/scene";
  12946. /**
  12947. * This represents a particle system in Babylon.
  12948. * 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.
  12949. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12950. * @example https://doc.babylonjs.com/babylon101/particles
  12951. */
  12952. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12953. /**
  12954. * Billboard mode will only apply to Y axis
  12955. */
  12956. static readonly BILLBOARDMODE_Y: number;
  12957. /**
  12958. * Billboard mode will apply to all axes
  12959. */
  12960. static readonly BILLBOARDMODE_ALL: number;
  12961. /**
  12962. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12963. */
  12964. static readonly BILLBOARDMODE_STRETCHED: number;
  12965. /**
  12966. * This function can be defined to provide custom update for active particles.
  12967. * This function will be called instead of regular update (age, position, color, etc.).
  12968. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12969. */
  12970. updateFunction: (particles: Particle[]) => void;
  12971. private _emitterWorldMatrix;
  12972. /**
  12973. * This function can be defined to specify initial direction for every new particle.
  12974. * It by default use the emitterType defined function
  12975. */
  12976. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12977. /**
  12978. * This function can be defined to specify initial position for every new particle.
  12979. * It by default use the emitterType defined function
  12980. */
  12981. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12982. /**
  12983. * @hidden
  12984. */
  12985. _inheritedVelocityOffset: Vector3;
  12986. /**
  12987. * An event triggered when the system is disposed
  12988. */
  12989. onDisposeObservable: Observable<IParticleSystem>;
  12990. /**
  12991. * An event triggered when the system is stopped
  12992. */
  12993. onStoppedObservable: Observable<IParticleSystem>;
  12994. private _onDisposeObserver;
  12995. /**
  12996. * Sets a callback that will be triggered when the system is disposed
  12997. */
  12998. set onDispose(callback: () => void);
  12999. private _particles;
  13000. private _epsilon;
  13001. private _capacity;
  13002. private _stockParticles;
  13003. private _newPartsExcess;
  13004. private _vertexData;
  13005. private _vertexBuffer;
  13006. private _vertexBuffers;
  13007. private _spriteBuffer;
  13008. private _indexBuffer;
  13009. private _effect;
  13010. private _customEffect;
  13011. private _cachedDefines;
  13012. private _scaledColorStep;
  13013. private _colorDiff;
  13014. private _scaledDirection;
  13015. private _scaledGravity;
  13016. private _currentRenderId;
  13017. private _alive;
  13018. private _useInstancing;
  13019. private _vertexArrayObject;
  13020. private _started;
  13021. private _stopped;
  13022. private _actualFrame;
  13023. private _scaledUpdateSpeed;
  13024. private _vertexBufferSize;
  13025. /** @hidden */
  13026. _currentEmitRateGradient: Nullable<FactorGradient>;
  13027. /** @hidden */
  13028. _currentEmitRate1: number;
  13029. /** @hidden */
  13030. _currentEmitRate2: number;
  13031. /** @hidden */
  13032. _currentStartSizeGradient: Nullable<FactorGradient>;
  13033. /** @hidden */
  13034. _currentStartSize1: number;
  13035. /** @hidden */
  13036. _currentStartSize2: number;
  13037. private readonly _rawTextureWidth;
  13038. private _rampGradientsTexture;
  13039. private _useRampGradients;
  13040. /** Gets or sets a matrix to use to compute projection */
  13041. defaultProjectionMatrix: Matrix;
  13042. /** Gets or sets a matrix to use to compute view */
  13043. defaultViewMatrix: Matrix;
  13044. /** Gets or sets a boolean indicating that ramp gradients must be used
  13045. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13046. */
  13047. get useRampGradients(): boolean;
  13048. set useRampGradients(value: boolean);
  13049. /**
  13050. * 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.
  13051. * 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: [])
  13052. */
  13053. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13054. private _subEmitters;
  13055. /**
  13056. * @hidden
  13057. * If the particle systems emitter should be disposed when the particle system is disposed
  13058. */
  13059. _disposeEmitterOnDispose: boolean;
  13060. /**
  13061. * The current active Sub-systems, this property is used by the root particle system only.
  13062. */
  13063. activeSubSystems: Array<ParticleSystem>;
  13064. /**
  13065. * Specifies if the particles are updated in emitter local space or world space
  13066. */
  13067. isLocal: boolean;
  13068. private _rootParticleSystem;
  13069. /**
  13070. * Gets the current list of active particles
  13071. */
  13072. get particles(): Particle[];
  13073. /**
  13074. * Gets the number of particles active at the same time.
  13075. * @returns The number of active particles.
  13076. */
  13077. getActiveCount(): number;
  13078. /**
  13079. * Returns the string "ParticleSystem"
  13080. * @returns a string containing the class name
  13081. */
  13082. getClassName(): string;
  13083. /**
  13084. * Gets a boolean indicating that the system is stopping
  13085. * @returns true if the system is currently stopping
  13086. */
  13087. isStopping(): boolean;
  13088. /**
  13089. * Gets the custom effect used to render the particles
  13090. * @param blendMode Blend mode for which the effect should be retrieved
  13091. * @returns The effect
  13092. */
  13093. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13094. /**
  13095. * Sets the custom effect used to render the particles
  13096. * @param effect The effect to set
  13097. * @param blendMode Blend mode for which the effect should be set
  13098. */
  13099. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13100. /** @hidden */
  13101. private _onBeforeDrawParticlesObservable;
  13102. /**
  13103. * Observable that will be called just before the particles are drawn
  13104. */
  13105. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13106. /**
  13107. * Gets the name of the particle vertex shader
  13108. */
  13109. get vertexShaderName(): string;
  13110. /**
  13111. * Instantiates a particle system.
  13112. * 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.
  13113. * @param name The name of the particle system
  13114. * @param capacity The max number of particles alive at the same time
  13115. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13116. * @param customEffect a custom effect used to change the way particles are rendered by default
  13117. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13118. * @param epsilon Offset used to render the particles
  13119. */
  13120. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13121. private _addFactorGradient;
  13122. private _removeFactorGradient;
  13123. /**
  13124. * Adds a new life time gradient
  13125. * @param gradient defines the gradient to use (between 0 and 1)
  13126. * @param factor defines the life time factor to affect to the specified gradient
  13127. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13128. * @returns the current particle system
  13129. */
  13130. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13131. /**
  13132. * Remove a specific life time gradient
  13133. * @param gradient defines the gradient to remove
  13134. * @returns the current particle system
  13135. */
  13136. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13137. /**
  13138. * Adds a new size gradient
  13139. * @param gradient defines the gradient to use (between 0 and 1)
  13140. * @param factor defines the size factor to affect to the specified gradient
  13141. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13142. * @returns the current particle system
  13143. */
  13144. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13145. /**
  13146. * Remove a specific size gradient
  13147. * @param gradient defines the gradient to remove
  13148. * @returns the current particle system
  13149. */
  13150. removeSizeGradient(gradient: number): IParticleSystem;
  13151. /**
  13152. * Adds a new color remap gradient
  13153. * @param gradient defines the gradient to use (between 0 and 1)
  13154. * @param min defines the color remap minimal range
  13155. * @param max defines the color remap maximal range
  13156. * @returns the current particle system
  13157. */
  13158. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13159. /**
  13160. * Remove a specific color remap gradient
  13161. * @param gradient defines the gradient to remove
  13162. * @returns the current particle system
  13163. */
  13164. removeColorRemapGradient(gradient: number): IParticleSystem;
  13165. /**
  13166. * Adds a new alpha remap gradient
  13167. * @param gradient defines the gradient to use (between 0 and 1)
  13168. * @param min defines the alpha remap minimal range
  13169. * @param max defines the alpha remap maximal range
  13170. * @returns the current particle system
  13171. */
  13172. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13173. /**
  13174. * Remove a specific alpha remap gradient
  13175. * @param gradient defines the gradient to remove
  13176. * @returns the current particle system
  13177. */
  13178. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13179. /**
  13180. * Adds a new angular speed gradient
  13181. * @param gradient defines the gradient to use (between 0 and 1)
  13182. * @param factor defines the angular speed to affect to the specified gradient
  13183. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13184. * @returns the current particle system
  13185. */
  13186. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13187. /**
  13188. * Remove a specific angular speed gradient
  13189. * @param gradient defines the gradient to remove
  13190. * @returns the current particle system
  13191. */
  13192. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13193. /**
  13194. * Adds a new velocity gradient
  13195. * @param gradient defines the gradient to use (between 0 and 1)
  13196. * @param factor defines the velocity to affect to the specified gradient
  13197. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13198. * @returns the current particle system
  13199. */
  13200. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13201. /**
  13202. * Remove a specific velocity gradient
  13203. * @param gradient defines the gradient to remove
  13204. * @returns the current particle system
  13205. */
  13206. removeVelocityGradient(gradient: number): IParticleSystem;
  13207. /**
  13208. * Adds a new limit velocity gradient
  13209. * @param gradient defines the gradient to use (between 0 and 1)
  13210. * @param factor defines the limit velocity value to affect to the specified gradient
  13211. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13212. * @returns the current particle system
  13213. */
  13214. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13215. /**
  13216. * Remove a specific limit velocity gradient
  13217. * @param gradient defines the gradient to remove
  13218. * @returns the current particle system
  13219. */
  13220. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13221. /**
  13222. * Adds a new drag gradient
  13223. * @param gradient defines the gradient to use (between 0 and 1)
  13224. * @param factor defines the drag value to affect to the specified gradient
  13225. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13226. * @returns the current particle system
  13227. */
  13228. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13229. /**
  13230. * Remove a specific drag gradient
  13231. * @param gradient defines the gradient to remove
  13232. * @returns the current particle system
  13233. */
  13234. removeDragGradient(gradient: number): IParticleSystem;
  13235. /**
  13236. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13237. * @param gradient defines the gradient to use (between 0 and 1)
  13238. * @param factor defines the emit rate value to affect to the specified gradient
  13239. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13240. * @returns the current particle system
  13241. */
  13242. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13243. /**
  13244. * Remove a specific emit rate gradient
  13245. * @param gradient defines the gradient to remove
  13246. * @returns the current particle system
  13247. */
  13248. removeEmitRateGradient(gradient: number): IParticleSystem;
  13249. /**
  13250. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13251. * @param gradient defines the gradient to use (between 0 and 1)
  13252. * @param factor defines the start size value to affect to the specified gradient
  13253. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13254. * @returns the current particle system
  13255. */
  13256. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13257. /**
  13258. * Remove a specific start size gradient
  13259. * @param gradient defines the gradient to remove
  13260. * @returns the current particle system
  13261. */
  13262. removeStartSizeGradient(gradient: number): IParticleSystem;
  13263. private _createRampGradientTexture;
  13264. /**
  13265. * Gets the current list of ramp gradients.
  13266. * You must use addRampGradient and removeRampGradient to udpate this list
  13267. * @returns the list of ramp gradients
  13268. */
  13269. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13270. /** Force the system to rebuild all gradients that need to be resync */
  13271. forceRefreshGradients(): void;
  13272. private _syncRampGradientTexture;
  13273. /**
  13274. * Adds a new ramp gradient used to remap particle colors
  13275. * @param gradient defines the gradient to use (between 0 and 1)
  13276. * @param color defines the color to affect to the specified gradient
  13277. * @returns the current particle system
  13278. */
  13279. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13280. /**
  13281. * Remove a specific ramp gradient
  13282. * @param gradient defines the gradient to remove
  13283. * @returns the current particle system
  13284. */
  13285. removeRampGradient(gradient: number): ParticleSystem;
  13286. /**
  13287. * Adds a new color gradient
  13288. * @param gradient defines the gradient to use (between 0 and 1)
  13289. * @param color1 defines the color to affect to the specified gradient
  13290. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13291. * @returns this particle system
  13292. */
  13293. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13294. /**
  13295. * Remove a specific color gradient
  13296. * @param gradient defines the gradient to remove
  13297. * @returns this particle system
  13298. */
  13299. removeColorGradient(gradient: number): IParticleSystem;
  13300. private _fetchR;
  13301. protected _reset(): void;
  13302. private _resetEffect;
  13303. private _createVertexBuffers;
  13304. private _createIndexBuffer;
  13305. /**
  13306. * Gets the maximum number of particles active at the same time.
  13307. * @returns The max number of active particles.
  13308. */
  13309. getCapacity(): number;
  13310. /**
  13311. * Gets whether there are still active particles in the system.
  13312. * @returns True if it is alive, otherwise false.
  13313. */
  13314. isAlive(): boolean;
  13315. /**
  13316. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13317. * @returns True if it has been started, otherwise false.
  13318. */
  13319. isStarted(): boolean;
  13320. private _prepareSubEmitterInternalArray;
  13321. /**
  13322. * Starts the particle system and begins to emit
  13323. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13324. */
  13325. start(delay?: number): void;
  13326. /**
  13327. * Stops the particle system.
  13328. * @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.
  13329. */
  13330. stop(stopSubEmitters?: boolean): void;
  13331. /**
  13332. * Remove all active particles
  13333. */
  13334. reset(): void;
  13335. /**
  13336. * @hidden (for internal use only)
  13337. */
  13338. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13339. /**
  13340. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13341. * Its lifetime will start back at 0.
  13342. */
  13343. recycleParticle: (particle: Particle) => void;
  13344. private _stopSubEmitters;
  13345. private _createParticle;
  13346. private _removeFromRoot;
  13347. private _emitFromParticle;
  13348. private _update;
  13349. /** @hidden */
  13350. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13351. /** @hidden */
  13352. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13353. /**
  13354. * Fill the defines array according to the current settings of the particle system
  13355. * @param defines Array to be updated
  13356. * @param blendMode blend mode to take into account when updating the array
  13357. */
  13358. fillDefines(defines: Array<string>, blendMode: number): void;
  13359. /**
  13360. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13361. * @param uniforms Uniforms array to fill
  13362. * @param attributes Attributes array to fill
  13363. * @param samplers Samplers array to fill
  13364. */
  13365. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13366. /** @hidden */
  13367. private _getEffect;
  13368. /**
  13369. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13370. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13371. */
  13372. animate(preWarmOnly?: boolean): void;
  13373. private _appendParticleVertices;
  13374. /**
  13375. * Rebuilds the particle system.
  13376. */
  13377. rebuild(): void;
  13378. /**
  13379. * Is this system ready to be used/rendered
  13380. * @return true if the system is ready
  13381. */
  13382. isReady(): boolean;
  13383. private _render;
  13384. /**
  13385. * Renders the particle system in its current state.
  13386. * @returns the current number of particles
  13387. */
  13388. render(): number;
  13389. /**
  13390. * Disposes the particle system and free the associated resources
  13391. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13392. */
  13393. dispose(disposeTexture?: boolean): void;
  13394. /**
  13395. * Clones the particle system.
  13396. * @param name The name of the cloned object
  13397. * @param newEmitter The new emitter to use
  13398. * @returns the cloned particle system
  13399. */
  13400. clone(name: string, newEmitter: any): ParticleSystem;
  13401. /**
  13402. * Serializes the particle system to a JSON object
  13403. * @param serializeTexture defines if the texture must be serialized as well
  13404. * @returns the JSON object
  13405. */
  13406. serialize(serializeTexture?: boolean): any;
  13407. /** @hidden */
  13408. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13409. /** @hidden */
  13410. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13411. /**
  13412. * Parses a JSON object to create a particle system.
  13413. * @param parsedParticleSystem The JSON object to parse
  13414. * @param sceneOrEngine The scene or the engine to create the particle system in
  13415. * @param rootUrl The root url to use to load external dependencies like texture
  13416. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13417. * @returns the Parsed particle system
  13418. */
  13419. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13420. }
  13421. }
  13422. declare module "babylonjs/Particles/particle" {
  13423. import { Nullable } from "babylonjs/types";
  13424. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13425. import { Color4 } from "babylonjs/Maths/math.color";
  13426. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13427. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13428. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13429. /**
  13430. * A particle represents one of the element emitted by a particle system.
  13431. * This is mainly define by its coordinates, direction, velocity and age.
  13432. */
  13433. export class Particle {
  13434. /**
  13435. * The particle system the particle belongs to.
  13436. */
  13437. particleSystem: ParticleSystem;
  13438. private static _Count;
  13439. /**
  13440. * Unique ID of the particle
  13441. */
  13442. id: number;
  13443. /**
  13444. * The world position of the particle in the scene.
  13445. */
  13446. position: Vector3;
  13447. /**
  13448. * The world direction of the particle in the scene.
  13449. */
  13450. direction: Vector3;
  13451. /**
  13452. * The color of the particle.
  13453. */
  13454. color: Color4;
  13455. /**
  13456. * The color change of the particle per step.
  13457. */
  13458. colorStep: Color4;
  13459. /**
  13460. * Defines how long will the life of the particle be.
  13461. */
  13462. lifeTime: number;
  13463. /**
  13464. * The current age of the particle.
  13465. */
  13466. age: number;
  13467. /**
  13468. * The current size of the particle.
  13469. */
  13470. size: number;
  13471. /**
  13472. * The current scale of the particle.
  13473. */
  13474. scale: Vector2;
  13475. /**
  13476. * The current angle of the particle.
  13477. */
  13478. angle: number;
  13479. /**
  13480. * Defines how fast is the angle changing.
  13481. */
  13482. angularSpeed: number;
  13483. /**
  13484. * Defines the cell index used by the particle to be rendered from a sprite.
  13485. */
  13486. cellIndex: number;
  13487. /**
  13488. * The information required to support color remapping
  13489. */
  13490. remapData: Vector4;
  13491. /** @hidden */
  13492. _randomCellOffset?: number;
  13493. /** @hidden */
  13494. _initialDirection: Nullable<Vector3>;
  13495. /** @hidden */
  13496. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13497. /** @hidden */
  13498. _initialStartSpriteCellID: number;
  13499. /** @hidden */
  13500. _initialEndSpriteCellID: number;
  13501. /** @hidden */
  13502. _currentColorGradient: Nullable<ColorGradient>;
  13503. /** @hidden */
  13504. _currentColor1: Color4;
  13505. /** @hidden */
  13506. _currentColor2: Color4;
  13507. /** @hidden */
  13508. _currentSizeGradient: Nullable<FactorGradient>;
  13509. /** @hidden */
  13510. _currentSize1: number;
  13511. /** @hidden */
  13512. _currentSize2: number;
  13513. /** @hidden */
  13514. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13515. /** @hidden */
  13516. _currentAngularSpeed1: number;
  13517. /** @hidden */
  13518. _currentAngularSpeed2: number;
  13519. /** @hidden */
  13520. _currentVelocityGradient: Nullable<FactorGradient>;
  13521. /** @hidden */
  13522. _currentVelocity1: number;
  13523. /** @hidden */
  13524. _currentVelocity2: number;
  13525. /** @hidden */
  13526. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13527. /** @hidden */
  13528. _currentLimitVelocity1: number;
  13529. /** @hidden */
  13530. _currentLimitVelocity2: number;
  13531. /** @hidden */
  13532. _currentDragGradient: Nullable<FactorGradient>;
  13533. /** @hidden */
  13534. _currentDrag1: number;
  13535. /** @hidden */
  13536. _currentDrag2: number;
  13537. /** @hidden */
  13538. _randomNoiseCoordinates1: Vector3;
  13539. /** @hidden */
  13540. _randomNoiseCoordinates2: Vector3;
  13541. /** @hidden */
  13542. _localPosition?: Vector3;
  13543. /**
  13544. * Creates a new instance Particle
  13545. * @param particleSystem the particle system the particle belongs to
  13546. */
  13547. constructor(
  13548. /**
  13549. * The particle system the particle belongs to.
  13550. */
  13551. particleSystem: ParticleSystem);
  13552. private updateCellInfoFromSystem;
  13553. /**
  13554. * Defines how the sprite cell index is updated for the particle
  13555. */
  13556. updateCellIndex(): void;
  13557. /** @hidden */
  13558. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13559. /** @hidden */
  13560. _inheritParticleInfoToSubEmitters(): void;
  13561. /** @hidden */
  13562. _reset(): void;
  13563. /**
  13564. * Copy the properties of particle to another one.
  13565. * @param other the particle to copy the information to.
  13566. */
  13567. copyTo(other: Particle): void;
  13568. }
  13569. }
  13570. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13571. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13572. import { Effect } from "babylonjs/Materials/effect";
  13573. import { Particle } from "babylonjs/Particles/particle";
  13574. import { Nullable } from "babylonjs/types";
  13575. import { Scene } from "babylonjs/scene";
  13576. /**
  13577. * Particle emitter represents a volume emitting particles.
  13578. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13579. */
  13580. export interface IParticleEmitterType {
  13581. /**
  13582. * Called by the particle System when the direction is computed for the created particle.
  13583. * @param worldMatrix is the world matrix of the particle system
  13584. * @param directionToUpdate is the direction vector to update with the result
  13585. * @param particle is the particle we are computed the direction for
  13586. * @param isLocal defines if the direction should be set in local space
  13587. */
  13588. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13589. /**
  13590. * Called by the particle System when the position is computed for the created particle.
  13591. * @param worldMatrix is the world matrix of the particle system
  13592. * @param positionToUpdate is the position vector to update with the result
  13593. * @param particle is the particle we are computed the position for
  13594. * @param isLocal defines if the position should be set in local space
  13595. */
  13596. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13597. /**
  13598. * Clones the current emitter and returns a copy of it
  13599. * @returns the new emitter
  13600. */
  13601. clone(): IParticleEmitterType;
  13602. /**
  13603. * Called by the GPUParticleSystem to setup the update shader
  13604. * @param effect defines the update shader
  13605. */
  13606. applyToShader(effect: Effect): void;
  13607. /**
  13608. * Returns a string to use to update the GPU particles update shader
  13609. * @returns the effect defines string
  13610. */
  13611. getEffectDefines(): string;
  13612. /**
  13613. * Returns a string representing the class name
  13614. * @returns a string containing the class name
  13615. */
  13616. getClassName(): string;
  13617. /**
  13618. * Serializes the particle system to a JSON object.
  13619. * @returns the JSON object
  13620. */
  13621. serialize(): any;
  13622. /**
  13623. * Parse properties from a JSON object
  13624. * @param serializationObject defines the JSON object
  13625. * @param scene defines the hosting scene
  13626. */
  13627. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13628. }
  13629. }
  13630. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13631. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13632. import { Effect } from "babylonjs/Materials/effect";
  13633. import { Particle } from "babylonjs/Particles/particle";
  13634. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13635. /**
  13636. * Particle emitter emitting particles from the inside of a box.
  13637. * It emits the particles randomly between 2 given directions.
  13638. */
  13639. export class BoxParticleEmitter implements IParticleEmitterType {
  13640. /**
  13641. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13642. */
  13643. direction1: Vector3;
  13644. /**
  13645. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13646. */
  13647. direction2: Vector3;
  13648. /**
  13649. * 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.
  13650. */
  13651. minEmitBox: Vector3;
  13652. /**
  13653. * 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.
  13654. */
  13655. maxEmitBox: Vector3;
  13656. /**
  13657. * Creates a new instance BoxParticleEmitter
  13658. */
  13659. constructor();
  13660. /**
  13661. * Called by the particle System when the direction is computed for the created particle.
  13662. * @param worldMatrix is the world matrix of the particle system
  13663. * @param directionToUpdate is the direction vector to update with the result
  13664. * @param particle is the particle we are computed the direction for
  13665. * @param isLocal defines if the direction should be set in local space
  13666. */
  13667. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13668. /**
  13669. * Called by the particle System when the position is computed for the created particle.
  13670. * @param worldMatrix is the world matrix of the particle system
  13671. * @param positionToUpdate is the position vector to update with the result
  13672. * @param particle is the particle we are computed the position for
  13673. * @param isLocal defines if the position should be set in local space
  13674. */
  13675. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13676. /**
  13677. * Clones the current emitter and returns a copy of it
  13678. * @returns the new emitter
  13679. */
  13680. clone(): BoxParticleEmitter;
  13681. /**
  13682. * Called by the GPUParticleSystem to setup the update shader
  13683. * @param effect defines the update shader
  13684. */
  13685. applyToShader(effect: Effect): void;
  13686. /**
  13687. * Returns a string to use to update the GPU particles update shader
  13688. * @returns a string containng the defines string
  13689. */
  13690. getEffectDefines(): string;
  13691. /**
  13692. * Returns the string "BoxParticleEmitter"
  13693. * @returns a string containing the class name
  13694. */
  13695. getClassName(): string;
  13696. /**
  13697. * Serializes the particle system to a JSON object.
  13698. * @returns the JSON object
  13699. */
  13700. serialize(): any;
  13701. /**
  13702. * Parse properties from a JSON object
  13703. * @param serializationObject defines the JSON object
  13704. */
  13705. parse(serializationObject: any): void;
  13706. }
  13707. }
  13708. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13709. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13710. import { Effect } from "babylonjs/Materials/effect";
  13711. import { Particle } from "babylonjs/Particles/particle";
  13712. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13713. /**
  13714. * Particle emitter emitting particles from the inside of a cone.
  13715. * It emits the particles alongside the cone volume from the base to the particle.
  13716. * The emission direction might be randomized.
  13717. */
  13718. export class ConeParticleEmitter implements IParticleEmitterType {
  13719. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13720. directionRandomizer: number;
  13721. private _radius;
  13722. private _angle;
  13723. private _height;
  13724. /**
  13725. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13726. */
  13727. radiusRange: number;
  13728. /**
  13729. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13730. */
  13731. heightRange: number;
  13732. /**
  13733. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13734. */
  13735. emitFromSpawnPointOnly: boolean;
  13736. /**
  13737. * Gets or sets the radius of the emission cone
  13738. */
  13739. get radius(): number;
  13740. set radius(value: number);
  13741. /**
  13742. * Gets or sets the angle of the emission cone
  13743. */
  13744. get angle(): number;
  13745. set angle(value: number);
  13746. private _buildHeight;
  13747. /**
  13748. * Creates a new instance ConeParticleEmitter
  13749. * @param radius the radius of the emission cone (1 by default)
  13750. * @param angle the cone base angle (PI by default)
  13751. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13752. */
  13753. constructor(radius?: number, angle?: number,
  13754. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13755. directionRandomizer?: number);
  13756. /**
  13757. * Called by the particle System when the direction is computed for the created particle.
  13758. * @param worldMatrix is the world matrix of the particle system
  13759. * @param directionToUpdate is the direction vector to update with the result
  13760. * @param particle is the particle we are computed the direction for
  13761. * @param isLocal defines if the direction should be set in local space
  13762. */
  13763. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13764. /**
  13765. * Called by the particle System when the position is computed for the created particle.
  13766. * @param worldMatrix is the world matrix of the particle system
  13767. * @param positionToUpdate is the position vector to update with the result
  13768. * @param particle is the particle we are computed the position for
  13769. * @param isLocal defines if the position should be set in local space
  13770. */
  13771. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13772. /**
  13773. * Clones the current emitter and returns a copy of it
  13774. * @returns the new emitter
  13775. */
  13776. clone(): ConeParticleEmitter;
  13777. /**
  13778. * Called by the GPUParticleSystem to setup the update shader
  13779. * @param effect defines the update shader
  13780. */
  13781. applyToShader(effect: Effect): void;
  13782. /**
  13783. * Returns a string to use to update the GPU particles update shader
  13784. * @returns a string containng the defines string
  13785. */
  13786. getEffectDefines(): string;
  13787. /**
  13788. * Returns the string "ConeParticleEmitter"
  13789. * @returns a string containing the class name
  13790. */
  13791. getClassName(): string;
  13792. /**
  13793. * Serializes the particle system to a JSON object.
  13794. * @returns the JSON object
  13795. */
  13796. serialize(): any;
  13797. /**
  13798. * Parse properties from a JSON object
  13799. * @param serializationObject defines the JSON object
  13800. */
  13801. parse(serializationObject: any): void;
  13802. }
  13803. }
  13804. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13805. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13806. import { Effect } from "babylonjs/Materials/effect";
  13807. import { Particle } from "babylonjs/Particles/particle";
  13808. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13809. /**
  13810. * Particle emitter emitting particles from the inside of a cylinder.
  13811. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13812. */
  13813. export class CylinderParticleEmitter implements IParticleEmitterType {
  13814. /**
  13815. * The radius of the emission cylinder.
  13816. */
  13817. radius: number;
  13818. /**
  13819. * The height of the emission cylinder.
  13820. */
  13821. height: number;
  13822. /**
  13823. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13824. */
  13825. radiusRange: number;
  13826. /**
  13827. * How much to randomize the particle direction [0-1].
  13828. */
  13829. directionRandomizer: number;
  13830. /**
  13831. * Creates a new instance CylinderParticleEmitter
  13832. * @param radius the radius of the emission cylinder (1 by default)
  13833. * @param height the height of the emission cylinder (1 by default)
  13834. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13835. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13836. */
  13837. constructor(
  13838. /**
  13839. * The radius of the emission cylinder.
  13840. */
  13841. radius?: number,
  13842. /**
  13843. * The height of the emission cylinder.
  13844. */
  13845. height?: number,
  13846. /**
  13847. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13848. */
  13849. radiusRange?: number,
  13850. /**
  13851. * How much to randomize the particle direction [0-1].
  13852. */
  13853. directionRandomizer?: number);
  13854. /**
  13855. * Called by the particle System when the direction is computed for the created particle.
  13856. * @param worldMatrix is the world matrix of the particle system
  13857. * @param directionToUpdate is the direction vector to update with the result
  13858. * @param particle is the particle we are computed the direction for
  13859. * @param isLocal defines if the direction should be set in local space
  13860. */
  13861. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13862. /**
  13863. * Called by the particle System when the position is computed for the created particle.
  13864. * @param worldMatrix is the world matrix of the particle system
  13865. * @param positionToUpdate is the position vector to update with the result
  13866. * @param particle is the particle we are computed the position for
  13867. * @param isLocal defines if the position should be set in local space
  13868. */
  13869. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13870. /**
  13871. * Clones the current emitter and returns a copy of it
  13872. * @returns the new emitter
  13873. */
  13874. clone(): CylinderParticleEmitter;
  13875. /**
  13876. * Called by the GPUParticleSystem to setup the update shader
  13877. * @param effect defines the update shader
  13878. */
  13879. applyToShader(effect: Effect): void;
  13880. /**
  13881. * Returns a string to use to update the GPU particles update shader
  13882. * @returns a string containng the defines string
  13883. */
  13884. getEffectDefines(): string;
  13885. /**
  13886. * Returns the string "CylinderParticleEmitter"
  13887. * @returns a string containing the class name
  13888. */
  13889. getClassName(): string;
  13890. /**
  13891. * Serializes the particle system to a JSON object.
  13892. * @returns the JSON object
  13893. */
  13894. serialize(): any;
  13895. /**
  13896. * Parse properties from a JSON object
  13897. * @param serializationObject defines the JSON object
  13898. */
  13899. parse(serializationObject: any): void;
  13900. }
  13901. /**
  13902. * Particle emitter emitting particles from the inside of a cylinder.
  13903. * It emits the particles randomly between two vectors.
  13904. */
  13905. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13906. /**
  13907. * The min limit of the emission direction.
  13908. */
  13909. direction1: Vector3;
  13910. /**
  13911. * The max limit of the emission direction.
  13912. */
  13913. direction2: Vector3;
  13914. /**
  13915. * Creates a new instance CylinderDirectedParticleEmitter
  13916. * @param radius the radius of the emission cylinder (1 by default)
  13917. * @param height the height of the emission cylinder (1 by default)
  13918. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13919. * @param direction1 the min limit of the emission direction (up vector by default)
  13920. * @param direction2 the max limit of the emission direction (up vector by default)
  13921. */
  13922. constructor(radius?: number, height?: number, radiusRange?: number,
  13923. /**
  13924. * The min limit of the emission direction.
  13925. */
  13926. direction1?: Vector3,
  13927. /**
  13928. * The max limit of the emission direction.
  13929. */
  13930. direction2?: Vector3);
  13931. /**
  13932. * Called by the particle System when the direction is computed for the created particle.
  13933. * @param worldMatrix is the world matrix of the particle system
  13934. * @param directionToUpdate is the direction vector to update with the result
  13935. * @param particle is the particle we are computed the direction for
  13936. */
  13937. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13938. /**
  13939. * Clones the current emitter and returns a copy of it
  13940. * @returns the new emitter
  13941. */
  13942. clone(): CylinderDirectedParticleEmitter;
  13943. /**
  13944. * Called by the GPUParticleSystem to setup the update shader
  13945. * @param effect defines the update shader
  13946. */
  13947. applyToShader(effect: Effect): void;
  13948. /**
  13949. * Returns a string to use to update the GPU particles update shader
  13950. * @returns a string containng the defines string
  13951. */
  13952. getEffectDefines(): string;
  13953. /**
  13954. * Returns the string "CylinderDirectedParticleEmitter"
  13955. * @returns a string containing the class name
  13956. */
  13957. getClassName(): string;
  13958. /**
  13959. * Serializes the particle system to a JSON object.
  13960. * @returns the JSON object
  13961. */
  13962. serialize(): any;
  13963. /**
  13964. * Parse properties from a JSON object
  13965. * @param serializationObject defines the JSON object
  13966. */
  13967. parse(serializationObject: any): void;
  13968. }
  13969. }
  13970. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13971. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13972. import { Effect } from "babylonjs/Materials/effect";
  13973. import { Particle } from "babylonjs/Particles/particle";
  13974. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13975. /**
  13976. * Particle emitter emitting particles from the inside of a hemisphere.
  13977. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13978. */
  13979. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13980. /**
  13981. * The radius of the emission hemisphere.
  13982. */
  13983. radius: number;
  13984. /**
  13985. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13986. */
  13987. radiusRange: number;
  13988. /**
  13989. * How much to randomize the particle direction [0-1].
  13990. */
  13991. directionRandomizer: number;
  13992. /**
  13993. * Creates a new instance HemisphericParticleEmitter
  13994. * @param radius the radius of the emission hemisphere (1 by default)
  13995. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13996. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13997. */
  13998. constructor(
  13999. /**
  14000. * The radius of the emission hemisphere.
  14001. */
  14002. radius?: number,
  14003. /**
  14004. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14005. */
  14006. radiusRange?: number,
  14007. /**
  14008. * How much to randomize the particle direction [0-1].
  14009. */
  14010. directionRandomizer?: number);
  14011. /**
  14012. * Called by the particle System when the direction is computed for the created particle.
  14013. * @param worldMatrix is the world matrix of the particle system
  14014. * @param directionToUpdate is the direction vector to update with the result
  14015. * @param particle is the particle we are computed the direction for
  14016. * @param isLocal defines if the direction should be set in local space
  14017. */
  14018. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14019. /**
  14020. * Called by the particle System when the position is computed for the created particle.
  14021. * @param worldMatrix is the world matrix of the particle system
  14022. * @param positionToUpdate is the position vector to update with the result
  14023. * @param particle is the particle we are computed the position for
  14024. * @param isLocal defines if the position should be set in local space
  14025. */
  14026. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14027. /**
  14028. * Clones the current emitter and returns a copy of it
  14029. * @returns the new emitter
  14030. */
  14031. clone(): HemisphericParticleEmitter;
  14032. /**
  14033. * Called by the GPUParticleSystem to setup the update shader
  14034. * @param effect defines the update shader
  14035. */
  14036. applyToShader(effect: Effect): void;
  14037. /**
  14038. * Returns a string to use to update the GPU particles update shader
  14039. * @returns a string containng the defines string
  14040. */
  14041. getEffectDefines(): string;
  14042. /**
  14043. * Returns the string "HemisphericParticleEmitter"
  14044. * @returns a string containing the class name
  14045. */
  14046. getClassName(): string;
  14047. /**
  14048. * Serializes the particle system to a JSON object.
  14049. * @returns the JSON object
  14050. */
  14051. serialize(): any;
  14052. /**
  14053. * Parse properties from a JSON object
  14054. * @param serializationObject defines the JSON object
  14055. */
  14056. parse(serializationObject: any): void;
  14057. }
  14058. }
  14059. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14060. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14061. import { Effect } from "babylonjs/Materials/effect";
  14062. import { Particle } from "babylonjs/Particles/particle";
  14063. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14064. /**
  14065. * Particle emitter emitting particles from a point.
  14066. * It emits the particles randomly between 2 given directions.
  14067. */
  14068. export class PointParticleEmitter implements IParticleEmitterType {
  14069. /**
  14070. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14071. */
  14072. direction1: Vector3;
  14073. /**
  14074. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14075. */
  14076. direction2: Vector3;
  14077. /**
  14078. * Creates a new instance PointParticleEmitter
  14079. */
  14080. constructor();
  14081. /**
  14082. * Called by the particle System when the direction is computed for the created particle.
  14083. * @param worldMatrix is the world matrix of the particle system
  14084. * @param directionToUpdate is the direction vector to update with the result
  14085. * @param particle is the particle we are computed the direction for
  14086. * @param isLocal defines if the direction should be set in local space
  14087. */
  14088. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14089. /**
  14090. * Called by the particle System when the position is computed for the created particle.
  14091. * @param worldMatrix is the world matrix of the particle system
  14092. * @param positionToUpdate is the position vector to update with the result
  14093. * @param particle is the particle we are computed the position for
  14094. * @param isLocal defines if the position should be set in local space
  14095. */
  14096. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14097. /**
  14098. * Clones the current emitter and returns a copy of it
  14099. * @returns the new emitter
  14100. */
  14101. clone(): PointParticleEmitter;
  14102. /**
  14103. * Called by the GPUParticleSystem to setup the update shader
  14104. * @param effect defines the update shader
  14105. */
  14106. applyToShader(effect: Effect): void;
  14107. /**
  14108. * Returns a string to use to update the GPU particles update shader
  14109. * @returns a string containng the defines string
  14110. */
  14111. getEffectDefines(): string;
  14112. /**
  14113. * Returns the string "PointParticleEmitter"
  14114. * @returns a string containing the class name
  14115. */
  14116. getClassName(): string;
  14117. /**
  14118. * Serializes the particle system to a JSON object.
  14119. * @returns the JSON object
  14120. */
  14121. serialize(): any;
  14122. /**
  14123. * Parse properties from a JSON object
  14124. * @param serializationObject defines the JSON object
  14125. */
  14126. parse(serializationObject: any): void;
  14127. }
  14128. }
  14129. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14130. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14131. import { Effect } from "babylonjs/Materials/effect";
  14132. import { Particle } from "babylonjs/Particles/particle";
  14133. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14134. /**
  14135. * Particle emitter emitting particles from the inside of a sphere.
  14136. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14137. */
  14138. export class SphereParticleEmitter implements IParticleEmitterType {
  14139. /**
  14140. * The radius of the emission sphere.
  14141. */
  14142. radius: number;
  14143. /**
  14144. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14145. */
  14146. radiusRange: number;
  14147. /**
  14148. * How much to randomize the particle direction [0-1].
  14149. */
  14150. directionRandomizer: number;
  14151. /**
  14152. * Creates a new instance SphereParticleEmitter
  14153. * @param radius the radius of the emission sphere (1 by default)
  14154. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14155. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14156. */
  14157. constructor(
  14158. /**
  14159. * The radius of the emission sphere.
  14160. */
  14161. radius?: number,
  14162. /**
  14163. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14164. */
  14165. radiusRange?: number,
  14166. /**
  14167. * How much to randomize the particle direction [0-1].
  14168. */
  14169. directionRandomizer?: number);
  14170. /**
  14171. * Called by the particle System when the direction is computed for the created particle.
  14172. * @param worldMatrix is the world matrix of the particle system
  14173. * @param directionToUpdate is the direction vector to update with the result
  14174. * @param particle is the particle we are computed the direction for
  14175. * @param isLocal defines if the direction should be set in local space
  14176. */
  14177. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14178. /**
  14179. * Called by the particle System when the position is computed for the created particle.
  14180. * @param worldMatrix is the world matrix of the particle system
  14181. * @param positionToUpdate is the position vector to update with the result
  14182. * @param particle is the particle we are computed the position for
  14183. * @param isLocal defines if the position should be set in local space
  14184. */
  14185. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14186. /**
  14187. * Clones the current emitter and returns a copy of it
  14188. * @returns the new emitter
  14189. */
  14190. clone(): SphereParticleEmitter;
  14191. /**
  14192. * Called by the GPUParticleSystem to setup the update shader
  14193. * @param effect defines the update shader
  14194. */
  14195. applyToShader(effect: Effect): void;
  14196. /**
  14197. * Returns a string to use to update the GPU particles update shader
  14198. * @returns a string containng the defines string
  14199. */
  14200. getEffectDefines(): string;
  14201. /**
  14202. * Returns the string "SphereParticleEmitter"
  14203. * @returns a string containing the class name
  14204. */
  14205. getClassName(): string;
  14206. /**
  14207. * Serializes the particle system to a JSON object.
  14208. * @returns the JSON object
  14209. */
  14210. serialize(): any;
  14211. /**
  14212. * Parse properties from a JSON object
  14213. * @param serializationObject defines the JSON object
  14214. */
  14215. parse(serializationObject: any): void;
  14216. }
  14217. /**
  14218. * Particle emitter emitting particles from the inside of a sphere.
  14219. * It emits the particles randomly between two vectors.
  14220. */
  14221. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14222. /**
  14223. * The min limit of the emission direction.
  14224. */
  14225. direction1: Vector3;
  14226. /**
  14227. * The max limit of the emission direction.
  14228. */
  14229. direction2: Vector3;
  14230. /**
  14231. * Creates a new instance SphereDirectedParticleEmitter
  14232. * @param radius the radius of the emission sphere (1 by default)
  14233. * @param direction1 the min limit of the emission direction (up vector by default)
  14234. * @param direction2 the max limit of the emission direction (up vector by default)
  14235. */
  14236. constructor(radius?: number,
  14237. /**
  14238. * The min limit of the emission direction.
  14239. */
  14240. direction1?: Vector3,
  14241. /**
  14242. * The max limit of the emission direction.
  14243. */
  14244. direction2?: Vector3);
  14245. /**
  14246. * Called by the particle System when the direction is computed for the created particle.
  14247. * @param worldMatrix is the world matrix of the particle system
  14248. * @param directionToUpdate is the direction vector to update with the result
  14249. * @param particle is the particle we are computed the direction for
  14250. */
  14251. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14252. /**
  14253. * Clones the current emitter and returns a copy of it
  14254. * @returns the new emitter
  14255. */
  14256. clone(): SphereDirectedParticleEmitter;
  14257. /**
  14258. * Called by the GPUParticleSystem to setup the update shader
  14259. * @param effect defines the update shader
  14260. */
  14261. applyToShader(effect: Effect): void;
  14262. /**
  14263. * Returns a string to use to update the GPU particles update shader
  14264. * @returns a string containng the defines string
  14265. */
  14266. getEffectDefines(): string;
  14267. /**
  14268. * Returns the string "SphereDirectedParticleEmitter"
  14269. * @returns a string containing the class name
  14270. */
  14271. getClassName(): string;
  14272. /**
  14273. * Serializes the particle system to a JSON object.
  14274. * @returns the JSON object
  14275. */
  14276. serialize(): any;
  14277. /**
  14278. * Parse properties from a JSON object
  14279. * @param serializationObject defines the JSON object
  14280. */
  14281. parse(serializationObject: any): void;
  14282. }
  14283. }
  14284. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14285. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14286. import { Effect } from "babylonjs/Materials/effect";
  14287. import { Particle } from "babylonjs/Particles/particle";
  14288. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14289. import { Nullable } from "babylonjs/types";
  14290. /**
  14291. * Particle emitter emitting particles from a custom list of positions.
  14292. */
  14293. export class CustomParticleEmitter implements IParticleEmitterType {
  14294. /**
  14295. * Gets or sets the position generator that will create the inital position of each particle.
  14296. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14297. */
  14298. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14299. /**
  14300. * Gets or sets the destination generator that will create the final destination of each particle.
  14301. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14302. */
  14303. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14304. /**
  14305. * Creates a new instance CustomParticleEmitter
  14306. */
  14307. constructor();
  14308. /**
  14309. * Called by the particle System when the direction is computed for the created particle.
  14310. * @param worldMatrix is the world matrix of the particle system
  14311. * @param directionToUpdate is the direction vector to update with the result
  14312. * @param particle is the particle we are computed the direction for
  14313. * @param isLocal defines if the direction should be set in local space
  14314. */
  14315. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14316. /**
  14317. * Called by the particle System when the position is computed for the created particle.
  14318. * @param worldMatrix is the world matrix of the particle system
  14319. * @param positionToUpdate is the position vector to update with the result
  14320. * @param particle is the particle we are computed the position for
  14321. * @param isLocal defines if the position should be set in local space
  14322. */
  14323. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14324. /**
  14325. * Clones the current emitter and returns a copy of it
  14326. * @returns the new emitter
  14327. */
  14328. clone(): CustomParticleEmitter;
  14329. /**
  14330. * Called by the GPUParticleSystem to setup the update shader
  14331. * @param effect defines the update shader
  14332. */
  14333. applyToShader(effect: Effect): void;
  14334. /**
  14335. * Returns a string to use to update the GPU particles update shader
  14336. * @returns a string containng the defines string
  14337. */
  14338. getEffectDefines(): string;
  14339. /**
  14340. * Returns the string "PointParticleEmitter"
  14341. * @returns a string containing the class name
  14342. */
  14343. getClassName(): string;
  14344. /**
  14345. * Serializes the particle system to a JSON object.
  14346. * @returns the JSON object
  14347. */
  14348. serialize(): any;
  14349. /**
  14350. * Parse properties from a JSON object
  14351. * @param serializationObject defines the JSON object
  14352. */
  14353. parse(serializationObject: any): void;
  14354. }
  14355. }
  14356. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14357. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14358. import { Effect } from "babylonjs/Materials/effect";
  14359. import { Particle } from "babylonjs/Particles/particle";
  14360. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14361. import { Nullable } from "babylonjs/types";
  14362. import { Scene } from "babylonjs/scene";
  14363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14364. /**
  14365. * Particle emitter emitting particles from the inside of a box.
  14366. * It emits the particles randomly between 2 given directions.
  14367. */
  14368. export class MeshParticleEmitter implements IParticleEmitterType {
  14369. private _indices;
  14370. private _positions;
  14371. private _normals;
  14372. private _storedNormal;
  14373. private _mesh;
  14374. /**
  14375. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14376. */
  14377. direction1: Vector3;
  14378. /**
  14379. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14380. */
  14381. direction2: Vector3;
  14382. /**
  14383. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14384. */
  14385. useMeshNormalsForDirection: boolean;
  14386. /** Defines the mesh to use as source */
  14387. get mesh(): Nullable<AbstractMesh>;
  14388. set mesh(value: Nullable<AbstractMesh>);
  14389. /**
  14390. * Creates a new instance MeshParticleEmitter
  14391. * @param mesh defines the mesh to use as source
  14392. */
  14393. constructor(mesh?: Nullable<AbstractMesh>);
  14394. /**
  14395. * Called by the particle System when the direction is computed for the created particle.
  14396. * @param worldMatrix is the world matrix of the particle system
  14397. * @param directionToUpdate is the direction vector to update with the result
  14398. * @param particle is the particle we are computed the direction for
  14399. * @param isLocal defines if the direction should be set in local space
  14400. */
  14401. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14402. /**
  14403. * Called by the particle System when the position is computed for the created particle.
  14404. * @param worldMatrix is the world matrix of the particle system
  14405. * @param positionToUpdate is the position vector to update with the result
  14406. * @param particle is the particle we are computed the position for
  14407. * @param isLocal defines if the position should be set in local space
  14408. */
  14409. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14410. /**
  14411. * Clones the current emitter and returns a copy of it
  14412. * @returns the new emitter
  14413. */
  14414. clone(): MeshParticleEmitter;
  14415. /**
  14416. * Called by the GPUParticleSystem to setup the update shader
  14417. * @param effect defines the update shader
  14418. */
  14419. applyToShader(effect: Effect): void;
  14420. /**
  14421. * Returns a string to use to update the GPU particles update shader
  14422. * @returns a string containng the defines string
  14423. */
  14424. getEffectDefines(): string;
  14425. /**
  14426. * Returns the string "BoxParticleEmitter"
  14427. * @returns a string containing the class name
  14428. */
  14429. getClassName(): string;
  14430. /**
  14431. * Serializes the particle system to a JSON object.
  14432. * @returns the JSON object
  14433. */
  14434. serialize(): any;
  14435. /**
  14436. * Parse properties from a JSON object
  14437. * @param serializationObject defines the JSON object
  14438. * @param scene defines the hosting scene
  14439. */
  14440. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14441. }
  14442. }
  14443. declare module "babylonjs/Particles/EmitterTypes/index" {
  14444. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14445. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14446. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14447. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14448. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14449. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14450. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14451. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14452. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14453. }
  14454. declare module "babylonjs/Particles/IParticleSystem" {
  14455. import { Nullable } from "babylonjs/types";
  14456. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14457. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14458. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14459. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14460. import { Scene } from "babylonjs/scene";
  14461. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14462. import { Effect } from "babylonjs/Materials/effect";
  14463. import { Observable } from "babylonjs/Misc/observable";
  14464. import { Animation } from "babylonjs/Animations/animation";
  14465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14466. /**
  14467. * Interface representing a particle system in Babylon.js.
  14468. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14469. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14470. */
  14471. export interface IParticleSystem {
  14472. /**
  14473. * List of animations used by the particle system.
  14474. */
  14475. animations: Animation[];
  14476. /**
  14477. * The id of the Particle system.
  14478. */
  14479. id: string;
  14480. /**
  14481. * The name of the Particle system.
  14482. */
  14483. name: string;
  14484. /**
  14485. * The emitter represents the Mesh or position we are attaching the particle system to.
  14486. */
  14487. emitter: Nullable<AbstractMesh | Vector3>;
  14488. /**
  14489. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14490. */
  14491. isBillboardBased: boolean;
  14492. /**
  14493. * The rendering group used by the Particle system to chose when to render.
  14494. */
  14495. renderingGroupId: number;
  14496. /**
  14497. * The layer mask we are rendering the particles through.
  14498. */
  14499. layerMask: number;
  14500. /**
  14501. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14502. */
  14503. updateSpeed: number;
  14504. /**
  14505. * The amount of time the particle system is running (depends of the overall update speed).
  14506. */
  14507. targetStopDuration: number;
  14508. /**
  14509. * The texture used to render each particle. (this can be a spritesheet)
  14510. */
  14511. particleTexture: Nullable<BaseTexture>;
  14512. /**
  14513. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14514. */
  14515. blendMode: number;
  14516. /**
  14517. * Minimum life time of emitting particles.
  14518. */
  14519. minLifeTime: number;
  14520. /**
  14521. * Maximum life time of emitting particles.
  14522. */
  14523. maxLifeTime: number;
  14524. /**
  14525. * Minimum Size of emitting particles.
  14526. */
  14527. minSize: number;
  14528. /**
  14529. * Maximum Size of emitting particles.
  14530. */
  14531. maxSize: number;
  14532. /**
  14533. * Minimum scale of emitting particles on X axis.
  14534. */
  14535. minScaleX: number;
  14536. /**
  14537. * Maximum scale of emitting particles on X axis.
  14538. */
  14539. maxScaleX: number;
  14540. /**
  14541. * Minimum scale of emitting particles on Y axis.
  14542. */
  14543. minScaleY: number;
  14544. /**
  14545. * Maximum scale of emitting particles on Y axis.
  14546. */
  14547. maxScaleY: number;
  14548. /**
  14549. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14550. */
  14551. color1: Color4;
  14552. /**
  14553. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14554. */
  14555. color2: Color4;
  14556. /**
  14557. * Color the particle will have at the end of its lifetime.
  14558. */
  14559. colorDead: Color4;
  14560. /**
  14561. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14562. */
  14563. emitRate: number;
  14564. /**
  14565. * You can use gravity if you want to give an orientation to your particles.
  14566. */
  14567. gravity: Vector3;
  14568. /**
  14569. * Minimum power of emitting particles.
  14570. */
  14571. minEmitPower: number;
  14572. /**
  14573. * Maximum power of emitting particles.
  14574. */
  14575. maxEmitPower: number;
  14576. /**
  14577. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14578. */
  14579. minAngularSpeed: number;
  14580. /**
  14581. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14582. */
  14583. maxAngularSpeed: number;
  14584. /**
  14585. * Gets or sets the minimal initial rotation in radians.
  14586. */
  14587. minInitialRotation: number;
  14588. /**
  14589. * Gets or sets the maximal initial rotation in radians.
  14590. */
  14591. maxInitialRotation: number;
  14592. /**
  14593. * The particle emitter type defines the emitter used by the particle system.
  14594. * It can be for example box, sphere, or cone...
  14595. */
  14596. particleEmitterType: Nullable<IParticleEmitterType>;
  14597. /**
  14598. * Defines the delay in milliseconds before starting the system (0 by default)
  14599. */
  14600. startDelay: number;
  14601. /**
  14602. * 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
  14603. */
  14604. preWarmCycles: number;
  14605. /**
  14606. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14607. */
  14608. preWarmStepOffset: number;
  14609. /**
  14610. * 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)
  14611. */
  14612. spriteCellChangeSpeed: number;
  14613. /**
  14614. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14615. */
  14616. startSpriteCellID: number;
  14617. /**
  14618. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14619. */
  14620. endSpriteCellID: number;
  14621. /**
  14622. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14623. */
  14624. spriteCellWidth: number;
  14625. /**
  14626. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14627. */
  14628. spriteCellHeight: number;
  14629. /**
  14630. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14631. */
  14632. spriteRandomStartCell: boolean;
  14633. /**
  14634. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14635. */
  14636. isAnimationSheetEnabled: boolean;
  14637. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14638. translationPivot: Vector2;
  14639. /**
  14640. * Gets or sets a texture used to add random noise to particle positions
  14641. */
  14642. noiseTexture: Nullable<BaseTexture>;
  14643. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14644. noiseStrength: Vector3;
  14645. /**
  14646. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14647. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14648. */
  14649. billboardMode: number;
  14650. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14651. limitVelocityDamping: number;
  14652. /**
  14653. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14654. */
  14655. beginAnimationOnStart: boolean;
  14656. /**
  14657. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14658. */
  14659. beginAnimationFrom: number;
  14660. /**
  14661. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14662. */
  14663. beginAnimationTo: number;
  14664. /**
  14665. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14666. */
  14667. beginAnimationLoop: boolean;
  14668. /**
  14669. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14670. */
  14671. disposeOnStop: boolean;
  14672. /**
  14673. * Specifies if the particles are updated in emitter local space or world space
  14674. */
  14675. isLocal: boolean;
  14676. /** Snippet ID if the particle system was created from the snippet server */
  14677. snippetId: string;
  14678. /** Gets or sets a matrix to use to compute projection */
  14679. defaultProjectionMatrix: Matrix;
  14680. /**
  14681. * Gets the maximum number of particles active at the same time.
  14682. * @returns The max number of active particles.
  14683. */
  14684. getCapacity(): number;
  14685. /**
  14686. * Gets the number of particles active at the same time.
  14687. * @returns The number of active particles.
  14688. */
  14689. getActiveCount(): number;
  14690. /**
  14691. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14692. * @returns True if it has been started, otherwise false.
  14693. */
  14694. isStarted(): boolean;
  14695. /**
  14696. * Animates the particle system for this frame.
  14697. */
  14698. animate(): void;
  14699. /**
  14700. * Renders the particle system in its current state.
  14701. * @returns the current number of particles
  14702. */
  14703. render(): number;
  14704. /**
  14705. * Dispose the particle system and frees its associated resources.
  14706. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14707. */
  14708. dispose(disposeTexture?: boolean): void;
  14709. /**
  14710. * An event triggered when the system is disposed
  14711. */
  14712. onDisposeObservable: Observable<IParticleSystem>;
  14713. /**
  14714. * An event triggered when the system is stopped
  14715. */
  14716. onStoppedObservable: Observable<IParticleSystem>;
  14717. /**
  14718. * Clones the particle system.
  14719. * @param name The name of the cloned object
  14720. * @param newEmitter The new emitter to use
  14721. * @returns the cloned particle system
  14722. */
  14723. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14724. /**
  14725. * Serializes the particle system to a JSON object
  14726. * @param serializeTexture defines if the texture must be serialized as well
  14727. * @returns the JSON object
  14728. */
  14729. serialize(serializeTexture: boolean): any;
  14730. /**
  14731. * Rebuild the particle system
  14732. */
  14733. rebuild(): void;
  14734. /** Force the system to rebuild all gradients that need to be resync */
  14735. forceRefreshGradients(): void;
  14736. /**
  14737. * Starts the particle system and begins to emit
  14738. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14739. */
  14740. start(delay?: number): void;
  14741. /**
  14742. * Stops the particle system.
  14743. */
  14744. stop(): void;
  14745. /**
  14746. * Remove all active particles
  14747. */
  14748. reset(): void;
  14749. /**
  14750. * Gets a boolean indicating that the system is stopping
  14751. * @returns true if the system is currently stopping
  14752. */
  14753. isStopping(): boolean;
  14754. /**
  14755. * Is this system ready to be used/rendered
  14756. * @return true if the system is ready
  14757. */
  14758. isReady(): boolean;
  14759. /**
  14760. * Returns the string "ParticleSystem"
  14761. * @returns a string containing the class name
  14762. */
  14763. getClassName(): string;
  14764. /**
  14765. * Gets the custom effect used to render the particles
  14766. * @param blendMode Blend mode for which the effect should be retrieved
  14767. * @returns The effect
  14768. */
  14769. getCustomEffect(blendMode: number): Nullable<Effect>;
  14770. /**
  14771. * Sets the custom effect used to render the particles
  14772. * @param effect The effect to set
  14773. * @param blendMode Blend mode for which the effect should be set
  14774. */
  14775. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14776. /**
  14777. * Fill the defines array according to the current settings of the particle system
  14778. * @param defines Array to be updated
  14779. * @param blendMode blend mode to take into account when updating the array
  14780. */
  14781. fillDefines(defines: Array<string>, blendMode: number): void;
  14782. /**
  14783. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14784. * @param uniforms Uniforms array to fill
  14785. * @param attributes Attributes array to fill
  14786. * @param samplers Samplers array to fill
  14787. */
  14788. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14789. /**
  14790. * Observable that will be called just before the particles are drawn
  14791. */
  14792. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14793. /**
  14794. * Gets the name of the particle vertex shader
  14795. */
  14796. vertexShaderName: string;
  14797. /**
  14798. * Adds a new color gradient
  14799. * @param gradient defines the gradient to use (between 0 and 1)
  14800. * @param color1 defines the color to affect to the specified gradient
  14801. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14802. * @returns the current particle system
  14803. */
  14804. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14805. /**
  14806. * Remove a specific color gradient
  14807. * @param gradient defines the gradient to remove
  14808. * @returns the current particle system
  14809. */
  14810. removeColorGradient(gradient: number): IParticleSystem;
  14811. /**
  14812. * Adds a new size gradient
  14813. * @param gradient defines the gradient to use (between 0 and 1)
  14814. * @param factor defines the size factor to affect to the specified gradient
  14815. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14816. * @returns the current particle system
  14817. */
  14818. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14819. /**
  14820. * Remove a specific size gradient
  14821. * @param gradient defines the gradient to remove
  14822. * @returns the current particle system
  14823. */
  14824. removeSizeGradient(gradient: number): IParticleSystem;
  14825. /**
  14826. * Gets the current list of color gradients.
  14827. * You must use addColorGradient and removeColorGradient to udpate this list
  14828. * @returns the list of color gradients
  14829. */
  14830. getColorGradients(): Nullable<Array<ColorGradient>>;
  14831. /**
  14832. * Gets the current list of size gradients.
  14833. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14834. * @returns the list of size gradients
  14835. */
  14836. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14837. /**
  14838. * Gets the current list of angular speed gradients.
  14839. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14840. * @returns the list of angular speed gradients
  14841. */
  14842. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14843. /**
  14844. * Adds a new angular speed gradient
  14845. * @param gradient defines the gradient to use (between 0 and 1)
  14846. * @param factor defines the angular speed to affect to the specified gradient
  14847. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14848. * @returns the current particle system
  14849. */
  14850. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14851. /**
  14852. * Remove a specific angular speed gradient
  14853. * @param gradient defines the gradient to remove
  14854. * @returns the current particle system
  14855. */
  14856. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14857. /**
  14858. * Gets the current list of velocity gradients.
  14859. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14860. * @returns the list of velocity gradients
  14861. */
  14862. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14863. /**
  14864. * Adds a new velocity gradient
  14865. * @param gradient defines the gradient to use (between 0 and 1)
  14866. * @param factor defines the velocity to affect to the specified gradient
  14867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14868. * @returns the current particle system
  14869. */
  14870. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14871. /**
  14872. * Remove a specific velocity gradient
  14873. * @param gradient defines the gradient to remove
  14874. * @returns the current particle system
  14875. */
  14876. removeVelocityGradient(gradient: number): IParticleSystem;
  14877. /**
  14878. * Gets the current list of limit velocity gradients.
  14879. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14880. * @returns the list of limit velocity gradients
  14881. */
  14882. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14883. /**
  14884. * Adds a new limit velocity gradient
  14885. * @param gradient defines the gradient to use (between 0 and 1)
  14886. * @param factor defines the limit velocity to affect to the specified gradient
  14887. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14888. * @returns the current particle system
  14889. */
  14890. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14891. /**
  14892. * Remove a specific limit velocity gradient
  14893. * @param gradient defines the gradient to remove
  14894. * @returns the current particle system
  14895. */
  14896. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14897. /**
  14898. * Adds a new drag gradient
  14899. * @param gradient defines the gradient to use (between 0 and 1)
  14900. * @param factor defines the drag to affect to the specified gradient
  14901. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14902. * @returns the current particle system
  14903. */
  14904. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14905. /**
  14906. * Remove a specific drag gradient
  14907. * @param gradient defines the gradient to remove
  14908. * @returns the current particle system
  14909. */
  14910. removeDragGradient(gradient: number): IParticleSystem;
  14911. /**
  14912. * Gets the current list of drag gradients.
  14913. * You must use addDragGradient and removeDragGradient to udpate this list
  14914. * @returns the list of drag gradients
  14915. */
  14916. getDragGradients(): Nullable<Array<FactorGradient>>;
  14917. /**
  14918. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14919. * @param gradient defines the gradient to use (between 0 and 1)
  14920. * @param factor defines the emit rate to affect to the specified gradient
  14921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14922. * @returns the current particle system
  14923. */
  14924. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14925. /**
  14926. * Remove a specific emit rate gradient
  14927. * @param gradient defines the gradient to remove
  14928. * @returns the current particle system
  14929. */
  14930. removeEmitRateGradient(gradient: number): IParticleSystem;
  14931. /**
  14932. * Gets the current list of emit rate gradients.
  14933. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14934. * @returns the list of emit rate gradients
  14935. */
  14936. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14937. /**
  14938. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14939. * @param gradient defines the gradient to use (between 0 and 1)
  14940. * @param factor defines the start size to affect to the specified gradient
  14941. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14942. * @returns the current particle system
  14943. */
  14944. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14945. /**
  14946. * Remove a specific start size gradient
  14947. * @param gradient defines the gradient to remove
  14948. * @returns the current particle system
  14949. */
  14950. removeStartSizeGradient(gradient: number): IParticleSystem;
  14951. /**
  14952. * Gets the current list of start size gradients.
  14953. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14954. * @returns the list of start size gradients
  14955. */
  14956. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14957. /**
  14958. * Adds a new life time gradient
  14959. * @param gradient defines the gradient to use (between 0 and 1)
  14960. * @param factor defines the life time factor to affect to the specified gradient
  14961. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14962. * @returns the current particle system
  14963. */
  14964. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14965. /**
  14966. * Remove a specific life time gradient
  14967. * @param gradient defines the gradient to remove
  14968. * @returns the current particle system
  14969. */
  14970. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14971. /**
  14972. * Gets the current list of life time gradients.
  14973. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14974. * @returns the list of life time gradients
  14975. */
  14976. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14977. /**
  14978. * Gets the current list of color gradients.
  14979. * You must use addColorGradient and removeColorGradient to udpate this list
  14980. * @returns the list of color gradients
  14981. */
  14982. getColorGradients(): Nullable<Array<ColorGradient>>;
  14983. /**
  14984. * Adds a new ramp gradient used to remap particle colors
  14985. * @param gradient defines the gradient to use (between 0 and 1)
  14986. * @param color defines the color to affect to the specified gradient
  14987. * @returns the current particle system
  14988. */
  14989. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14990. /**
  14991. * Gets the current list of ramp gradients.
  14992. * You must use addRampGradient and removeRampGradient to udpate this list
  14993. * @returns the list of ramp gradients
  14994. */
  14995. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14996. /** Gets or sets a boolean indicating that ramp gradients must be used
  14997. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14998. */
  14999. useRampGradients: boolean;
  15000. /**
  15001. * Adds a new color remap gradient
  15002. * @param gradient defines the gradient to use (between 0 and 1)
  15003. * @param min defines the color remap minimal range
  15004. * @param max defines the color remap maximal range
  15005. * @returns the current particle system
  15006. */
  15007. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15008. /**
  15009. * Gets the current list of color remap gradients.
  15010. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15011. * @returns the list of color remap gradients
  15012. */
  15013. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15014. /**
  15015. * Adds a new alpha remap gradient
  15016. * @param gradient defines the gradient to use (between 0 and 1)
  15017. * @param min defines the alpha remap minimal range
  15018. * @param max defines the alpha remap maximal range
  15019. * @returns the current particle system
  15020. */
  15021. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15022. /**
  15023. * Gets the current list of alpha remap gradients.
  15024. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15025. * @returns the list of alpha remap gradients
  15026. */
  15027. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15028. /**
  15029. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15030. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15031. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15032. * @returns the emitter
  15033. */
  15034. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15035. /**
  15036. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15037. * @param radius The radius of the hemisphere to emit from
  15038. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15039. * @returns the emitter
  15040. */
  15041. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  15042. /**
  15043. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15044. * @param radius The radius of the sphere to emit from
  15045. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15046. * @returns the emitter
  15047. */
  15048. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  15049. /**
  15050. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15051. * @param radius The radius of the sphere to emit from
  15052. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15053. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15054. * @returns the emitter
  15055. */
  15056. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15057. /**
  15058. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15059. * @param radius The radius of the emission cylinder
  15060. * @param height The height of the emission cylinder
  15061. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15062. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15063. * @returns the emitter
  15064. */
  15065. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15066. /**
  15067. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15068. * @param radius The radius of the cylinder to emit from
  15069. * @param height The height of the emission cylinder
  15070. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15071. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15072. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15073. * @returns the emitter
  15074. */
  15075. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15076. /**
  15077. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15078. * @param radius The radius of the cone to emit from
  15079. * @param angle The base angle of the cone
  15080. * @returns the emitter
  15081. */
  15082. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15083. /**
  15084. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15085. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15086. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15087. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15088. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15089. * @returns the emitter
  15090. */
  15091. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15092. /**
  15093. * Get hosting scene
  15094. * @returns the scene
  15095. */
  15096. getScene(): Nullable<Scene>;
  15097. }
  15098. }
  15099. declare module "babylonjs/Meshes/transformNode" {
  15100. import { DeepImmutable } from "babylonjs/types";
  15101. import { Observable } from "babylonjs/Misc/observable";
  15102. import { Nullable } from "babylonjs/types";
  15103. import { Camera } from "babylonjs/Cameras/camera";
  15104. import { Scene } from "babylonjs/scene";
  15105. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15106. import { Node } from "babylonjs/node";
  15107. import { Bone } from "babylonjs/Bones/bone";
  15108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15109. import { Space } from "babylonjs/Maths/math.axis";
  15110. /**
  15111. * 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.
  15112. * @see https://doc.babylonjs.com/how_to/transformnode
  15113. */
  15114. export class TransformNode extends Node {
  15115. /**
  15116. * Object will not rotate to face the camera
  15117. */
  15118. static BILLBOARDMODE_NONE: number;
  15119. /**
  15120. * Object will rotate to face the camera but only on the x axis
  15121. */
  15122. static BILLBOARDMODE_X: number;
  15123. /**
  15124. * Object will rotate to face the camera but only on the y axis
  15125. */
  15126. static BILLBOARDMODE_Y: number;
  15127. /**
  15128. * Object will rotate to face the camera but only on the z axis
  15129. */
  15130. static BILLBOARDMODE_Z: number;
  15131. /**
  15132. * Object will rotate to face the camera
  15133. */
  15134. static BILLBOARDMODE_ALL: number;
  15135. /**
  15136. * Object will rotate to face the camera's position instead of orientation
  15137. */
  15138. static BILLBOARDMODE_USE_POSITION: number;
  15139. private static _TmpRotation;
  15140. private static _TmpScaling;
  15141. private static _TmpTranslation;
  15142. private _forward;
  15143. private _forwardInverted;
  15144. private _up;
  15145. private _right;
  15146. private _rightInverted;
  15147. private _position;
  15148. private _rotation;
  15149. private _rotationQuaternion;
  15150. protected _scaling: Vector3;
  15151. protected _isDirty: boolean;
  15152. private _transformToBoneReferal;
  15153. private _isAbsoluteSynced;
  15154. private _billboardMode;
  15155. /**
  15156. * Gets or sets the billboard mode. Default is 0.
  15157. *
  15158. * | Value | Type | Description |
  15159. * | --- | --- | --- |
  15160. * | 0 | BILLBOARDMODE_NONE | |
  15161. * | 1 | BILLBOARDMODE_X | |
  15162. * | 2 | BILLBOARDMODE_Y | |
  15163. * | 4 | BILLBOARDMODE_Z | |
  15164. * | 7 | BILLBOARDMODE_ALL | |
  15165. *
  15166. */
  15167. get billboardMode(): number;
  15168. set billboardMode(value: number);
  15169. private _preserveParentRotationForBillboard;
  15170. /**
  15171. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15172. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15173. */
  15174. get preserveParentRotationForBillboard(): boolean;
  15175. set preserveParentRotationForBillboard(value: boolean);
  15176. /**
  15177. * 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
  15178. */
  15179. scalingDeterminant: number;
  15180. private _infiniteDistance;
  15181. /**
  15182. * Gets or sets the distance of the object to max, often used by skybox
  15183. */
  15184. get infiniteDistance(): boolean;
  15185. set infiniteDistance(value: boolean);
  15186. /**
  15187. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15188. * By default the system will update normals to compensate
  15189. */
  15190. ignoreNonUniformScaling: boolean;
  15191. /**
  15192. * 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
  15193. */
  15194. reIntegrateRotationIntoRotationQuaternion: boolean;
  15195. /** @hidden */
  15196. _poseMatrix: Nullable<Matrix>;
  15197. /** @hidden */
  15198. _localMatrix: Matrix;
  15199. private _usePivotMatrix;
  15200. private _absolutePosition;
  15201. private _absoluteScaling;
  15202. private _absoluteRotationQuaternion;
  15203. private _pivotMatrix;
  15204. private _pivotMatrixInverse;
  15205. /** @hidden */
  15206. _postMultiplyPivotMatrix: boolean;
  15207. protected _isWorldMatrixFrozen: boolean;
  15208. /** @hidden */
  15209. _indexInSceneTransformNodesArray: number;
  15210. /**
  15211. * An event triggered after the world matrix is updated
  15212. */
  15213. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15214. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15215. /**
  15216. * Gets a string identifying the name of the class
  15217. * @returns "TransformNode" string
  15218. */
  15219. getClassName(): string;
  15220. /**
  15221. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15222. */
  15223. get position(): Vector3;
  15224. set position(newPosition: Vector3);
  15225. /**
  15226. * 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)).
  15227. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15228. */
  15229. get rotation(): Vector3;
  15230. set rotation(newRotation: Vector3);
  15231. /**
  15232. * 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)).
  15233. */
  15234. get scaling(): Vector3;
  15235. set scaling(newScaling: Vector3);
  15236. /**
  15237. * 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).
  15238. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15239. */
  15240. get rotationQuaternion(): Nullable<Quaternion>;
  15241. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15242. /**
  15243. * The forward direction of that transform in world space.
  15244. */
  15245. get forward(): Vector3;
  15246. /**
  15247. * The up direction of that transform in world space.
  15248. */
  15249. get up(): Vector3;
  15250. /**
  15251. * The right direction of that transform in world space.
  15252. */
  15253. get right(): Vector3;
  15254. /**
  15255. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15256. * @param matrix the matrix to copy the pose from
  15257. * @returns this TransformNode.
  15258. */
  15259. updatePoseMatrix(matrix: Matrix): TransformNode;
  15260. /**
  15261. * Returns the mesh Pose matrix.
  15262. * @returns the pose matrix
  15263. */
  15264. getPoseMatrix(): Matrix;
  15265. /** @hidden */
  15266. _isSynchronized(): boolean;
  15267. /** @hidden */
  15268. _initCache(): void;
  15269. /**
  15270. * Flag the transform node as dirty (Forcing it to update everything)
  15271. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15272. * @returns this transform node
  15273. */
  15274. markAsDirty(property: string): TransformNode;
  15275. /**
  15276. * Returns the current mesh absolute position.
  15277. * Returns a Vector3.
  15278. */
  15279. get absolutePosition(): Vector3;
  15280. /**
  15281. * Returns the current mesh absolute scaling.
  15282. * Returns a Vector3.
  15283. */
  15284. get absoluteScaling(): Vector3;
  15285. /**
  15286. * Returns the current mesh absolute rotation.
  15287. * Returns a Quaternion.
  15288. */
  15289. get absoluteRotationQuaternion(): Quaternion;
  15290. /**
  15291. * Sets a new matrix to apply before all other transformation
  15292. * @param matrix defines the transform matrix
  15293. * @returns the current TransformNode
  15294. */
  15295. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15296. /**
  15297. * Sets a new pivot matrix to the current node
  15298. * @param matrix defines the new pivot matrix to use
  15299. * @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
  15300. * @returns the current TransformNode
  15301. */
  15302. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15303. /**
  15304. * Returns the mesh pivot matrix.
  15305. * Default : Identity.
  15306. * @returns the matrix
  15307. */
  15308. getPivotMatrix(): Matrix;
  15309. /**
  15310. * Instantiate (when possible) or clone that node with its hierarchy
  15311. * @param newParent defines the new parent to use for the instance (or clone)
  15312. * @param options defines options to configure how copy is done
  15313. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15314. * @returns an instance (or a clone) of the current node with its hiearchy
  15315. */
  15316. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15317. doNotInstantiate: boolean;
  15318. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15319. /**
  15320. * Prevents the World matrix to be computed any longer
  15321. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15322. * @returns the TransformNode.
  15323. */
  15324. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15325. /**
  15326. * Allows back the World matrix computation.
  15327. * @returns the TransformNode.
  15328. */
  15329. unfreezeWorldMatrix(): this;
  15330. /**
  15331. * True if the World matrix has been frozen.
  15332. */
  15333. get isWorldMatrixFrozen(): boolean;
  15334. /**
  15335. * Retuns the mesh absolute position in the World.
  15336. * @returns a Vector3.
  15337. */
  15338. getAbsolutePosition(): Vector3;
  15339. /**
  15340. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15341. * @param absolutePosition the absolute position to set
  15342. * @returns the TransformNode.
  15343. */
  15344. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15345. /**
  15346. * Sets the mesh position in its local space.
  15347. * @param vector3 the position to set in localspace
  15348. * @returns the TransformNode.
  15349. */
  15350. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15351. /**
  15352. * Returns the mesh position in the local space from the current World matrix values.
  15353. * @returns a new Vector3.
  15354. */
  15355. getPositionExpressedInLocalSpace(): Vector3;
  15356. /**
  15357. * Translates the mesh along the passed Vector3 in its local space.
  15358. * @param vector3 the distance to translate in localspace
  15359. * @returns the TransformNode.
  15360. */
  15361. locallyTranslate(vector3: Vector3): TransformNode;
  15362. private static _lookAtVectorCache;
  15363. /**
  15364. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15365. * @param targetPoint the position (must be in same space as current mesh) to look at
  15366. * @param yawCor optional yaw (y-axis) correction in radians
  15367. * @param pitchCor optional pitch (x-axis) correction in radians
  15368. * @param rollCor optional roll (z-axis) correction in radians
  15369. * @param space the choosen space of the target
  15370. * @returns the TransformNode.
  15371. */
  15372. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15373. /**
  15374. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15375. * This Vector3 is expressed in the World space.
  15376. * @param localAxis axis to rotate
  15377. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15378. */
  15379. getDirection(localAxis: Vector3): Vector3;
  15380. /**
  15381. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15382. * localAxis is expressed in the mesh local space.
  15383. * result is computed in the Wordl space from the mesh World matrix.
  15384. * @param localAxis axis to rotate
  15385. * @param result the resulting transformnode
  15386. * @returns this TransformNode.
  15387. */
  15388. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15389. /**
  15390. * Sets this transform node rotation to the given local axis.
  15391. * @param localAxis the axis in local space
  15392. * @param yawCor optional yaw (y-axis) correction in radians
  15393. * @param pitchCor optional pitch (x-axis) correction in radians
  15394. * @param rollCor optional roll (z-axis) correction in radians
  15395. * @returns this TransformNode
  15396. */
  15397. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15398. /**
  15399. * Sets a new pivot point to the current node
  15400. * @param point defines the new pivot point to use
  15401. * @param space defines if the point is in world or local space (local by default)
  15402. * @returns the current TransformNode
  15403. */
  15404. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15405. /**
  15406. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15407. * @returns the pivot point
  15408. */
  15409. getPivotPoint(): Vector3;
  15410. /**
  15411. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15412. * @param result the vector3 to store the result
  15413. * @returns this TransformNode.
  15414. */
  15415. getPivotPointToRef(result: Vector3): TransformNode;
  15416. /**
  15417. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15418. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15419. */
  15420. getAbsolutePivotPoint(): Vector3;
  15421. /**
  15422. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15423. * @param result vector3 to store the result
  15424. * @returns this TransformNode.
  15425. */
  15426. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15427. /**
  15428. * Defines the passed node as the parent of the current node.
  15429. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15430. * @see https://doc.babylonjs.com/how_to/parenting
  15431. * @param node the node ot set as the parent
  15432. * @returns this TransformNode.
  15433. */
  15434. setParent(node: Nullable<Node>): TransformNode;
  15435. private _nonUniformScaling;
  15436. /**
  15437. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15438. */
  15439. get nonUniformScaling(): boolean;
  15440. /** @hidden */
  15441. _updateNonUniformScalingState(value: boolean): boolean;
  15442. /**
  15443. * Attach the current TransformNode to another TransformNode associated with a bone
  15444. * @param bone Bone affecting the TransformNode
  15445. * @param affectedTransformNode TransformNode associated with the bone
  15446. * @returns this object
  15447. */
  15448. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15449. /**
  15450. * Detach the transform node if its associated with a bone
  15451. * @returns this object
  15452. */
  15453. detachFromBone(): TransformNode;
  15454. private static _rotationAxisCache;
  15455. /**
  15456. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15457. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15458. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15459. * The passed axis is also normalized.
  15460. * @param axis the axis to rotate around
  15461. * @param amount the amount to rotate in radians
  15462. * @param space Space to rotate in (Default: local)
  15463. * @returns the TransformNode.
  15464. */
  15465. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15466. /**
  15467. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15468. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15469. * The passed axis is also normalized. .
  15470. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15471. * @param point the point to rotate around
  15472. * @param axis the axis to rotate around
  15473. * @param amount the amount to rotate in radians
  15474. * @returns the TransformNode
  15475. */
  15476. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15477. /**
  15478. * Translates the mesh along the axis vector for the passed distance in the given space.
  15479. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15480. * @param axis the axis to translate in
  15481. * @param distance the distance to translate
  15482. * @param space Space to rotate in (Default: local)
  15483. * @returns the TransformNode.
  15484. */
  15485. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15486. /**
  15487. * Adds a rotation step to the mesh current rotation.
  15488. * x, y, z are Euler angles expressed in radians.
  15489. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15490. * This means this rotation is made in the mesh local space only.
  15491. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15492. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15493. * ```javascript
  15494. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15495. * ```
  15496. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15497. * 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.
  15498. * @param x Rotation to add
  15499. * @param y Rotation to add
  15500. * @param z Rotation to add
  15501. * @returns the TransformNode.
  15502. */
  15503. addRotation(x: number, y: number, z: number): TransformNode;
  15504. /**
  15505. * @hidden
  15506. */
  15507. protected _getEffectiveParent(): Nullable<Node>;
  15508. /**
  15509. * Computes the world matrix of the node
  15510. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15511. * @returns the world matrix
  15512. */
  15513. computeWorldMatrix(force?: boolean): Matrix;
  15514. /**
  15515. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15516. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15517. */
  15518. resetLocalMatrix(independentOfChildren?: boolean): void;
  15519. protected _afterComputeWorldMatrix(): void;
  15520. /**
  15521. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15522. * @param func callback function to add
  15523. *
  15524. * @returns the TransformNode.
  15525. */
  15526. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15527. /**
  15528. * Removes a registered callback function.
  15529. * @param func callback function to remove
  15530. * @returns the TransformNode.
  15531. */
  15532. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15533. /**
  15534. * Gets the position of the current mesh in camera space
  15535. * @param camera defines the camera to use
  15536. * @returns a position
  15537. */
  15538. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15539. /**
  15540. * Returns the distance from the mesh to the active camera
  15541. * @param camera defines the camera to use
  15542. * @returns the distance
  15543. */
  15544. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15545. /**
  15546. * Clone the current transform node
  15547. * @param name Name of the new clone
  15548. * @param newParent New parent for the clone
  15549. * @param doNotCloneChildren Do not clone children hierarchy
  15550. * @returns the new transform node
  15551. */
  15552. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15553. /**
  15554. * Serializes the objects information.
  15555. * @param currentSerializationObject defines the object to serialize in
  15556. * @returns the serialized object
  15557. */
  15558. serialize(currentSerializationObject?: any): any;
  15559. /**
  15560. * Returns a new TransformNode object parsed from the source provided.
  15561. * @param parsedTransformNode is the source.
  15562. * @param scene the scne the object belongs to
  15563. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15564. * @returns a new TransformNode object parsed from the source provided.
  15565. */
  15566. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15567. /**
  15568. * Get all child-transformNodes of this node
  15569. * @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
  15570. * @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
  15571. * @returns an array of TransformNode
  15572. */
  15573. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15574. /**
  15575. * Releases resources associated with this transform node.
  15576. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15577. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15578. */
  15579. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15580. /**
  15581. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15582. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15583. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15584. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15585. * @returns the current mesh
  15586. */
  15587. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15588. private _syncAbsoluteScalingAndRotation;
  15589. }
  15590. }
  15591. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15592. /**
  15593. * Class used to override all child animations of a given target
  15594. */
  15595. export class AnimationPropertiesOverride {
  15596. /**
  15597. * Gets or sets a value indicating if animation blending must be used
  15598. */
  15599. enableBlending: boolean;
  15600. /**
  15601. * Gets or sets the blending speed to use when enableBlending is true
  15602. */
  15603. blendingSpeed: number;
  15604. /**
  15605. * Gets or sets the default loop mode to use
  15606. */
  15607. loopMode: number;
  15608. }
  15609. }
  15610. declare module "babylonjs/Bones/bone" {
  15611. import { Skeleton } from "babylonjs/Bones/skeleton";
  15612. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15613. import { Nullable } from "babylonjs/types";
  15614. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15615. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15616. import { Node } from "babylonjs/node";
  15617. import { Space } from "babylonjs/Maths/math.axis";
  15618. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15619. /**
  15620. * Class used to store bone information
  15621. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15622. */
  15623. export class Bone extends Node {
  15624. /**
  15625. * defines the bone name
  15626. */
  15627. name: string;
  15628. private static _tmpVecs;
  15629. private static _tmpQuat;
  15630. private static _tmpMats;
  15631. /**
  15632. * Gets the list of child bones
  15633. */
  15634. children: Bone[];
  15635. /** Gets the animations associated with this bone */
  15636. animations: import("babylonjs/Animations/animation").Animation[];
  15637. /**
  15638. * Gets or sets bone length
  15639. */
  15640. length: number;
  15641. /**
  15642. * @hidden Internal only
  15643. * Set this value to map this bone to a different index in the transform matrices
  15644. * Set this value to -1 to exclude the bone from the transform matrices
  15645. */
  15646. _index: Nullable<number>;
  15647. private _skeleton;
  15648. private _localMatrix;
  15649. private _restPose;
  15650. private _bindPose;
  15651. private _baseMatrix;
  15652. private _absoluteTransform;
  15653. private _invertedAbsoluteTransform;
  15654. private _parent;
  15655. private _scalingDeterminant;
  15656. private _worldTransform;
  15657. private _localScaling;
  15658. private _localRotation;
  15659. private _localPosition;
  15660. private _needToDecompose;
  15661. private _needToCompose;
  15662. /** @hidden */
  15663. _linkedTransformNode: Nullable<TransformNode>;
  15664. /** @hidden */
  15665. _waitingTransformNodeId: Nullable<string>;
  15666. /** @hidden */
  15667. get _matrix(): Matrix;
  15668. /** @hidden */
  15669. set _matrix(value: Matrix);
  15670. /**
  15671. * Create a new bone
  15672. * @param name defines the bone name
  15673. * @param skeleton defines the parent skeleton
  15674. * @param parentBone defines the parent (can be null if the bone is the root)
  15675. * @param localMatrix defines the local matrix
  15676. * @param restPose defines the rest pose matrix
  15677. * @param baseMatrix defines the base matrix
  15678. * @param index defines index of the bone in the hiearchy
  15679. */
  15680. constructor(
  15681. /**
  15682. * defines the bone name
  15683. */
  15684. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15685. /**
  15686. * Gets the current object class name.
  15687. * @return the class name
  15688. */
  15689. getClassName(): string;
  15690. /**
  15691. * Gets the parent skeleton
  15692. * @returns a skeleton
  15693. */
  15694. getSkeleton(): Skeleton;
  15695. /**
  15696. * Gets parent bone
  15697. * @returns a bone or null if the bone is the root of the bone hierarchy
  15698. */
  15699. getParent(): Nullable<Bone>;
  15700. /**
  15701. * Returns an array containing the root bones
  15702. * @returns an array containing the root bones
  15703. */
  15704. getChildren(): Array<Bone>;
  15705. /**
  15706. * Gets the node index in matrix array generated for rendering
  15707. * @returns the node index
  15708. */
  15709. getIndex(): number;
  15710. /**
  15711. * Sets the parent bone
  15712. * @param parent defines the parent (can be null if the bone is the root)
  15713. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15714. */
  15715. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15716. /**
  15717. * Gets the local matrix
  15718. * @returns a matrix
  15719. */
  15720. getLocalMatrix(): Matrix;
  15721. /**
  15722. * Gets the base matrix (initial matrix which remains unchanged)
  15723. * @returns a matrix
  15724. */
  15725. getBaseMatrix(): Matrix;
  15726. /**
  15727. * Gets the rest pose matrix
  15728. * @returns a matrix
  15729. */
  15730. getRestPose(): Matrix;
  15731. /**
  15732. * Sets the rest pose matrix
  15733. * @param matrix the local-space rest pose to set for this bone
  15734. */
  15735. setRestPose(matrix: Matrix): void;
  15736. /**
  15737. * Gets the bind pose matrix
  15738. * @returns the bind pose matrix
  15739. */
  15740. getBindPose(): Matrix;
  15741. /**
  15742. * Sets the bind pose matrix
  15743. * @param matrix the local-space bind pose to set for this bone
  15744. */
  15745. setBindPose(matrix: Matrix): void;
  15746. /**
  15747. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15748. */
  15749. getWorldMatrix(): Matrix;
  15750. /**
  15751. * Sets the local matrix to rest pose matrix
  15752. */
  15753. returnToRest(): void;
  15754. /**
  15755. * Gets the inverse of the absolute transform matrix.
  15756. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15757. * @returns a matrix
  15758. */
  15759. getInvertedAbsoluteTransform(): Matrix;
  15760. /**
  15761. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15762. * @returns a matrix
  15763. */
  15764. getAbsoluteTransform(): Matrix;
  15765. /**
  15766. * Links with the given transform node.
  15767. * The local matrix of this bone is copied from the transform node every frame.
  15768. * @param transformNode defines the transform node to link to
  15769. */
  15770. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15771. /**
  15772. * Gets the node used to drive the bone's transformation
  15773. * @returns a transform node or null
  15774. */
  15775. getTransformNode(): Nullable<TransformNode>;
  15776. /** Gets or sets current position (in local space) */
  15777. get position(): Vector3;
  15778. set position(newPosition: Vector3);
  15779. /** Gets or sets current rotation (in local space) */
  15780. get rotation(): Vector3;
  15781. set rotation(newRotation: Vector3);
  15782. /** Gets or sets current rotation quaternion (in local space) */
  15783. get rotationQuaternion(): Quaternion;
  15784. set rotationQuaternion(newRotation: Quaternion);
  15785. /** Gets or sets current scaling (in local space) */
  15786. get scaling(): Vector3;
  15787. set scaling(newScaling: Vector3);
  15788. /**
  15789. * Gets the animation properties override
  15790. */
  15791. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15792. private _decompose;
  15793. private _compose;
  15794. /**
  15795. * Update the base and local matrices
  15796. * @param matrix defines the new base or local matrix
  15797. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15798. * @param updateLocalMatrix defines if the local matrix should be updated
  15799. */
  15800. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15801. /** @hidden */
  15802. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15803. /**
  15804. * Flag the bone as dirty (Forcing it to update everything)
  15805. */
  15806. markAsDirty(): void;
  15807. /** @hidden */
  15808. _markAsDirtyAndCompose(): void;
  15809. private _markAsDirtyAndDecompose;
  15810. /**
  15811. * Translate the bone in local or world space
  15812. * @param vec The amount to translate the bone
  15813. * @param space The space that the translation is in
  15814. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15815. */
  15816. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15817. /**
  15818. * Set the postion of the bone in local or world space
  15819. * @param position The position to set the bone
  15820. * @param space The space that the position is in
  15821. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15822. */
  15823. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15824. /**
  15825. * Set the absolute position of the bone (world space)
  15826. * @param position The position to set the bone
  15827. * @param mesh The mesh that this bone is attached to
  15828. */
  15829. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15830. /**
  15831. * Scale the bone on the x, y and z axes (in local space)
  15832. * @param x The amount to scale the bone on the x axis
  15833. * @param y The amount to scale the bone on the y axis
  15834. * @param z The amount to scale the bone on the z axis
  15835. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15836. */
  15837. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15838. /**
  15839. * Set the bone scaling in local space
  15840. * @param scale defines the scaling vector
  15841. */
  15842. setScale(scale: Vector3): void;
  15843. /**
  15844. * Gets the current scaling in local space
  15845. * @returns the current scaling vector
  15846. */
  15847. getScale(): Vector3;
  15848. /**
  15849. * Gets the current scaling in local space and stores it in a target vector
  15850. * @param result defines the target vector
  15851. */
  15852. getScaleToRef(result: Vector3): void;
  15853. /**
  15854. * Set the yaw, pitch, and roll of the bone in local or world space
  15855. * @param yaw The rotation of the bone on the y axis
  15856. * @param pitch The rotation of the bone on the x axis
  15857. * @param roll The rotation of the bone on the z axis
  15858. * @param space The space that the axes of rotation are in
  15859. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15860. */
  15861. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15862. /**
  15863. * Add a rotation to the bone on an axis in local or world space
  15864. * @param axis The axis to rotate the bone on
  15865. * @param amount The amount to rotate the bone
  15866. * @param space The space that the axis is in
  15867. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15868. */
  15869. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15870. /**
  15871. * Set the rotation of the bone to a particular axis angle in local or world space
  15872. * @param axis The axis to rotate the bone on
  15873. * @param angle The angle that the bone should be rotated to
  15874. * @param space The space that the axis is in
  15875. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15876. */
  15877. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15878. /**
  15879. * Set the euler rotation of the bone in local or world space
  15880. * @param rotation The euler rotation that the bone should be set to
  15881. * @param space The space that the rotation is in
  15882. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15883. */
  15884. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15885. /**
  15886. * Set the quaternion rotation of the bone in local or world space
  15887. * @param quat The quaternion rotation that the bone should be set to
  15888. * @param space The space that the rotation is in
  15889. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15890. */
  15891. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15892. /**
  15893. * Set the rotation matrix of the bone in local or world space
  15894. * @param rotMat The rotation matrix that the bone should be set to
  15895. * @param space The space that the rotation is in
  15896. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15897. */
  15898. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15899. private _rotateWithMatrix;
  15900. private _getNegativeRotationToRef;
  15901. /**
  15902. * Get the position of the bone in local or world space
  15903. * @param space The space that the returned position is in
  15904. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15905. * @returns The position of the bone
  15906. */
  15907. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15908. /**
  15909. * Copy the position of the bone to a vector3 in local or world space
  15910. * @param space The space that the returned position is in
  15911. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15912. * @param result The vector3 to copy the position to
  15913. */
  15914. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15915. /**
  15916. * Get the absolute position of the bone (world space)
  15917. * @param mesh The mesh that this bone is attached to
  15918. * @returns The absolute position of the bone
  15919. */
  15920. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15921. /**
  15922. * Copy the absolute position of the bone (world space) to the result param
  15923. * @param mesh The mesh that this bone is attached to
  15924. * @param result The vector3 to copy the absolute position to
  15925. */
  15926. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15927. /**
  15928. * Compute the absolute transforms of this bone and its children
  15929. */
  15930. computeAbsoluteTransforms(): void;
  15931. /**
  15932. * Get the world direction from an axis that is in the local space of the bone
  15933. * @param localAxis The local direction that is used to compute the world direction
  15934. * @param mesh The mesh that this bone is attached to
  15935. * @returns The world direction
  15936. */
  15937. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15938. /**
  15939. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15940. * @param localAxis The local direction that is used to compute the world direction
  15941. * @param mesh The mesh that this bone is attached to
  15942. * @param result The vector3 that the world direction will be copied to
  15943. */
  15944. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15945. /**
  15946. * Get the euler rotation of the bone in local or world space
  15947. * @param space The space that the rotation should be in
  15948. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15949. * @returns The euler rotation
  15950. */
  15951. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15952. /**
  15953. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15954. * @param space The space that the rotation should be in
  15955. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15956. * @param result The vector3 that the rotation should be copied to
  15957. */
  15958. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15959. /**
  15960. * Get the quaternion rotation of the bone in either local or world space
  15961. * @param space The space that the rotation should be in
  15962. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15963. * @returns The quaternion rotation
  15964. */
  15965. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15966. /**
  15967. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15968. * @param space The space that the rotation should be in
  15969. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15970. * @param result The quaternion that the rotation should be copied to
  15971. */
  15972. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15973. /**
  15974. * Get the rotation matrix of the bone in local or world space
  15975. * @param space The space that the rotation should be in
  15976. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15977. * @returns The rotation matrix
  15978. */
  15979. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15980. /**
  15981. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15982. * @param space The space that the rotation should be in
  15983. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15984. * @param result The quaternion that the rotation should be copied to
  15985. */
  15986. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15987. /**
  15988. * Get the world position of a point that is in the local space of the bone
  15989. * @param position The local position
  15990. * @param mesh The mesh that this bone is attached to
  15991. * @returns The world position
  15992. */
  15993. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15994. /**
  15995. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15996. * @param position The local position
  15997. * @param mesh The mesh that this bone is attached to
  15998. * @param result The vector3 that the world position should be copied to
  15999. */
  16000. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  16001. /**
  16002. * Get the local position of a point that is in world space
  16003. * @param position The world position
  16004. * @param mesh The mesh that this bone is attached to
  16005. * @returns The local position
  16006. */
  16007. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  16008. /**
  16009. * Get the local position of a point that is in world space and copy it to the result param
  16010. * @param position The world position
  16011. * @param mesh The mesh that this bone is attached to
  16012. * @param result The vector3 that the local position should be copied to
  16013. */
  16014. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  16015. /**
  16016. * Set the current local matrix as the restPose for this bone.
  16017. */
  16018. setCurrentPoseAsRest(): void;
  16019. }
  16020. }
  16021. declare module "babylonjs/Animations/runtimeAnimation" {
  16022. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  16023. import { Animatable } from "babylonjs/Animations/animatable";
  16024. import { Scene } from "babylonjs/scene";
  16025. /**
  16026. * Defines a runtime animation
  16027. */
  16028. export class RuntimeAnimation {
  16029. private _events;
  16030. /**
  16031. * The current frame of the runtime animation
  16032. */
  16033. private _currentFrame;
  16034. /**
  16035. * The animation used by the runtime animation
  16036. */
  16037. private _animation;
  16038. /**
  16039. * The target of the runtime animation
  16040. */
  16041. private _target;
  16042. /**
  16043. * The initiating animatable
  16044. */
  16045. private _host;
  16046. /**
  16047. * The original value of the runtime animation
  16048. */
  16049. private _originalValue;
  16050. /**
  16051. * The original blend value of the runtime animation
  16052. */
  16053. private _originalBlendValue;
  16054. /**
  16055. * The offsets cache of the runtime animation
  16056. */
  16057. private _offsetsCache;
  16058. /**
  16059. * The high limits cache of the runtime animation
  16060. */
  16061. private _highLimitsCache;
  16062. /**
  16063. * Specifies if the runtime animation has been stopped
  16064. */
  16065. private _stopped;
  16066. /**
  16067. * The blending factor of the runtime animation
  16068. */
  16069. private _blendingFactor;
  16070. /**
  16071. * The BabylonJS scene
  16072. */
  16073. private _scene;
  16074. /**
  16075. * The current value of the runtime animation
  16076. */
  16077. private _currentValue;
  16078. /** @hidden */
  16079. _animationState: _IAnimationState;
  16080. /**
  16081. * The active target of the runtime animation
  16082. */
  16083. private _activeTargets;
  16084. private _currentActiveTarget;
  16085. private _directTarget;
  16086. /**
  16087. * The target path of the runtime animation
  16088. */
  16089. private _targetPath;
  16090. /**
  16091. * The weight of the runtime animation
  16092. */
  16093. private _weight;
  16094. /**
  16095. * The ratio offset of the runtime animation
  16096. */
  16097. private _ratioOffset;
  16098. /**
  16099. * The previous delay of the runtime animation
  16100. */
  16101. private _previousDelay;
  16102. /**
  16103. * The previous ratio of the runtime animation
  16104. */
  16105. private _previousRatio;
  16106. private _enableBlending;
  16107. private _keys;
  16108. private _minFrame;
  16109. private _maxFrame;
  16110. private _minValue;
  16111. private _maxValue;
  16112. private _targetIsArray;
  16113. /**
  16114. * Gets the current frame of the runtime animation
  16115. */
  16116. get currentFrame(): number;
  16117. /**
  16118. * Gets the weight of the runtime animation
  16119. */
  16120. get weight(): number;
  16121. /**
  16122. * Gets the current value of the runtime animation
  16123. */
  16124. get currentValue(): any;
  16125. /**
  16126. * Gets the target path of the runtime animation
  16127. */
  16128. get targetPath(): string;
  16129. /**
  16130. * Gets the actual target of the runtime animation
  16131. */
  16132. get target(): any;
  16133. /**
  16134. * Gets the additive state of the runtime animation
  16135. */
  16136. get isAdditive(): boolean;
  16137. /** @hidden */
  16138. _onLoop: () => void;
  16139. /**
  16140. * Create a new RuntimeAnimation object
  16141. * @param target defines the target of the animation
  16142. * @param animation defines the source animation object
  16143. * @param scene defines the hosting scene
  16144. * @param host defines the initiating Animatable
  16145. */
  16146. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16147. private _preparePath;
  16148. /**
  16149. * Gets the animation from the runtime animation
  16150. */
  16151. get animation(): Animation;
  16152. /**
  16153. * Resets the runtime animation to the beginning
  16154. * @param restoreOriginal defines whether to restore the target property to the original value
  16155. */
  16156. reset(restoreOriginal?: boolean): void;
  16157. /**
  16158. * Specifies if the runtime animation is stopped
  16159. * @returns Boolean specifying if the runtime animation is stopped
  16160. */
  16161. isStopped(): boolean;
  16162. /**
  16163. * Disposes of the runtime animation
  16164. */
  16165. dispose(): void;
  16166. /**
  16167. * Apply the interpolated value to the target
  16168. * @param currentValue defines the value computed by the animation
  16169. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16170. */
  16171. setValue(currentValue: any, weight: number): void;
  16172. private _getOriginalValues;
  16173. private _setValue;
  16174. /**
  16175. * Gets the loop pmode of the runtime animation
  16176. * @returns Loop Mode
  16177. */
  16178. private _getCorrectLoopMode;
  16179. /**
  16180. * Move the current animation to a given frame
  16181. * @param frame defines the frame to move to
  16182. */
  16183. goToFrame(frame: number): void;
  16184. /**
  16185. * @hidden Internal use only
  16186. */
  16187. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16188. /**
  16189. * Execute the current animation
  16190. * @param delay defines the delay to add to the current frame
  16191. * @param from defines the lower bound of the animation range
  16192. * @param to defines the upper bound of the animation range
  16193. * @param loop defines if the current animation must loop
  16194. * @param speedRatio defines the current speed ratio
  16195. * @param weight defines the weight of the animation (default is -1 so no weight)
  16196. * @param onLoop optional callback called when animation loops
  16197. * @returns a boolean indicating if the animation is running
  16198. */
  16199. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16200. }
  16201. }
  16202. declare module "babylonjs/Animations/animatable" {
  16203. import { Animation } from "babylonjs/Animations/animation";
  16204. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16205. import { Nullable } from "babylonjs/types";
  16206. import { Observable } from "babylonjs/Misc/observable";
  16207. import { Scene } from "babylonjs/scene";
  16208. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16209. import { Node } from "babylonjs/node";
  16210. /**
  16211. * Class used to store an actual running animation
  16212. */
  16213. export class Animatable {
  16214. /** defines the target object */
  16215. target: any;
  16216. /** defines the starting frame number (default is 0) */
  16217. fromFrame: number;
  16218. /** defines the ending frame number (default is 100) */
  16219. toFrame: number;
  16220. /** defines if the animation must loop (default is false) */
  16221. loopAnimation: boolean;
  16222. /** defines a callback to call when animation ends if it is not looping */
  16223. onAnimationEnd?: (() => void) | null | undefined;
  16224. /** defines a callback to call when animation loops */
  16225. onAnimationLoop?: (() => void) | null | undefined;
  16226. /** defines whether the animation should be evaluated additively */
  16227. isAdditive: boolean;
  16228. private _localDelayOffset;
  16229. private _pausedDelay;
  16230. private _runtimeAnimations;
  16231. private _paused;
  16232. private _scene;
  16233. private _speedRatio;
  16234. private _weight;
  16235. private _syncRoot;
  16236. /**
  16237. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16238. * This will only apply for non looping animation (default is true)
  16239. */
  16240. disposeOnEnd: boolean;
  16241. /**
  16242. * Gets a boolean indicating if the animation has started
  16243. */
  16244. animationStarted: boolean;
  16245. /**
  16246. * Observer raised when the animation ends
  16247. */
  16248. onAnimationEndObservable: Observable<Animatable>;
  16249. /**
  16250. * Observer raised when the animation loops
  16251. */
  16252. onAnimationLoopObservable: Observable<Animatable>;
  16253. /**
  16254. * Gets the root Animatable used to synchronize and normalize animations
  16255. */
  16256. get syncRoot(): Nullable<Animatable>;
  16257. /**
  16258. * Gets the current frame of the first RuntimeAnimation
  16259. * Used to synchronize Animatables
  16260. */
  16261. get masterFrame(): number;
  16262. /**
  16263. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16264. */
  16265. get weight(): number;
  16266. set weight(value: number);
  16267. /**
  16268. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16269. */
  16270. get speedRatio(): number;
  16271. set speedRatio(value: number);
  16272. /**
  16273. * Creates a new Animatable
  16274. * @param scene defines the hosting scene
  16275. * @param target defines the target object
  16276. * @param fromFrame defines the starting frame number (default is 0)
  16277. * @param toFrame defines the ending frame number (default is 100)
  16278. * @param loopAnimation defines if the animation must loop (default is false)
  16279. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16280. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16281. * @param animations defines a group of animation to add to the new Animatable
  16282. * @param onAnimationLoop defines a callback to call when animation loops
  16283. * @param isAdditive defines whether the animation should be evaluated additively
  16284. */
  16285. constructor(scene: Scene,
  16286. /** defines the target object */
  16287. target: any,
  16288. /** defines the starting frame number (default is 0) */
  16289. fromFrame?: number,
  16290. /** defines the ending frame number (default is 100) */
  16291. toFrame?: number,
  16292. /** defines if the animation must loop (default is false) */
  16293. loopAnimation?: boolean, speedRatio?: number,
  16294. /** defines a callback to call when animation ends if it is not looping */
  16295. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16296. /** defines a callback to call when animation loops */
  16297. onAnimationLoop?: (() => void) | null | undefined,
  16298. /** defines whether the animation should be evaluated additively */
  16299. isAdditive?: boolean);
  16300. /**
  16301. * Synchronize and normalize current Animatable with a source Animatable
  16302. * This is useful when using animation weights and when animations are not of the same length
  16303. * @param root defines the root Animatable to synchronize with
  16304. * @returns the current Animatable
  16305. */
  16306. syncWith(root: Animatable): Animatable;
  16307. /**
  16308. * Gets the list of runtime animations
  16309. * @returns an array of RuntimeAnimation
  16310. */
  16311. getAnimations(): RuntimeAnimation[];
  16312. /**
  16313. * Adds more animations to the current animatable
  16314. * @param target defines the target of the animations
  16315. * @param animations defines the new animations to add
  16316. */
  16317. appendAnimations(target: any, animations: Animation[]): void;
  16318. /**
  16319. * Gets the source animation for a specific property
  16320. * @param property defines the propertyu to look for
  16321. * @returns null or the source animation for the given property
  16322. */
  16323. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16324. /**
  16325. * Gets the runtime animation for a specific property
  16326. * @param property defines the propertyu to look for
  16327. * @returns null or the runtime animation for the given property
  16328. */
  16329. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16330. /**
  16331. * Resets the animatable to its original state
  16332. */
  16333. reset(): void;
  16334. /**
  16335. * Allows the animatable to blend with current running animations
  16336. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16337. * @param blendingSpeed defines the blending speed to use
  16338. */
  16339. enableBlending(blendingSpeed: number): void;
  16340. /**
  16341. * Disable animation blending
  16342. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16343. */
  16344. disableBlending(): void;
  16345. /**
  16346. * Jump directly to a given frame
  16347. * @param frame defines the frame to jump to
  16348. */
  16349. goToFrame(frame: number): void;
  16350. /**
  16351. * Pause the animation
  16352. */
  16353. pause(): void;
  16354. /**
  16355. * Restart the animation
  16356. */
  16357. restart(): void;
  16358. private _raiseOnAnimationEnd;
  16359. /**
  16360. * Stop and delete the current animation
  16361. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16362. * @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)
  16363. */
  16364. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16365. /**
  16366. * Wait asynchronously for the animation to end
  16367. * @returns a promise which will be fullfilled when the animation ends
  16368. */
  16369. waitAsync(): Promise<Animatable>;
  16370. /** @hidden */
  16371. _animate(delay: number): boolean;
  16372. }
  16373. module "babylonjs/scene" {
  16374. interface Scene {
  16375. /** @hidden */
  16376. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16377. /** @hidden */
  16378. _processLateAnimationBindingsForMatrices(holder: {
  16379. totalWeight: number;
  16380. totalAdditiveWeight: number;
  16381. animations: RuntimeAnimation[];
  16382. additiveAnimations: RuntimeAnimation[];
  16383. originalValue: Matrix;
  16384. }): any;
  16385. /** @hidden */
  16386. _processLateAnimationBindingsForQuaternions(holder: {
  16387. totalWeight: number;
  16388. totalAdditiveWeight: number;
  16389. animations: RuntimeAnimation[];
  16390. additiveAnimations: RuntimeAnimation[];
  16391. originalValue: Quaternion;
  16392. }, refQuaternion: Quaternion): Quaternion;
  16393. /** @hidden */
  16394. _processLateAnimationBindings(): void;
  16395. /**
  16396. * Will start the animation sequence of a given target
  16397. * @param target defines the target
  16398. * @param from defines from which frame should animation start
  16399. * @param to defines until which frame should animation run.
  16400. * @param weight defines the weight to apply to the animation (1.0 by default)
  16401. * @param loop defines if the animation loops
  16402. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16403. * @param onAnimationEnd defines the function to be executed when the animation ends
  16404. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16405. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16406. * @param onAnimationLoop defines the callback to call when an animation loops
  16407. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16408. * @returns the animatable object created for this animation
  16409. */
  16410. 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;
  16411. /**
  16412. * Will start the animation sequence of a given target
  16413. * @param target defines the target
  16414. * @param from defines from which frame should animation start
  16415. * @param to defines until which frame should animation run.
  16416. * @param loop defines if the animation loops
  16417. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16418. * @param onAnimationEnd defines the function to be executed when the animation ends
  16419. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16420. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16421. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16422. * @param onAnimationLoop defines the callback to call when an animation loops
  16423. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16424. * @returns the animatable object created for this animation
  16425. */
  16426. 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;
  16427. /**
  16428. * Will start the animation sequence of a given target and its hierarchy
  16429. * @param target defines the target
  16430. * @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.
  16431. * @param from defines from which frame should animation start
  16432. * @param to defines until which frame should animation run.
  16433. * @param loop defines if the animation loops
  16434. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16435. * @param onAnimationEnd defines the function to be executed when the animation ends
  16436. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16437. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16438. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16439. * @param onAnimationLoop defines the callback to call when an animation loops
  16440. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16441. * @returns the list of created animatables
  16442. */
  16443. 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[];
  16444. /**
  16445. * Begin a new animation on a given node
  16446. * @param target defines the target where the animation will take place
  16447. * @param animations defines the list of animations to start
  16448. * @param from defines the initial value
  16449. * @param to defines the final value
  16450. * @param loop defines if you want animation to loop (off by default)
  16451. * @param speedRatio defines the speed ratio to apply to all animations
  16452. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16453. * @param onAnimationLoop defines the callback to call when an animation loops
  16454. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16455. * @returns the list of created animatables
  16456. */
  16457. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16458. /**
  16459. * Begin a new animation on a given node and its hierarchy
  16460. * @param target defines the root node where the animation will take place
  16461. * @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.
  16462. * @param animations defines the list of animations to start
  16463. * @param from defines the initial value
  16464. * @param to defines the final value
  16465. * @param loop defines if you want animation to loop (off by default)
  16466. * @param speedRatio defines the speed ratio to apply to all animations
  16467. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16468. * @param onAnimationLoop defines the callback to call when an animation loops
  16469. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16470. * @returns the list of animatables created for all nodes
  16471. */
  16472. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16473. /**
  16474. * Gets the animatable associated with a specific target
  16475. * @param target defines the target of the animatable
  16476. * @returns the required animatable if found
  16477. */
  16478. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16479. /**
  16480. * Gets all animatables associated with a given target
  16481. * @param target defines the target to look animatables for
  16482. * @returns an array of Animatables
  16483. */
  16484. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16485. /**
  16486. * Stops and removes all animations that have been applied to the scene
  16487. */
  16488. stopAllAnimations(): void;
  16489. /**
  16490. * Gets the current delta time used by animation engine
  16491. */
  16492. deltaTime: number;
  16493. }
  16494. }
  16495. module "babylonjs/Bones/bone" {
  16496. interface Bone {
  16497. /**
  16498. * Copy an animation range from another bone
  16499. * @param source defines the source bone
  16500. * @param rangeName defines the range name to copy
  16501. * @param frameOffset defines the frame offset
  16502. * @param rescaleAsRequired defines if rescaling must be applied if required
  16503. * @param skelDimensionsRatio defines the scaling ratio
  16504. * @returns true if operation was successful
  16505. */
  16506. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16507. }
  16508. }
  16509. }
  16510. declare module "babylonjs/Bones/skeleton" {
  16511. import { Bone } from "babylonjs/Bones/bone";
  16512. import { Observable } from "babylonjs/Misc/observable";
  16513. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16514. import { Scene } from "babylonjs/scene";
  16515. import { Nullable } from "babylonjs/types";
  16516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16517. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16518. import { Animatable } from "babylonjs/Animations/animatable";
  16519. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16520. import { Animation } from "babylonjs/Animations/animation";
  16521. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16522. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16523. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16524. /**
  16525. * Class used to handle skinning animations
  16526. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16527. */
  16528. export class Skeleton implements IAnimatable {
  16529. /** defines the skeleton name */
  16530. name: string;
  16531. /** defines the skeleton Id */
  16532. id: string;
  16533. /**
  16534. * Defines the list of child bones
  16535. */
  16536. bones: Bone[];
  16537. /**
  16538. * Defines an estimate of the dimension of the skeleton at rest
  16539. */
  16540. dimensionsAtRest: Vector3;
  16541. /**
  16542. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16543. */
  16544. needInitialSkinMatrix: boolean;
  16545. /**
  16546. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16547. */
  16548. overrideMesh: Nullable<AbstractMesh>;
  16549. /**
  16550. * Gets the list of animations attached to this skeleton
  16551. */
  16552. animations: Array<Animation>;
  16553. private _scene;
  16554. private _isDirty;
  16555. private _transformMatrices;
  16556. private _transformMatrixTexture;
  16557. private _meshesWithPoseMatrix;
  16558. private _animatables;
  16559. private _identity;
  16560. private _synchronizedWithMesh;
  16561. private _ranges;
  16562. private _lastAbsoluteTransformsUpdateId;
  16563. private _canUseTextureForBones;
  16564. private _uniqueId;
  16565. /** @hidden */
  16566. _numBonesWithLinkedTransformNode: number;
  16567. /** @hidden */
  16568. _hasWaitingData: Nullable<boolean>;
  16569. /** @hidden */
  16570. _waitingOverrideMeshId: Nullable<string>;
  16571. /**
  16572. * Specifies if the skeleton should be serialized
  16573. */
  16574. doNotSerialize: boolean;
  16575. private _useTextureToStoreBoneMatrices;
  16576. /**
  16577. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16578. * Please note that this option is not available if the hardware does not support it
  16579. */
  16580. get useTextureToStoreBoneMatrices(): boolean;
  16581. set useTextureToStoreBoneMatrices(value: boolean);
  16582. private _animationPropertiesOverride;
  16583. /**
  16584. * Gets or sets the animation properties override
  16585. */
  16586. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16587. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16588. /**
  16589. * List of inspectable custom properties (used by the Inspector)
  16590. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16591. */
  16592. inspectableCustomProperties: IInspectable[];
  16593. /**
  16594. * An observable triggered before computing the skeleton's matrices
  16595. */
  16596. onBeforeComputeObservable: Observable<Skeleton>;
  16597. /**
  16598. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16599. */
  16600. get isUsingTextureForMatrices(): boolean;
  16601. /**
  16602. * Gets the unique ID of this skeleton
  16603. */
  16604. get uniqueId(): number;
  16605. /**
  16606. * Creates a new skeleton
  16607. * @param name defines the skeleton name
  16608. * @param id defines the skeleton Id
  16609. * @param scene defines the hosting scene
  16610. */
  16611. constructor(
  16612. /** defines the skeleton name */
  16613. name: string,
  16614. /** defines the skeleton Id */
  16615. id: string, scene: Scene);
  16616. /**
  16617. * Gets the current object class name.
  16618. * @return the class name
  16619. */
  16620. getClassName(): string;
  16621. /**
  16622. * Returns an array containing the root bones
  16623. * @returns an array containing the root bones
  16624. */
  16625. getChildren(): Array<Bone>;
  16626. /**
  16627. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16628. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16629. * @returns a Float32Array containing matrices data
  16630. */
  16631. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16632. /**
  16633. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16634. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16635. * @returns a raw texture containing the data
  16636. */
  16637. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16638. /**
  16639. * Gets the current hosting scene
  16640. * @returns a scene object
  16641. */
  16642. getScene(): Scene;
  16643. /**
  16644. * Gets a string representing the current skeleton data
  16645. * @param fullDetails defines a boolean indicating if we want a verbose version
  16646. * @returns a string representing the current skeleton data
  16647. */
  16648. toString(fullDetails?: boolean): string;
  16649. /**
  16650. * Get bone's index searching by name
  16651. * @param name defines bone's name to search for
  16652. * @return the indice of the bone. Returns -1 if not found
  16653. */
  16654. getBoneIndexByName(name: string): number;
  16655. /**
  16656. * Creater a new animation range
  16657. * @param name defines the name of the range
  16658. * @param from defines the start key
  16659. * @param to defines the end key
  16660. */
  16661. createAnimationRange(name: string, from: number, to: number): void;
  16662. /**
  16663. * Delete a specific animation range
  16664. * @param name defines the name of the range
  16665. * @param deleteFrames defines if frames must be removed as well
  16666. */
  16667. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16668. /**
  16669. * Gets a specific animation range
  16670. * @param name defines the name of the range to look for
  16671. * @returns the requested animation range or null if not found
  16672. */
  16673. getAnimationRange(name: string): Nullable<AnimationRange>;
  16674. /**
  16675. * Gets the list of all animation ranges defined on this skeleton
  16676. * @returns an array
  16677. */
  16678. getAnimationRanges(): Nullable<AnimationRange>[];
  16679. /**
  16680. * Copy animation range from a source skeleton.
  16681. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16682. * @param source defines the source skeleton
  16683. * @param name defines the name of the range to copy
  16684. * @param rescaleAsRequired defines if rescaling must be applied if required
  16685. * @returns true if operation was successful
  16686. */
  16687. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16688. /**
  16689. * Forces the skeleton to go to rest pose
  16690. */
  16691. returnToRest(): void;
  16692. private _getHighestAnimationFrame;
  16693. /**
  16694. * Begin a specific animation range
  16695. * @param name defines the name of the range to start
  16696. * @param loop defines if looping must be turned on (false by default)
  16697. * @param speedRatio defines the speed ratio to apply (1 by default)
  16698. * @param onAnimationEnd defines a callback which will be called when animation will end
  16699. * @returns a new animatable
  16700. */
  16701. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16702. /**
  16703. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16704. * @param skeleton defines the Skeleton containing the animation range to convert
  16705. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16706. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16707. * @returns the original skeleton
  16708. */
  16709. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16710. /** @hidden */
  16711. _markAsDirty(): void;
  16712. /** @hidden */
  16713. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16714. /** @hidden */
  16715. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16716. private _computeTransformMatrices;
  16717. /**
  16718. * Build all resources required to render a skeleton
  16719. */
  16720. prepare(): void;
  16721. /**
  16722. * Gets the list of animatables currently running for this skeleton
  16723. * @returns an array of animatables
  16724. */
  16725. getAnimatables(): IAnimatable[];
  16726. /**
  16727. * Clone the current skeleton
  16728. * @param name defines the name of the new skeleton
  16729. * @param id defines the id of the new skeleton
  16730. * @returns the new skeleton
  16731. */
  16732. clone(name: string, id?: string): Skeleton;
  16733. /**
  16734. * Enable animation blending for this skeleton
  16735. * @param blendingSpeed defines the blending speed to apply
  16736. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16737. */
  16738. enableBlending(blendingSpeed?: number): void;
  16739. /**
  16740. * Releases all resources associated with the current skeleton
  16741. */
  16742. dispose(): void;
  16743. /**
  16744. * Serialize the skeleton in a JSON object
  16745. * @returns a JSON object
  16746. */
  16747. serialize(): any;
  16748. /**
  16749. * Creates a new skeleton from serialized data
  16750. * @param parsedSkeleton defines the serialized data
  16751. * @param scene defines the hosting scene
  16752. * @returns a new skeleton
  16753. */
  16754. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16755. /**
  16756. * Compute all node absolute transforms
  16757. * @param forceUpdate defines if computation must be done even if cache is up to date
  16758. */
  16759. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16760. /**
  16761. * Gets the root pose matrix
  16762. * @returns a matrix
  16763. */
  16764. getPoseMatrix(): Nullable<Matrix>;
  16765. /**
  16766. * Sorts bones per internal index
  16767. */
  16768. sortBones(): void;
  16769. private _sortBones;
  16770. /**
  16771. * Set the current local matrix as the restPose for all bones in the skeleton.
  16772. */
  16773. setCurrentPoseAsRest(): void;
  16774. }
  16775. }
  16776. declare module "babylonjs/Meshes/instancedMesh" {
  16777. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16778. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16779. import { Camera } from "babylonjs/Cameras/camera";
  16780. import { Node } from "babylonjs/node";
  16781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16782. import { Mesh } from "babylonjs/Meshes/mesh";
  16783. import { Material } from "babylonjs/Materials/material";
  16784. import { Skeleton } from "babylonjs/Bones/skeleton";
  16785. import { Light } from "babylonjs/Lights/light";
  16786. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16787. /**
  16788. * Creates an instance based on a source mesh.
  16789. */
  16790. export class InstancedMesh extends AbstractMesh {
  16791. private _sourceMesh;
  16792. private _currentLOD;
  16793. /** @hidden */
  16794. _indexInSourceMeshInstanceArray: number;
  16795. constructor(name: string, source: Mesh);
  16796. /**
  16797. * Returns the string "InstancedMesh".
  16798. */
  16799. getClassName(): string;
  16800. /** Gets the list of lights affecting that mesh */
  16801. get lightSources(): Light[];
  16802. _resyncLightSources(): void;
  16803. _resyncLightSource(light: Light): void;
  16804. _removeLightSource(light: Light, dispose: boolean): void;
  16805. /**
  16806. * If the source mesh receives shadows
  16807. */
  16808. get receiveShadows(): boolean;
  16809. /**
  16810. * The material of the source mesh
  16811. */
  16812. get material(): Nullable<Material>;
  16813. /**
  16814. * Visibility of the source mesh
  16815. */
  16816. get visibility(): number;
  16817. /**
  16818. * Skeleton of the source mesh
  16819. */
  16820. get skeleton(): Nullable<Skeleton>;
  16821. /**
  16822. * Rendering ground id of the source mesh
  16823. */
  16824. get renderingGroupId(): number;
  16825. set renderingGroupId(value: number);
  16826. /**
  16827. * Returns the total number of vertices (integer).
  16828. */
  16829. getTotalVertices(): number;
  16830. /**
  16831. * Returns a positive integer : the total number of indices in this mesh geometry.
  16832. * @returns the numner of indices or zero if the mesh has no geometry.
  16833. */
  16834. getTotalIndices(): number;
  16835. /**
  16836. * The source mesh of the instance
  16837. */
  16838. get sourceMesh(): Mesh;
  16839. /**
  16840. * Creates a new InstancedMesh object from the mesh model.
  16841. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16842. * @param name defines the name of the new instance
  16843. * @returns a new InstancedMesh
  16844. */
  16845. createInstance(name: string): InstancedMesh;
  16846. /**
  16847. * Is this node ready to be used/rendered
  16848. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16849. * @return {boolean} is it ready
  16850. */
  16851. isReady(completeCheck?: boolean): boolean;
  16852. /**
  16853. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16854. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16855. * @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.
  16856. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16857. */
  16858. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16859. /**
  16860. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16861. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16862. * The `data` are either a numeric array either a Float32Array.
  16863. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16864. * 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).
  16865. * Note that a new underlying VertexBuffer object is created each call.
  16866. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16867. *
  16868. * Possible `kind` values :
  16869. * - VertexBuffer.PositionKind
  16870. * - VertexBuffer.UVKind
  16871. * - VertexBuffer.UV2Kind
  16872. * - VertexBuffer.UV3Kind
  16873. * - VertexBuffer.UV4Kind
  16874. * - VertexBuffer.UV5Kind
  16875. * - VertexBuffer.UV6Kind
  16876. * - VertexBuffer.ColorKind
  16877. * - VertexBuffer.MatricesIndicesKind
  16878. * - VertexBuffer.MatricesIndicesExtraKind
  16879. * - VertexBuffer.MatricesWeightsKind
  16880. * - VertexBuffer.MatricesWeightsExtraKind
  16881. *
  16882. * Returns the Mesh.
  16883. */
  16884. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16885. /**
  16886. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16887. * If the mesh has no geometry, it is simply returned as it is.
  16888. * The `data` are either a numeric array either a Float32Array.
  16889. * No new underlying VertexBuffer object is created.
  16890. * 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.
  16891. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16892. *
  16893. * Possible `kind` values :
  16894. * - VertexBuffer.PositionKind
  16895. * - VertexBuffer.UVKind
  16896. * - VertexBuffer.UV2Kind
  16897. * - VertexBuffer.UV3Kind
  16898. * - VertexBuffer.UV4Kind
  16899. * - VertexBuffer.UV5Kind
  16900. * - VertexBuffer.UV6Kind
  16901. * - VertexBuffer.ColorKind
  16902. * - VertexBuffer.MatricesIndicesKind
  16903. * - VertexBuffer.MatricesIndicesExtraKind
  16904. * - VertexBuffer.MatricesWeightsKind
  16905. * - VertexBuffer.MatricesWeightsExtraKind
  16906. *
  16907. * Returns the Mesh.
  16908. */
  16909. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16910. /**
  16911. * Sets the mesh indices.
  16912. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16913. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16914. * This method creates a new index buffer each call.
  16915. * Returns the Mesh.
  16916. */
  16917. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16918. /**
  16919. * Boolean : True if the mesh owns the requested kind of data.
  16920. */
  16921. isVerticesDataPresent(kind: string): boolean;
  16922. /**
  16923. * Returns an array of indices (IndicesArray).
  16924. */
  16925. getIndices(): Nullable<IndicesArray>;
  16926. get _positions(): Nullable<Vector3[]>;
  16927. /**
  16928. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16929. * This means the mesh underlying bounding box and sphere are recomputed.
  16930. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16931. * @returns the current mesh
  16932. */
  16933. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16934. /** @hidden */
  16935. _preActivate(): InstancedMesh;
  16936. /** @hidden */
  16937. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16938. /** @hidden */
  16939. _postActivate(): void;
  16940. getWorldMatrix(): Matrix;
  16941. get isAnInstance(): boolean;
  16942. /**
  16943. * Returns the current associated LOD AbstractMesh.
  16944. */
  16945. getLOD(camera: Camera): AbstractMesh;
  16946. /** @hidden */
  16947. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16948. /** @hidden */
  16949. _syncSubMeshes(): InstancedMesh;
  16950. /** @hidden */
  16951. _generatePointsArray(): boolean;
  16952. /** @hidden */
  16953. _updateBoundingInfo(): AbstractMesh;
  16954. /**
  16955. * Creates a new InstancedMesh from the current mesh.
  16956. * - name (string) : the cloned mesh name
  16957. * - newParent (optional Node) : the optional Node to parent the clone to.
  16958. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16959. *
  16960. * Returns the clone.
  16961. */
  16962. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16963. /**
  16964. * Disposes the InstancedMesh.
  16965. * Returns nothing.
  16966. */
  16967. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16968. }
  16969. module "babylonjs/Meshes/mesh" {
  16970. interface Mesh {
  16971. /**
  16972. * Register a custom buffer that will be instanced
  16973. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16974. * @param kind defines the buffer kind
  16975. * @param stride defines the stride in floats
  16976. */
  16977. registerInstancedBuffer(kind: string, stride: number): void;
  16978. /**
  16979. * true to use the edge renderer for all instances of this mesh
  16980. */
  16981. edgesShareWithInstances: boolean;
  16982. /** @hidden */
  16983. _userInstancedBuffersStorage: {
  16984. data: {
  16985. [key: string]: Float32Array;
  16986. };
  16987. sizes: {
  16988. [key: string]: number;
  16989. };
  16990. vertexBuffers: {
  16991. [key: string]: Nullable<VertexBuffer>;
  16992. };
  16993. strides: {
  16994. [key: string]: number;
  16995. };
  16996. };
  16997. }
  16998. }
  16999. module "babylonjs/Meshes/abstractMesh" {
  17000. interface AbstractMesh {
  17001. /**
  17002. * Object used to store instanced buffers defined by user
  17003. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  17004. */
  17005. instancedBuffers: {
  17006. [key: string]: any;
  17007. };
  17008. }
  17009. }
  17010. }
  17011. declare module "babylonjs/Materials/shaderMaterial" {
  17012. import { Nullable } from "babylonjs/types";
  17013. import { Scene } from "babylonjs/scene";
  17014. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  17015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17016. import { Mesh } from "babylonjs/Meshes/mesh";
  17017. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17018. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17019. import { Effect } from "babylonjs/Materials/effect";
  17020. import { Material } from "babylonjs/Materials/material";
  17021. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  17022. /**
  17023. * Defines the options associated with the creation of a shader material.
  17024. */
  17025. export interface IShaderMaterialOptions {
  17026. /**
  17027. * Does the material work in alpha blend mode
  17028. */
  17029. needAlphaBlending: boolean;
  17030. /**
  17031. * Does the material work in alpha test mode
  17032. */
  17033. needAlphaTesting: boolean;
  17034. /**
  17035. * The list of attribute names used in the shader
  17036. */
  17037. attributes: string[];
  17038. /**
  17039. * The list of unifrom names used in the shader
  17040. */
  17041. uniforms: string[];
  17042. /**
  17043. * The list of UBO names used in the shader
  17044. */
  17045. uniformBuffers: string[];
  17046. /**
  17047. * The list of sampler names used in the shader
  17048. */
  17049. samplers: string[];
  17050. /**
  17051. * The list of defines used in the shader
  17052. */
  17053. defines: string[];
  17054. }
  17055. /**
  17056. * 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.
  17057. *
  17058. * This returned material effects how the mesh will look based on the code in the shaders.
  17059. *
  17060. * @see https://doc.babylonjs.com/how_to/shader_material
  17061. */
  17062. export class ShaderMaterial extends Material {
  17063. private _shaderPath;
  17064. private _options;
  17065. private _textures;
  17066. private _textureArrays;
  17067. private _floats;
  17068. private _ints;
  17069. private _floatsArrays;
  17070. private _colors3;
  17071. private _colors3Arrays;
  17072. private _colors4;
  17073. private _colors4Arrays;
  17074. private _vectors2;
  17075. private _vectors3;
  17076. private _vectors4;
  17077. private _matrices;
  17078. private _matrixArrays;
  17079. private _matrices3x3;
  17080. private _matrices2x2;
  17081. private _vectors2Arrays;
  17082. private _vectors3Arrays;
  17083. private _vectors4Arrays;
  17084. private _cachedWorldViewMatrix;
  17085. private _cachedWorldViewProjectionMatrix;
  17086. private _renderId;
  17087. private _multiview;
  17088. private _cachedDefines;
  17089. /** Define the Url to load snippets */
  17090. static SnippetUrl: string;
  17091. /** Snippet ID if the material was created from the snippet server */
  17092. snippetId: string;
  17093. /**
  17094. * Instantiate a new shader material.
  17095. * 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.
  17096. * This returned material effects how the mesh will look based on the code in the shaders.
  17097. * @see https://doc.babylonjs.com/how_to/shader_material
  17098. * @param name Define the name of the material in the scene
  17099. * @param scene Define the scene the material belongs to
  17100. * @param shaderPath Defines the route to the shader code in one of three ways:
  17101. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17102. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17103. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17104. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17105. * @param options Define the options used to create the shader
  17106. */
  17107. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17108. /**
  17109. * Gets the shader path used to define the shader code
  17110. * It can be modified to trigger a new compilation
  17111. */
  17112. get shaderPath(): any;
  17113. /**
  17114. * Sets the shader path used to define the shader code
  17115. * It can be modified to trigger a new compilation
  17116. */
  17117. set shaderPath(shaderPath: any);
  17118. /**
  17119. * Gets the options used to compile the shader.
  17120. * They can be modified to trigger a new compilation
  17121. */
  17122. get options(): IShaderMaterialOptions;
  17123. /**
  17124. * Gets the current class name of the material e.g. "ShaderMaterial"
  17125. * Mainly use in serialization.
  17126. * @returns the class name
  17127. */
  17128. getClassName(): string;
  17129. /**
  17130. * Specifies if the material will require alpha blending
  17131. * @returns a boolean specifying if alpha blending is needed
  17132. */
  17133. needAlphaBlending(): boolean;
  17134. /**
  17135. * Specifies if this material should be rendered in alpha test mode
  17136. * @returns a boolean specifying if an alpha test is needed.
  17137. */
  17138. needAlphaTesting(): boolean;
  17139. private _checkUniform;
  17140. /**
  17141. * Set a texture in the shader.
  17142. * @param name Define the name of the uniform samplers as defined in the shader
  17143. * @param texture Define the texture to bind to this sampler
  17144. * @return the material itself allowing "fluent" like uniform updates
  17145. */
  17146. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17147. /**
  17148. * Set a texture array in the shader.
  17149. * @param name Define the name of the uniform sampler array as defined in the shader
  17150. * @param textures Define the list of textures to bind to this sampler
  17151. * @return the material itself allowing "fluent" like uniform updates
  17152. */
  17153. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17154. /**
  17155. * Set a float in the shader.
  17156. * @param name Define the name of the uniform as defined in the shader
  17157. * @param value Define the value to give to the uniform
  17158. * @return the material itself allowing "fluent" like uniform updates
  17159. */
  17160. setFloat(name: string, value: number): ShaderMaterial;
  17161. /**
  17162. * Set a int in the shader.
  17163. * @param name Define the name of the uniform as defined in the shader
  17164. * @param value Define the value to give to the uniform
  17165. * @return the material itself allowing "fluent" like uniform updates
  17166. */
  17167. setInt(name: string, value: number): ShaderMaterial;
  17168. /**
  17169. * Set an array of floats in the shader.
  17170. * @param name Define the name of the uniform as defined in the shader
  17171. * @param value Define the value to give to the uniform
  17172. * @return the material itself allowing "fluent" like uniform updates
  17173. */
  17174. setFloats(name: string, value: number[]): ShaderMaterial;
  17175. /**
  17176. * Set a vec3 in the shader from a Color3.
  17177. * @param name Define the name of the uniform as defined in the shader
  17178. * @param value Define the value to give to the uniform
  17179. * @return the material itself allowing "fluent" like uniform updates
  17180. */
  17181. setColor3(name: string, value: Color3): ShaderMaterial;
  17182. /**
  17183. * Set a vec3 array in the shader from a Color3 array.
  17184. * @param name Define the name of the uniform as defined in the shader
  17185. * @param value Define the value to give to the uniform
  17186. * @return the material itself allowing "fluent" like uniform updates
  17187. */
  17188. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17189. /**
  17190. * Set a vec4 in the shader from a Color4.
  17191. * @param name Define the name of the uniform as defined in the shader
  17192. * @param value Define the value to give to the uniform
  17193. * @return the material itself allowing "fluent" like uniform updates
  17194. */
  17195. setColor4(name: string, value: Color4): ShaderMaterial;
  17196. /**
  17197. * Set a vec4 array in the shader from a Color4 array.
  17198. * @param name Define the name of the uniform as defined in the shader
  17199. * @param value Define the value to give to the uniform
  17200. * @return the material itself allowing "fluent" like uniform updates
  17201. */
  17202. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17203. /**
  17204. * Set a vec2 in the shader from a Vector2.
  17205. * @param name Define the name of the uniform as defined in the shader
  17206. * @param value Define the value to give to the uniform
  17207. * @return the material itself allowing "fluent" like uniform updates
  17208. */
  17209. setVector2(name: string, value: Vector2): ShaderMaterial;
  17210. /**
  17211. * Set a vec3 in the shader from a Vector3.
  17212. * @param name Define the name of the uniform as defined in the shader
  17213. * @param value Define the value to give to the uniform
  17214. * @return the material itself allowing "fluent" like uniform updates
  17215. */
  17216. setVector3(name: string, value: Vector3): ShaderMaterial;
  17217. /**
  17218. * Set a vec4 in the shader from a Vector4.
  17219. * @param name Define the name of the uniform as defined in the shader
  17220. * @param value Define the value to give to the uniform
  17221. * @return the material itself allowing "fluent" like uniform updates
  17222. */
  17223. setVector4(name: string, value: Vector4): ShaderMaterial;
  17224. /**
  17225. * Set a mat4 in the shader from a Matrix.
  17226. * @param name Define the name of the uniform as defined in the shader
  17227. * @param value Define the value to give to the uniform
  17228. * @return the material itself allowing "fluent" like uniform updates
  17229. */
  17230. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17231. /**
  17232. * Set a float32Array in the shader from a matrix array.
  17233. * @param name Define the name of the uniform as defined in the shader
  17234. * @param value Define the value to give to the uniform
  17235. * @return the material itself allowing "fluent" like uniform updates
  17236. */
  17237. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17238. /**
  17239. * Set a mat3 in the shader from a Float32Array.
  17240. * @param name Define the name of the uniform as defined in the shader
  17241. * @param value Define the value to give to the uniform
  17242. * @return the material itself allowing "fluent" like uniform updates
  17243. */
  17244. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17245. /**
  17246. * Set a mat2 in the shader from a Float32Array.
  17247. * @param name Define the name of the uniform as defined in the shader
  17248. * @param value Define the value to give to the uniform
  17249. * @return the material itself allowing "fluent" like uniform updates
  17250. */
  17251. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17252. /**
  17253. * Set a vec2 array in the shader from a number array.
  17254. * @param name Define the name of the uniform as defined in the shader
  17255. * @param value Define the value to give to the uniform
  17256. * @return the material itself allowing "fluent" like uniform updates
  17257. */
  17258. setArray2(name: string, value: number[]): ShaderMaterial;
  17259. /**
  17260. * Set a vec3 array in the shader from a number array.
  17261. * @param name Define the name of the uniform as defined in the shader
  17262. * @param value Define the value to give to the uniform
  17263. * @return the material itself allowing "fluent" like uniform updates
  17264. */
  17265. setArray3(name: string, value: number[]): ShaderMaterial;
  17266. /**
  17267. * Set a vec4 array in the shader from a number array.
  17268. * @param name Define the name of the uniform as defined in the shader
  17269. * @param value Define the value to give to the uniform
  17270. * @return the material itself allowing "fluent" like uniform updates
  17271. */
  17272. setArray4(name: string, value: number[]): ShaderMaterial;
  17273. private _checkCache;
  17274. /**
  17275. * Specifies that the submesh is ready to be used
  17276. * @param mesh defines the mesh to check
  17277. * @param subMesh defines which submesh to check
  17278. * @param useInstances specifies that instances should be used
  17279. * @returns a boolean indicating that the submesh is ready or not
  17280. */
  17281. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17282. /**
  17283. * Checks if the material is ready to render the requested mesh
  17284. * @param mesh Define the mesh to render
  17285. * @param useInstances Define whether or not the material is used with instances
  17286. * @returns true if ready, otherwise false
  17287. */
  17288. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17289. /**
  17290. * Binds the world matrix to the material
  17291. * @param world defines the world transformation matrix
  17292. * @param effectOverride - If provided, use this effect instead of internal effect
  17293. */
  17294. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17295. /**
  17296. * Binds the submesh to this material by preparing the effect and shader to draw
  17297. * @param world defines the world transformation matrix
  17298. * @param mesh defines the mesh containing the submesh
  17299. * @param subMesh defines the submesh to bind the material to
  17300. */
  17301. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17302. /**
  17303. * Binds the material to the mesh
  17304. * @param world defines the world transformation matrix
  17305. * @param mesh defines the mesh to bind the material to
  17306. * @param effectOverride - If provided, use this effect instead of internal effect
  17307. */
  17308. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17309. protected _afterBind(mesh?: Mesh): void;
  17310. /**
  17311. * Gets the active textures from the material
  17312. * @returns an array of textures
  17313. */
  17314. getActiveTextures(): BaseTexture[];
  17315. /**
  17316. * Specifies if the material uses a texture
  17317. * @param texture defines the texture to check against the material
  17318. * @returns a boolean specifying if the material uses the texture
  17319. */
  17320. hasTexture(texture: BaseTexture): boolean;
  17321. /**
  17322. * Makes a duplicate of the material, and gives it a new name
  17323. * @param name defines the new name for the duplicated material
  17324. * @returns the cloned material
  17325. */
  17326. clone(name: string): ShaderMaterial;
  17327. /**
  17328. * Disposes the material
  17329. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17330. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17331. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17332. */
  17333. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17334. /**
  17335. * Serializes this material in a JSON representation
  17336. * @returns the serialized material object
  17337. */
  17338. serialize(): any;
  17339. /**
  17340. * Creates a shader material from parsed shader material data
  17341. * @param source defines the JSON represnetation of the material
  17342. * @param scene defines the hosting scene
  17343. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17344. * @returns a new material
  17345. */
  17346. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17347. /**
  17348. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17349. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17350. * @param url defines the url to load from
  17351. * @param scene defines the hosting scene
  17352. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17353. * @returns a promise that will resolve to the new ShaderMaterial
  17354. */
  17355. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17356. /**
  17357. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17358. * @param snippetId defines the snippet to load
  17359. * @param scene defines the hosting scene
  17360. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17361. * @returns a promise that will resolve to the new ShaderMaterial
  17362. */
  17363. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17364. }
  17365. }
  17366. declare module "babylonjs/Shaders/color.fragment" {
  17367. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17368. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17369. /** @hidden */
  17370. export var colorPixelShader: {
  17371. name: string;
  17372. shader: string;
  17373. };
  17374. }
  17375. declare module "babylonjs/Shaders/color.vertex" {
  17376. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17377. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17378. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17379. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17380. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17381. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17382. /** @hidden */
  17383. export var colorVertexShader: {
  17384. name: string;
  17385. shader: string;
  17386. };
  17387. }
  17388. declare module "babylonjs/Meshes/linesMesh" {
  17389. import { Nullable } from "babylonjs/types";
  17390. import { Scene } from "babylonjs/scene";
  17391. import { Color3 } from "babylonjs/Maths/math.color";
  17392. import { Node } from "babylonjs/node";
  17393. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17394. import { Mesh } from "babylonjs/Meshes/mesh";
  17395. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17396. import { Effect } from "babylonjs/Materials/effect";
  17397. import { Material } from "babylonjs/Materials/material";
  17398. import "babylonjs/Shaders/color.fragment";
  17399. import "babylonjs/Shaders/color.vertex";
  17400. /**
  17401. * Line mesh
  17402. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17403. */
  17404. export class LinesMesh extends Mesh {
  17405. /**
  17406. * If vertex color should be applied to the mesh
  17407. */
  17408. readonly useVertexColor?: boolean | undefined;
  17409. /**
  17410. * If vertex alpha should be applied to the mesh
  17411. */
  17412. readonly useVertexAlpha?: boolean | undefined;
  17413. /**
  17414. * Color of the line (Default: White)
  17415. */
  17416. color: Color3;
  17417. /**
  17418. * Alpha of the line (Default: 1)
  17419. */
  17420. alpha: number;
  17421. /**
  17422. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17423. * This margin is expressed in world space coordinates, so its value may vary.
  17424. * Default value is 0.1
  17425. */
  17426. intersectionThreshold: number;
  17427. private _colorShader;
  17428. private color4;
  17429. /**
  17430. * Creates a new LinesMesh
  17431. * @param name defines the name
  17432. * @param scene defines the hosting scene
  17433. * @param parent defines the parent mesh if any
  17434. * @param source defines the optional source LinesMesh used to clone data from
  17435. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17436. * When false, achieved by calling a clone(), also passing False.
  17437. * This will make creation of children, recursive.
  17438. * @param useVertexColor defines if this LinesMesh supports vertex color
  17439. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17440. */
  17441. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17442. /**
  17443. * If vertex color should be applied to the mesh
  17444. */
  17445. useVertexColor?: boolean | undefined,
  17446. /**
  17447. * If vertex alpha should be applied to the mesh
  17448. */
  17449. useVertexAlpha?: boolean | undefined);
  17450. private _addClipPlaneDefine;
  17451. private _removeClipPlaneDefine;
  17452. isReady(): boolean;
  17453. /**
  17454. * Returns the string "LineMesh"
  17455. */
  17456. getClassName(): string;
  17457. /**
  17458. * @hidden
  17459. */
  17460. get material(): Material;
  17461. /**
  17462. * @hidden
  17463. */
  17464. set material(value: Material);
  17465. /**
  17466. * @hidden
  17467. */
  17468. get checkCollisions(): boolean;
  17469. /** @hidden */
  17470. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17471. /** @hidden */
  17472. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17473. /**
  17474. * Disposes of the line mesh
  17475. * @param doNotRecurse If children should be disposed
  17476. */
  17477. dispose(doNotRecurse?: boolean): void;
  17478. /**
  17479. * Returns a new LineMesh object cloned from the current one.
  17480. */
  17481. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17482. /**
  17483. * Creates a new InstancedLinesMesh object from the mesh model.
  17484. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17485. * @param name defines the name of the new instance
  17486. * @returns a new InstancedLinesMesh
  17487. */
  17488. createInstance(name: string): InstancedLinesMesh;
  17489. }
  17490. /**
  17491. * Creates an instance based on a source LinesMesh
  17492. */
  17493. export class InstancedLinesMesh extends InstancedMesh {
  17494. /**
  17495. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17496. * This margin is expressed in world space coordinates, so its value may vary.
  17497. * Initilized with the intersectionThreshold value of the source LinesMesh
  17498. */
  17499. intersectionThreshold: number;
  17500. constructor(name: string, source: LinesMesh);
  17501. /**
  17502. * Returns the string "InstancedLinesMesh".
  17503. */
  17504. getClassName(): string;
  17505. }
  17506. }
  17507. declare module "babylonjs/Shaders/line.fragment" {
  17508. /** @hidden */
  17509. export var linePixelShader: {
  17510. name: string;
  17511. shader: string;
  17512. };
  17513. }
  17514. declare module "babylonjs/Shaders/line.vertex" {
  17515. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17516. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17517. /** @hidden */
  17518. export var lineVertexShader: {
  17519. name: string;
  17520. shader: string;
  17521. };
  17522. }
  17523. declare module "babylonjs/Rendering/edgesRenderer" {
  17524. import { Nullable } from "babylonjs/types";
  17525. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17527. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17528. import { IDisposable } from "babylonjs/scene";
  17529. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17530. import "babylonjs/Shaders/line.fragment";
  17531. import "babylonjs/Shaders/line.vertex";
  17532. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17533. import { SmartArray } from "babylonjs/Misc/smartArray";
  17534. module "babylonjs/scene" {
  17535. interface Scene {
  17536. /** @hidden */
  17537. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17538. }
  17539. }
  17540. module "babylonjs/Meshes/abstractMesh" {
  17541. interface AbstractMesh {
  17542. /**
  17543. * Gets the edgesRenderer associated with the mesh
  17544. */
  17545. edgesRenderer: Nullable<EdgesRenderer>;
  17546. }
  17547. }
  17548. module "babylonjs/Meshes/linesMesh" {
  17549. interface LinesMesh {
  17550. /**
  17551. * Enables the edge rendering mode on the mesh.
  17552. * This mode makes the mesh edges visible
  17553. * @param epsilon defines the maximal distance between two angles to detect a face
  17554. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17555. * @returns the currentAbstractMesh
  17556. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17557. */
  17558. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17559. }
  17560. }
  17561. module "babylonjs/Meshes/linesMesh" {
  17562. interface InstancedLinesMesh {
  17563. /**
  17564. * Enables the edge rendering mode on the mesh.
  17565. * This mode makes the mesh edges visible
  17566. * @param epsilon defines the maximal distance between two angles to detect a face
  17567. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17568. * @returns the current InstancedLinesMesh
  17569. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17570. */
  17571. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17572. }
  17573. }
  17574. /**
  17575. * Defines the minimum contract an Edges renderer should follow.
  17576. */
  17577. export interface IEdgesRenderer extends IDisposable {
  17578. /**
  17579. * Gets or sets a boolean indicating if the edgesRenderer is active
  17580. */
  17581. isEnabled: boolean;
  17582. /**
  17583. * Renders the edges of the attached mesh,
  17584. */
  17585. render(): void;
  17586. /**
  17587. * Checks wether or not the edges renderer is ready to render.
  17588. * @return true if ready, otherwise false.
  17589. */
  17590. isReady(): boolean;
  17591. /**
  17592. * List of instances to render in case the source mesh has instances
  17593. */
  17594. customInstances: SmartArray<Matrix>;
  17595. }
  17596. /**
  17597. * Defines the additional options of the edges renderer
  17598. */
  17599. export interface IEdgesRendererOptions {
  17600. /**
  17601. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17602. * If not defined, the default value is true
  17603. */
  17604. useAlternateEdgeFinder?: boolean;
  17605. /**
  17606. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17607. * If not defined, the default value is true.
  17608. * 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)
  17609. * This option is used only if useAlternateEdgeFinder = true
  17610. */
  17611. useFastVertexMerger?: boolean;
  17612. /**
  17613. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17614. * The default value is 1e-6
  17615. * This option is used only if useAlternateEdgeFinder = true
  17616. */
  17617. epsilonVertexMerge?: number;
  17618. /**
  17619. * 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
  17620. * 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.
  17621. * This option is used only if useAlternateEdgeFinder = true
  17622. */
  17623. applyTessellation?: boolean;
  17624. /**
  17625. * 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
  17626. * The default value is 1e-6
  17627. * This option is used only if useAlternateEdgeFinder = true
  17628. */
  17629. epsilonVertexAligned?: number;
  17630. }
  17631. /**
  17632. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17633. */
  17634. export class EdgesRenderer implements IEdgesRenderer {
  17635. /**
  17636. * Define the size of the edges with an orthographic camera
  17637. */
  17638. edgesWidthScalerForOrthographic: number;
  17639. /**
  17640. * Define the size of the edges with a perspective camera
  17641. */
  17642. edgesWidthScalerForPerspective: number;
  17643. protected _source: AbstractMesh;
  17644. protected _linesPositions: number[];
  17645. protected _linesNormals: number[];
  17646. protected _linesIndices: number[];
  17647. protected _epsilon: number;
  17648. protected _indicesCount: number;
  17649. protected _lineShader: ShaderMaterial;
  17650. protected _ib: DataBuffer;
  17651. protected _buffers: {
  17652. [key: string]: Nullable<VertexBuffer>;
  17653. };
  17654. protected _buffersForInstances: {
  17655. [key: string]: Nullable<VertexBuffer>;
  17656. };
  17657. protected _checkVerticesInsteadOfIndices: boolean;
  17658. protected _options: Nullable<IEdgesRendererOptions>;
  17659. private _meshRebuildObserver;
  17660. private _meshDisposeObserver;
  17661. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17662. isEnabled: boolean;
  17663. /**
  17664. * List of instances to render in case the source mesh has instances
  17665. */
  17666. customInstances: SmartArray<Matrix>;
  17667. private static GetShader;
  17668. /**
  17669. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17670. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17671. * @param source Mesh used to create edges
  17672. * @param epsilon sum of angles in adjacency to check for edge
  17673. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17674. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17675. * @param options The options to apply when generating the edges
  17676. */
  17677. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17678. protected _prepareRessources(): void;
  17679. /** @hidden */
  17680. _rebuild(): void;
  17681. /**
  17682. * Releases the required resources for the edges renderer
  17683. */
  17684. dispose(): void;
  17685. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17686. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17687. /**
  17688. * Checks if the pair of p0 and p1 is en edge
  17689. * @param faceIndex
  17690. * @param edge
  17691. * @param faceNormals
  17692. * @param p0
  17693. * @param p1
  17694. * @private
  17695. */
  17696. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17697. /**
  17698. * push line into the position, normal and index buffer
  17699. * @protected
  17700. */
  17701. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17702. /**
  17703. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17704. */
  17705. private _tessellateTriangle;
  17706. private _generateEdgesLinesAlternate;
  17707. /**
  17708. * Generates lines edges from adjacencjes
  17709. * @private
  17710. */
  17711. _generateEdgesLines(): void;
  17712. /**
  17713. * Checks wether or not the edges renderer is ready to render.
  17714. * @return true if ready, otherwise false.
  17715. */
  17716. isReady(): boolean;
  17717. /**
  17718. * Renders the edges of the attached mesh,
  17719. */
  17720. render(): void;
  17721. }
  17722. /**
  17723. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17724. */
  17725. export class LineEdgesRenderer extends EdgesRenderer {
  17726. /**
  17727. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17728. * @param source LineMesh used to generate edges
  17729. * @param epsilon not important (specified angle for edge detection)
  17730. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17731. */
  17732. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17733. /**
  17734. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17735. */
  17736. _generateEdgesLines(): void;
  17737. }
  17738. }
  17739. declare module "babylonjs/Rendering/renderingGroup" {
  17740. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17741. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17743. import { Nullable } from "babylonjs/types";
  17744. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17745. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17746. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17747. import { Material } from "babylonjs/Materials/material";
  17748. import { Scene } from "babylonjs/scene";
  17749. /**
  17750. * This represents the object necessary to create a rendering group.
  17751. * This is exclusively used and created by the rendering manager.
  17752. * To modify the behavior, you use the available helpers in your scene or meshes.
  17753. * @hidden
  17754. */
  17755. export class RenderingGroup {
  17756. index: number;
  17757. private static _zeroVector;
  17758. private _scene;
  17759. private _opaqueSubMeshes;
  17760. private _transparentSubMeshes;
  17761. private _alphaTestSubMeshes;
  17762. private _depthOnlySubMeshes;
  17763. private _particleSystems;
  17764. private _spriteManagers;
  17765. private _opaqueSortCompareFn;
  17766. private _alphaTestSortCompareFn;
  17767. private _transparentSortCompareFn;
  17768. private _renderOpaque;
  17769. private _renderAlphaTest;
  17770. private _renderTransparent;
  17771. /** @hidden */
  17772. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17773. onBeforeTransparentRendering: () => void;
  17774. /**
  17775. * Set the opaque sort comparison function.
  17776. * If null the sub meshes will be render in the order they were created
  17777. */
  17778. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17779. /**
  17780. * Set the alpha test sort comparison function.
  17781. * If null the sub meshes will be render in the order they were created
  17782. */
  17783. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17784. /**
  17785. * Set the transparent sort comparison function.
  17786. * If null the sub meshes will be render in the order they were created
  17787. */
  17788. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17789. /**
  17790. * Creates a new rendering group.
  17791. * @param index The rendering group index
  17792. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17793. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17794. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17795. */
  17796. 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>);
  17797. /**
  17798. * Render all the sub meshes contained in the group.
  17799. * @param customRenderFunction Used to override the default render behaviour of the group.
  17800. * @returns true if rendered some submeshes.
  17801. */
  17802. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17803. /**
  17804. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17805. * @param subMeshes The submeshes to render
  17806. */
  17807. private renderOpaqueSorted;
  17808. /**
  17809. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17810. * @param subMeshes The submeshes to render
  17811. */
  17812. private renderAlphaTestSorted;
  17813. /**
  17814. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17815. * @param subMeshes The submeshes to render
  17816. */
  17817. private renderTransparentSorted;
  17818. /**
  17819. * Renders the submeshes in a specified order.
  17820. * @param subMeshes The submeshes to sort before render
  17821. * @param sortCompareFn The comparison function use to sort
  17822. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17823. * @param transparent Specifies to activate blending if true
  17824. */
  17825. private static renderSorted;
  17826. /**
  17827. * Renders the submeshes in the order they were dispatched (no sort applied).
  17828. * @param subMeshes The submeshes to render
  17829. */
  17830. private static renderUnsorted;
  17831. /**
  17832. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17833. * are rendered back to front if in the same alpha index.
  17834. *
  17835. * @param a The first submesh
  17836. * @param b The second submesh
  17837. * @returns The result of the comparison
  17838. */
  17839. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17840. /**
  17841. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17842. * are rendered back to front.
  17843. *
  17844. * @param a The first submesh
  17845. * @param b The second submesh
  17846. * @returns The result of the comparison
  17847. */
  17848. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17849. /**
  17850. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17851. * are rendered front to back (prevent overdraw).
  17852. *
  17853. * @param a The first submesh
  17854. * @param b The second submesh
  17855. * @returns The result of the comparison
  17856. */
  17857. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17858. /**
  17859. * Resets the different lists of submeshes to prepare a new frame.
  17860. */
  17861. prepare(): void;
  17862. dispose(): void;
  17863. /**
  17864. * Inserts the submesh in its correct queue depending on its material.
  17865. * @param subMesh The submesh to dispatch
  17866. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17867. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17868. */
  17869. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17870. dispatchSprites(spriteManager: ISpriteManager): void;
  17871. dispatchParticles(particleSystem: IParticleSystem): void;
  17872. private _renderParticles;
  17873. private _renderSprites;
  17874. }
  17875. }
  17876. declare module "babylonjs/Rendering/renderingManager" {
  17877. import { Nullable } from "babylonjs/types";
  17878. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17879. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17880. import { SmartArray } from "babylonjs/Misc/smartArray";
  17881. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17882. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17883. import { Material } from "babylonjs/Materials/material";
  17884. import { Scene } from "babylonjs/scene";
  17885. import { Camera } from "babylonjs/Cameras/camera";
  17886. /**
  17887. * Interface describing the different options available in the rendering manager
  17888. * regarding Auto Clear between groups.
  17889. */
  17890. export interface IRenderingManagerAutoClearSetup {
  17891. /**
  17892. * Defines whether or not autoclear is enable.
  17893. */
  17894. autoClear: boolean;
  17895. /**
  17896. * Defines whether or not to autoclear the depth buffer.
  17897. */
  17898. depth: boolean;
  17899. /**
  17900. * Defines whether or not to autoclear the stencil buffer.
  17901. */
  17902. stencil: boolean;
  17903. }
  17904. /**
  17905. * This class is used by the onRenderingGroupObservable
  17906. */
  17907. export class RenderingGroupInfo {
  17908. /**
  17909. * The Scene that being rendered
  17910. */
  17911. scene: Scene;
  17912. /**
  17913. * The camera currently used for the rendering pass
  17914. */
  17915. camera: Nullable<Camera>;
  17916. /**
  17917. * The ID of the renderingGroup being processed
  17918. */
  17919. renderingGroupId: number;
  17920. }
  17921. /**
  17922. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17923. * It is enable to manage the different groups as well as the different necessary sort functions.
  17924. * This should not be used directly aside of the few static configurations
  17925. */
  17926. export class RenderingManager {
  17927. /**
  17928. * The max id used for rendering groups (not included)
  17929. */
  17930. static MAX_RENDERINGGROUPS: number;
  17931. /**
  17932. * The min id used for rendering groups (included)
  17933. */
  17934. static MIN_RENDERINGGROUPS: number;
  17935. /**
  17936. * Used to globally prevent autoclearing scenes.
  17937. */
  17938. static AUTOCLEAR: boolean;
  17939. /**
  17940. * @hidden
  17941. */
  17942. _useSceneAutoClearSetup: boolean;
  17943. private _scene;
  17944. private _renderingGroups;
  17945. private _depthStencilBufferAlreadyCleaned;
  17946. private _autoClearDepthStencil;
  17947. private _customOpaqueSortCompareFn;
  17948. private _customAlphaTestSortCompareFn;
  17949. private _customTransparentSortCompareFn;
  17950. private _renderingGroupInfo;
  17951. /**
  17952. * Instantiates a new rendering group for a particular scene
  17953. * @param scene Defines the scene the groups belongs to
  17954. */
  17955. constructor(scene: Scene);
  17956. private _clearDepthStencilBuffer;
  17957. /**
  17958. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17959. * @hidden
  17960. */
  17961. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17962. /**
  17963. * Resets the different information of the group to prepare a new frame
  17964. * @hidden
  17965. */
  17966. reset(): void;
  17967. /**
  17968. * Dispose and release the group and its associated resources.
  17969. * @hidden
  17970. */
  17971. dispose(): void;
  17972. /**
  17973. * Clear the info related to rendering groups preventing retention points during dispose.
  17974. */
  17975. freeRenderingGroups(): void;
  17976. private _prepareRenderingGroup;
  17977. /**
  17978. * Add a sprite manager to the rendering manager in order to render it this frame.
  17979. * @param spriteManager Define the sprite manager to render
  17980. */
  17981. dispatchSprites(spriteManager: ISpriteManager): void;
  17982. /**
  17983. * Add a particle system to the rendering manager in order to render it this frame.
  17984. * @param particleSystem Define the particle system to render
  17985. */
  17986. dispatchParticles(particleSystem: IParticleSystem): void;
  17987. /**
  17988. * Add a submesh to the manager in order to render it this frame
  17989. * @param subMesh The submesh to dispatch
  17990. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17991. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17992. */
  17993. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17994. /**
  17995. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17996. * This allowed control for front to back rendering or reversly depending of the special needs.
  17997. *
  17998. * @param renderingGroupId The rendering group id corresponding to its index
  17999. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18000. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18001. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18002. */
  18003. 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;
  18004. /**
  18005. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18006. *
  18007. * @param renderingGroupId The rendering group id corresponding to its index
  18008. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18009. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18010. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18011. */
  18012. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18013. /**
  18014. * Gets the current auto clear configuration for one rendering group of the rendering
  18015. * manager.
  18016. * @param index the rendering group index to get the information for
  18017. * @returns The auto clear setup for the requested rendering group
  18018. */
  18019. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18020. }
  18021. }
  18022. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  18023. import { SmartArray } from "babylonjs/Misc/smartArray";
  18024. import { Nullable } from "babylonjs/types";
  18025. import { Scene } from "babylonjs/scene";
  18026. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  18027. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18029. import { Mesh } from "babylonjs/Meshes/mesh";
  18030. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  18031. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  18032. import { Effect } from "babylonjs/Materials/effect";
  18033. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18034. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18035. import "babylonjs/Shaders/shadowMap.fragment";
  18036. import "babylonjs/Shaders/shadowMap.vertex";
  18037. import "babylonjs/Shaders/depthBoxBlur.fragment";
  18038. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  18039. import { Observable } from "babylonjs/Misc/observable";
  18040. /**
  18041. * Defines the options associated with the creation of a custom shader for a shadow generator.
  18042. */
  18043. export interface ICustomShaderOptions {
  18044. /**
  18045. * Gets or sets the custom shader name to use
  18046. */
  18047. shaderName: string;
  18048. /**
  18049. * The list of attribute names used in the shader
  18050. */
  18051. attributes?: string[];
  18052. /**
  18053. * The list of unifrom names used in the shader
  18054. */
  18055. uniforms?: string[];
  18056. /**
  18057. * The list of sampler names used in the shader
  18058. */
  18059. samplers?: string[];
  18060. /**
  18061. * The list of defines used in the shader
  18062. */
  18063. defines?: string[];
  18064. }
  18065. /**
  18066. * Interface to implement to create a shadow generator compatible with BJS.
  18067. */
  18068. export interface IShadowGenerator {
  18069. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18070. id: string;
  18071. /**
  18072. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18073. * @returns The render target texture if present otherwise, null
  18074. */
  18075. getShadowMap(): Nullable<RenderTargetTexture>;
  18076. /**
  18077. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18078. * @param subMesh The submesh we want to render in the shadow map
  18079. * @param useInstances Defines wether will draw in the map using instances
  18080. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18081. * @returns true if ready otherwise, false
  18082. */
  18083. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18084. /**
  18085. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18086. * @param defines Defines of the material we want to update
  18087. * @param lightIndex Index of the light in the enabled light list of the material
  18088. */
  18089. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18090. /**
  18091. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18092. * defined in the generator but impacting the effect).
  18093. * It implies the unifroms available on the materials are the standard BJS ones.
  18094. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18095. * @param effect The effect we are binfing the information for
  18096. */
  18097. bindShadowLight(lightIndex: string, effect: Effect): void;
  18098. /**
  18099. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18100. * (eq to shadow prjection matrix * light transform matrix)
  18101. * @returns The transform matrix used to create the shadow map
  18102. */
  18103. getTransformMatrix(): Matrix;
  18104. /**
  18105. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18106. * Cube and 2D textures for instance.
  18107. */
  18108. recreateShadowMap(): void;
  18109. /**
  18110. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18111. * @param onCompiled Callback triggered at the and of the effects compilation
  18112. * @param options Sets of optional options forcing the compilation with different modes
  18113. */
  18114. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18115. useInstances: boolean;
  18116. }>): void;
  18117. /**
  18118. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18119. * @param options Sets of optional options forcing the compilation with different modes
  18120. * @returns A promise that resolves when the compilation completes
  18121. */
  18122. forceCompilationAsync(options?: Partial<{
  18123. useInstances: boolean;
  18124. }>): Promise<void>;
  18125. /**
  18126. * Serializes the shadow generator setup to a json object.
  18127. * @returns The serialized JSON object
  18128. */
  18129. serialize(): any;
  18130. /**
  18131. * Disposes the Shadow map and related Textures and effects.
  18132. */
  18133. dispose(): void;
  18134. }
  18135. /**
  18136. * Default implementation IShadowGenerator.
  18137. * This is the main object responsible of generating shadows in the framework.
  18138. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18139. */
  18140. export class ShadowGenerator implements IShadowGenerator {
  18141. /**
  18142. * Name of the shadow generator class
  18143. */
  18144. static CLASSNAME: string;
  18145. /**
  18146. * Shadow generator mode None: no filtering applied.
  18147. */
  18148. static readonly FILTER_NONE: number;
  18149. /**
  18150. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18151. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18152. */
  18153. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18154. /**
  18155. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18156. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18157. */
  18158. static readonly FILTER_POISSONSAMPLING: number;
  18159. /**
  18160. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18161. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18162. */
  18163. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18164. /**
  18165. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18166. * edge artifacts on steep falloff.
  18167. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18168. */
  18169. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18170. /**
  18171. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18172. * edge artifacts on steep falloff.
  18173. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18174. */
  18175. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18176. /**
  18177. * Shadow generator mode PCF: Percentage Closer Filtering
  18178. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18179. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18180. */
  18181. static readonly FILTER_PCF: number;
  18182. /**
  18183. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18184. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18185. * Contact Hardening
  18186. */
  18187. static readonly FILTER_PCSS: number;
  18188. /**
  18189. * Reserved for PCF and PCSS
  18190. * Highest Quality.
  18191. *
  18192. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18193. *
  18194. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18195. */
  18196. static readonly QUALITY_HIGH: number;
  18197. /**
  18198. * Reserved for PCF and PCSS
  18199. * Good tradeoff for quality/perf cross devices
  18200. *
  18201. * Execute PCF on a 3*3 kernel.
  18202. *
  18203. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18204. */
  18205. static readonly QUALITY_MEDIUM: number;
  18206. /**
  18207. * Reserved for PCF and PCSS
  18208. * The lowest quality but the fastest.
  18209. *
  18210. * Execute PCF on a 1*1 kernel.
  18211. *
  18212. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18213. */
  18214. static readonly QUALITY_LOW: number;
  18215. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18216. id: string;
  18217. /** Gets or sets the custom shader name to use */
  18218. customShaderOptions: ICustomShaderOptions;
  18219. /**
  18220. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18221. */
  18222. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18223. /**
  18224. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18225. */
  18226. onAfterShadowMapRenderObservable: Observable<Effect>;
  18227. /**
  18228. * Observable triggered before a mesh is rendered in the shadow map.
  18229. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18230. */
  18231. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18232. /**
  18233. * Observable triggered after a mesh is rendered in the shadow map.
  18234. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18235. */
  18236. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18237. protected _bias: number;
  18238. /**
  18239. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18240. */
  18241. get bias(): number;
  18242. /**
  18243. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18244. */
  18245. set bias(bias: number);
  18246. protected _normalBias: number;
  18247. /**
  18248. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18249. */
  18250. get normalBias(): number;
  18251. /**
  18252. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18253. */
  18254. set normalBias(normalBias: number);
  18255. protected _blurBoxOffset: number;
  18256. /**
  18257. * Gets the blur box offset: offset applied during the blur pass.
  18258. * Only useful if useKernelBlur = false
  18259. */
  18260. get blurBoxOffset(): number;
  18261. /**
  18262. * Sets the blur box offset: offset applied during the blur pass.
  18263. * Only useful if useKernelBlur = false
  18264. */
  18265. set blurBoxOffset(value: number);
  18266. protected _blurScale: number;
  18267. /**
  18268. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18269. * 2 means half of the size.
  18270. */
  18271. get blurScale(): number;
  18272. /**
  18273. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18274. * 2 means half of the size.
  18275. */
  18276. set blurScale(value: number);
  18277. protected _blurKernel: number;
  18278. /**
  18279. * Gets the blur kernel: kernel size of the blur pass.
  18280. * Only useful if useKernelBlur = true
  18281. */
  18282. get blurKernel(): number;
  18283. /**
  18284. * Sets the blur kernel: kernel size of the blur pass.
  18285. * Only useful if useKernelBlur = true
  18286. */
  18287. set blurKernel(value: number);
  18288. protected _useKernelBlur: boolean;
  18289. /**
  18290. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18291. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18292. */
  18293. get useKernelBlur(): boolean;
  18294. /**
  18295. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18296. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18297. */
  18298. set useKernelBlur(value: boolean);
  18299. protected _depthScale: number;
  18300. /**
  18301. * Gets the depth scale used in ESM mode.
  18302. */
  18303. get depthScale(): number;
  18304. /**
  18305. * Sets the depth scale used in ESM mode.
  18306. * This can override the scale stored on the light.
  18307. */
  18308. set depthScale(value: number);
  18309. protected _validateFilter(filter: number): number;
  18310. protected _filter: number;
  18311. /**
  18312. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18313. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18314. */
  18315. get filter(): number;
  18316. /**
  18317. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18318. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18319. */
  18320. set filter(value: number);
  18321. /**
  18322. * Gets if the current filter is set to Poisson Sampling.
  18323. */
  18324. get usePoissonSampling(): boolean;
  18325. /**
  18326. * Sets the current filter to Poisson Sampling.
  18327. */
  18328. set usePoissonSampling(value: boolean);
  18329. /**
  18330. * Gets if the current filter is set to ESM.
  18331. */
  18332. get useExponentialShadowMap(): boolean;
  18333. /**
  18334. * Sets the current filter is to ESM.
  18335. */
  18336. set useExponentialShadowMap(value: boolean);
  18337. /**
  18338. * Gets if the current filter is set to filtered ESM.
  18339. */
  18340. get useBlurExponentialShadowMap(): boolean;
  18341. /**
  18342. * Gets if the current filter is set to filtered ESM.
  18343. */
  18344. set useBlurExponentialShadowMap(value: boolean);
  18345. /**
  18346. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18347. * exponential to prevent steep falloff artifacts).
  18348. */
  18349. get useCloseExponentialShadowMap(): boolean;
  18350. /**
  18351. * Sets the current filter to "close ESM" (using the inverse of the
  18352. * exponential to prevent steep falloff artifacts).
  18353. */
  18354. set useCloseExponentialShadowMap(value: boolean);
  18355. /**
  18356. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18357. * exponential to prevent steep falloff artifacts).
  18358. */
  18359. get useBlurCloseExponentialShadowMap(): boolean;
  18360. /**
  18361. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18362. * exponential to prevent steep falloff artifacts).
  18363. */
  18364. set useBlurCloseExponentialShadowMap(value: boolean);
  18365. /**
  18366. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18367. */
  18368. get usePercentageCloserFiltering(): boolean;
  18369. /**
  18370. * Sets the current filter to "PCF" (percentage closer filtering).
  18371. */
  18372. set usePercentageCloserFiltering(value: boolean);
  18373. protected _filteringQuality: number;
  18374. /**
  18375. * Gets the PCF or PCSS Quality.
  18376. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18377. */
  18378. get filteringQuality(): number;
  18379. /**
  18380. * Sets the PCF or PCSS Quality.
  18381. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18382. */
  18383. set filteringQuality(filteringQuality: number);
  18384. /**
  18385. * Gets if the current filter is set to "PCSS" (contact hardening).
  18386. */
  18387. get useContactHardeningShadow(): boolean;
  18388. /**
  18389. * Sets the current filter to "PCSS" (contact hardening).
  18390. */
  18391. set useContactHardeningShadow(value: boolean);
  18392. protected _contactHardeningLightSizeUVRatio: number;
  18393. /**
  18394. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18395. * Using a ratio helps keeping shape stability independently of the map size.
  18396. *
  18397. * It does not account for the light projection as it was having too much
  18398. * instability during the light setup or during light position changes.
  18399. *
  18400. * Only valid if useContactHardeningShadow is true.
  18401. */
  18402. get contactHardeningLightSizeUVRatio(): number;
  18403. /**
  18404. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18405. * Using a ratio helps keeping shape stability independently of the map size.
  18406. *
  18407. * It does not account for the light projection as it was having too much
  18408. * instability during the light setup or during light position changes.
  18409. *
  18410. * Only valid if useContactHardeningShadow is true.
  18411. */
  18412. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18413. protected _darkness: number;
  18414. /** Gets or sets the actual darkness of a shadow */
  18415. get darkness(): number;
  18416. set darkness(value: number);
  18417. /**
  18418. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18419. * 0 means strongest and 1 would means no shadow.
  18420. * @returns the darkness.
  18421. */
  18422. getDarkness(): number;
  18423. /**
  18424. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18425. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18426. * @returns the shadow generator allowing fluent coding.
  18427. */
  18428. setDarkness(darkness: number): ShadowGenerator;
  18429. protected _transparencyShadow: boolean;
  18430. /** Gets or sets the ability to have transparent shadow */
  18431. get transparencyShadow(): boolean;
  18432. set transparencyShadow(value: boolean);
  18433. /**
  18434. * Sets the ability to have transparent shadow (boolean).
  18435. * @param transparent True if transparent else False
  18436. * @returns the shadow generator allowing fluent coding
  18437. */
  18438. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18439. /**
  18440. * Enables or disables shadows with varying strength based on the transparency
  18441. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18442. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18443. * mesh.visibility * alphaTexture.a
  18444. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18445. */
  18446. enableSoftTransparentShadow: boolean;
  18447. protected _shadowMap: Nullable<RenderTargetTexture>;
  18448. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18449. /**
  18450. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18451. * @returns The render target texture if present otherwise, null
  18452. */
  18453. getShadowMap(): Nullable<RenderTargetTexture>;
  18454. /**
  18455. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18456. * @returns The render target texture if the shadow map is present otherwise, null
  18457. */
  18458. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18459. /**
  18460. * Gets the class name of that object
  18461. * @returns "ShadowGenerator"
  18462. */
  18463. getClassName(): string;
  18464. /**
  18465. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18466. * @param mesh Mesh to add
  18467. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18468. * @returns the Shadow Generator itself
  18469. */
  18470. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18471. /**
  18472. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18473. * @param mesh Mesh to remove
  18474. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18475. * @returns the Shadow Generator itself
  18476. */
  18477. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18478. /**
  18479. * Controls the extent to which the shadows fade out at the edge of the frustum
  18480. */
  18481. frustumEdgeFalloff: number;
  18482. protected _light: IShadowLight;
  18483. /**
  18484. * Returns the associated light object.
  18485. * @returns the light generating the shadow
  18486. */
  18487. getLight(): IShadowLight;
  18488. /**
  18489. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18490. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18491. * It might on the other hand introduce peter panning.
  18492. */
  18493. forceBackFacesOnly: boolean;
  18494. protected _scene: Scene;
  18495. protected _lightDirection: Vector3;
  18496. protected _effect: Effect;
  18497. protected _viewMatrix: Matrix;
  18498. protected _projectionMatrix: Matrix;
  18499. protected _transformMatrix: Matrix;
  18500. protected _cachedPosition: Vector3;
  18501. protected _cachedDirection: Vector3;
  18502. protected _cachedDefines: string;
  18503. protected _currentRenderID: number;
  18504. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18505. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18506. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18507. protected _blurPostProcesses: PostProcess[];
  18508. protected _mapSize: number;
  18509. protected _currentFaceIndex: number;
  18510. protected _currentFaceIndexCache: number;
  18511. protected _textureType: number;
  18512. protected _defaultTextureMatrix: Matrix;
  18513. protected _storedUniqueId: Nullable<number>;
  18514. /** @hidden */
  18515. static _SceneComponentInitialization: (scene: Scene) => void;
  18516. /**
  18517. * Gets or sets the size of the texture what stores the shadows
  18518. */
  18519. get mapSize(): number;
  18520. set mapSize(size: number);
  18521. /**
  18522. * Creates a ShadowGenerator object.
  18523. * A ShadowGenerator is the required tool to use the shadows.
  18524. * Each light casting shadows needs to use its own ShadowGenerator.
  18525. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18526. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18527. * @param light The light object generating the shadows.
  18528. * @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.
  18529. */
  18530. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18531. protected _initializeGenerator(): void;
  18532. protected _createTargetRenderTexture(): void;
  18533. protected _initializeShadowMap(): void;
  18534. protected _initializeBlurRTTAndPostProcesses(): void;
  18535. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18536. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18537. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18538. protected _applyFilterValues(): void;
  18539. /**
  18540. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18541. * @param onCompiled Callback triggered at the and of the effects compilation
  18542. * @param options Sets of optional options forcing the compilation with different modes
  18543. */
  18544. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18545. useInstances: boolean;
  18546. }>): void;
  18547. /**
  18548. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18549. * @param options Sets of optional options forcing the compilation with different modes
  18550. * @returns A promise that resolves when the compilation completes
  18551. */
  18552. forceCompilationAsync(options?: Partial<{
  18553. useInstances: boolean;
  18554. }>): Promise<void>;
  18555. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18556. private _prepareShadowDefines;
  18557. /**
  18558. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18559. * @param subMesh The submesh we want to render in the shadow map
  18560. * @param useInstances Defines wether will draw in the map using instances
  18561. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18562. * @returns true if ready otherwise, false
  18563. */
  18564. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18565. /**
  18566. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18567. * @param defines Defines of the material we want to update
  18568. * @param lightIndex Index of the light in the enabled light list of the material
  18569. */
  18570. prepareDefines(defines: any, lightIndex: number): void;
  18571. /**
  18572. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18573. * defined in the generator but impacting the effect).
  18574. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18575. * @param effect The effect we are binfing the information for
  18576. */
  18577. bindShadowLight(lightIndex: string, effect: Effect): void;
  18578. /**
  18579. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18580. * (eq to shadow prjection matrix * light transform matrix)
  18581. * @returns The transform matrix used to create the shadow map
  18582. */
  18583. getTransformMatrix(): Matrix;
  18584. /**
  18585. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18586. * Cube and 2D textures for instance.
  18587. */
  18588. recreateShadowMap(): void;
  18589. protected _disposeBlurPostProcesses(): void;
  18590. protected _disposeRTTandPostProcesses(): void;
  18591. /**
  18592. * Disposes the ShadowGenerator.
  18593. * Returns nothing.
  18594. */
  18595. dispose(): void;
  18596. /**
  18597. * Serializes the shadow generator setup to a json object.
  18598. * @returns The serialized JSON object
  18599. */
  18600. serialize(): any;
  18601. /**
  18602. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18603. * @param parsedShadowGenerator The JSON object to parse
  18604. * @param scene The scene to create the shadow map for
  18605. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18606. * @returns The parsed shadow generator
  18607. */
  18608. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18609. }
  18610. }
  18611. declare module "babylonjs/Lights/light" {
  18612. import { Nullable } from "babylonjs/types";
  18613. import { Scene } from "babylonjs/scene";
  18614. import { Vector3 } from "babylonjs/Maths/math.vector";
  18615. import { Color3 } from "babylonjs/Maths/math.color";
  18616. import { Node } from "babylonjs/node";
  18617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18618. import { Effect } from "babylonjs/Materials/effect";
  18619. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18620. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18621. /**
  18622. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18623. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18624. * 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.
  18625. */
  18626. export abstract class Light extends Node {
  18627. /**
  18628. * Falloff Default: light is falling off following the material specification:
  18629. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18630. */
  18631. static readonly FALLOFF_DEFAULT: number;
  18632. /**
  18633. * Falloff Physical: light is falling off following the inverse squared distance law.
  18634. */
  18635. static readonly FALLOFF_PHYSICAL: number;
  18636. /**
  18637. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18638. * to enhance interoperability with other engines.
  18639. */
  18640. static readonly FALLOFF_GLTF: number;
  18641. /**
  18642. * Falloff Standard: light is falling off like in the standard material
  18643. * to enhance interoperability with other materials.
  18644. */
  18645. static readonly FALLOFF_STANDARD: number;
  18646. /**
  18647. * If every light affecting the material is in this lightmapMode,
  18648. * material.lightmapTexture adds or multiplies
  18649. * (depends on material.useLightmapAsShadowmap)
  18650. * after every other light calculations.
  18651. */
  18652. static readonly LIGHTMAP_DEFAULT: number;
  18653. /**
  18654. * material.lightmapTexture as only diffuse lighting from this light
  18655. * adds only specular lighting from this light
  18656. * adds dynamic shadows
  18657. */
  18658. static readonly LIGHTMAP_SPECULAR: number;
  18659. /**
  18660. * material.lightmapTexture as only lighting
  18661. * no light calculation from this light
  18662. * only adds dynamic shadows from this light
  18663. */
  18664. static readonly LIGHTMAP_SHADOWSONLY: number;
  18665. /**
  18666. * Each light type uses the default quantity according to its type:
  18667. * point/spot lights use luminous intensity
  18668. * directional lights use illuminance
  18669. */
  18670. static readonly INTENSITYMODE_AUTOMATIC: number;
  18671. /**
  18672. * lumen (lm)
  18673. */
  18674. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18675. /**
  18676. * candela (lm/sr)
  18677. */
  18678. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18679. /**
  18680. * lux (lm/m^2)
  18681. */
  18682. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18683. /**
  18684. * nit (cd/m^2)
  18685. */
  18686. static readonly INTENSITYMODE_LUMINANCE: number;
  18687. /**
  18688. * Light type const id of the point light.
  18689. */
  18690. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18691. /**
  18692. * Light type const id of the directional light.
  18693. */
  18694. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18695. /**
  18696. * Light type const id of the spot light.
  18697. */
  18698. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18699. /**
  18700. * Light type const id of the hemispheric light.
  18701. */
  18702. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18703. /**
  18704. * Diffuse gives the basic color to an object.
  18705. */
  18706. diffuse: Color3;
  18707. /**
  18708. * Specular produces a highlight color on an object.
  18709. * Note: This is note affecting PBR materials.
  18710. */
  18711. specular: Color3;
  18712. /**
  18713. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18714. * falling off base on range or angle.
  18715. * This can be set to any values in Light.FALLOFF_x.
  18716. *
  18717. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18718. * other types of materials.
  18719. */
  18720. falloffType: number;
  18721. /**
  18722. * Strength of the light.
  18723. * Note: By default it is define in the framework own unit.
  18724. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18725. */
  18726. intensity: number;
  18727. private _range;
  18728. protected _inverseSquaredRange: number;
  18729. /**
  18730. * Defines how far from the source the light is impacting in scene units.
  18731. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18732. */
  18733. get range(): number;
  18734. /**
  18735. * Defines how far from the source the light is impacting in scene units.
  18736. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18737. */
  18738. set range(value: number);
  18739. /**
  18740. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18741. * of light.
  18742. */
  18743. private _photometricScale;
  18744. private _intensityMode;
  18745. /**
  18746. * Gets the photometric scale used to interpret the intensity.
  18747. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18748. */
  18749. get intensityMode(): number;
  18750. /**
  18751. * Sets the photometric scale used to interpret the intensity.
  18752. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18753. */
  18754. set intensityMode(value: number);
  18755. private _radius;
  18756. /**
  18757. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18758. */
  18759. get radius(): number;
  18760. /**
  18761. * sets the light radius used by PBR Materials to simulate soft area lights.
  18762. */
  18763. set radius(value: number);
  18764. private _renderPriority;
  18765. /**
  18766. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18767. * exceeding the number allowed of the materials.
  18768. */
  18769. renderPriority: number;
  18770. private _shadowEnabled;
  18771. /**
  18772. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18773. * the current shadow generator.
  18774. */
  18775. get shadowEnabled(): boolean;
  18776. /**
  18777. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18778. * the current shadow generator.
  18779. */
  18780. set shadowEnabled(value: boolean);
  18781. private _includedOnlyMeshes;
  18782. /**
  18783. * Gets the only meshes impacted by this light.
  18784. */
  18785. get includedOnlyMeshes(): AbstractMesh[];
  18786. /**
  18787. * Sets the only meshes impacted by this light.
  18788. */
  18789. set includedOnlyMeshes(value: AbstractMesh[]);
  18790. private _excludedMeshes;
  18791. /**
  18792. * Gets the meshes not impacted by this light.
  18793. */
  18794. get excludedMeshes(): AbstractMesh[];
  18795. /**
  18796. * Sets the meshes not impacted by this light.
  18797. */
  18798. set excludedMeshes(value: AbstractMesh[]);
  18799. private _excludeWithLayerMask;
  18800. /**
  18801. * Gets the layer id use to find what meshes are not impacted by the light.
  18802. * Inactive if 0
  18803. */
  18804. get excludeWithLayerMask(): number;
  18805. /**
  18806. * Sets the layer id use to find what meshes are not impacted by the light.
  18807. * Inactive if 0
  18808. */
  18809. set excludeWithLayerMask(value: number);
  18810. private _includeOnlyWithLayerMask;
  18811. /**
  18812. * Gets the layer id use to find what meshes are impacted by the light.
  18813. * Inactive if 0
  18814. */
  18815. get includeOnlyWithLayerMask(): number;
  18816. /**
  18817. * Sets the layer id use to find what meshes are impacted by the light.
  18818. * Inactive if 0
  18819. */
  18820. set includeOnlyWithLayerMask(value: number);
  18821. private _lightmapMode;
  18822. /**
  18823. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18824. */
  18825. get lightmapMode(): number;
  18826. /**
  18827. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18828. */
  18829. set lightmapMode(value: number);
  18830. /**
  18831. * Shadow generator associted to the light.
  18832. * @hidden Internal use only.
  18833. */
  18834. _shadowGenerator: Nullable<IShadowGenerator>;
  18835. /**
  18836. * @hidden Internal use only.
  18837. */
  18838. _excludedMeshesIds: string[];
  18839. /**
  18840. * @hidden Internal use only.
  18841. */
  18842. _includedOnlyMeshesIds: string[];
  18843. /**
  18844. * The current light unifom buffer.
  18845. * @hidden Internal use only.
  18846. */
  18847. _uniformBuffer: UniformBuffer;
  18848. /** @hidden */
  18849. _renderId: number;
  18850. /**
  18851. * Creates a Light object in the scene.
  18852. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18853. * @param name The firendly name of the light
  18854. * @param scene The scene the light belongs too
  18855. */
  18856. constructor(name: string, scene: Scene);
  18857. protected abstract _buildUniformLayout(): void;
  18858. /**
  18859. * Sets the passed Effect "effect" with the Light information.
  18860. * @param effect The effect to update
  18861. * @param lightIndex The index of the light in the effect to update
  18862. * @returns The light
  18863. */
  18864. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18865. /**
  18866. * Sets the passed Effect "effect" with the Light textures.
  18867. * @param effect The effect to update
  18868. * @param lightIndex The index of the light in the effect to update
  18869. * @returns The light
  18870. */
  18871. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18872. /**
  18873. * Binds the lights information from the scene to the effect for the given mesh.
  18874. * @param lightIndex Light index
  18875. * @param scene The scene where the light belongs to
  18876. * @param effect The effect we are binding the data to
  18877. * @param useSpecular Defines if specular is supported
  18878. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18879. */
  18880. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18881. /**
  18882. * Sets the passed Effect "effect" with the Light information.
  18883. * @param effect The effect to update
  18884. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18885. * @returns The light
  18886. */
  18887. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18888. /**
  18889. * Returns the string "Light".
  18890. * @returns the class name
  18891. */
  18892. getClassName(): string;
  18893. /** @hidden */
  18894. readonly _isLight: boolean;
  18895. /**
  18896. * Converts the light information to a readable string for debug purpose.
  18897. * @param fullDetails Supports for multiple levels of logging within scene loading
  18898. * @returns the human readable light info
  18899. */
  18900. toString(fullDetails?: boolean): string;
  18901. /** @hidden */
  18902. protected _syncParentEnabledState(): void;
  18903. /**
  18904. * Set the enabled state of this node.
  18905. * @param value - the new enabled state
  18906. */
  18907. setEnabled(value: boolean): void;
  18908. /**
  18909. * Returns the Light associated shadow generator if any.
  18910. * @return the associated shadow generator.
  18911. */
  18912. getShadowGenerator(): Nullable<IShadowGenerator>;
  18913. /**
  18914. * Returns a Vector3, the absolute light position in the World.
  18915. * @returns the world space position of the light
  18916. */
  18917. getAbsolutePosition(): Vector3;
  18918. /**
  18919. * Specifies if the light will affect the passed mesh.
  18920. * @param mesh The mesh to test against the light
  18921. * @return true the mesh is affected otherwise, false.
  18922. */
  18923. canAffectMesh(mesh: AbstractMesh): boolean;
  18924. /**
  18925. * Sort function to order lights for rendering.
  18926. * @param a First Light object to compare to second.
  18927. * @param b Second Light object to compare first.
  18928. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18929. */
  18930. static CompareLightsPriority(a: Light, b: Light): number;
  18931. /**
  18932. * Releases resources associated with this node.
  18933. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18934. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18935. */
  18936. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18937. /**
  18938. * Returns the light type ID (integer).
  18939. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18940. */
  18941. getTypeID(): number;
  18942. /**
  18943. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18944. * @returns the scaled intensity in intensity mode unit
  18945. */
  18946. getScaledIntensity(): number;
  18947. /**
  18948. * Returns a new Light object, named "name", from the current one.
  18949. * @param name The name of the cloned light
  18950. * @param newParent The parent of this light, if it has one
  18951. * @returns the new created light
  18952. */
  18953. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18954. /**
  18955. * Serializes the current light into a Serialization object.
  18956. * @returns the serialized object.
  18957. */
  18958. serialize(): any;
  18959. /**
  18960. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18961. * This new light is named "name" and added to the passed scene.
  18962. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18963. * @param name The friendly name of the light
  18964. * @param scene The scene the new light will belong to
  18965. * @returns the constructor function
  18966. */
  18967. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18968. /**
  18969. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18970. * @param parsedLight The JSON representation of the light
  18971. * @param scene The scene to create the parsed light in
  18972. * @returns the created light after parsing
  18973. */
  18974. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18975. private _hookArrayForExcluded;
  18976. private _hookArrayForIncludedOnly;
  18977. private _resyncMeshes;
  18978. /**
  18979. * Forces the meshes to update their light related information in their rendering used effects
  18980. * @hidden Internal Use Only
  18981. */
  18982. _markMeshesAsLightDirty(): void;
  18983. /**
  18984. * Recomputes the cached photometric scale if needed.
  18985. */
  18986. private _computePhotometricScale;
  18987. /**
  18988. * Returns the Photometric Scale according to the light type and intensity mode.
  18989. */
  18990. private _getPhotometricScale;
  18991. /**
  18992. * Reorder the light in the scene according to their defined priority.
  18993. * @hidden Internal Use Only
  18994. */
  18995. _reorderLightsInScene(): void;
  18996. /**
  18997. * Prepares the list of defines specific to the light type.
  18998. * @param defines the list of defines
  18999. * @param lightIndex defines the index of the light for the effect
  19000. */
  19001. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19002. }
  19003. }
  19004. declare module "babylonjs/Materials/prePassConfiguration" {
  19005. import { Matrix } from "babylonjs/Maths/math.vector";
  19006. import { Mesh } from "babylonjs/Meshes/mesh";
  19007. import { Scene } from "babylonjs/scene";
  19008. import { Effect } from "babylonjs/Materials/effect";
  19009. /**
  19010. * Configuration needed for prepass-capable materials
  19011. */
  19012. export class PrePassConfiguration {
  19013. /**
  19014. * Previous world matrices of meshes carrying this material
  19015. * Used for computing velocity
  19016. */
  19017. previousWorldMatrices: {
  19018. [index: number]: Matrix;
  19019. };
  19020. /**
  19021. * Previous view project matrix
  19022. * Used for computing velocity
  19023. */
  19024. previousViewProjection: Matrix;
  19025. /**
  19026. * Previous bones of meshes carrying this material
  19027. * Used for computing velocity
  19028. */
  19029. previousBones: {
  19030. [index: number]: Float32Array;
  19031. };
  19032. /**
  19033. * Add the required uniforms to the current list.
  19034. * @param uniforms defines the current uniform list.
  19035. */
  19036. static AddUniforms(uniforms: string[]): void;
  19037. /**
  19038. * Add the required samplers to the current list.
  19039. * @param samplers defines the current sampler list.
  19040. */
  19041. static AddSamplers(samplers: string[]): void;
  19042. /**
  19043. * Binds the material data.
  19044. * @param effect defines the effect to update
  19045. * @param scene defines the scene the material belongs to.
  19046. * @param mesh The mesh
  19047. * @param world World matrix of this mesh
  19048. * @param isFrozen Is the material frozen
  19049. */
  19050. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  19051. }
  19052. }
  19053. declare module "babylonjs/Cameras/targetCamera" {
  19054. import { Nullable } from "babylonjs/types";
  19055. import { Camera } from "babylonjs/Cameras/camera";
  19056. import { Scene } from "babylonjs/scene";
  19057. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  19058. /**
  19059. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  19060. * This is the base of the follow, arc rotate cameras and Free camera
  19061. * @see https://doc.babylonjs.com/features/cameras
  19062. */
  19063. export class TargetCamera extends Camera {
  19064. private static _RigCamTransformMatrix;
  19065. private static _TargetTransformMatrix;
  19066. private static _TargetFocalPoint;
  19067. private _tmpUpVector;
  19068. private _tmpTargetVector;
  19069. /**
  19070. * Define the current direction the camera is moving to
  19071. */
  19072. cameraDirection: Vector3;
  19073. /**
  19074. * Define the current rotation the camera is rotating to
  19075. */
  19076. cameraRotation: Vector2;
  19077. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  19078. ignoreParentScaling: boolean;
  19079. /**
  19080. * When set, the up vector of the camera will be updated by the rotation of the camera
  19081. */
  19082. updateUpVectorFromRotation: boolean;
  19083. private _tmpQuaternion;
  19084. /**
  19085. * Define the current rotation of the camera
  19086. */
  19087. rotation: Vector3;
  19088. /**
  19089. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  19090. */
  19091. rotationQuaternion: Quaternion;
  19092. /**
  19093. * Define the current speed of the camera
  19094. */
  19095. speed: number;
  19096. /**
  19097. * Add constraint to the camera to prevent it to move freely in all directions and
  19098. * around all axis.
  19099. */
  19100. noRotationConstraint: boolean;
  19101. /**
  19102. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  19103. * panning
  19104. */
  19105. invertRotation: boolean;
  19106. /**
  19107. * Speed multiplier for inverse camera panning
  19108. */
  19109. inverseRotationSpeed: number;
  19110. /**
  19111. * Define the current target of the camera as an object or a position.
  19112. */
  19113. lockedTarget: any;
  19114. /** @hidden */
  19115. _currentTarget: Vector3;
  19116. /** @hidden */
  19117. _initialFocalDistance: number;
  19118. /** @hidden */
  19119. _viewMatrix: Matrix;
  19120. /** @hidden */
  19121. _camMatrix: Matrix;
  19122. /** @hidden */
  19123. _cameraTransformMatrix: Matrix;
  19124. /** @hidden */
  19125. _cameraRotationMatrix: Matrix;
  19126. /** @hidden */
  19127. _referencePoint: Vector3;
  19128. /** @hidden */
  19129. _transformedReferencePoint: Vector3;
  19130. /** @hidden */
  19131. _reset: () => void;
  19132. private _defaultUp;
  19133. /**
  19134. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19135. * This is the base of the follow, arc rotate cameras and Free camera
  19136. * @see https://doc.babylonjs.com/features/cameras
  19137. * @param name Defines the name of the camera in the scene
  19138. * @param position Defines the start position of the camera in the scene
  19139. * @param scene Defines the scene the camera belongs to
  19140. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19141. */
  19142. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19143. /**
  19144. * Gets the position in front of the camera at a given distance.
  19145. * @param distance The distance from the camera we want the position to be
  19146. * @returns the position
  19147. */
  19148. getFrontPosition(distance: number): Vector3;
  19149. /** @hidden */
  19150. _getLockedTargetPosition(): Nullable<Vector3>;
  19151. private _storedPosition;
  19152. private _storedRotation;
  19153. private _storedRotationQuaternion;
  19154. /**
  19155. * Store current camera state of the camera (fov, position, rotation, etc..)
  19156. * @returns the camera
  19157. */
  19158. storeState(): Camera;
  19159. /**
  19160. * Restored camera state. You must call storeState() first
  19161. * @returns whether it was successful or not
  19162. * @hidden
  19163. */
  19164. _restoreStateValues(): boolean;
  19165. /** @hidden */
  19166. _initCache(): void;
  19167. /** @hidden */
  19168. _updateCache(ignoreParentClass?: boolean): void;
  19169. /** @hidden */
  19170. _isSynchronizedViewMatrix(): boolean;
  19171. /** @hidden */
  19172. _computeLocalCameraSpeed(): number;
  19173. /**
  19174. * Defines the target the camera should look at.
  19175. * @param target Defines the new target as a Vector or a mesh
  19176. */
  19177. setTarget(target: Vector3): void;
  19178. /**
  19179. * Defines the target point of the camera.
  19180. * The camera looks towards it form the radius distance.
  19181. */
  19182. get target(): Vector3;
  19183. set target(value: Vector3);
  19184. /**
  19185. * Return the current target position of the camera. This value is expressed in local space.
  19186. * @returns the target position
  19187. */
  19188. getTarget(): Vector3;
  19189. /** @hidden */
  19190. _decideIfNeedsToMove(): boolean;
  19191. /** @hidden */
  19192. _updatePosition(): void;
  19193. /** @hidden */
  19194. _checkInputs(): void;
  19195. protected _updateCameraRotationMatrix(): void;
  19196. /**
  19197. * 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)
  19198. * @returns the current camera
  19199. */
  19200. private _rotateUpVectorWithCameraRotationMatrix;
  19201. private _cachedRotationZ;
  19202. private _cachedQuaternionRotationZ;
  19203. /** @hidden */
  19204. _getViewMatrix(): Matrix;
  19205. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19206. /**
  19207. * @hidden
  19208. */
  19209. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19210. /**
  19211. * @hidden
  19212. */
  19213. _updateRigCameras(): void;
  19214. private _getRigCamPositionAndTarget;
  19215. /**
  19216. * Gets the current object class name.
  19217. * @return the class name
  19218. */
  19219. getClassName(): string;
  19220. }
  19221. }
  19222. declare module "babylonjs/Events/keyboardEvents" {
  19223. /**
  19224. * Gather the list of keyboard event types as constants.
  19225. */
  19226. export class KeyboardEventTypes {
  19227. /**
  19228. * The keydown event is fired when a key becomes active (pressed).
  19229. */
  19230. static readonly KEYDOWN: number;
  19231. /**
  19232. * The keyup event is fired when a key has been released.
  19233. */
  19234. static readonly KEYUP: number;
  19235. }
  19236. /**
  19237. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19238. */
  19239. export class KeyboardInfo {
  19240. /**
  19241. * Defines the type of event (KeyboardEventTypes)
  19242. */
  19243. type: number;
  19244. /**
  19245. * Defines the related dom event
  19246. */
  19247. event: KeyboardEvent;
  19248. /**
  19249. * Instantiates a new keyboard info.
  19250. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19251. * @param type Defines the type of event (KeyboardEventTypes)
  19252. * @param event Defines the related dom event
  19253. */
  19254. constructor(
  19255. /**
  19256. * Defines the type of event (KeyboardEventTypes)
  19257. */
  19258. type: number,
  19259. /**
  19260. * Defines the related dom event
  19261. */
  19262. event: KeyboardEvent);
  19263. }
  19264. /**
  19265. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19266. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19267. */
  19268. export class KeyboardInfoPre extends KeyboardInfo {
  19269. /**
  19270. * Defines the type of event (KeyboardEventTypes)
  19271. */
  19272. type: number;
  19273. /**
  19274. * Defines the related dom event
  19275. */
  19276. event: KeyboardEvent;
  19277. /**
  19278. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19279. */
  19280. skipOnPointerObservable: boolean;
  19281. /**
  19282. * Instantiates a new keyboard pre info.
  19283. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19284. * @param type Defines the type of event (KeyboardEventTypes)
  19285. * @param event Defines the related dom event
  19286. */
  19287. constructor(
  19288. /**
  19289. * Defines the type of event (KeyboardEventTypes)
  19290. */
  19291. type: number,
  19292. /**
  19293. * Defines the related dom event
  19294. */
  19295. event: KeyboardEvent);
  19296. }
  19297. }
  19298. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19299. import { Nullable } from "babylonjs/types";
  19300. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19301. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19302. /**
  19303. * Manage the keyboard inputs to control the movement of a free camera.
  19304. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19305. */
  19306. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19307. /**
  19308. * Defines the camera the input is attached to.
  19309. */
  19310. camera: FreeCamera;
  19311. /**
  19312. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19313. */
  19314. keysUp: number[];
  19315. /**
  19316. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19317. */
  19318. keysUpward: number[];
  19319. /**
  19320. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19321. */
  19322. keysDown: number[];
  19323. /**
  19324. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19325. */
  19326. keysDownward: number[];
  19327. /**
  19328. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19329. */
  19330. keysLeft: number[];
  19331. /**
  19332. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19333. */
  19334. keysRight: number[];
  19335. private _keys;
  19336. private _onCanvasBlurObserver;
  19337. private _onKeyboardObserver;
  19338. private _engine;
  19339. private _scene;
  19340. /**
  19341. * Attach the input controls to a specific dom element to get the input from.
  19342. * @param element Defines the element the controls should be listened from
  19343. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19344. */
  19345. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19346. /**
  19347. * Detach the current controls from the specified dom element.
  19348. * @param element Defines the element to stop listening the inputs from
  19349. */
  19350. detachControl(element: Nullable<HTMLElement>): void;
  19351. /**
  19352. * Update the current camera state depending on the inputs that have been used this frame.
  19353. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19354. */
  19355. checkInputs(): void;
  19356. /**
  19357. * Gets the class name of the current intput.
  19358. * @returns the class name
  19359. */
  19360. getClassName(): string;
  19361. /** @hidden */
  19362. _onLostFocus(): void;
  19363. /**
  19364. * Get the friendly name associated with the input class.
  19365. * @returns the input friendly name
  19366. */
  19367. getSimpleName(): string;
  19368. }
  19369. }
  19370. declare module "babylonjs/Events/pointerEvents" {
  19371. import { Nullable } from "babylonjs/types";
  19372. import { Vector2 } from "babylonjs/Maths/math.vector";
  19373. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19374. import { Ray } from "babylonjs/Culling/ray";
  19375. /**
  19376. * Gather the list of pointer event types as constants.
  19377. */
  19378. export class PointerEventTypes {
  19379. /**
  19380. * 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.
  19381. */
  19382. static readonly POINTERDOWN: number;
  19383. /**
  19384. * The pointerup event is fired when a pointer is no longer active.
  19385. */
  19386. static readonly POINTERUP: number;
  19387. /**
  19388. * The pointermove event is fired when a pointer changes coordinates.
  19389. */
  19390. static readonly POINTERMOVE: number;
  19391. /**
  19392. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19393. */
  19394. static readonly POINTERWHEEL: number;
  19395. /**
  19396. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19397. */
  19398. static readonly POINTERPICK: number;
  19399. /**
  19400. * The pointertap event is fired when a the object has been touched and released without drag.
  19401. */
  19402. static readonly POINTERTAP: number;
  19403. /**
  19404. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19405. */
  19406. static readonly POINTERDOUBLETAP: number;
  19407. }
  19408. /**
  19409. * Base class of pointer info types.
  19410. */
  19411. export class PointerInfoBase {
  19412. /**
  19413. * Defines the type of event (PointerEventTypes)
  19414. */
  19415. type: number;
  19416. /**
  19417. * Defines the related dom event
  19418. */
  19419. event: PointerEvent | MouseWheelEvent;
  19420. /**
  19421. * Instantiates the base class of pointers info.
  19422. * @param type Defines the type of event (PointerEventTypes)
  19423. * @param event Defines the related dom event
  19424. */
  19425. constructor(
  19426. /**
  19427. * Defines the type of event (PointerEventTypes)
  19428. */
  19429. type: number,
  19430. /**
  19431. * Defines the related dom event
  19432. */
  19433. event: PointerEvent | MouseWheelEvent);
  19434. }
  19435. /**
  19436. * This class is used to store pointer related info for the onPrePointerObservable event.
  19437. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19438. */
  19439. export class PointerInfoPre extends PointerInfoBase {
  19440. /**
  19441. * Ray from a pointer if availible (eg. 6dof controller)
  19442. */
  19443. ray: Nullable<Ray>;
  19444. /**
  19445. * Defines the local position of the pointer on the canvas.
  19446. */
  19447. localPosition: Vector2;
  19448. /**
  19449. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19450. */
  19451. skipOnPointerObservable: boolean;
  19452. /**
  19453. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19454. * @param type Defines the type of event (PointerEventTypes)
  19455. * @param event Defines the related dom event
  19456. * @param localX Defines the local x coordinates of the pointer when the event occured
  19457. * @param localY Defines the local y coordinates of the pointer when the event occured
  19458. */
  19459. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19460. }
  19461. /**
  19462. * This type contains all the data related to a pointer event in Babylon.js.
  19463. * 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.
  19464. */
  19465. export class PointerInfo extends PointerInfoBase {
  19466. /**
  19467. * Defines the picking info associated to the info (if any)\
  19468. */
  19469. pickInfo: Nullable<PickingInfo>;
  19470. /**
  19471. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19472. * @param type Defines the type of event (PointerEventTypes)
  19473. * @param event Defines the related dom event
  19474. * @param pickInfo Defines the picking info associated to the info (if any)\
  19475. */
  19476. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19477. /**
  19478. * Defines the picking info associated to the info (if any)\
  19479. */
  19480. pickInfo: Nullable<PickingInfo>);
  19481. }
  19482. /**
  19483. * Data relating to a touch event on the screen.
  19484. */
  19485. export interface PointerTouch {
  19486. /**
  19487. * X coordinate of touch.
  19488. */
  19489. x: number;
  19490. /**
  19491. * Y coordinate of touch.
  19492. */
  19493. y: number;
  19494. /**
  19495. * Id of touch. Unique for each finger.
  19496. */
  19497. pointerId: number;
  19498. /**
  19499. * Event type passed from DOM.
  19500. */
  19501. type: any;
  19502. }
  19503. }
  19504. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19505. import { Observable } from "babylonjs/Misc/observable";
  19506. import { Nullable } from "babylonjs/types";
  19507. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19508. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19509. /**
  19510. * Manage the mouse inputs to control the movement of a free camera.
  19511. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19512. */
  19513. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19514. /**
  19515. * Define if touch is enabled in the mouse input
  19516. */
  19517. touchEnabled: boolean;
  19518. /**
  19519. * Defines the camera the input is attached to.
  19520. */
  19521. camera: FreeCamera;
  19522. /**
  19523. * Defines the buttons associated with the input to handle camera move.
  19524. */
  19525. buttons: number[];
  19526. /**
  19527. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19528. */
  19529. angularSensibility: number;
  19530. private _pointerInput;
  19531. private _onMouseMove;
  19532. private _observer;
  19533. private previousPosition;
  19534. /**
  19535. * Observable for when a pointer move event occurs containing the move offset
  19536. */
  19537. onPointerMovedObservable: Observable<{
  19538. offsetX: number;
  19539. offsetY: number;
  19540. }>;
  19541. /**
  19542. * @hidden
  19543. * If the camera should be rotated automatically based on pointer movement
  19544. */
  19545. _allowCameraRotation: boolean;
  19546. /**
  19547. * Manage the mouse inputs to control the movement of a free camera.
  19548. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19549. * @param touchEnabled Defines if touch is enabled or not
  19550. */
  19551. constructor(
  19552. /**
  19553. * Define if touch is enabled in the mouse input
  19554. */
  19555. touchEnabled?: boolean);
  19556. /**
  19557. * Attach the input controls to a specific dom element to get the input from.
  19558. * @param element Defines the element the controls should be listened from
  19559. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19560. */
  19561. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19562. /**
  19563. * Called on JS contextmenu event.
  19564. * Override this method to provide functionality.
  19565. */
  19566. protected onContextMenu(evt: PointerEvent): void;
  19567. /**
  19568. * Detach the current controls from the specified dom element.
  19569. * @param element Defines the element to stop listening the inputs from
  19570. */
  19571. detachControl(element: Nullable<HTMLElement>): void;
  19572. /**
  19573. * Gets the class name of the current intput.
  19574. * @returns the class name
  19575. */
  19576. getClassName(): string;
  19577. /**
  19578. * Get the friendly name associated with the input class.
  19579. * @returns the input friendly name
  19580. */
  19581. getSimpleName(): string;
  19582. }
  19583. }
  19584. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19585. import { Nullable } from "babylonjs/types";
  19586. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19587. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19588. /**
  19589. * Manage the touch inputs to control the movement of a free camera.
  19590. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19591. */
  19592. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19593. /**
  19594. * Define if mouse events can be treated as touch events
  19595. */
  19596. allowMouse: boolean;
  19597. /**
  19598. * Defines the camera the input is attached to.
  19599. */
  19600. camera: FreeCamera;
  19601. /**
  19602. * Defines the touch sensibility for rotation.
  19603. * The higher the faster.
  19604. */
  19605. touchAngularSensibility: number;
  19606. /**
  19607. * Defines the touch sensibility for move.
  19608. * The higher the faster.
  19609. */
  19610. touchMoveSensibility: number;
  19611. private _offsetX;
  19612. private _offsetY;
  19613. private _pointerPressed;
  19614. private _pointerInput;
  19615. private _observer;
  19616. private _onLostFocus;
  19617. /**
  19618. * Manage the touch inputs to control the movement of a free camera.
  19619. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19620. * @param allowMouse Defines if mouse events can be treated as touch events
  19621. */
  19622. constructor(
  19623. /**
  19624. * Define if mouse events can be treated as touch events
  19625. */
  19626. allowMouse?: boolean);
  19627. /**
  19628. * Attach the input controls to a specific dom element to get the input from.
  19629. * @param element Defines the element the controls should be listened from
  19630. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19631. */
  19632. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19633. /**
  19634. * Detach the current controls from the specified dom element.
  19635. * @param element Defines the element to stop listening the inputs from
  19636. */
  19637. detachControl(element: Nullable<HTMLElement>): void;
  19638. /**
  19639. * Update the current camera state depending on the inputs that have been used this frame.
  19640. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19641. */
  19642. checkInputs(): void;
  19643. /**
  19644. * Gets the class name of the current intput.
  19645. * @returns the class name
  19646. */
  19647. getClassName(): string;
  19648. /**
  19649. * Get the friendly name associated with the input class.
  19650. * @returns the input friendly name
  19651. */
  19652. getSimpleName(): string;
  19653. }
  19654. }
  19655. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19656. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19657. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19658. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19659. import { Nullable } from "babylonjs/types";
  19660. /**
  19661. * Default Inputs manager for the FreeCamera.
  19662. * It groups all the default supported inputs for ease of use.
  19663. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19664. */
  19665. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19666. /**
  19667. * @hidden
  19668. */
  19669. _mouseInput: Nullable<FreeCameraMouseInput>;
  19670. /**
  19671. * Instantiates a new FreeCameraInputsManager.
  19672. * @param camera Defines the camera the inputs belong to
  19673. */
  19674. constructor(camera: FreeCamera);
  19675. /**
  19676. * Add keyboard input support to the input manager.
  19677. * @returns the current input manager
  19678. */
  19679. addKeyboard(): FreeCameraInputsManager;
  19680. /**
  19681. * Add mouse input support to the input manager.
  19682. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19683. * @returns the current input manager
  19684. */
  19685. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19686. /**
  19687. * Removes the mouse input support from the manager
  19688. * @returns the current input manager
  19689. */
  19690. removeMouse(): FreeCameraInputsManager;
  19691. /**
  19692. * Add touch input support to the input manager.
  19693. * @returns the current input manager
  19694. */
  19695. addTouch(): FreeCameraInputsManager;
  19696. /**
  19697. * Remove all attached input methods from a camera
  19698. */
  19699. clear(): void;
  19700. }
  19701. }
  19702. declare module "babylonjs/Cameras/freeCamera" {
  19703. import { Vector3 } from "babylonjs/Maths/math.vector";
  19704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19705. import { Scene } from "babylonjs/scene";
  19706. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19707. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19708. /**
  19709. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19710. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19711. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19712. */
  19713. export class FreeCamera extends TargetCamera {
  19714. /**
  19715. * Define the collision ellipsoid of the camera.
  19716. * This is helpful to simulate a camera body like the player body around the camera
  19717. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19718. */
  19719. ellipsoid: Vector3;
  19720. /**
  19721. * Define an offset for the position of the ellipsoid around the camera.
  19722. * This can be helpful to determine the center of the body near the gravity center of the body
  19723. * instead of its head.
  19724. */
  19725. ellipsoidOffset: Vector3;
  19726. /**
  19727. * Enable or disable collisions of the camera with the rest of the scene objects.
  19728. */
  19729. checkCollisions: boolean;
  19730. /**
  19731. * Enable or disable gravity on the camera.
  19732. */
  19733. applyGravity: boolean;
  19734. /**
  19735. * Define the input manager associated to the camera.
  19736. */
  19737. inputs: FreeCameraInputsManager;
  19738. /**
  19739. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19740. * Higher values reduce sensitivity.
  19741. */
  19742. get angularSensibility(): number;
  19743. /**
  19744. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19745. * Higher values reduce sensitivity.
  19746. */
  19747. set angularSensibility(value: number);
  19748. /**
  19749. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19750. */
  19751. get keysUp(): number[];
  19752. set keysUp(value: number[]);
  19753. /**
  19754. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19755. */
  19756. get keysUpward(): number[];
  19757. set keysUpward(value: number[]);
  19758. /**
  19759. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19760. */
  19761. get keysDown(): number[];
  19762. set keysDown(value: number[]);
  19763. /**
  19764. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19765. */
  19766. get keysDownward(): number[];
  19767. set keysDownward(value: number[]);
  19768. /**
  19769. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19770. */
  19771. get keysLeft(): number[];
  19772. set keysLeft(value: number[]);
  19773. /**
  19774. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19775. */
  19776. get keysRight(): number[];
  19777. set keysRight(value: number[]);
  19778. /**
  19779. * Event raised when the camera collide with a mesh in the scene.
  19780. */
  19781. onCollide: (collidedMesh: AbstractMesh) => void;
  19782. private _collider;
  19783. private _needMoveForGravity;
  19784. private _oldPosition;
  19785. private _diffPosition;
  19786. private _newPosition;
  19787. /** @hidden */
  19788. _localDirection: Vector3;
  19789. /** @hidden */
  19790. _transformedDirection: Vector3;
  19791. /**
  19792. * Instantiates a Free Camera.
  19793. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19794. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19795. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19796. * @param name Define the name of the camera in the scene
  19797. * @param position Define the start position of the camera in the scene
  19798. * @param scene Define the scene the camera belongs to
  19799. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19800. */
  19801. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19802. /**
  19803. * Attached controls to the current camera.
  19804. * @param element Defines the element the controls should be listened from
  19805. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19806. */
  19807. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19808. /**
  19809. * Detach the current controls from the camera.
  19810. * The camera will stop reacting to inputs.
  19811. * @param element Defines the element to stop listening the inputs from
  19812. */
  19813. detachControl(element: HTMLElement): void;
  19814. private _collisionMask;
  19815. /**
  19816. * Define a collision mask to limit the list of object the camera can collide with
  19817. */
  19818. get collisionMask(): number;
  19819. set collisionMask(mask: number);
  19820. /** @hidden */
  19821. _collideWithWorld(displacement: Vector3): void;
  19822. private _onCollisionPositionChange;
  19823. /** @hidden */
  19824. _checkInputs(): void;
  19825. /** @hidden */
  19826. _decideIfNeedsToMove(): boolean;
  19827. /** @hidden */
  19828. _updatePosition(): void;
  19829. /**
  19830. * Destroy the camera and release the current resources hold by it.
  19831. */
  19832. dispose(): void;
  19833. /**
  19834. * Gets the current object class name.
  19835. * @return the class name
  19836. */
  19837. getClassName(): string;
  19838. }
  19839. }
  19840. declare module "babylonjs/Gamepads/gamepad" {
  19841. import { Observable } from "babylonjs/Misc/observable";
  19842. /**
  19843. * Represents a gamepad control stick position
  19844. */
  19845. export class StickValues {
  19846. /**
  19847. * The x component of the control stick
  19848. */
  19849. x: number;
  19850. /**
  19851. * The y component of the control stick
  19852. */
  19853. y: number;
  19854. /**
  19855. * Initializes the gamepad x and y control stick values
  19856. * @param x The x component of the gamepad control stick value
  19857. * @param y The y component of the gamepad control stick value
  19858. */
  19859. constructor(
  19860. /**
  19861. * The x component of the control stick
  19862. */
  19863. x: number,
  19864. /**
  19865. * The y component of the control stick
  19866. */
  19867. y: number);
  19868. }
  19869. /**
  19870. * An interface which manages callbacks for gamepad button changes
  19871. */
  19872. export interface GamepadButtonChanges {
  19873. /**
  19874. * Called when a gamepad has been changed
  19875. */
  19876. changed: boolean;
  19877. /**
  19878. * Called when a gamepad press event has been triggered
  19879. */
  19880. pressChanged: boolean;
  19881. /**
  19882. * Called when a touch event has been triggered
  19883. */
  19884. touchChanged: boolean;
  19885. /**
  19886. * Called when a value has changed
  19887. */
  19888. valueChanged: boolean;
  19889. }
  19890. /**
  19891. * Represents a gamepad
  19892. */
  19893. export class Gamepad {
  19894. /**
  19895. * The id of the gamepad
  19896. */
  19897. id: string;
  19898. /**
  19899. * The index of the gamepad
  19900. */
  19901. index: number;
  19902. /**
  19903. * The browser gamepad
  19904. */
  19905. browserGamepad: any;
  19906. /**
  19907. * Specifies what type of gamepad this represents
  19908. */
  19909. type: number;
  19910. private _leftStick;
  19911. private _rightStick;
  19912. /** @hidden */
  19913. _isConnected: boolean;
  19914. private _leftStickAxisX;
  19915. private _leftStickAxisY;
  19916. private _rightStickAxisX;
  19917. private _rightStickAxisY;
  19918. /**
  19919. * Triggered when the left control stick has been changed
  19920. */
  19921. private _onleftstickchanged;
  19922. /**
  19923. * Triggered when the right control stick has been changed
  19924. */
  19925. private _onrightstickchanged;
  19926. /**
  19927. * Represents a gamepad controller
  19928. */
  19929. static GAMEPAD: number;
  19930. /**
  19931. * Represents a generic controller
  19932. */
  19933. static GENERIC: number;
  19934. /**
  19935. * Represents an XBox controller
  19936. */
  19937. static XBOX: number;
  19938. /**
  19939. * Represents a pose-enabled controller
  19940. */
  19941. static POSE_ENABLED: number;
  19942. /**
  19943. * Represents an Dual Shock controller
  19944. */
  19945. static DUALSHOCK: number;
  19946. /**
  19947. * Specifies whether the left control stick should be Y-inverted
  19948. */
  19949. protected _invertLeftStickY: boolean;
  19950. /**
  19951. * Specifies if the gamepad has been connected
  19952. */
  19953. get isConnected(): boolean;
  19954. /**
  19955. * Initializes the gamepad
  19956. * @param id The id of the gamepad
  19957. * @param index The index of the gamepad
  19958. * @param browserGamepad The browser gamepad
  19959. * @param leftStickX The x component of the left joystick
  19960. * @param leftStickY The y component of the left joystick
  19961. * @param rightStickX The x component of the right joystick
  19962. * @param rightStickY The y component of the right joystick
  19963. */
  19964. constructor(
  19965. /**
  19966. * The id of the gamepad
  19967. */
  19968. id: string,
  19969. /**
  19970. * The index of the gamepad
  19971. */
  19972. index: number,
  19973. /**
  19974. * The browser gamepad
  19975. */
  19976. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19977. /**
  19978. * Callback triggered when the left joystick has changed
  19979. * @param callback
  19980. */
  19981. onleftstickchanged(callback: (values: StickValues) => void): void;
  19982. /**
  19983. * Callback triggered when the right joystick has changed
  19984. * @param callback
  19985. */
  19986. onrightstickchanged(callback: (values: StickValues) => void): void;
  19987. /**
  19988. * Gets the left joystick
  19989. */
  19990. get leftStick(): StickValues;
  19991. /**
  19992. * Sets the left joystick values
  19993. */
  19994. set leftStick(newValues: StickValues);
  19995. /**
  19996. * Gets the right joystick
  19997. */
  19998. get rightStick(): StickValues;
  19999. /**
  20000. * Sets the right joystick value
  20001. */
  20002. set rightStick(newValues: StickValues);
  20003. /**
  20004. * Updates the gamepad joystick positions
  20005. */
  20006. update(): void;
  20007. /**
  20008. * Disposes the gamepad
  20009. */
  20010. dispose(): void;
  20011. }
  20012. /**
  20013. * Represents a generic gamepad
  20014. */
  20015. export class GenericPad extends Gamepad {
  20016. private _buttons;
  20017. private _onbuttondown;
  20018. private _onbuttonup;
  20019. /**
  20020. * Observable triggered when a button has been pressed
  20021. */
  20022. onButtonDownObservable: Observable<number>;
  20023. /**
  20024. * Observable triggered when a button has been released
  20025. */
  20026. onButtonUpObservable: Observable<number>;
  20027. /**
  20028. * Callback triggered when a button has been pressed
  20029. * @param callback Called when a button has been pressed
  20030. */
  20031. onbuttondown(callback: (buttonPressed: number) => void): void;
  20032. /**
  20033. * Callback triggered when a button has been released
  20034. * @param callback Called when a button has been released
  20035. */
  20036. onbuttonup(callback: (buttonReleased: number) => void): void;
  20037. /**
  20038. * Initializes the generic gamepad
  20039. * @param id The id of the generic gamepad
  20040. * @param index The index of the generic gamepad
  20041. * @param browserGamepad The browser gamepad
  20042. */
  20043. constructor(id: string, index: number, browserGamepad: any);
  20044. private _setButtonValue;
  20045. /**
  20046. * Updates the generic gamepad
  20047. */
  20048. update(): void;
  20049. /**
  20050. * Disposes the generic gamepad
  20051. */
  20052. dispose(): void;
  20053. }
  20054. }
  20055. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  20056. import { Observable } from "babylonjs/Misc/observable";
  20057. import { Nullable } from "babylonjs/types";
  20058. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20059. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20061. import { Ray } from "babylonjs/Culling/ray";
  20062. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  20063. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  20064. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  20065. /**
  20066. * Defines the types of pose enabled controllers that are supported
  20067. */
  20068. export enum PoseEnabledControllerType {
  20069. /**
  20070. * HTC Vive
  20071. */
  20072. VIVE = 0,
  20073. /**
  20074. * Oculus Rift
  20075. */
  20076. OCULUS = 1,
  20077. /**
  20078. * Windows mixed reality
  20079. */
  20080. WINDOWS = 2,
  20081. /**
  20082. * Samsung gear VR
  20083. */
  20084. GEAR_VR = 3,
  20085. /**
  20086. * Google Daydream
  20087. */
  20088. DAYDREAM = 4,
  20089. /**
  20090. * Generic
  20091. */
  20092. GENERIC = 5
  20093. }
  20094. /**
  20095. * Defines the MutableGamepadButton interface for the state of a gamepad button
  20096. */
  20097. export interface MutableGamepadButton {
  20098. /**
  20099. * Value of the button/trigger
  20100. */
  20101. value: number;
  20102. /**
  20103. * If the button/trigger is currently touched
  20104. */
  20105. touched: boolean;
  20106. /**
  20107. * If the button/trigger is currently pressed
  20108. */
  20109. pressed: boolean;
  20110. }
  20111. /**
  20112. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20113. * @hidden
  20114. */
  20115. export interface ExtendedGamepadButton extends GamepadButton {
  20116. /**
  20117. * If the button/trigger is currently pressed
  20118. */
  20119. readonly pressed: boolean;
  20120. /**
  20121. * If the button/trigger is currently touched
  20122. */
  20123. readonly touched: boolean;
  20124. /**
  20125. * Value of the button/trigger
  20126. */
  20127. readonly value: number;
  20128. }
  20129. /** @hidden */
  20130. export interface _GamePadFactory {
  20131. /**
  20132. * Returns whether or not the current gamepad can be created for this type of controller.
  20133. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20134. * @returns true if it can be created, otherwise false
  20135. */
  20136. canCreate(gamepadInfo: any): boolean;
  20137. /**
  20138. * Creates a new instance of the Gamepad.
  20139. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20140. * @returns the new gamepad instance
  20141. */
  20142. create(gamepadInfo: any): Gamepad;
  20143. }
  20144. /**
  20145. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20146. */
  20147. export class PoseEnabledControllerHelper {
  20148. /** @hidden */
  20149. static _ControllerFactories: _GamePadFactory[];
  20150. /** @hidden */
  20151. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20152. /**
  20153. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20154. * @param vrGamepad the gamepad to initialized
  20155. * @returns a vr controller of the type the gamepad identified as
  20156. */
  20157. static InitiateController(vrGamepad: any): Gamepad;
  20158. }
  20159. /**
  20160. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20161. */
  20162. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20163. /**
  20164. * If the controller is used in a webXR session
  20165. */
  20166. isXR: boolean;
  20167. private _deviceRoomPosition;
  20168. private _deviceRoomRotationQuaternion;
  20169. /**
  20170. * The device position in babylon space
  20171. */
  20172. devicePosition: Vector3;
  20173. /**
  20174. * The device rotation in babylon space
  20175. */
  20176. deviceRotationQuaternion: Quaternion;
  20177. /**
  20178. * The scale factor of the device in babylon space
  20179. */
  20180. deviceScaleFactor: number;
  20181. /**
  20182. * (Likely devicePosition should be used instead) The device position in its room space
  20183. */
  20184. position: Vector3;
  20185. /**
  20186. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20187. */
  20188. rotationQuaternion: Quaternion;
  20189. /**
  20190. * The type of controller (Eg. Windows mixed reality)
  20191. */
  20192. controllerType: PoseEnabledControllerType;
  20193. protected _calculatedPosition: Vector3;
  20194. private _calculatedRotation;
  20195. /**
  20196. * The raw pose from the device
  20197. */
  20198. rawPose: DevicePose;
  20199. private _trackPosition;
  20200. private _maxRotationDistFromHeadset;
  20201. private _draggedRoomRotation;
  20202. /**
  20203. * @hidden
  20204. */
  20205. _disableTrackPosition(fixedPosition: Vector3): void;
  20206. /**
  20207. * Internal, the mesh attached to the controller
  20208. * @hidden
  20209. */
  20210. _mesh: Nullable<AbstractMesh>;
  20211. private _poseControlledCamera;
  20212. private _leftHandSystemQuaternion;
  20213. /**
  20214. * Internal, matrix used to convert room space to babylon space
  20215. * @hidden
  20216. */
  20217. _deviceToWorld: Matrix;
  20218. /**
  20219. * Node to be used when casting a ray from the controller
  20220. * @hidden
  20221. */
  20222. _pointingPoseNode: Nullable<TransformNode>;
  20223. /**
  20224. * Name of the child mesh that can be used to cast a ray from the controller
  20225. */
  20226. static readonly POINTING_POSE: string;
  20227. /**
  20228. * Creates a new PoseEnabledController from a gamepad
  20229. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20230. */
  20231. constructor(browserGamepad: any);
  20232. private _workingMatrix;
  20233. /**
  20234. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20235. */
  20236. update(): void;
  20237. /**
  20238. * Updates only the pose device and mesh without doing any button event checking
  20239. */
  20240. protected _updatePoseAndMesh(): void;
  20241. /**
  20242. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20243. * @param poseData raw pose fromthe device
  20244. */
  20245. updateFromDevice(poseData: DevicePose): void;
  20246. /**
  20247. * @hidden
  20248. */
  20249. _meshAttachedObservable: Observable<AbstractMesh>;
  20250. /**
  20251. * Attaches a mesh to the controller
  20252. * @param mesh the mesh to be attached
  20253. */
  20254. attachToMesh(mesh: AbstractMesh): void;
  20255. /**
  20256. * Attaches the controllers mesh to a camera
  20257. * @param camera the camera the mesh should be attached to
  20258. */
  20259. attachToPoseControlledCamera(camera: TargetCamera): void;
  20260. /**
  20261. * Disposes of the controller
  20262. */
  20263. dispose(): void;
  20264. /**
  20265. * The mesh that is attached to the controller
  20266. */
  20267. get mesh(): Nullable<AbstractMesh>;
  20268. /**
  20269. * Gets the ray of the controller in the direction the controller is pointing
  20270. * @param length the length the resulting ray should be
  20271. * @returns a ray in the direction the controller is pointing
  20272. */
  20273. getForwardRay(length?: number): Ray;
  20274. }
  20275. }
  20276. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20277. import { Observable } from "babylonjs/Misc/observable";
  20278. import { Scene } from "babylonjs/scene";
  20279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20280. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20281. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20282. import { Nullable } from "babylonjs/types";
  20283. /**
  20284. * Defines the WebVRController object that represents controllers tracked in 3D space
  20285. */
  20286. export abstract class WebVRController extends PoseEnabledController {
  20287. /**
  20288. * Internal, the default controller model for the controller
  20289. */
  20290. protected _defaultModel: Nullable<AbstractMesh>;
  20291. /**
  20292. * Fired when the trigger state has changed
  20293. */
  20294. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20295. /**
  20296. * Fired when the main button state has changed
  20297. */
  20298. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20299. /**
  20300. * Fired when the secondary button state has changed
  20301. */
  20302. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20303. /**
  20304. * Fired when the pad state has changed
  20305. */
  20306. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20307. /**
  20308. * Fired when controllers stick values have changed
  20309. */
  20310. onPadValuesChangedObservable: Observable<StickValues>;
  20311. /**
  20312. * Array of button availible on the controller
  20313. */
  20314. protected _buttons: Array<MutableGamepadButton>;
  20315. private _onButtonStateChange;
  20316. /**
  20317. * Fired when a controller button's state has changed
  20318. * @param callback the callback containing the button that was modified
  20319. */
  20320. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20321. /**
  20322. * X and Y axis corresponding to the controllers joystick
  20323. */
  20324. pad: StickValues;
  20325. /**
  20326. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20327. */
  20328. hand: string;
  20329. /**
  20330. * The default controller model for the controller
  20331. */
  20332. get defaultModel(): Nullable<AbstractMesh>;
  20333. /**
  20334. * Creates a new WebVRController from a gamepad
  20335. * @param vrGamepad the gamepad that the WebVRController should be created from
  20336. */
  20337. constructor(vrGamepad: any);
  20338. /**
  20339. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20340. */
  20341. update(): void;
  20342. /**
  20343. * Function to be called when a button is modified
  20344. */
  20345. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20346. /**
  20347. * Loads a mesh and attaches it to the controller
  20348. * @param scene the scene the mesh should be added to
  20349. * @param meshLoaded callback for when the mesh has been loaded
  20350. */
  20351. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20352. private _setButtonValue;
  20353. private _changes;
  20354. private _checkChanges;
  20355. /**
  20356. * Disposes of th webVRCOntroller
  20357. */
  20358. dispose(): void;
  20359. }
  20360. }
  20361. declare module "babylonjs/Lights/hemisphericLight" {
  20362. import { Nullable } from "babylonjs/types";
  20363. import { Scene } from "babylonjs/scene";
  20364. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20365. import { Color3 } from "babylonjs/Maths/math.color";
  20366. import { Effect } from "babylonjs/Materials/effect";
  20367. import { Light } from "babylonjs/Lights/light";
  20368. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20369. /**
  20370. * The HemisphericLight simulates the ambient environment light,
  20371. * so the passed direction is the light reflection direction, not the incoming direction.
  20372. */
  20373. export class HemisphericLight extends Light {
  20374. /**
  20375. * The groundColor is the light in the opposite direction to the one specified during creation.
  20376. * 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.
  20377. */
  20378. groundColor: Color3;
  20379. /**
  20380. * The light reflection direction, not the incoming direction.
  20381. */
  20382. direction: Vector3;
  20383. /**
  20384. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20385. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20386. * The HemisphericLight can't cast shadows.
  20387. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20388. * @param name The friendly name of the light
  20389. * @param direction The direction of the light reflection
  20390. * @param scene The scene the light belongs to
  20391. */
  20392. constructor(name: string, direction: Vector3, scene: Scene);
  20393. protected _buildUniformLayout(): void;
  20394. /**
  20395. * Returns the string "HemisphericLight".
  20396. * @return The class name
  20397. */
  20398. getClassName(): string;
  20399. /**
  20400. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20401. * Returns the updated direction.
  20402. * @param target The target the direction should point to
  20403. * @return The computed direction
  20404. */
  20405. setDirectionToTarget(target: Vector3): Vector3;
  20406. /**
  20407. * Returns the shadow generator associated to the light.
  20408. * @returns Always null for hemispheric lights because it does not support shadows.
  20409. */
  20410. getShadowGenerator(): Nullable<IShadowGenerator>;
  20411. /**
  20412. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20413. * @param effect The effect to update
  20414. * @param lightIndex The index of the light in the effect to update
  20415. * @returns The hemispheric light
  20416. */
  20417. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20418. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20419. /**
  20420. * Computes the world matrix of the node
  20421. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20422. * @param useWasUpdatedFlag defines a reserved property
  20423. * @returns the world matrix
  20424. */
  20425. computeWorldMatrix(): Matrix;
  20426. /**
  20427. * Returns the integer 3.
  20428. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20429. */
  20430. getTypeID(): number;
  20431. /**
  20432. * Prepares the list of defines specific to the light type.
  20433. * @param defines the list of defines
  20434. * @param lightIndex defines the index of the light for the effect
  20435. */
  20436. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20437. }
  20438. }
  20439. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20440. /** @hidden */
  20441. export var vrMultiviewToSingleviewPixelShader: {
  20442. name: string;
  20443. shader: string;
  20444. };
  20445. }
  20446. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20447. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20448. import { Scene } from "babylonjs/scene";
  20449. /**
  20450. * Renders to multiple views with a single draw call
  20451. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20452. */
  20453. export class MultiviewRenderTarget extends RenderTargetTexture {
  20454. /**
  20455. * Creates a multiview render target
  20456. * @param scene scene used with the render target
  20457. * @param size the size of the render target (used for each view)
  20458. */
  20459. constructor(scene: Scene, size?: number | {
  20460. width: number;
  20461. height: number;
  20462. } | {
  20463. ratio: number;
  20464. });
  20465. /**
  20466. * @hidden
  20467. * @param faceIndex the face index, if its a cube texture
  20468. */
  20469. _bindFrameBuffer(faceIndex?: number): void;
  20470. /**
  20471. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20472. * @returns the view count
  20473. */
  20474. getViewCount(): number;
  20475. }
  20476. }
  20477. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20478. import { Camera } from "babylonjs/Cameras/camera";
  20479. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20480. import { Nullable } from "babylonjs/types";
  20481. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20482. import { Matrix } from "babylonjs/Maths/math.vector";
  20483. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20484. module "babylonjs/Engines/engine" {
  20485. interface Engine {
  20486. /**
  20487. * Creates a new multiview render target
  20488. * @param width defines the width of the texture
  20489. * @param height defines the height of the texture
  20490. * @returns the created multiview texture
  20491. */
  20492. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20493. /**
  20494. * Binds a multiview framebuffer to be drawn to
  20495. * @param multiviewTexture texture to bind
  20496. */
  20497. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20498. }
  20499. }
  20500. module "babylonjs/Cameras/camera" {
  20501. interface Camera {
  20502. /**
  20503. * @hidden
  20504. * 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)
  20505. */
  20506. _useMultiviewToSingleView: boolean;
  20507. /**
  20508. * @hidden
  20509. * 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)
  20510. */
  20511. _multiviewTexture: Nullable<RenderTargetTexture>;
  20512. /**
  20513. * @hidden
  20514. * ensures the multiview texture of the camera exists and has the specified width/height
  20515. * @param width height to set on the multiview texture
  20516. * @param height width to set on the multiview texture
  20517. */
  20518. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20519. }
  20520. }
  20521. module "babylonjs/scene" {
  20522. interface Scene {
  20523. /** @hidden */
  20524. _transformMatrixR: Matrix;
  20525. /** @hidden */
  20526. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20527. /** @hidden */
  20528. _createMultiviewUbo(): void;
  20529. /** @hidden */
  20530. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20531. /** @hidden */
  20532. _renderMultiviewToSingleView(camera: Camera): void;
  20533. }
  20534. }
  20535. }
  20536. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20537. import { Camera } from "babylonjs/Cameras/camera";
  20538. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20539. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20540. import "babylonjs/Engines/Extensions/engine.multiview";
  20541. /**
  20542. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20543. * This will not be used for webXR as it supports displaying texture arrays directly
  20544. */
  20545. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20546. /**
  20547. * Gets a string identifying the name of the class
  20548. * @returns "VRMultiviewToSingleviewPostProcess" string
  20549. */
  20550. getClassName(): string;
  20551. /**
  20552. * Initializes a VRMultiviewToSingleview
  20553. * @param name name of the post process
  20554. * @param camera camera to be applied to
  20555. * @param scaleFactor scaling factor to the size of the output texture
  20556. */
  20557. constructor(name: string, camera: Camera, scaleFactor: number);
  20558. }
  20559. }
  20560. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20561. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20562. import { Nullable } from "babylonjs/types";
  20563. import { Size } from "babylonjs/Maths/math.size";
  20564. import { Observable } from "babylonjs/Misc/observable";
  20565. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20566. /**
  20567. * Interface used to define additional presentation attributes
  20568. */
  20569. export interface IVRPresentationAttributes {
  20570. /**
  20571. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20572. */
  20573. highRefreshRate: boolean;
  20574. /**
  20575. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20576. */
  20577. foveationLevel: number;
  20578. }
  20579. module "babylonjs/Engines/engine" {
  20580. interface Engine {
  20581. /** @hidden */
  20582. _vrDisplay: any;
  20583. /** @hidden */
  20584. _vrSupported: boolean;
  20585. /** @hidden */
  20586. _oldSize: Size;
  20587. /** @hidden */
  20588. _oldHardwareScaleFactor: number;
  20589. /** @hidden */
  20590. _vrExclusivePointerMode: boolean;
  20591. /** @hidden */
  20592. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20593. /** @hidden */
  20594. _onVRDisplayPointerRestricted: () => void;
  20595. /** @hidden */
  20596. _onVRDisplayPointerUnrestricted: () => void;
  20597. /** @hidden */
  20598. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20599. /** @hidden */
  20600. _onVrDisplayDisconnect: Nullable<() => void>;
  20601. /** @hidden */
  20602. _onVrDisplayPresentChange: Nullable<() => void>;
  20603. /**
  20604. * Observable signaled when VR display mode changes
  20605. */
  20606. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20607. /**
  20608. * Observable signaled when VR request present is complete
  20609. */
  20610. onVRRequestPresentComplete: Observable<boolean>;
  20611. /**
  20612. * Observable signaled when VR request present starts
  20613. */
  20614. onVRRequestPresentStart: Observable<Engine>;
  20615. /**
  20616. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20617. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20618. */
  20619. isInVRExclusivePointerMode: boolean;
  20620. /**
  20621. * Gets a boolean indicating if a webVR device was detected
  20622. * @returns true if a webVR device was detected
  20623. */
  20624. isVRDevicePresent(): boolean;
  20625. /**
  20626. * Gets the current webVR device
  20627. * @returns the current webVR device (or null)
  20628. */
  20629. getVRDevice(): any;
  20630. /**
  20631. * Initializes a webVR display and starts listening to display change events
  20632. * The onVRDisplayChangedObservable will be notified upon these changes
  20633. * @returns A promise containing a VRDisplay and if vr is supported
  20634. */
  20635. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20636. /** @hidden */
  20637. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20638. /**
  20639. * Gets or sets the presentation attributes used to configure VR rendering
  20640. */
  20641. vrPresentationAttributes?: IVRPresentationAttributes;
  20642. /**
  20643. * Call this function to switch to webVR mode
  20644. * Will do nothing if webVR is not supported or if there is no webVR device
  20645. * @param options the webvr options provided to the camera. mainly used for multiview
  20646. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20647. */
  20648. enableVR(options: WebVROptions): void;
  20649. /** @hidden */
  20650. _onVRFullScreenTriggered(): void;
  20651. }
  20652. }
  20653. }
  20654. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20655. import { Nullable } from "babylonjs/types";
  20656. import { Observable } from "babylonjs/Misc/observable";
  20657. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20658. import { Scene } from "babylonjs/scene";
  20659. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20660. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20661. import { Node } from "babylonjs/node";
  20662. import { Ray } from "babylonjs/Culling/ray";
  20663. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20664. import "babylonjs/Engines/Extensions/engine.webVR";
  20665. /**
  20666. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20667. * IMPORTANT!! The data is right-hand data.
  20668. * @export
  20669. * @interface DevicePose
  20670. */
  20671. export interface DevicePose {
  20672. /**
  20673. * The position of the device, values in array are [x,y,z].
  20674. */
  20675. readonly position: Nullable<Float32Array>;
  20676. /**
  20677. * The linearVelocity of the device, values in array are [x,y,z].
  20678. */
  20679. readonly linearVelocity: Nullable<Float32Array>;
  20680. /**
  20681. * The linearAcceleration of the device, values in array are [x,y,z].
  20682. */
  20683. readonly linearAcceleration: Nullable<Float32Array>;
  20684. /**
  20685. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20686. */
  20687. readonly orientation: Nullable<Float32Array>;
  20688. /**
  20689. * The angularVelocity of the device, values in array are [x,y,z].
  20690. */
  20691. readonly angularVelocity: Nullable<Float32Array>;
  20692. /**
  20693. * The angularAcceleration of the device, values in array are [x,y,z].
  20694. */
  20695. readonly angularAcceleration: Nullable<Float32Array>;
  20696. }
  20697. /**
  20698. * Interface representing a pose controlled object in Babylon.
  20699. * A pose controlled object has both regular pose values as well as pose values
  20700. * from an external device such as a VR head mounted display
  20701. */
  20702. export interface PoseControlled {
  20703. /**
  20704. * The position of the object in babylon space.
  20705. */
  20706. position: Vector3;
  20707. /**
  20708. * The rotation quaternion of the object in babylon space.
  20709. */
  20710. rotationQuaternion: Quaternion;
  20711. /**
  20712. * The position of the device in babylon space.
  20713. */
  20714. devicePosition?: Vector3;
  20715. /**
  20716. * The rotation quaternion of the device in babylon space.
  20717. */
  20718. deviceRotationQuaternion: Quaternion;
  20719. /**
  20720. * The raw pose coming from the device.
  20721. */
  20722. rawPose: Nullable<DevicePose>;
  20723. /**
  20724. * The scale of the device to be used when translating from device space to babylon space.
  20725. */
  20726. deviceScaleFactor: number;
  20727. /**
  20728. * Updates the poseControlled values based on the input device pose.
  20729. * @param poseData the pose data to update the object with
  20730. */
  20731. updateFromDevice(poseData: DevicePose): void;
  20732. }
  20733. /**
  20734. * Set of options to customize the webVRCamera
  20735. */
  20736. export interface WebVROptions {
  20737. /**
  20738. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20739. */
  20740. trackPosition?: boolean;
  20741. /**
  20742. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20743. */
  20744. positionScale?: number;
  20745. /**
  20746. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20747. */
  20748. displayName?: string;
  20749. /**
  20750. * Should the native controller meshes be initialized. (default: true)
  20751. */
  20752. controllerMeshes?: boolean;
  20753. /**
  20754. * Creating a default HemiLight only on controllers. (default: true)
  20755. */
  20756. defaultLightingOnControllers?: boolean;
  20757. /**
  20758. * If you don't want to use the default VR button of the helper. (default: false)
  20759. */
  20760. useCustomVRButton?: boolean;
  20761. /**
  20762. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20763. */
  20764. customVRButton?: HTMLButtonElement;
  20765. /**
  20766. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20767. */
  20768. rayLength?: number;
  20769. /**
  20770. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20771. */
  20772. defaultHeight?: number;
  20773. /**
  20774. * If multiview should be used if availible (default: false)
  20775. */
  20776. useMultiview?: boolean;
  20777. }
  20778. /**
  20779. * This represents a WebVR camera.
  20780. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20781. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20782. */
  20783. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20784. private webVROptions;
  20785. /**
  20786. * @hidden
  20787. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20788. */
  20789. _vrDevice: any;
  20790. /**
  20791. * The rawPose of the vrDevice.
  20792. */
  20793. rawPose: Nullable<DevicePose>;
  20794. private _onVREnabled;
  20795. private _specsVersion;
  20796. private _attached;
  20797. private _frameData;
  20798. protected _descendants: Array<Node>;
  20799. private _deviceRoomPosition;
  20800. /** @hidden */
  20801. _deviceRoomRotationQuaternion: Quaternion;
  20802. private _standingMatrix;
  20803. /**
  20804. * Represents device position in babylon space.
  20805. */
  20806. devicePosition: Vector3;
  20807. /**
  20808. * Represents device rotation in babylon space.
  20809. */
  20810. deviceRotationQuaternion: Quaternion;
  20811. /**
  20812. * The scale of the device to be used when translating from device space to babylon space.
  20813. */
  20814. deviceScaleFactor: number;
  20815. private _deviceToWorld;
  20816. private _worldToDevice;
  20817. /**
  20818. * References to the webVR controllers for the vrDevice.
  20819. */
  20820. controllers: Array<WebVRController>;
  20821. /**
  20822. * Emits an event when a controller is attached.
  20823. */
  20824. onControllersAttachedObservable: Observable<WebVRController[]>;
  20825. /**
  20826. * Emits an event when a controller's mesh has been loaded;
  20827. */
  20828. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20829. /**
  20830. * Emits an event when the HMD's pose has been updated.
  20831. */
  20832. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20833. private _poseSet;
  20834. /**
  20835. * If the rig cameras be used as parent instead of this camera.
  20836. */
  20837. rigParenting: boolean;
  20838. private _lightOnControllers;
  20839. private _defaultHeight?;
  20840. /**
  20841. * Instantiates a WebVRFreeCamera.
  20842. * @param name The name of the WebVRFreeCamera
  20843. * @param position The starting anchor position for the camera
  20844. * @param scene The scene the camera belongs to
  20845. * @param webVROptions a set of customizable options for the webVRCamera
  20846. */
  20847. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20848. /**
  20849. * Gets the device distance from the ground in meters.
  20850. * @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.
  20851. */
  20852. deviceDistanceToRoomGround(): number;
  20853. /**
  20854. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20855. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20856. */
  20857. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20858. /**
  20859. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20860. * @returns A promise with a boolean set to if the standing matrix is supported.
  20861. */
  20862. useStandingMatrixAsync(): Promise<boolean>;
  20863. /**
  20864. * Disposes the camera
  20865. */
  20866. dispose(): void;
  20867. /**
  20868. * Gets a vrController by name.
  20869. * @param name The name of the controller to retreive
  20870. * @returns the controller matching the name specified or null if not found
  20871. */
  20872. getControllerByName(name: string): Nullable<WebVRController>;
  20873. private _leftController;
  20874. /**
  20875. * The controller corresponding to the users left hand.
  20876. */
  20877. get leftController(): Nullable<WebVRController>;
  20878. private _rightController;
  20879. /**
  20880. * The controller corresponding to the users right hand.
  20881. */
  20882. get rightController(): Nullable<WebVRController>;
  20883. /**
  20884. * Casts a ray forward from the vrCamera's gaze.
  20885. * @param length Length of the ray (default: 100)
  20886. * @returns the ray corresponding to the gaze
  20887. */
  20888. getForwardRay(length?: number): Ray;
  20889. /**
  20890. * @hidden
  20891. * Updates the camera based on device's frame data
  20892. */
  20893. _checkInputs(): void;
  20894. /**
  20895. * Updates the poseControlled values based on the input device pose.
  20896. * @param poseData Pose coming from the device
  20897. */
  20898. updateFromDevice(poseData: DevicePose): void;
  20899. private _htmlElementAttached;
  20900. private _detachIfAttached;
  20901. /**
  20902. * WebVR's attach control will start broadcasting frames to the device.
  20903. * Note that in certain browsers (chrome for example) this function must be called
  20904. * within a user-interaction callback. Example:
  20905. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20906. *
  20907. * @param element html element to attach the vrDevice to
  20908. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20909. */
  20910. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20911. /**
  20912. * Detaches the camera from the html element and disables VR
  20913. *
  20914. * @param element html element to detach from
  20915. */
  20916. detachControl(element: HTMLElement): void;
  20917. /**
  20918. * @returns the name of this class
  20919. */
  20920. getClassName(): string;
  20921. /**
  20922. * Calls resetPose on the vrDisplay
  20923. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20924. */
  20925. resetToCurrentRotation(): void;
  20926. /**
  20927. * @hidden
  20928. * Updates the rig cameras (left and right eye)
  20929. */
  20930. _updateRigCameras(): void;
  20931. private _workingVector;
  20932. private _oneVector;
  20933. private _workingMatrix;
  20934. private updateCacheCalled;
  20935. private _correctPositionIfNotTrackPosition;
  20936. /**
  20937. * @hidden
  20938. * Updates the cached values of the camera
  20939. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20940. */
  20941. _updateCache(ignoreParentClass?: boolean): void;
  20942. /**
  20943. * @hidden
  20944. * Get current device position in babylon world
  20945. */
  20946. _computeDevicePosition(): void;
  20947. /**
  20948. * Updates the current device position and rotation in the babylon world
  20949. */
  20950. update(): void;
  20951. /**
  20952. * @hidden
  20953. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20954. * @returns an identity matrix
  20955. */
  20956. _getViewMatrix(): Matrix;
  20957. private _tmpMatrix;
  20958. /**
  20959. * This function is called by the two RIG cameras.
  20960. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20961. * @hidden
  20962. */
  20963. _getWebVRViewMatrix(): Matrix;
  20964. /** @hidden */
  20965. _getWebVRProjectionMatrix(): Matrix;
  20966. private _onGamepadConnectedObserver;
  20967. private _onGamepadDisconnectedObserver;
  20968. private _updateCacheWhenTrackingDisabledObserver;
  20969. /**
  20970. * Initializes the controllers and their meshes
  20971. */
  20972. initControllers(): void;
  20973. }
  20974. }
  20975. declare module "babylonjs/Materials/materialHelper" {
  20976. import { Nullable } from "babylonjs/types";
  20977. import { Scene } from "babylonjs/scene";
  20978. import { Engine } from "babylonjs/Engines/engine";
  20979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20980. import { Light } from "babylonjs/Lights/light";
  20981. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  20982. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20983. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20984. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20985. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20986. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20987. /**
  20988. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20989. *
  20990. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20991. *
  20992. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20993. */
  20994. export class MaterialHelper {
  20995. /**
  20996. * Bind the current view position to an effect.
  20997. * @param effect The effect to be bound
  20998. * @param scene The scene the eyes position is used from
  20999. * @param variableName name of the shader variable that will hold the eye position
  21000. */
  21001. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  21002. /**
  21003. * Helps preparing the defines values about the UVs in used in the effect.
  21004. * UVs are shared as much as we can accross channels in the shaders.
  21005. * @param texture The texture we are preparing the UVs for
  21006. * @param defines The defines to update
  21007. * @param key The channel key "diffuse", "specular"... used in the shader
  21008. */
  21009. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  21010. /**
  21011. * Binds a texture matrix value to its corrsponding uniform
  21012. * @param texture The texture to bind the matrix for
  21013. * @param uniformBuffer The uniform buffer receivin the data
  21014. * @param key The channel key "diffuse", "specular"... used in the shader
  21015. */
  21016. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  21017. /**
  21018. * Gets the current status of the fog (should it be enabled?)
  21019. * @param mesh defines the mesh to evaluate for fog support
  21020. * @param scene defines the hosting scene
  21021. * @returns true if fog must be enabled
  21022. */
  21023. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  21024. /**
  21025. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  21026. * @param mesh defines the current mesh
  21027. * @param scene defines the current scene
  21028. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  21029. * @param pointsCloud defines if point cloud rendering has to be turned on
  21030. * @param fogEnabled defines if fog has to be turned on
  21031. * @param alphaTest defines if alpha testing has to be turned on
  21032. * @param defines defines the current list of defines
  21033. */
  21034. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  21035. /**
  21036. * Helper used to prepare the list of defines associated with frame values for shader compilation
  21037. * @param scene defines the current scene
  21038. * @param engine defines the current engine
  21039. * @param defines specifies the list of active defines
  21040. * @param useInstances defines if instances have to be turned on
  21041. * @param useClipPlane defines if clip plane have to be turned on
  21042. * @param useInstances defines if instances have to be turned on
  21043. * @param useThinInstances defines if thin instances have to be turned on
  21044. */
  21045. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  21046. /**
  21047. * Prepares the defines for bones
  21048. * @param mesh The mesh containing the geometry data we will draw
  21049. * @param defines The defines to update
  21050. */
  21051. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  21052. /**
  21053. * Prepares the defines for morph targets
  21054. * @param mesh The mesh containing the geometry data we will draw
  21055. * @param defines The defines to update
  21056. */
  21057. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  21058. /**
  21059. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  21060. * @param mesh The mesh containing the geometry data we will draw
  21061. * @param defines The defines to update
  21062. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  21063. * @param useBones Precise whether bones should be used or not (override mesh info)
  21064. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  21065. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  21066. * @returns false if defines are considered not dirty and have not been checked
  21067. */
  21068. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  21069. /**
  21070. * Prepares the defines related to multiview
  21071. * @param scene The scene we are intending to draw
  21072. * @param defines The defines to update
  21073. */
  21074. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  21075. /**
  21076. * Prepares the defines related to the prepass
  21077. * @param scene The scene we are intending to draw
  21078. * @param defines The defines to update
  21079. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  21080. */
  21081. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  21082. /**
  21083. * Prepares the defines related to the light information passed in parameter
  21084. * @param scene The scene we are intending to draw
  21085. * @param mesh The mesh the effect is compiling for
  21086. * @param light The light the effect is compiling for
  21087. * @param lightIndex The index of the light
  21088. * @param defines The defines to update
  21089. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21090. * @param state Defines the current state regarding what is needed (normals, etc...)
  21091. */
  21092. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  21093. needNormals: boolean;
  21094. needRebuild: boolean;
  21095. shadowEnabled: boolean;
  21096. specularEnabled: boolean;
  21097. lightmapMode: boolean;
  21098. }): void;
  21099. /**
  21100. * Prepares the defines related to the light information passed in parameter
  21101. * @param scene The scene we are intending to draw
  21102. * @param mesh The mesh the effect is compiling for
  21103. * @param defines The defines to update
  21104. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21105. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21106. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21107. * @returns true if normals will be required for the rest of the effect
  21108. */
  21109. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21110. /**
  21111. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21112. * @param lightIndex defines the light index
  21113. * @param uniformsList The uniform list
  21114. * @param samplersList The sampler list
  21115. * @param projectedLightTexture defines if projected texture must be used
  21116. * @param uniformBuffersList defines an optional list of uniform buffers
  21117. */
  21118. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21119. /**
  21120. * Prepares the uniforms and samplers list to be used in the effect
  21121. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21122. * @param samplersList The sampler list
  21123. * @param defines The defines helping in the list generation
  21124. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21125. */
  21126. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21127. /**
  21128. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21129. * @param defines The defines to update while falling back
  21130. * @param fallbacks The authorized effect fallbacks
  21131. * @param maxSimultaneousLights The maximum number of lights allowed
  21132. * @param rank the current rank of the Effect
  21133. * @returns The newly affected rank
  21134. */
  21135. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21136. private static _TmpMorphInfluencers;
  21137. /**
  21138. * Prepares the list of attributes required for morph targets according to the effect defines.
  21139. * @param attribs The current list of supported attribs
  21140. * @param mesh The mesh to prepare the morph targets attributes for
  21141. * @param influencers The number of influencers
  21142. */
  21143. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21144. /**
  21145. * Prepares the list of attributes required for morph targets according to the effect defines.
  21146. * @param attribs The current list of supported attribs
  21147. * @param mesh The mesh to prepare the morph targets attributes for
  21148. * @param defines The current Defines of the effect
  21149. */
  21150. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21151. /**
  21152. * Prepares the list of attributes required for bones according to the effect defines.
  21153. * @param attribs The current list of supported attribs
  21154. * @param mesh The mesh to prepare the bones attributes for
  21155. * @param defines The current Defines of the effect
  21156. * @param fallbacks The current efffect fallback strategy
  21157. */
  21158. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21159. /**
  21160. * Check and prepare the list of attributes required for instances according to the effect defines.
  21161. * @param attribs The current list of supported attribs
  21162. * @param defines The current MaterialDefines of the effect
  21163. */
  21164. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21165. /**
  21166. * Add the list of attributes required for instances to the attribs array.
  21167. * @param attribs The current list of supported attribs
  21168. */
  21169. static PushAttributesForInstances(attribs: string[]): void;
  21170. /**
  21171. * Binds the light information to the effect.
  21172. * @param light The light containing the generator
  21173. * @param effect The effect we are binding the data to
  21174. * @param lightIndex The light index in the effect used to render
  21175. */
  21176. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21177. /**
  21178. * Binds the lights information from the scene to the effect for the given mesh.
  21179. * @param light Light to bind
  21180. * @param lightIndex Light index
  21181. * @param scene The scene where the light belongs to
  21182. * @param effect The effect we are binding the data to
  21183. * @param useSpecular Defines if specular is supported
  21184. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21185. */
  21186. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21187. /**
  21188. * Binds the lights information from the scene to the effect for the given mesh.
  21189. * @param scene The scene the lights belongs to
  21190. * @param mesh The mesh we are binding the information to render
  21191. * @param effect The effect we are binding the data to
  21192. * @param defines The generated defines for the effect
  21193. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21194. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21195. */
  21196. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21197. private static _tempFogColor;
  21198. /**
  21199. * Binds the fog information from the scene to the effect for the given mesh.
  21200. * @param scene The scene the lights belongs to
  21201. * @param mesh The mesh we are binding the information to render
  21202. * @param effect The effect we are binding the data to
  21203. * @param linearSpace Defines if the fog effect is applied in linear space
  21204. */
  21205. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21206. /**
  21207. * Binds the bones information from the mesh to the effect.
  21208. * @param mesh The mesh we are binding the information to render
  21209. * @param effect The effect we are binding the data to
  21210. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  21211. */
  21212. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  21213. private static _CopyBonesTransformationMatrices;
  21214. /**
  21215. * Binds the morph targets information from the mesh to the effect.
  21216. * @param abstractMesh The mesh we are binding the information to render
  21217. * @param effect The effect we are binding the data to
  21218. */
  21219. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21220. /**
  21221. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21222. * @param defines The generated defines used in the effect
  21223. * @param effect The effect we are binding the data to
  21224. * @param scene The scene we are willing to render with logarithmic scale for
  21225. */
  21226. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21227. /**
  21228. * Binds the clip plane information from the scene to the effect.
  21229. * @param scene The scene the clip plane information are extracted from
  21230. * @param effect The effect we are binding the data to
  21231. */
  21232. static BindClipPlane(effect: Effect, scene: Scene): void;
  21233. }
  21234. }
  21235. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21236. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21237. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21238. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21239. import { Nullable } from "babylonjs/types";
  21240. import { Effect } from "babylonjs/Materials/effect";
  21241. import { Matrix } from "babylonjs/Maths/math.vector";
  21242. import { Scene } from "babylonjs/scene";
  21243. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21244. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21245. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21246. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21247. import { Observable } from "babylonjs/Misc/observable";
  21248. /**
  21249. * Block used to expose an input value
  21250. */
  21251. export class InputBlock extends NodeMaterialBlock {
  21252. private _mode;
  21253. private _associatedVariableName;
  21254. private _storedValue;
  21255. private _valueCallback;
  21256. private _type;
  21257. private _animationType;
  21258. /** Gets or set a value used to limit the range of float values */
  21259. min: number;
  21260. /** Gets or set a value used to limit the range of float values */
  21261. max: number;
  21262. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21263. isBoolean: boolean;
  21264. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21265. matrixMode: number;
  21266. /** @hidden */
  21267. _systemValue: Nullable<NodeMaterialSystemValues>;
  21268. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21269. isConstant: boolean;
  21270. /** Gets or sets the group to use to display this block in the Inspector */
  21271. groupInInspector: string;
  21272. /** Gets an observable raised when the value is changed */
  21273. onValueChangedObservable: Observable<InputBlock>;
  21274. /**
  21275. * Gets or sets the connection point type (default is float)
  21276. */
  21277. get type(): NodeMaterialBlockConnectionPointTypes;
  21278. /**
  21279. * Creates a new InputBlock
  21280. * @param name defines the block name
  21281. * @param target defines the target of that block (Vertex by default)
  21282. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21283. */
  21284. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21285. /**
  21286. * Validates if a name is a reserve word.
  21287. * @param newName the new name to be given to the node.
  21288. * @returns false if the name is a reserve word, else true.
  21289. */
  21290. validateBlockName(newName: string): boolean;
  21291. /**
  21292. * Gets the output component
  21293. */
  21294. get output(): NodeMaterialConnectionPoint;
  21295. /**
  21296. * Set the source of this connection point to a vertex attribute
  21297. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21298. * @returns the current connection point
  21299. */
  21300. setAsAttribute(attributeName?: string): InputBlock;
  21301. /**
  21302. * Set the source of this connection point to a system value
  21303. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21304. * @returns the current connection point
  21305. */
  21306. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21307. /**
  21308. * Gets or sets the value of that point.
  21309. * Please note that this value will be ignored if valueCallback is defined
  21310. */
  21311. get value(): any;
  21312. set value(value: any);
  21313. /**
  21314. * Gets or sets a callback used to get the value of that point.
  21315. * Please note that setting this value will force the connection point to ignore the value property
  21316. */
  21317. get valueCallback(): () => any;
  21318. set valueCallback(value: () => any);
  21319. /**
  21320. * Gets or sets the associated variable name in the shader
  21321. */
  21322. get associatedVariableName(): string;
  21323. set associatedVariableName(value: string);
  21324. /** Gets or sets the type of animation applied to the input */
  21325. get animationType(): AnimatedInputBlockTypes;
  21326. set animationType(value: AnimatedInputBlockTypes);
  21327. /**
  21328. * Gets a boolean indicating that this connection point not defined yet
  21329. */
  21330. get isUndefined(): boolean;
  21331. /**
  21332. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21333. * In this case the connection point name must be the name of the uniform to use.
  21334. * Can only be set on inputs
  21335. */
  21336. get isUniform(): boolean;
  21337. set isUniform(value: boolean);
  21338. /**
  21339. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21340. * In this case the connection point name must be the name of the attribute to use
  21341. * Can only be set on inputs
  21342. */
  21343. get isAttribute(): boolean;
  21344. set isAttribute(value: boolean);
  21345. /**
  21346. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21347. * Can only be set on exit points
  21348. */
  21349. get isVarying(): boolean;
  21350. set isVarying(value: boolean);
  21351. /**
  21352. * Gets a boolean indicating that the current connection point is a system value
  21353. */
  21354. get isSystemValue(): boolean;
  21355. /**
  21356. * Gets or sets the current well known value or null if not defined as a system value
  21357. */
  21358. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21359. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21360. /**
  21361. * Gets the current class name
  21362. * @returns the class name
  21363. */
  21364. getClassName(): string;
  21365. /**
  21366. * Animate the input if animationType !== None
  21367. * @param scene defines the rendering scene
  21368. */
  21369. animate(scene: Scene): void;
  21370. private _emitDefine;
  21371. initialize(state: NodeMaterialBuildState): void;
  21372. /**
  21373. * Set the input block to its default value (based on its type)
  21374. */
  21375. setDefaultValue(): void;
  21376. private _emitConstant;
  21377. /** @hidden */
  21378. get _noContextSwitch(): boolean;
  21379. private _emit;
  21380. /** @hidden */
  21381. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21382. /** @hidden */
  21383. _transmit(effect: Effect, scene: Scene): void;
  21384. protected _buildBlock(state: NodeMaterialBuildState): void;
  21385. protected _dumpPropertiesCode(): string;
  21386. dispose(): void;
  21387. serialize(): any;
  21388. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21389. }
  21390. }
  21391. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21392. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21393. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21394. import { Nullable } from "babylonjs/types";
  21395. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21396. import { Observable } from "babylonjs/Misc/observable";
  21397. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21398. /**
  21399. * Enum used to define the compatibility state between two connection points
  21400. */
  21401. export enum NodeMaterialConnectionPointCompatibilityStates {
  21402. /** Points are compatibles */
  21403. Compatible = 0,
  21404. /** Points are incompatible because of their types */
  21405. TypeIncompatible = 1,
  21406. /** Points are incompatible because of their targets (vertex vs fragment) */
  21407. TargetIncompatible = 2
  21408. }
  21409. /**
  21410. * Defines the direction of a connection point
  21411. */
  21412. export enum NodeMaterialConnectionPointDirection {
  21413. /** Input */
  21414. Input = 0,
  21415. /** Output */
  21416. Output = 1
  21417. }
  21418. /**
  21419. * Defines a connection point for a block
  21420. */
  21421. export class NodeMaterialConnectionPoint {
  21422. /** @hidden */
  21423. _ownerBlock: NodeMaterialBlock;
  21424. /** @hidden */
  21425. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21426. private _endpoints;
  21427. private _associatedVariableName;
  21428. private _direction;
  21429. /** @hidden */
  21430. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21431. /** @hidden */
  21432. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21433. private _type;
  21434. /** @hidden */
  21435. _enforceAssociatedVariableName: boolean;
  21436. /** Gets the direction of the point */
  21437. get direction(): NodeMaterialConnectionPointDirection;
  21438. /** Indicates that this connection point needs dual validation before being connected to another point */
  21439. needDualDirectionValidation: boolean;
  21440. /**
  21441. * Gets or sets the additional types supported by this connection point
  21442. */
  21443. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21444. /**
  21445. * Gets or sets the additional types excluded by this connection point
  21446. */
  21447. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21448. /**
  21449. * Observable triggered when this point is connected
  21450. */
  21451. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21452. /**
  21453. * Gets or sets the associated variable name in the shader
  21454. */
  21455. get associatedVariableName(): string;
  21456. set associatedVariableName(value: string);
  21457. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21458. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21459. /**
  21460. * Gets or sets the connection point type (default is float)
  21461. */
  21462. get type(): NodeMaterialBlockConnectionPointTypes;
  21463. set type(value: NodeMaterialBlockConnectionPointTypes);
  21464. /**
  21465. * Gets or sets the connection point name
  21466. */
  21467. name: string;
  21468. /**
  21469. * Gets or sets the connection point name
  21470. */
  21471. displayName: string;
  21472. /**
  21473. * Gets or sets a boolean indicating that this connection point can be omitted
  21474. */
  21475. isOptional: boolean;
  21476. /**
  21477. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21478. */
  21479. isExposedOnFrame: boolean;
  21480. /**
  21481. * Gets or sets number indicating the position that the port is exposed to on a frame
  21482. */
  21483. exposedPortPosition: number;
  21484. /**
  21485. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21486. */
  21487. define: string;
  21488. /** @hidden */
  21489. _prioritizeVertex: boolean;
  21490. private _target;
  21491. /** Gets or sets the target of that connection point */
  21492. get target(): NodeMaterialBlockTargets;
  21493. set target(value: NodeMaterialBlockTargets);
  21494. /**
  21495. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21496. */
  21497. get isConnected(): boolean;
  21498. /**
  21499. * Gets a boolean indicating that the current point is connected to an input block
  21500. */
  21501. get isConnectedToInputBlock(): boolean;
  21502. /**
  21503. * Gets a the connected input block (if any)
  21504. */
  21505. get connectInputBlock(): Nullable<InputBlock>;
  21506. /** Get the other side of the connection (if any) */
  21507. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21508. /** Get the block that owns this connection point */
  21509. get ownerBlock(): NodeMaterialBlock;
  21510. /** Get the block connected on the other side of this connection (if any) */
  21511. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21512. /** Get the block connected on the endpoints of this connection (if any) */
  21513. get connectedBlocks(): Array<NodeMaterialBlock>;
  21514. /** Gets the list of connected endpoints */
  21515. get endpoints(): NodeMaterialConnectionPoint[];
  21516. /** Gets a boolean indicating if that output point is connected to at least one input */
  21517. get hasEndpoints(): boolean;
  21518. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21519. get isConnectedInVertexShader(): boolean;
  21520. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21521. get isConnectedInFragmentShader(): boolean;
  21522. /**
  21523. * Creates a block suitable to be used as an input for this input point.
  21524. * If null is returned, a block based on the point type will be created.
  21525. * @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
  21526. */
  21527. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21528. /**
  21529. * Creates a new connection point
  21530. * @param name defines the connection point name
  21531. * @param ownerBlock defines the block hosting this connection point
  21532. * @param direction defines the direction of the connection point
  21533. */
  21534. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21535. /**
  21536. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21537. * @returns the class name
  21538. */
  21539. getClassName(): string;
  21540. /**
  21541. * Gets a boolean indicating if the current point can be connected to another point
  21542. * @param connectionPoint defines the other connection point
  21543. * @returns a boolean
  21544. */
  21545. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21546. /**
  21547. * Gets a number indicating if the current point can be connected to another point
  21548. * @param connectionPoint defines the other connection point
  21549. * @returns a number defining the compatibility state
  21550. */
  21551. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21552. /**
  21553. * Connect this point to another connection point
  21554. * @param connectionPoint defines the other connection point
  21555. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21556. * @returns the current connection point
  21557. */
  21558. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21559. /**
  21560. * Disconnect this point from one of his endpoint
  21561. * @param endpoint defines the other connection point
  21562. * @returns the current connection point
  21563. */
  21564. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21565. /**
  21566. * Serializes this point in a JSON representation
  21567. * @param isInput defines if the connection point is an input (default is true)
  21568. * @returns the serialized point object
  21569. */
  21570. serialize(isInput?: boolean): any;
  21571. /**
  21572. * Release resources
  21573. */
  21574. dispose(): void;
  21575. }
  21576. }
  21577. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21578. /**
  21579. * Enum used to define the material modes
  21580. */
  21581. export enum NodeMaterialModes {
  21582. /** Regular material */
  21583. Material = 0,
  21584. /** For post process */
  21585. PostProcess = 1,
  21586. /** For particle system */
  21587. Particle = 2,
  21588. /** For procedural texture */
  21589. ProceduralTexture = 3
  21590. }
  21591. }
  21592. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21593. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21594. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21595. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21596. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21598. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21599. import { Effect } from "babylonjs/Materials/effect";
  21600. import { Mesh } from "babylonjs/Meshes/mesh";
  21601. import { Nullable } from "babylonjs/types";
  21602. import { Texture } from "babylonjs/Materials/Textures/texture";
  21603. import { Scene } from "babylonjs/scene";
  21604. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21605. /**
  21606. * Block used to read a texture from a sampler
  21607. */
  21608. export class TextureBlock extends NodeMaterialBlock {
  21609. private _defineName;
  21610. private _linearDefineName;
  21611. private _gammaDefineName;
  21612. private _tempTextureRead;
  21613. private _samplerName;
  21614. private _transformedUVName;
  21615. private _textureTransformName;
  21616. private _textureInfoName;
  21617. private _mainUVName;
  21618. private _mainUVDefineName;
  21619. private _fragmentOnly;
  21620. /**
  21621. * Gets or sets the texture associated with the node
  21622. */
  21623. texture: Nullable<Texture>;
  21624. /**
  21625. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21626. */
  21627. convertToGammaSpace: boolean;
  21628. /**
  21629. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21630. */
  21631. convertToLinearSpace: boolean;
  21632. /**
  21633. * Create a new TextureBlock
  21634. * @param name defines the block name
  21635. */
  21636. constructor(name: string, fragmentOnly?: boolean);
  21637. /**
  21638. * Gets the current class name
  21639. * @returns the class name
  21640. */
  21641. getClassName(): string;
  21642. /**
  21643. * Gets the uv input component
  21644. */
  21645. get uv(): NodeMaterialConnectionPoint;
  21646. /**
  21647. * Gets the rgba output component
  21648. */
  21649. get rgba(): NodeMaterialConnectionPoint;
  21650. /**
  21651. * Gets the rgb output component
  21652. */
  21653. get rgb(): NodeMaterialConnectionPoint;
  21654. /**
  21655. * Gets the r output component
  21656. */
  21657. get r(): NodeMaterialConnectionPoint;
  21658. /**
  21659. * Gets the g output component
  21660. */
  21661. get g(): NodeMaterialConnectionPoint;
  21662. /**
  21663. * Gets the b output component
  21664. */
  21665. get b(): NodeMaterialConnectionPoint;
  21666. /**
  21667. * Gets the a output component
  21668. */
  21669. get a(): NodeMaterialConnectionPoint;
  21670. get target(): NodeMaterialBlockTargets;
  21671. autoConfigure(material: NodeMaterial): void;
  21672. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21673. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21674. isReady(): boolean;
  21675. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21676. private get _isMixed();
  21677. private _injectVertexCode;
  21678. private _writeTextureRead;
  21679. private _writeOutput;
  21680. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21681. protected _dumpPropertiesCode(): string;
  21682. serialize(): any;
  21683. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21684. }
  21685. }
  21686. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21687. /** @hidden */
  21688. export var reflectionFunction: {
  21689. name: string;
  21690. shader: string;
  21691. };
  21692. }
  21693. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21694. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21695. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21696. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21697. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21699. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21700. import { Effect } from "babylonjs/Materials/effect";
  21701. import { Mesh } from "babylonjs/Meshes/mesh";
  21702. import { Nullable } from "babylonjs/types";
  21703. import { Scene } from "babylonjs/scene";
  21704. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21705. /**
  21706. * Base block used to read a reflection texture from a sampler
  21707. */
  21708. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21709. /** @hidden */
  21710. _define3DName: string;
  21711. /** @hidden */
  21712. _defineCubicName: string;
  21713. /** @hidden */
  21714. _defineExplicitName: string;
  21715. /** @hidden */
  21716. _defineProjectionName: string;
  21717. /** @hidden */
  21718. _defineLocalCubicName: string;
  21719. /** @hidden */
  21720. _defineSphericalName: string;
  21721. /** @hidden */
  21722. _definePlanarName: string;
  21723. /** @hidden */
  21724. _defineEquirectangularName: string;
  21725. /** @hidden */
  21726. _defineMirroredEquirectangularFixedName: string;
  21727. /** @hidden */
  21728. _defineEquirectangularFixedName: string;
  21729. /** @hidden */
  21730. _defineSkyboxName: string;
  21731. /** @hidden */
  21732. _defineOppositeZ: string;
  21733. /** @hidden */
  21734. _cubeSamplerName: string;
  21735. /** @hidden */
  21736. _2DSamplerName: string;
  21737. protected _positionUVWName: string;
  21738. protected _directionWName: string;
  21739. protected _reflectionVectorName: string;
  21740. /** @hidden */
  21741. _reflectionCoordsName: string;
  21742. /** @hidden */
  21743. _reflectionMatrixName: string;
  21744. protected _reflectionColorName: string;
  21745. /**
  21746. * Gets or sets the texture associated with the node
  21747. */
  21748. texture: Nullable<BaseTexture>;
  21749. /**
  21750. * Create a new ReflectionTextureBaseBlock
  21751. * @param name defines the block name
  21752. */
  21753. constructor(name: string);
  21754. /**
  21755. * Gets the current class name
  21756. * @returns the class name
  21757. */
  21758. getClassName(): string;
  21759. /**
  21760. * Gets the world position input component
  21761. */
  21762. abstract get position(): NodeMaterialConnectionPoint;
  21763. /**
  21764. * Gets the world position input component
  21765. */
  21766. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21767. /**
  21768. * Gets the world normal input component
  21769. */
  21770. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21771. /**
  21772. * Gets the world input component
  21773. */
  21774. abstract get world(): NodeMaterialConnectionPoint;
  21775. /**
  21776. * Gets the camera (or eye) position component
  21777. */
  21778. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21779. /**
  21780. * Gets the view input component
  21781. */
  21782. abstract get view(): NodeMaterialConnectionPoint;
  21783. protected _getTexture(): Nullable<BaseTexture>;
  21784. autoConfigure(material: NodeMaterial): void;
  21785. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21786. isReady(): boolean;
  21787. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21788. /**
  21789. * Gets the code to inject in the vertex shader
  21790. * @param state current state of the node material building
  21791. * @returns the shader code
  21792. */
  21793. handleVertexSide(state: NodeMaterialBuildState): string;
  21794. /**
  21795. * Handles the inits for the fragment code path
  21796. * @param state node material build state
  21797. */
  21798. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21799. /**
  21800. * Generates the reflection coords code for the fragment code path
  21801. * @param worldNormalVarName name of the world normal variable
  21802. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21803. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21804. * @returns the shader code
  21805. */
  21806. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21807. /**
  21808. * Generates the reflection color code for the fragment code path
  21809. * @param lodVarName name of the lod variable
  21810. * @param swizzleLookupTexture swizzle to use for the final color variable
  21811. * @returns the shader code
  21812. */
  21813. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21814. /**
  21815. * Generates the code corresponding to the connected output points
  21816. * @param state node material build state
  21817. * @param varName name of the variable to output
  21818. * @returns the shader code
  21819. */
  21820. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21821. protected _buildBlock(state: NodeMaterialBuildState): this;
  21822. protected _dumpPropertiesCode(): string;
  21823. serialize(): any;
  21824. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21825. }
  21826. }
  21827. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21828. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21829. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21830. import { Nullable } from "babylonjs/types";
  21831. /**
  21832. * Defines a connection point to be used for points with a custom object type
  21833. */
  21834. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21835. private _blockType;
  21836. private _blockName;
  21837. private _nameForCheking?;
  21838. /**
  21839. * Creates a new connection point
  21840. * @param name defines the connection point name
  21841. * @param ownerBlock defines the block hosting this connection point
  21842. * @param direction defines the direction of the connection point
  21843. */
  21844. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21845. /**
  21846. * Gets a number indicating if the current point can be connected to another point
  21847. * @param connectionPoint defines the other connection point
  21848. * @returns a number defining the compatibility state
  21849. */
  21850. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21851. /**
  21852. * Creates a block suitable to be used as an input for this input point.
  21853. * If null is returned, a block based on the point type will be created.
  21854. * @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
  21855. */
  21856. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21857. }
  21858. }
  21859. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21860. /**
  21861. * Enum defining the type of properties that can be edited in the property pages in the NME
  21862. */
  21863. export enum PropertyTypeForEdition {
  21864. /** property is a boolean */
  21865. Boolean = 0,
  21866. /** property is a float */
  21867. Float = 1,
  21868. /** property is a Vector2 */
  21869. Vector2 = 2,
  21870. /** property is a list of values */
  21871. List = 3
  21872. }
  21873. /**
  21874. * Interface that defines an option in a variable of type list
  21875. */
  21876. export interface IEditablePropertyListOption {
  21877. /** label of the option */
  21878. "label": string;
  21879. /** value of the option */
  21880. "value": number;
  21881. }
  21882. /**
  21883. * Interface that defines the options available for an editable property
  21884. */
  21885. export interface IEditablePropertyOption {
  21886. /** min value */
  21887. "min"?: number;
  21888. /** max value */
  21889. "max"?: number;
  21890. /** notifiers: indicates which actions to take when the property is changed */
  21891. "notifiers"?: {
  21892. /** the material should be rebuilt */
  21893. "rebuild"?: boolean;
  21894. /** the preview should be updated */
  21895. "update"?: boolean;
  21896. };
  21897. /** list of the options for a variable of type list */
  21898. "options"?: IEditablePropertyListOption[];
  21899. }
  21900. /**
  21901. * Interface that describes an editable property
  21902. */
  21903. export interface IPropertyDescriptionForEdition {
  21904. /** name of the property */
  21905. "propertyName": string;
  21906. /** display name of the property */
  21907. "displayName": string;
  21908. /** type of the property */
  21909. "type": PropertyTypeForEdition;
  21910. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21911. "groupName": string;
  21912. /** options for the property */
  21913. "options": IEditablePropertyOption;
  21914. }
  21915. /**
  21916. * Decorator that flags a property in a node material block as being editable
  21917. */
  21918. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21919. }
  21920. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21921. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21922. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21923. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21925. import { Nullable } from "babylonjs/types";
  21926. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21927. import { Mesh } from "babylonjs/Meshes/mesh";
  21928. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21929. import { Effect } from "babylonjs/Materials/effect";
  21930. import { Scene } from "babylonjs/scene";
  21931. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21932. /**
  21933. * Block used to implement the refraction part of the sub surface module of the PBR material
  21934. */
  21935. export class RefractionBlock extends NodeMaterialBlock {
  21936. /** @hidden */
  21937. _define3DName: string;
  21938. /** @hidden */
  21939. _refractionMatrixName: string;
  21940. /** @hidden */
  21941. _defineLODRefractionAlpha: string;
  21942. /** @hidden */
  21943. _defineLinearSpecularRefraction: string;
  21944. /** @hidden */
  21945. _defineOppositeZ: string;
  21946. /** @hidden */
  21947. _cubeSamplerName: string;
  21948. /** @hidden */
  21949. _2DSamplerName: string;
  21950. /** @hidden */
  21951. _vRefractionMicrosurfaceInfosName: string;
  21952. /** @hidden */
  21953. _vRefractionInfosName: string;
  21954. private _scene;
  21955. /**
  21956. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21957. * Materials half opaque for instance using refraction could benefit from this control.
  21958. */
  21959. linkRefractionWithTransparency: boolean;
  21960. /**
  21961. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21962. */
  21963. invertRefractionY: boolean;
  21964. /**
  21965. * Gets or sets the texture associated with the node
  21966. */
  21967. texture: Nullable<BaseTexture>;
  21968. /**
  21969. * Create a new RefractionBlock
  21970. * @param name defines the block name
  21971. */
  21972. constructor(name: string);
  21973. /**
  21974. * Gets the current class name
  21975. * @returns the class name
  21976. */
  21977. getClassName(): string;
  21978. /**
  21979. * Gets the intensity input component
  21980. */
  21981. get intensity(): NodeMaterialConnectionPoint;
  21982. /**
  21983. * Gets the index of refraction input component
  21984. */
  21985. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21986. /**
  21987. * Gets the tint at distance input component
  21988. */
  21989. get tintAtDistance(): NodeMaterialConnectionPoint;
  21990. /**
  21991. * Gets the view input component
  21992. */
  21993. get view(): NodeMaterialConnectionPoint;
  21994. /**
  21995. * Gets the refraction object output component
  21996. */
  21997. get refraction(): NodeMaterialConnectionPoint;
  21998. /**
  21999. * Returns true if the block has a texture
  22000. */
  22001. get hasTexture(): boolean;
  22002. protected _getTexture(): Nullable<BaseTexture>;
  22003. autoConfigure(material: NodeMaterial): void;
  22004. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22005. isReady(): boolean;
  22006. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22007. /**
  22008. * Gets the main code of the block (fragment side)
  22009. * @param state current state of the node material building
  22010. * @returns the shader code
  22011. */
  22012. getCode(state: NodeMaterialBuildState): string;
  22013. protected _buildBlock(state: NodeMaterialBuildState): this;
  22014. protected _dumpPropertiesCode(): string;
  22015. serialize(): any;
  22016. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22017. }
  22018. }
  22019. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  22020. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22021. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22022. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22023. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22025. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22026. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22027. import { Nullable } from "babylonjs/types";
  22028. import { Scene } from "babylonjs/scene";
  22029. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22030. /**
  22031. * Base block used as input for post process
  22032. */
  22033. export class CurrentScreenBlock extends NodeMaterialBlock {
  22034. private _samplerName;
  22035. private _linearDefineName;
  22036. private _gammaDefineName;
  22037. private _mainUVName;
  22038. private _tempTextureRead;
  22039. /**
  22040. * Gets or sets the texture associated with the node
  22041. */
  22042. texture: Nullable<BaseTexture>;
  22043. /**
  22044. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22045. */
  22046. convertToGammaSpace: boolean;
  22047. /**
  22048. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22049. */
  22050. convertToLinearSpace: boolean;
  22051. /**
  22052. * Create a new CurrentScreenBlock
  22053. * @param name defines the block name
  22054. */
  22055. constructor(name: string);
  22056. /**
  22057. * Gets the current class name
  22058. * @returns the class name
  22059. */
  22060. getClassName(): string;
  22061. /**
  22062. * Gets the uv input component
  22063. */
  22064. get uv(): NodeMaterialConnectionPoint;
  22065. /**
  22066. * Gets the rgba output component
  22067. */
  22068. get rgba(): NodeMaterialConnectionPoint;
  22069. /**
  22070. * Gets the rgb output component
  22071. */
  22072. get rgb(): NodeMaterialConnectionPoint;
  22073. /**
  22074. * Gets the r output component
  22075. */
  22076. get r(): NodeMaterialConnectionPoint;
  22077. /**
  22078. * Gets the g output component
  22079. */
  22080. get g(): NodeMaterialConnectionPoint;
  22081. /**
  22082. * Gets the b output component
  22083. */
  22084. get b(): NodeMaterialConnectionPoint;
  22085. /**
  22086. * Gets the a output component
  22087. */
  22088. get a(): NodeMaterialConnectionPoint;
  22089. /**
  22090. * Initialize the block and prepare the context for build
  22091. * @param state defines the state that will be used for the build
  22092. */
  22093. initialize(state: NodeMaterialBuildState): void;
  22094. get target(): NodeMaterialBlockTargets;
  22095. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22096. isReady(): boolean;
  22097. private _injectVertexCode;
  22098. private _writeTextureRead;
  22099. private _writeOutput;
  22100. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22101. serialize(): any;
  22102. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22103. }
  22104. }
  22105. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  22106. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22107. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22108. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22110. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22111. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22112. import { Nullable } from "babylonjs/types";
  22113. import { Scene } from "babylonjs/scene";
  22114. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22115. /**
  22116. * Base block used for the particle texture
  22117. */
  22118. export class ParticleTextureBlock extends NodeMaterialBlock {
  22119. private _samplerName;
  22120. private _linearDefineName;
  22121. private _gammaDefineName;
  22122. private _tempTextureRead;
  22123. /**
  22124. * Gets or sets the texture associated with the node
  22125. */
  22126. texture: Nullable<BaseTexture>;
  22127. /**
  22128. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22129. */
  22130. convertToGammaSpace: boolean;
  22131. /**
  22132. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22133. */
  22134. convertToLinearSpace: boolean;
  22135. /**
  22136. * Create a new ParticleTextureBlock
  22137. * @param name defines the block name
  22138. */
  22139. constructor(name: string);
  22140. /**
  22141. * Gets the current class name
  22142. * @returns the class name
  22143. */
  22144. getClassName(): string;
  22145. /**
  22146. * Gets the uv input component
  22147. */
  22148. get uv(): NodeMaterialConnectionPoint;
  22149. /**
  22150. * Gets the rgba output component
  22151. */
  22152. get rgba(): NodeMaterialConnectionPoint;
  22153. /**
  22154. * Gets the rgb output component
  22155. */
  22156. get rgb(): NodeMaterialConnectionPoint;
  22157. /**
  22158. * Gets the r output component
  22159. */
  22160. get r(): NodeMaterialConnectionPoint;
  22161. /**
  22162. * Gets the g output component
  22163. */
  22164. get g(): NodeMaterialConnectionPoint;
  22165. /**
  22166. * Gets the b output component
  22167. */
  22168. get b(): NodeMaterialConnectionPoint;
  22169. /**
  22170. * Gets the a output component
  22171. */
  22172. get a(): NodeMaterialConnectionPoint;
  22173. /**
  22174. * Initialize the block and prepare the context for build
  22175. * @param state defines the state that will be used for the build
  22176. */
  22177. initialize(state: NodeMaterialBuildState): void;
  22178. autoConfigure(material: NodeMaterial): void;
  22179. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22180. isReady(): boolean;
  22181. private _writeOutput;
  22182. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22183. serialize(): any;
  22184. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22185. }
  22186. }
  22187. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22188. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22189. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22190. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22191. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22192. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22193. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22194. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22195. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22196. import { Scene } from "babylonjs/scene";
  22197. /**
  22198. * Class used to store shared data between 2 NodeMaterialBuildState
  22199. */
  22200. export class NodeMaterialBuildStateSharedData {
  22201. /**
  22202. * Gets the list of emitted varyings
  22203. */
  22204. temps: string[];
  22205. /**
  22206. * Gets the list of emitted varyings
  22207. */
  22208. varyings: string[];
  22209. /**
  22210. * Gets the varying declaration string
  22211. */
  22212. varyingDeclaration: string;
  22213. /**
  22214. * Input blocks
  22215. */
  22216. inputBlocks: InputBlock[];
  22217. /**
  22218. * Input blocks
  22219. */
  22220. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22221. /**
  22222. * Bindable blocks (Blocks that need to set data to the effect)
  22223. */
  22224. bindableBlocks: NodeMaterialBlock[];
  22225. /**
  22226. * List of blocks that can provide a compilation fallback
  22227. */
  22228. blocksWithFallbacks: NodeMaterialBlock[];
  22229. /**
  22230. * List of blocks that can provide a define update
  22231. */
  22232. blocksWithDefines: NodeMaterialBlock[];
  22233. /**
  22234. * List of blocks that can provide a repeatable content
  22235. */
  22236. repeatableContentBlocks: NodeMaterialBlock[];
  22237. /**
  22238. * List of blocks that can provide a dynamic list of uniforms
  22239. */
  22240. dynamicUniformBlocks: NodeMaterialBlock[];
  22241. /**
  22242. * List of blocks that can block the isReady function for the material
  22243. */
  22244. blockingBlocks: NodeMaterialBlock[];
  22245. /**
  22246. * Gets the list of animated inputs
  22247. */
  22248. animatedInputs: InputBlock[];
  22249. /**
  22250. * Build Id used to avoid multiple recompilations
  22251. */
  22252. buildId: number;
  22253. /** List of emitted variables */
  22254. variableNames: {
  22255. [key: string]: number;
  22256. };
  22257. /** List of emitted defines */
  22258. defineNames: {
  22259. [key: string]: number;
  22260. };
  22261. /** Should emit comments? */
  22262. emitComments: boolean;
  22263. /** Emit build activity */
  22264. verbose: boolean;
  22265. /** Gets or sets the hosting scene */
  22266. scene: Scene;
  22267. /**
  22268. * Gets the compilation hints emitted at compilation time
  22269. */
  22270. hints: {
  22271. needWorldViewMatrix: boolean;
  22272. needWorldViewProjectionMatrix: boolean;
  22273. needAlphaBlending: boolean;
  22274. needAlphaTesting: boolean;
  22275. };
  22276. /**
  22277. * List of compilation checks
  22278. */
  22279. checks: {
  22280. emitVertex: boolean;
  22281. emitFragment: boolean;
  22282. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22283. };
  22284. /**
  22285. * Is vertex program allowed to be empty?
  22286. */
  22287. allowEmptyVertexProgram: boolean;
  22288. /** Creates a new shared data */
  22289. constructor();
  22290. /**
  22291. * Emits console errors and exceptions if there is a failing check
  22292. */
  22293. emitErrors(): void;
  22294. }
  22295. }
  22296. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22297. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22298. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22299. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22300. /**
  22301. * Class used to store node based material build state
  22302. */
  22303. export class NodeMaterialBuildState {
  22304. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22305. supportUniformBuffers: boolean;
  22306. /**
  22307. * Gets the list of emitted attributes
  22308. */
  22309. attributes: string[];
  22310. /**
  22311. * Gets the list of emitted uniforms
  22312. */
  22313. uniforms: string[];
  22314. /**
  22315. * Gets the list of emitted constants
  22316. */
  22317. constants: string[];
  22318. /**
  22319. * Gets the list of emitted samplers
  22320. */
  22321. samplers: string[];
  22322. /**
  22323. * Gets the list of emitted functions
  22324. */
  22325. functions: {
  22326. [key: string]: string;
  22327. };
  22328. /**
  22329. * Gets the list of emitted extensions
  22330. */
  22331. extensions: {
  22332. [key: string]: string;
  22333. };
  22334. /**
  22335. * Gets the target of the compilation state
  22336. */
  22337. target: NodeMaterialBlockTargets;
  22338. /**
  22339. * Gets the list of emitted counters
  22340. */
  22341. counters: {
  22342. [key: string]: number;
  22343. };
  22344. /**
  22345. * Shared data between multiple NodeMaterialBuildState instances
  22346. */
  22347. sharedData: NodeMaterialBuildStateSharedData;
  22348. /** @hidden */
  22349. _vertexState: NodeMaterialBuildState;
  22350. /** @hidden */
  22351. _attributeDeclaration: string;
  22352. /** @hidden */
  22353. _uniformDeclaration: string;
  22354. /** @hidden */
  22355. _constantDeclaration: string;
  22356. /** @hidden */
  22357. _samplerDeclaration: string;
  22358. /** @hidden */
  22359. _varyingTransfer: string;
  22360. /** @hidden */
  22361. _injectAtEnd: string;
  22362. private _repeatableContentAnchorIndex;
  22363. /** @hidden */
  22364. _builtCompilationString: string;
  22365. /**
  22366. * Gets the emitted compilation strings
  22367. */
  22368. compilationString: string;
  22369. /**
  22370. * Finalize the compilation strings
  22371. * @param state defines the current compilation state
  22372. */
  22373. finalize(state: NodeMaterialBuildState): void;
  22374. /** @hidden */
  22375. get _repeatableContentAnchor(): string;
  22376. /** @hidden */
  22377. _getFreeVariableName(prefix: string): string;
  22378. /** @hidden */
  22379. _getFreeDefineName(prefix: string): string;
  22380. /** @hidden */
  22381. _excludeVariableName(name: string): void;
  22382. /** @hidden */
  22383. _emit2DSampler(name: string): void;
  22384. /** @hidden */
  22385. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22386. /** @hidden */
  22387. _emitExtension(name: string, extension: string, define?: string): void;
  22388. /** @hidden */
  22389. _emitFunction(name: string, code: string, comments: string): void;
  22390. /** @hidden */
  22391. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22392. replaceStrings?: {
  22393. search: RegExp;
  22394. replace: string;
  22395. }[];
  22396. repeatKey?: string;
  22397. }): string;
  22398. /** @hidden */
  22399. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22400. repeatKey?: string;
  22401. removeAttributes?: boolean;
  22402. removeUniforms?: boolean;
  22403. removeVaryings?: boolean;
  22404. removeIfDef?: boolean;
  22405. replaceStrings?: {
  22406. search: RegExp;
  22407. replace: string;
  22408. }[];
  22409. }, storeKey?: string): void;
  22410. /** @hidden */
  22411. _registerTempVariable(name: string): boolean;
  22412. /** @hidden */
  22413. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22414. /** @hidden */
  22415. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22416. /** @hidden */
  22417. _emitFloat(value: number): string;
  22418. }
  22419. }
  22420. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22421. /**
  22422. * Helper class used to generate session unique ID
  22423. */
  22424. export class UniqueIdGenerator {
  22425. private static _UniqueIdCounter;
  22426. /**
  22427. * Gets an unique (relatively to the current scene) Id
  22428. */
  22429. static get UniqueId(): number;
  22430. }
  22431. }
  22432. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22433. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22434. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22435. import { Nullable } from "babylonjs/types";
  22436. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22437. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22438. import { Effect } from "babylonjs/Materials/effect";
  22439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22440. import { Mesh } from "babylonjs/Meshes/mesh";
  22441. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22442. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22443. import { Scene } from "babylonjs/scene";
  22444. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22445. /**
  22446. * Defines a block that can be used inside a node based material
  22447. */
  22448. export class NodeMaterialBlock {
  22449. private _buildId;
  22450. private _buildTarget;
  22451. private _target;
  22452. private _isFinalMerger;
  22453. private _isInput;
  22454. private _name;
  22455. protected _isUnique: boolean;
  22456. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22457. inputsAreExclusive: boolean;
  22458. /** @hidden */
  22459. _codeVariableName: string;
  22460. /** @hidden */
  22461. _inputs: NodeMaterialConnectionPoint[];
  22462. /** @hidden */
  22463. _outputs: NodeMaterialConnectionPoint[];
  22464. /** @hidden */
  22465. _preparationId: number;
  22466. /**
  22467. * Gets the name of the block
  22468. */
  22469. get name(): string;
  22470. /**
  22471. * Sets the name of the block. Will check if the name is valid.
  22472. */
  22473. set name(newName: string);
  22474. /**
  22475. * Gets or sets the unique id of the node
  22476. */
  22477. uniqueId: number;
  22478. /**
  22479. * Gets or sets the comments associated with this block
  22480. */
  22481. comments: string;
  22482. /**
  22483. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22484. */
  22485. get isUnique(): boolean;
  22486. /**
  22487. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22488. */
  22489. get isFinalMerger(): boolean;
  22490. /**
  22491. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22492. */
  22493. get isInput(): boolean;
  22494. /**
  22495. * Gets or sets the build Id
  22496. */
  22497. get buildId(): number;
  22498. set buildId(value: number);
  22499. /**
  22500. * Gets or sets the target of the block
  22501. */
  22502. get target(): NodeMaterialBlockTargets;
  22503. set target(value: NodeMaterialBlockTargets);
  22504. /**
  22505. * Gets the list of input points
  22506. */
  22507. get inputs(): NodeMaterialConnectionPoint[];
  22508. /** Gets the list of output points */
  22509. get outputs(): NodeMaterialConnectionPoint[];
  22510. /**
  22511. * Find an input by its name
  22512. * @param name defines the name of the input to look for
  22513. * @returns the input or null if not found
  22514. */
  22515. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22516. /**
  22517. * Find an output by its name
  22518. * @param name defines the name of the outputto look for
  22519. * @returns the output or null if not found
  22520. */
  22521. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22522. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22523. visibleInInspector: boolean;
  22524. /**
  22525. * Creates a new NodeMaterialBlock
  22526. * @param name defines the block name
  22527. * @param target defines the target of that block (Vertex by default)
  22528. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22529. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22530. */
  22531. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22532. /**
  22533. * Initialize the block and prepare the context for build
  22534. * @param state defines the state that will be used for the build
  22535. */
  22536. initialize(state: NodeMaterialBuildState): void;
  22537. /**
  22538. * Bind data to effect. Will only be called for blocks with isBindable === true
  22539. * @param effect defines the effect to bind data to
  22540. * @param nodeMaterial defines the hosting NodeMaterial
  22541. * @param mesh defines the mesh that will be rendered
  22542. * @param subMesh defines the submesh that will be rendered
  22543. */
  22544. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22545. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22546. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22547. protected _writeFloat(value: number): string;
  22548. /**
  22549. * Gets the current class name e.g. "NodeMaterialBlock"
  22550. * @returns the class name
  22551. */
  22552. getClassName(): string;
  22553. /**
  22554. * Register a new input. Must be called inside a block constructor
  22555. * @param name defines the connection point name
  22556. * @param type defines the connection point type
  22557. * @param isOptional defines a boolean indicating that this input can be omitted
  22558. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22559. * @param point an already created connection point. If not provided, create a new one
  22560. * @returns the current block
  22561. */
  22562. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22563. /**
  22564. * Register a new output. Must be called inside a block constructor
  22565. * @param name defines the connection point name
  22566. * @param type defines the connection point type
  22567. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22568. * @param point an already created connection point. If not provided, create a new one
  22569. * @returns the current block
  22570. */
  22571. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22572. /**
  22573. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22574. * @param forOutput defines an optional connection point to check compatibility with
  22575. * @returns the first available input or null
  22576. */
  22577. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22578. /**
  22579. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22580. * @param forBlock defines an optional block to check compatibility with
  22581. * @returns the first available input or null
  22582. */
  22583. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22584. /**
  22585. * Gets the sibling of the given output
  22586. * @param current defines the current output
  22587. * @returns the next output in the list or null
  22588. */
  22589. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22590. /**
  22591. * Connect current block with another block
  22592. * @param other defines the block to connect with
  22593. * @param options define the various options to help pick the right connections
  22594. * @returns the current block
  22595. */
  22596. connectTo(other: NodeMaterialBlock, options?: {
  22597. input?: string;
  22598. output?: string;
  22599. outputSwizzle?: string;
  22600. }): this | undefined;
  22601. protected _buildBlock(state: NodeMaterialBuildState): void;
  22602. /**
  22603. * Add uniforms, samplers and uniform buffers at compilation time
  22604. * @param state defines the state to update
  22605. * @param nodeMaterial defines the node material requesting the update
  22606. * @param defines defines the material defines to update
  22607. * @param uniformBuffers defines the list of uniform buffer names
  22608. */
  22609. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22610. /**
  22611. * Add potential fallbacks if shader compilation fails
  22612. * @param mesh defines the mesh to be rendered
  22613. * @param fallbacks defines the current prioritized list of fallbacks
  22614. */
  22615. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22616. /**
  22617. * Initialize defines for shader compilation
  22618. * @param mesh defines the mesh to be rendered
  22619. * @param nodeMaterial defines the node material requesting the update
  22620. * @param defines defines the material defines to update
  22621. * @param useInstances specifies that instances should be used
  22622. */
  22623. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22624. /**
  22625. * Update defines for shader compilation
  22626. * @param mesh defines the mesh to be rendered
  22627. * @param nodeMaterial defines the node material requesting the update
  22628. * @param defines defines the material defines to update
  22629. * @param useInstances specifies that instances should be used
  22630. * @param subMesh defines which submesh to render
  22631. */
  22632. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22633. /**
  22634. * Lets the block try to connect some inputs automatically
  22635. * @param material defines the hosting NodeMaterial
  22636. */
  22637. autoConfigure(material: NodeMaterial): void;
  22638. /**
  22639. * Function called when a block is declared as repeatable content generator
  22640. * @param vertexShaderState defines the current compilation state for the vertex shader
  22641. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22642. * @param mesh defines the mesh to be rendered
  22643. * @param defines defines the material defines to update
  22644. */
  22645. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22646. /**
  22647. * Checks if the block is ready
  22648. * @param mesh defines the mesh to be rendered
  22649. * @param nodeMaterial defines the node material requesting the update
  22650. * @param defines defines the material defines to update
  22651. * @param useInstances specifies that instances should be used
  22652. * @returns true if the block is ready
  22653. */
  22654. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22655. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22656. private _processBuild;
  22657. /**
  22658. * Validates the new name for the block node.
  22659. * @param newName the new name to be given to the node.
  22660. * @returns false if the name is a reserve word, else true.
  22661. */
  22662. validateBlockName(newName: string): boolean;
  22663. /**
  22664. * Compile the current node and generate the shader code
  22665. * @param state defines the current compilation state (uniforms, samplers, current string)
  22666. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22667. * @returns true if already built
  22668. */
  22669. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22670. protected _inputRename(name: string): string;
  22671. protected _outputRename(name: string): string;
  22672. protected _dumpPropertiesCode(): string;
  22673. /** @hidden */
  22674. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22675. /** @hidden */
  22676. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22677. /**
  22678. * Clone the current block to a new identical block
  22679. * @param scene defines the hosting scene
  22680. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22681. * @returns a copy of the current block
  22682. */
  22683. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22684. /**
  22685. * Serializes this block in a JSON representation
  22686. * @returns the serialized block object
  22687. */
  22688. serialize(): any;
  22689. /** @hidden */
  22690. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22691. private _deserializePortDisplayNamesAndExposedOnFrame;
  22692. /**
  22693. * Release resources
  22694. */
  22695. dispose(): void;
  22696. }
  22697. }
  22698. declare module "babylonjs/Materials/pushMaterial" {
  22699. import { Nullable } from "babylonjs/types";
  22700. import { Scene } from "babylonjs/scene";
  22701. import { Matrix } from "babylonjs/Maths/math.vector";
  22702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22703. import { Mesh } from "babylonjs/Meshes/mesh";
  22704. import { Material } from "babylonjs/Materials/material";
  22705. import { Effect } from "babylonjs/Materials/effect";
  22706. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22707. /**
  22708. * Base class of materials working in push mode in babylon JS
  22709. * @hidden
  22710. */
  22711. export class PushMaterial extends Material {
  22712. protected _activeEffect: Effect;
  22713. protected _normalMatrix: Matrix;
  22714. constructor(name: string, scene: Scene);
  22715. getEffect(): Effect;
  22716. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22717. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22718. /**
  22719. * Binds the given world matrix to the active effect
  22720. *
  22721. * @param world the matrix to bind
  22722. */
  22723. bindOnlyWorldMatrix(world: Matrix): void;
  22724. /**
  22725. * Binds the given normal matrix to the active effect
  22726. *
  22727. * @param normalMatrix the matrix to bind
  22728. */
  22729. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22730. bind(world: Matrix, mesh?: Mesh): void;
  22731. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22732. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22733. }
  22734. }
  22735. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22736. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22737. /**
  22738. * Root class for all node material optimizers
  22739. */
  22740. export class NodeMaterialOptimizer {
  22741. /**
  22742. * Function used to optimize a NodeMaterial graph
  22743. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22744. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22745. */
  22746. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22747. }
  22748. }
  22749. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22750. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22751. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22752. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22753. import { Scene } from "babylonjs/scene";
  22754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22755. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22756. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22757. /**
  22758. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22759. */
  22760. export class TransformBlock extends NodeMaterialBlock {
  22761. /**
  22762. * Defines the value to use to complement W value to transform it to a Vector4
  22763. */
  22764. complementW: number;
  22765. /**
  22766. * Defines the value to use to complement z value to transform it to a Vector4
  22767. */
  22768. complementZ: number;
  22769. /**
  22770. * Creates a new TransformBlock
  22771. * @param name defines the block name
  22772. */
  22773. constructor(name: string);
  22774. /**
  22775. * Gets the current class name
  22776. * @returns the class name
  22777. */
  22778. getClassName(): string;
  22779. /**
  22780. * Gets the vector input
  22781. */
  22782. get vector(): NodeMaterialConnectionPoint;
  22783. /**
  22784. * Gets the output component
  22785. */
  22786. get output(): NodeMaterialConnectionPoint;
  22787. /**
  22788. * Gets the xyz output component
  22789. */
  22790. get xyz(): NodeMaterialConnectionPoint;
  22791. /**
  22792. * Gets the matrix transform input
  22793. */
  22794. get transform(): NodeMaterialConnectionPoint;
  22795. protected _buildBlock(state: NodeMaterialBuildState): this;
  22796. /**
  22797. * Update defines for shader compilation
  22798. * @param mesh defines the mesh to be rendered
  22799. * @param nodeMaterial defines the node material requesting the update
  22800. * @param defines defines the material defines to update
  22801. * @param useInstances specifies that instances should be used
  22802. * @param subMesh defines which submesh to render
  22803. */
  22804. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22805. serialize(): any;
  22806. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22807. protected _dumpPropertiesCode(): string;
  22808. }
  22809. }
  22810. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22811. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22812. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22813. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22814. /**
  22815. * Block used to output the vertex position
  22816. */
  22817. export class VertexOutputBlock extends NodeMaterialBlock {
  22818. /**
  22819. * Creates a new VertexOutputBlock
  22820. * @param name defines the block name
  22821. */
  22822. constructor(name: string);
  22823. /**
  22824. * Gets the current class name
  22825. * @returns the class name
  22826. */
  22827. getClassName(): string;
  22828. /**
  22829. * Gets the vector input component
  22830. */
  22831. get vector(): NodeMaterialConnectionPoint;
  22832. protected _buildBlock(state: NodeMaterialBuildState): this;
  22833. }
  22834. }
  22835. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22836. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22837. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22838. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22839. /**
  22840. * Block used to output the final color
  22841. */
  22842. export class FragmentOutputBlock extends NodeMaterialBlock {
  22843. /**
  22844. * Create a new FragmentOutputBlock
  22845. * @param name defines the block name
  22846. */
  22847. constructor(name: string);
  22848. /**
  22849. * Gets the current class name
  22850. * @returns the class name
  22851. */
  22852. getClassName(): string;
  22853. /**
  22854. * Gets the rgba input component
  22855. */
  22856. get rgba(): NodeMaterialConnectionPoint;
  22857. /**
  22858. * Gets the rgb input component
  22859. */
  22860. get rgb(): NodeMaterialConnectionPoint;
  22861. /**
  22862. * Gets the a input component
  22863. */
  22864. get a(): NodeMaterialConnectionPoint;
  22865. protected _buildBlock(state: NodeMaterialBuildState): this;
  22866. }
  22867. }
  22868. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22869. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22870. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22871. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22872. /**
  22873. * Block used for the particle ramp gradient section
  22874. */
  22875. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22876. /**
  22877. * Create a new ParticleRampGradientBlock
  22878. * @param name defines the block name
  22879. */
  22880. constructor(name: string);
  22881. /**
  22882. * Gets the current class name
  22883. * @returns the class name
  22884. */
  22885. getClassName(): string;
  22886. /**
  22887. * Gets the color input component
  22888. */
  22889. get color(): NodeMaterialConnectionPoint;
  22890. /**
  22891. * Gets the rampColor output component
  22892. */
  22893. get rampColor(): NodeMaterialConnectionPoint;
  22894. /**
  22895. * Initialize the block and prepare the context for build
  22896. * @param state defines the state that will be used for the build
  22897. */
  22898. initialize(state: NodeMaterialBuildState): void;
  22899. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22900. }
  22901. }
  22902. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22903. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22904. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22905. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22906. /**
  22907. * Block used for the particle blend multiply section
  22908. */
  22909. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22910. /**
  22911. * Create a new ParticleBlendMultiplyBlock
  22912. * @param name defines the block name
  22913. */
  22914. constructor(name: string);
  22915. /**
  22916. * Gets the current class name
  22917. * @returns the class name
  22918. */
  22919. getClassName(): string;
  22920. /**
  22921. * Gets the color input component
  22922. */
  22923. get color(): NodeMaterialConnectionPoint;
  22924. /**
  22925. * Gets the alphaTexture input component
  22926. */
  22927. get alphaTexture(): NodeMaterialConnectionPoint;
  22928. /**
  22929. * Gets the alphaColor input component
  22930. */
  22931. get alphaColor(): NodeMaterialConnectionPoint;
  22932. /**
  22933. * Gets the blendColor output component
  22934. */
  22935. get blendColor(): NodeMaterialConnectionPoint;
  22936. /**
  22937. * Initialize the block and prepare the context for build
  22938. * @param state defines the state that will be used for the build
  22939. */
  22940. initialize(state: NodeMaterialBuildState): void;
  22941. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22942. }
  22943. }
  22944. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22945. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22946. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22947. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22948. /**
  22949. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22950. */
  22951. export class VectorMergerBlock extends NodeMaterialBlock {
  22952. /**
  22953. * Create a new VectorMergerBlock
  22954. * @param name defines the block name
  22955. */
  22956. constructor(name: string);
  22957. /**
  22958. * Gets the current class name
  22959. * @returns the class name
  22960. */
  22961. getClassName(): string;
  22962. /**
  22963. * Gets the xyz component (input)
  22964. */
  22965. get xyzIn(): NodeMaterialConnectionPoint;
  22966. /**
  22967. * Gets the xy component (input)
  22968. */
  22969. get xyIn(): NodeMaterialConnectionPoint;
  22970. /**
  22971. * Gets the x component (input)
  22972. */
  22973. get x(): NodeMaterialConnectionPoint;
  22974. /**
  22975. * Gets the y component (input)
  22976. */
  22977. get y(): NodeMaterialConnectionPoint;
  22978. /**
  22979. * Gets the z component (input)
  22980. */
  22981. get z(): NodeMaterialConnectionPoint;
  22982. /**
  22983. * Gets the w component (input)
  22984. */
  22985. get w(): NodeMaterialConnectionPoint;
  22986. /**
  22987. * Gets the xyzw component (output)
  22988. */
  22989. get xyzw(): NodeMaterialConnectionPoint;
  22990. /**
  22991. * Gets the xyz component (output)
  22992. */
  22993. get xyzOut(): NodeMaterialConnectionPoint;
  22994. /**
  22995. * Gets the xy component (output)
  22996. */
  22997. get xyOut(): NodeMaterialConnectionPoint;
  22998. /**
  22999. * Gets the xy component (output)
  23000. * @deprecated Please use xyOut instead.
  23001. */
  23002. get xy(): NodeMaterialConnectionPoint;
  23003. /**
  23004. * Gets the xyz component (output)
  23005. * @deprecated Please use xyzOut instead.
  23006. */
  23007. get xyz(): NodeMaterialConnectionPoint;
  23008. protected _buildBlock(state: NodeMaterialBuildState): this;
  23009. }
  23010. }
  23011. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  23012. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23013. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23014. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23015. import { Vector2 } from "babylonjs/Maths/math.vector";
  23016. import { Scene } from "babylonjs/scene";
  23017. /**
  23018. * Block used to remap a float from a range to a new one
  23019. */
  23020. export class RemapBlock extends NodeMaterialBlock {
  23021. /**
  23022. * Gets or sets the source range
  23023. */
  23024. sourceRange: Vector2;
  23025. /**
  23026. * Gets or sets the target range
  23027. */
  23028. targetRange: Vector2;
  23029. /**
  23030. * Creates a new RemapBlock
  23031. * @param name defines the block name
  23032. */
  23033. constructor(name: string);
  23034. /**
  23035. * Gets the current class name
  23036. * @returns the class name
  23037. */
  23038. getClassName(): string;
  23039. /**
  23040. * Gets the input component
  23041. */
  23042. get input(): NodeMaterialConnectionPoint;
  23043. /**
  23044. * Gets the source min input component
  23045. */
  23046. get sourceMin(): NodeMaterialConnectionPoint;
  23047. /**
  23048. * Gets the source max input component
  23049. */
  23050. get sourceMax(): NodeMaterialConnectionPoint;
  23051. /**
  23052. * Gets the target min input component
  23053. */
  23054. get targetMin(): NodeMaterialConnectionPoint;
  23055. /**
  23056. * Gets the target max input component
  23057. */
  23058. get targetMax(): NodeMaterialConnectionPoint;
  23059. /**
  23060. * Gets the output component
  23061. */
  23062. get output(): NodeMaterialConnectionPoint;
  23063. protected _buildBlock(state: NodeMaterialBuildState): this;
  23064. protected _dumpPropertiesCode(): string;
  23065. serialize(): any;
  23066. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23067. }
  23068. }
  23069. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  23070. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23071. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23072. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23073. /**
  23074. * Block used to multiply 2 values
  23075. */
  23076. export class MultiplyBlock extends NodeMaterialBlock {
  23077. /**
  23078. * Creates a new MultiplyBlock
  23079. * @param name defines the block name
  23080. */
  23081. constructor(name: string);
  23082. /**
  23083. * Gets the current class name
  23084. * @returns the class name
  23085. */
  23086. getClassName(): string;
  23087. /**
  23088. * Gets the left operand input component
  23089. */
  23090. get left(): NodeMaterialConnectionPoint;
  23091. /**
  23092. * Gets the right operand input component
  23093. */
  23094. get right(): NodeMaterialConnectionPoint;
  23095. /**
  23096. * Gets the output component
  23097. */
  23098. get output(): NodeMaterialConnectionPoint;
  23099. protected _buildBlock(state: NodeMaterialBuildState): this;
  23100. }
  23101. }
  23102. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  23103. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23104. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23105. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23106. /**
  23107. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  23108. */
  23109. export class ColorSplitterBlock extends NodeMaterialBlock {
  23110. /**
  23111. * Create a new ColorSplitterBlock
  23112. * @param name defines the block name
  23113. */
  23114. constructor(name: string);
  23115. /**
  23116. * Gets the current class name
  23117. * @returns the class name
  23118. */
  23119. getClassName(): string;
  23120. /**
  23121. * Gets the rgba component (input)
  23122. */
  23123. get rgba(): NodeMaterialConnectionPoint;
  23124. /**
  23125. * Gets the rgb component (input)
  23126. */
  23127. get rgbIn(): NodeMaterialConnectionPoint;
  23128. /**
  23129. * Gets the rgb component (output)
  23130. */
  23131. get rgbOut(): NodeMaterialConnectionPoint;
  23132. /**
  23133. * Gets the r component (output)
  23134. */
  23135. get r(): NodeMaterialConnectionPoint;
  23136. /**
  23137. * Gets the g component (output)
  23138. */
  23139. get g(): NodeMaterialConnectionPoint;
  23140. /**
  23141. * Gets the b component (output)
  23142. */
  23143. get b(): NodeMaterialConnectionPoint;
  23144. /**
  23145. * Gets the a component (output)
  23146. */
  23147. get a(): NodeMaterialConnectionPoint;
  23148. protected _inputRename(name: string): string;
  23149. protected _outputRename(name: string): string;
  23150. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23151. }
  23152. }
  23153. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23154. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23155. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23156. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23157. import { Scene } from "babylonjs/scene";
  23158. /**
  23159. * Operations supported by the Trigonometry block
  23160. */
  23161. export enum TrigonometryBlockOperations {
  23162. /** Cos */
  23163. Cos = 0,
  23164. /** Sin */
  23165. Sin = 1,
  23166. /** Abs */
  23167. Abs = 2,
  23168. /** Exp */
  23169. Exp = 3,
  23170. /** Exp2 */
  23171. Exp2 = 4,
  23172. /** Round */
  23173. Round = 5,
  23174. /** Floor */
  23175. Floor = 6,
  23176. /** Ceiling */
  23177. Ceiling = 7,
  23178. /** Square root */
  23179. Sqrt = 8,
  23180. /** Log */
  23181. Log = 9,
  23182. /** Tangent */
  23183. Tan = 10,
  23184. /** Arc tangent */
  23185. ArcTan = 11,
  23186. /** Arc cosinus */
  23187. ArcCos = 12,
  23188. /** Arc sinus */
  23189. ArcSin = 13,
  23190. /** Fraction */
  23191. Fract = 14,
  23192. /** Sign */
  23193. Sign = 15,
  23194. /** To radians (from degrees) */
  23195. Radians = 16,
  23196. /** To degrees (from radians) */
  23197. Degrees = 17
  23198. }
  23199. /**
  23200. * Block used to apply trigonometry operation to floats
  23201. */
  23202. export class TrigonometryBlock extends NodeMaterialBlock {
  23203. /**
  23204. * Gets or sets the operation applied by the block
  23205. */
  23206. operation: TrigonometryBlockOperations;
  23207. /**
  23208. * Creates a new TrigonometryBlock
  23209. * @param name defines the block name
  23210. */
  23211. constructor(name: string);
  23212. /**
  23213. * Gets the current class name
  23214. * @returns the class name
  23215. */
  23216. getClassName(): string;
  23217. /**
  23218. * Gets the input component
  23219. */
  23220. get input(): NodeMaterialConnectionPoint;
  23221. /**
  23222. * Gets the output component
  23223. */
  23224. get output(): NodeMaterialConnectionPoint;
  23225. protected _buildBlock(state: NodeMaterialBuildState): this;
  23226. serialize(): any;
  23227. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23228. protected _dumpPropertiesCode(): string;
  23229. }
  23230. }
  23231. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23232. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23233. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23234. import { Scene } from "babylonjs/scene";
  23235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23236. import { Matrix } from "babylonjs/Maths/math.vector";
  23237. import { Mesh } from "babylonjs/Meshes/mesh";
  23238. import { Engine } from "babylonjs/Engines/engine";
  23239. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23240. import { Observable } from "babylonjs/Misc/observable";
  23241. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23242. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23243. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23244. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23245. import { Nullable } from "babylonjs/types";
  23246. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23247. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23248. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23249. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23250. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23251. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23252. import { Effect } from "babylonjs/Materials/effect";
  23253. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23254. import { Camera } from "babylonjs/Cameras/camera";
  23255. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23256. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23257. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23258. /**
  23259. * Interface used to configure the node material editor
  23260. */
  23261. export interface INodeMaterialEditorOptions {
  23262. /** Define the URl to load node editor script */
  23263. editorURL?: string;
  23264. }
  23265. /** @hidden */
  23266. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23267. NORMAL: boolean;
  23268. TANGENT: boolean;
  23269. UV1: boolean;
  23270. /** BONES */
  23271. NUM_BONE_INFLUENCERS: number;
  23272. BonesPerMesh: number;
  23273. BONETEXTURE: boolean;
  23274. /** MORPH TARGETS */
  23275. MORPHTARGETS: boolean;
  23276. MORPHTARGETS_NORMAL: boolean;
  23277. MORPHTARGETS_TANGENT: boolean;
  23278. MORPHTARGETS_UV: boolean;
  23279. NUM_MORPH_INFLUENCERS: number;
  23280. /** IMAGE PROCESSING */
  23281. IMAGEPROCESSING: boolean;
  23282. VIGNETTE: boolean;
  23283. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23284. VIGNETTEBLENDMODEOPAQUE: boolean;
  23285. TONEMAPPING: boolean;
  23286. TONEMAPPING_ACES: boolean;
  23287. CONTRAST: boolean;
  23288. EXPOSURE: boolean;
  23289. COLORCURVES: boolean;
  23290. COLORGRADING: boolean;
  23291. COLORGRADING3D: boolean;
  23292. SAMPLER3DGREENDEPTH: boolean;
  23293. SAMPLER3DBGRMAP: boolean;
  23294. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23295. /** MISC. */
  23296. BUMPDIRECTUV: number;
  23297. constructor();
  23298. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23299. }
  23300. /**
  23301. * Class used to configure NodeMaterial
  23302. */
  23303. export interface INodeMaterialOptions {
  23304. /**
  23305. * Defines if blocks should emit comments
  23306. */
  23307. emitComments: boolean;
  23308. }
  23309. /**
  23310. * Class used to create a node based material built by assembling shader blocks
  23311. */
  23312. export class NodeMaterial extends PushMaterial {
  23313. private static _BuildIdGenerator;
  23314. private _options;
  23315. private _vertexCompilationState;
  23316. private _fragmentCompilationState;
  23317. private _sharedData;
  23318. private _buildId;
  23319. private _buildWasSuccessful;
  23320. private _cachedWorldViewMatrix;
  23321. private _cachedWorldViewProjectionMatrix;
  23322. private _optimizers;
  23323. private _animationFrame;
  23324. /** Define the Url to load node editor script */
  23325. static EditorURL: string;
  23326. /** Define the Url to load snippets */
  23327. static SnippetUrl: string;
  23328. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23329. static IgnoreTexturesAtLoadTime: boolean;
  23330. private BJSNODEMATERIALEDITOR;
  23331. /** Get the inspector from bundle or global */
  23332. private _getGlobalNodeMaterialEditor;
  23333. /**
  23334. * Snippet ID if the material was created from the snippet server
  23335. */
  23336. snippetId: string;
  23337. /**
  23338. * Gets or sets data used by visual editor
  23339. * @see https://nme.babylonjs.com
  23340. */
  23341. editorData: any;
  23342. /**
  23343. * 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)
  23344. */
  23345. ignoreAlpha: boolean;
  23346. /**
  23347. * Defines the maximum number of lights that can be used in the material
  23348. */
  23349. maxSimultaneousLights: number;
  23350. /**
  23351. * Observable raised when the material is built
  23352. */
  23353. onBuildObservable: Observable<NodeMaterial>;
  23354. /**
  23355. * Gets or sets the root nodes of the material vertex shader
  23356. */
  23357. _vertexOutputNodes: NodeMaterialBlock[];
  23358. /**
  23359. * Gets or sets the root nodes of the material fragment (pixel) shader
  23360. */
  23361. _fragmentOutputNodes: NodeMaterialBlock[];
  23362. /** Gets or sets options to control the node material overall behavior */
  23363. get options(): INodeMaterialOptions;
  23364. set options(options: INodeMaterialOptions);
  23365. /**
  23366. * Default configuration related to image processing available in the standard Material.
  23367. */
  23368. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23369. /**
  23370. * Gets the image processing configuration used either in this material.
  23371. */
  23372. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23373. /**
  23374. * Sets the Default image processing configuration used either in the this material.
  23375. *
  23376. * If sets to null, the scene one is in use.
  23377. */
  23378. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23379. /**
  23380. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23381. */
  23382. attachedBlocks: NodeMaterialBlock[];
  23383. /**
  23384. * Specifies the mode of the node material
  23385. * @hidden
  23386. */
  23387. _mode: NodeMaterialModes;
  23388. /**
  23389. * Gets the mode property
  23390. */
  23391. get mode(): NodeMaterialModes;
  23392. /**
  23393. * Create a new node based material
  23394. * @param name defines the material name
  23395. * @param scene defines the hosting scene
  23396. * @param options defines creation option
  23397. */
  23398. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23399. /**
  23400. * Gets the current class name of the material e.g. "NodeMaterial"
  23401. * @returns the class name
  23402. */
  23403. getClassName(): string;
  23404. /**
  23405. * Keep track of the image processing observer to allow dispose and replace.
  23406. */
  23407. private _imageProcessingObserver;
  23408. /**
  23409. * Attaches a new image processing configuration to the Standard Material.
  23410. * @param configuration
  23411. */
  23412. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23413. /**
  23414. * Get a block by its name
  23415. * @param name defines the name of the block to retrieve
  23416. * @returns the required block or null if not found
  23417. */
  23418. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23419. /**
  23420. * Get a block by its name
  23421. * @param predicate defines the predicate used to find the good candidate
  23422. * @returns the required block or null if not found
  23423. */
  23424. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23425. /**
  23426. * Get an input block by its name
  23427. * @param predicate defines the predicate used to find the good candidate
  23428. * @returns the required input block or null if not found
  23429. */
  23430. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23431. /**
  23432. * Gets the list of input blocks attached to this material
  23433. * @returns an array of InputBlocks
  23434. */
  23435. getInputBlocks(): InputBlock[];
  23436. /**
  23437. * Adds a new optimizer to the list of optimizers
  23438. * @param optimizer defines the optimizers to add
  23439. * @returns the current material
  23440. */
  23441. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23442. /**
  23443. * Remove an optimizer from the list of optimizers
  23444. * @param optimizer defines the optimizers to remove
  23445. * @returns the current material
  23446. */
  23447. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23448. /**
  23449. * Add a new block to the list of output nodes
  23450. * @param node defines the node to add
  23451. * @returns the current material
  23452. */
  23453. addOutputNode(node: NodeMaterialBlock): this;
  23454. /**
  23455. * Remove a block from the list of root nodes
  23456. * @param node defines the node to remove
  23457. * @returns the current material
  23458. */
  23459. removeOutputNode(node: NodeMaterialBlock): this;
  23460. private _addVertexOutputNode;
  23461. private _removeVertexOutputNode;
  23462. private _addFragmentOutputNode;
  23463. private _removeFragmentOutputNode;
  23464. /**
  23465. * Specifies if the material will require alpha blending
  23466. * @returns a boolean specifying if alpha blending is needed
  23467. */
  23468. needAlphaBlending(): boolean;
  23469. /**
  23470. * Specifies if this material should be rendered in alpha test mode
  23471. * @returns a boolean specifying if an alpha test is needed.
  23472. */
  23473. needAlphaTesting(): boolean;
  23474. private _initializeBlock;
  23475. private _resetDualBlocks;
  23476. /**
  23477. * Remove a block from the current node material
  23478. * @param block defines the block to remove
  23479. */
  23480. removeBlock(block: NodeMaterialBlock): void;
  23481. /**
  23482. * Build the material and generates the inner effect
  23483. * @param verbose defines if the build should log activity
  23484. */
  23485. build(verbose?: boolean): void;
  23486. /**
  23487. * Runs an otpimization phase to try to improve the shader code
  23488. */
  23489. optimize(): void;
  23490. private _prepareDefinesForAttributes;
  23491. /**
  23492. * Create a post process from the material
  23493. * @param camera The camera to apply the render pass to.
  23494. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23495. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23496. * @param engine The engine which the post process will be applied. (default: current engine)
  23497. * @param reusable If the post process can be reused on the same frame. (default: false)
  23498. * @param textureType Type of textures used when performing the post process. (default: 0)
  23499. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23500. * @returns the post process created
  23501. */
  23502. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23503. /**
  23504. * Create the post process effect from the material
  23505. * @param postProcess The post process to create the effect for
  23506. */
  23507. createEffectForPostProcess(postProcess: PostProcess): void;
  23508. private _createEffectForPostProcess;
  23509. /**
  23510. * Create a new procedural texture based on this node material
  23511. * @param size defines the size of the texture
  23512. * @param scene defines the hosting scene
  23513. * @returns the new procedural texture attached to this node material
  23514. */
  23515. createProceduralTexture(size: number | {
  23516. width: number;
  23517. height: number;
  23518. layers?: number;
  23519. }, scene: Scene): Nullable<ProceduralTexture>;
  23520. private _createEffectForParticles;
  23521. private _checkInternals;
  23522. /**
  23523. * Create the effect to be used as the custom effect for a particle system
  23524. * @param particleSystem Particle system to create the effect for
  23525. * @param onCompiled defines a function to call when the effect creation is successful
  23526. * @param onError defines a function to call when the effect creation has failed
  23527. */
  23528. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23529. private _processDefines;
  23530. /**
  23531. * Get if the submesh is ready to be used and all its information available.
  23532. * Child classes can use it to update shaders
  23533. * @param mesh defines the mesh to check
  23534. * @param subMesh defines which submesh to check
  23535. * @param useInstances specifies that instances should be used
  23536. * @returns a boolean indicating that the submesh is ready or not
  23537. */
  23538. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23539. /**
  23540. * Get a string representing the shaders built by the current node graph
  23541. */
  23542. get compiledShaders(): string;
  23543. /**
  23544. * Binds the world matrix to the material
  23545. * @param world defines the world transformation matrix
  23546. */
  23547. bindOnlyWorldMatrix(world: Matrix): void;
  23548. /**
  23549. * Binds the submesh to this material by preparing the effect and shader to draw
  23550. * @param world defines the world transformation matrix
  23551. * @param mesh defines the mesh containing the submesh
  23552. * @param subMesh defines the submesh to bind the material to
  23553. */
  23554. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23555. /**
  23556. * Gets the active textures from the material
  23557. * @returns an array of textures
  23558. */
  23559. getActiveTextures(): BaseTexture[];
  23560. /**
  23561. * Gets the list of texture blocks
  23562. * @returns an array of texture blocks
  23563. */
  23564. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23565. /**
  23566. * Specifies if the material uses a texture
  23567. * @param texture defines the texture to check against the material
  23568. * @returns a boolean specifying if the material uses the texture
  23569. */
  23570. hasTexture(texture: BaseTexture): boolean;
  23571. /**
  23572. * Disposes the material
  23573. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23574. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23575. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23576. */
  23577. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23578. /** Creates the node editor window. */
  23579. private _createNodeEditor;
  23580. /**
  23581. * Launch the node material editor
  23582. * @param config Define the configuration of the editor
  23583. * @return a promise fulfilled when the node editor is visible
  23584. */
  23585. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23586. /**
  23587. * Clear the current material
  23588. */
  23589. clear(): void;
  23590. /**
  23591. * Clear the current material and set it to a default state
  23592. */
  23593. setToDefault(): void;
  23594. /**
  23595. * Clear the current material and set it to a default state for post process
  23596. */
  23597. setToDefaultPostProcess(): void;
  23598. /**
  23599. * Clear the current material and set it to a default state for procedural texture
  23600. */
  23601. setToDefaultProceduralTexture(): void;
  23602. /**
  23603. * Clear the current material and set it to a default state for particle
  23604. */
  23605. setToDefaultParticle(): void;
  23606. /**
  23607. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23608. * @param url defines the url to load from
  23609. * @returns a promise that will fullfil when the material is fully loaded
  23610. */
  23611. loadAsync(url: string): Promise<void>;
  23612. private _gatherBlocks;
  23613. /**
  23614. * Generate a string containing the code declaration required to create an equivalent of this material
  23615. * @returns a string
  23616. */
  23617. generateCode(): string;
  23618. /**
  23619. * Serializes this material in a JSON representation
  23620. * @returns the serialized material object
  23621. */
  23622. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23623. private _restoreConnections;
  23624. /**
  23625. * Clear the current graph and load a new one from a serialization object
  23626. * @param source defines the JSON representation of the material
  23627. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23628. * @param merge defines whether or not the source must be merged or replace the current content
  23629. */
  23630. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23631. /**
  23632. * Makes a duplicate of the current material.
  23633. * @param name - name to use for the new material.
  23634. */
  23635. clone(name: string): NodeMaterial;
  23636. /**
  23637. * Creates a node material from parsed material data
  23638. * @param source defines the JSON representation of the material
  23639. * @param scene defines the hosting scene
  23640. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23641. * @returns a new node material
  23642. */
  23643. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23644. /**
  23645. * Creates a node material from a snippet saved in a remote file
  23646. * @param name defines the name of the material to create
  23647. * @param url defines the url to load from
  23648. * @param scene defines the hosting scene
  23649. * @returns a promise that will resolve to the new node material
  23650. */
  23651. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23652. /**
  23653. * Creates a node material from a snippet saved by the node material editor
  23654. * @param snippetId defines the snippet to load
  23655. * @param scene defines the hosting scene
  23656. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23657. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23658. * @returns a promise that will resolve to the new node material
  23659. */
  23660. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23661. /**
  23662. * Creates a new node material set to default basic configuration
  23663. * @param name defines the name of the material
  23664. * @param scene defines the hosting scene
  23665. * @returns a new NodeMaterial
  23666. */
  23667. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23668. }
  23669. }
  23670. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  23671. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23672. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  23673. import { Nullable } from "babylonjs/types";
  23674. module "babylonjs/Engines/thinEngine" {
  23675. interface ThinEngine {
  23676. /**
  23677. * Unbind a list of render target textures from the webGL context
  23678. * This is used only when drawBuffer extension or webGL2 are active
  23679. * @param textures defines the render target textures to unbind
  23680. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23681. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23682. */
  23683. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23684. /**
  23685. * Create a multi render target texture
  23686. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23687. * @param size defines the size of the texture
  23688. * @param options defines the creation options
  23689. * @returns the cube texture as an InternalTexture
  23690. */
  23691. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23692. /**
  23693. * Update the sample count for a given multiple render target texture
  23694. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23695. * @param textures defines the textures to update
  23696. * @param samples defines the sample count to set
  23697. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23698. */
  23699. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23700. /**
  23701. * Select a subsets of attachments to draw to.
  23702. * @param attachments gl attachments
  23703. */
  23704. bindAttachments(attachments: number[]): void;
  23705. /**
  23706. * Creates a layout object to draw/clear on specific textures in a MRT
  23707. * @param textureStatus textureStatus[i] indicates if the i-th is active
  23708. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  23709. */
  23710. buildTextureLayout(textureStatus: boolean[]): number[];
  23711. /**
  23712. * Restores the webgl state to only draw on the main color attachment
  23713. */
  23714. restoreSingleAttachment(): void;
  23715. }
  23716. }
  23717. }
  23718. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  23719. import { Scene } from "babylonjs/scene";
  23720. import { Engine } from "babylonjs/Engines/engine";
  23721. import { Texture } from "babylonjs/Materials/Textures/texture";
  23722. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23723. import "babylonjs/Engines/Extensions/engine.multiRender";
  23724. /**
  23725. * Creation options of the multi render target texture.
  23726. */
  23727. export interface IMultiRenderTargetOptions {
  23728. /**
  23729. * Define if the texture needs to create mip maps after render.
  23730. */
  23731. generateMipMaps?: boolean;
  23732. /**
  23733. * Define the types of all the draw buffers we want to create
  23734. */
  23735. types?: number[];
  23736. /**
  23737. * Define the sampling modes of all the draw buffers we want to create
  23738. */
  23739. samplingModes?: number[];
  23740. /**
  23741. * Define if a depth buffer is required
  23742. */
  23743. generateDepthBuffer?: boolean;
  23744. /**
  23745. * Define if a stencil buffer is required
  23746. */
  23747. generateStencilBuffer?: boolean;
  23748. /**
  23749. * Define if a depth texture is required instead of a depth buffer
  23750. */
  23751. generateDepthTexture?: boolean;
  23752. /**
  23753. * Define the number of desired draw buffers
  23754. */
  23755. textureCount?: number;
  23756. /**
  23757. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23758. */
  23759. doNotChangeAspectRatio?: boolean;
  23760. /**
  23761. * Define the default type of the buffers we are creating
  23762. */
  23763. defaultType?: number;
  23764. }
  23765. /**
  23766. * A multi render target, like a render target provides the ability to render to a texture.
  23767. * Unlike the render target, it can render to several draw buffers in one draw.
  23768. * This is specially interesting in deferred rendering or for any effects requiring more than
  23769. * just one color from a single pass.
  23770. */
  23771. export class MultiRenderTarget extends RenderTargetTexture {
  23772. private _internalTextures;
  23773. private _textures;
  23774. private _multiRenderTargetOptions;
  23775. private _count;
  23776. /**
  23777. * Get if draw buffers are currently supported by the used hardware and browser.
  23778. */
  23779. get isSupported(): boolean;
  23780. /**
  23781. * Get the list of textures generated by the multi render target.
  23782. */
  23783. get textures(): Texture[];
  23784. /**
  23785. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23786. */
  23787. get count(): number;
  23788. /**
  23789. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23790. */
  23791. get depthTexture(): Texture;
  23792. /**
  23793. * Set the wrapping mode on U of all the textures we are rendering to.
  23794. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23795. */
  23796. set wrapU(wrap: number);
  23797. /**
  23798. * Set the wrapping mode on V of all the textures we are rendering to.
  23799. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23800. */
  23801. set wrapV(wrap: number);
  23802. /**
  23803. * Instantiate a new multi render target texture.
  23804. * A multi render target, like a render target provides the ability to render to a texture.
  23805. * Unlike the render target, it can render to several draw buffers in one draw.
  23806. * This is specially interesting in deferred rendering or for any effects requiring more than
  23807. * just one color from a single pass.
  23808. * @param name Define the name of the texture
  23809. * @param size Define the size of the buffers to render to
  23810. * @param count Define the number of target we are rendering into
  23811. * @param scene Define the scene the texture belongs to
  23812. * @param options Define the options used to create the multi render target
  23813. */
  23814. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23815. private _initTypes;
  23816. /** @hidden */
  23817. _rebuild(forceFullRebuild?: boolean): void;
  23818. private _createInternalTextures;
  23819. private _createTextures;
  23820. /**
  23821. * Replaces a texture within the MRT.
  23822. * @param texture The new texture to insert in the MRT
  23823. * @param index The index of the texture to replace
  23824. */
  23825. replaceTexture(texture: Texture, index: number): void;
  23826. /**
  23827. * Define the number of samples used if MSAA is enabled.
  23828. */
  23829. get samples(): number;
  23830. set samples(value: number);
  23831. /**
  23832. * Resize all the textures in the multi render target.
  23833. * Be careful as it will recreate all the data in the new texture.
  23834. * @param size Define the new size
  23835. */
  23836. resize(size: any): void;
  23837. /**
  23838. * Changes the number of render targets in this MRT
  23839. * Be careful as it will recreate all the data in the new texture.
  23840. * @param count new texture count
  23841. * @param options Specifies texture types and sampling modes for new textures
  23842. */
  23843. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23844. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23845. /**
  23846. * Dispose the render targets and their associated resources
  23847. */
  23848. dispose(): void;
  23849. /**
  23850. * Release all the underlying texture used as draw buffers.
  23851. */
  23852. releaseInternalTextures(): void;
  23853. }
  23854. }
  23855. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  23856. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  23857. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  23858. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  23859. /** @hidden */
  23860. export var imageProcessingPixelShader: {
  23861. name: string;
  23862. shader: string;
  23863. };
  23864. }
  23865. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  23866. import { Nullable } from "babylonjs/types";
  23867. import { Color4 } from "babylonjs/Maths/math.color";
  23868. import { Camera } from "babylonjs/Cameras/camera";
  23869. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23870. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  23871. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  23872. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23873. import { Engine } from "babylonjs/Engines/engine";
  23874. import "babylonjs/Shaders/imageProcessing.fragment";
  23875. import "babylonjs/Shaders/postprocess.vertex";
  23876. /**
  23877. * ImageProcessingPostProcess
  23878. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23879. */
  23880. export class ImageProcessingPostProcess extends PostProcess {
  23881. /**
  23882. * Default configuration related to image processing available in the PBR Material.
  23883. */
  23884. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23885. /**
  23886. * Gets the image processing configuration used either in this material.
  23887. */
  23888. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23889. /**
  23890. * Sets the Default image processing configuration used either in the this material.
  23891. *
  23892. * If sets to null, the scene one is in use.
  23893. */
  23894. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23895. /**
  23896. * Keep track of the image processing observer to allow dispose and replace.
  23897. */
  23898. private _imageProcessingObserver;
  23899. /**
  23900. * Attaches a new image processing configuration to the PBR Material.
  23901. * @param configuration
  23902. */
  23903. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23904. /**
  23905. * If the post process is supported.
  23906. */
  23907. get isSupported(): boolean;
  23908. /**
  23909. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23910. */
  23911. get colorCurves(): Nullable<ColorCurves>;
  23912. /**
  23913. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23914. */
  23915. set colorCurves(value: Nullable<ColorCurves>);
  23916. /**
  23917. * Gets wether the color curves effect is enabled.
  23918. */
  23919. get colorCurvesEnabled(): boolean;
  23920. /**
  23921. * Sets wether the color curves effect is enabled.
  23922. */
  23923. set colorCurvesEnabled(value: boolean);
  23924. /**
  23925. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23926. */
  23927. get colorGradingTexture(): Nullable<BaseTexture>;
  23928. /**
  23929. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23930. */
  23931. set colorGradingTexture(value: Nullable<BaseTexture>);
  23932. /**
  23933. * Gets wether the color grading effect is enabled.
  23934. */
  23935. get colorGradingEnabled(): boolean;
  23936. /**
  23937. * Gets wether the color grading effect is enabled.
  23938. */
  23939. set colorGradingEnabled(value: boolean);
  23940. /**
  23941. * Gets exposure used in the effect.
  23942. */
  23943. get exposure(): number;
  23944. /**
  23945. * Sets exposure used in the effect.
  23946. */
  23947. set exposure(value: number);
  23948. /**
  23949. * Gets wether tonemapping is enabled or not.
  23950. */
  23951. get toneMappingEnabled(): boolean;
  23952. /**
  23953. * Sets wether tonemapping is enabled or not
  23954. */
  23955. set toneMappingEnabled(value: boolean);
  23956. /**
  23957. * Gets the type of tone mapping effect.
  23958. */
  23959. get toneMappingType(): number;
  23960. /**
  23961. * Sets the type of tone mapping effect.
  23962. */
  23963. set toneMappingType(value: number);
  23964. /**
  23965. * Gets contrast used in the effect.
  23966. */
  23967. get contrast(): number;
  23968. /**
  23969. * Sets contrast used in the effect.
  23970. */
  23971. set contrast(value: number);
  23972. /**
  23973. * Gets Vignette stretch size.
  23974. */
  23975. get vignetteStretch(): number;
  23976. /**
  23977. * Sets Vignette stretch size.
  23978. */
  23979. set vignetteStretch(value: number);
  23980. /**
  23981. * Gets Vignette centre X Offset.
  23982. */
  23983. get vignetteCentreX(): number;
  23984. /**
  23985. * Sets Vignette centre X Offset.
  23986. */
  23987. set vignetteCentreX(value: number);
  23988. /**
  23989. * Gets Vignette centre Y Offset.
  23990. */
  23991. get vignetteCentreY(): number;
  23992. /**
  23993. * Sets Vignette centre Y Offset.
  23994. */
  23995. set vignetteCentreY(value: number);
  23996. /**
  23997. * Gets Vignette weight or intensity of the vignette effect.
  23998. */
  23999. get vignetteWeight(): number;
  24000. /**
  24001. * Sets Vignette weight or intensity of the vignette effect.
  24002. */
  24003. set vignetteWeight(value: number);
  24004. /**
  24005. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24006. * if vignetteEnabled is set to true.
  24007. */
  24008. get vignetteColor(): Color4;
  24009. /**
  24010. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24011. * if vignetteEnabled is set to true.
  24012. */
  24013. set vignetteColor(value: Color4);
  24014. /**
  24015. * Gets Camera field of view used by the Vignette effect.
  24016. */
  24017. get vignetteCameraFov(): number;
  24018. /**
  24019. * Sets Camera field of view used by the Vignette effect.
  24020. */
  24021. set vignetteCameraFov(value: number);
  24022. /**
  24023. * Gets the vignette blend mode allowing different kind of effect.
  24024. */
  24025. get vignetteBlendMode(): number;
  24026. /**
  24027. * Sets the vignette blend mode allowing different kind of effect.
  24028. */
  24029. set vignetteBlendMode(value: number);
  24030. /**
  24031. * Gets wether the vignette effect is enabled.
  24032. */
  24033. get vignetteEnabled(): boolean;
  24034. /**
  24035. * Sets wether the vignette effect is enabled.
  24036. */
  24037. set vignetteEnabled(value: boolean);
  24038. private _fromLinearSpace;
  24039. /**
  24040. * Gets wether the input of the processing is in Gamma or Linear Space.
  24041. */
  24042. get fromLinearSpace(): boolean;
  24043. /**
  24044. * Sets wether the input of the processing is in Gamma or Linear Space.
  24045. */
  24046. set fromLinearSpace(value: boolean);
  24047. /**
  24048. * Defines cache preventing GC.
  24049. */
  24050. private _defines;
  24051. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24052. /**
  24053. * "ImageProcessingPostProcess"
  24054. * @returns "ImageProcessingPostProcess"
  24055. */
  24056. getClassName(): string;
  24057. /**
  24058. * @hidden
  24059. */
  24060. _updateParameters(): void;
  24061. dispose(camera?: Camera): void;
  24062. }
  24063. }
  24064. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  24065. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24066. /**
  24067. * Interface for defining prepass effects in the prepass post-process pipeline
  24068. */
  24069. export interface PrePassEffectConfiguration {
  24070. /**
  24071. * Name of the effect
  24072. */
  24073. name: string;
  24074. /**
  24075. * Post process to attach for this effect
  24076. */
  24077. postProcess?: PostProcess;
  24078. /**
  24079. * Textures required in the MRT
  24080. */
  24081. texturesRequired: number[];
  24082. /**
  24083. * Is the effect enabled
  24084. */
  24085. enabled: boolean;
  24086. /**
  24087. * Disposes the effect configuration
  24088. */
  24089. dispose?: () => void;
  24090. /**
  24091. * Creates the associated post process
  24092. */
  24093. createPostProcess?: () => PostProcess;
  24094. }
  24095. }
  24096. declare module "babylonjs/Materials/fresnelParameters" {
  24097. import { DeepImmutable } from "babylonjs/types";
  24098. import { Color3 } from "babylonjs/Maths/math.color";
  24099. /**
  24100. * Options to be used when creating a FresnelParameters.
  24101. */
  24102. export type IFresnelParametersCreationOptions = {
  24103. /**
  24104. * Define the color used on edges (grazing angle)
  24105. */
  24106. leftColor?: Color3;
  24107. /**
  24108. * Define the color used on center
  24109. */
  24110. rightColor?: Color3;
  24111. /**
  24112. * Define bias applied to computed fresnel term
  24113. */
  24114. bias?: number;
  24115. /**
  24116. * Defined the power exponent applied to fresnel term
  24117. */
  24118. power?: number;
  24119. /**
  24120. * Define if the fresnel effect is enable or not.
  24121. */
  24122. isEnabled?: boolean;
  24123. };
  24124. /**
  24125. * Serialized format for FresnelParameters.
  24126. */
  24127. export type IFresnelParametersSerialized = {
  24128. /**
  24129. * Define the color used on edges (grazing angle) [as an array]
  24130. */
  24131. leftColor: number[];
  24132. /**
  24133. * Define the color used on center [as an array]
  24134. */
  24135. rightColor: number[];
  24136. /**
  24137. * Define bias applied to computed fresnel term
  24138. */
  24139. bias: number;
  24140. /**
  24141. * Defined the power exponent applied to fresnel term
  24142. */
  24143. power?: number;
  24144. /**
  24145. * Define if the fresnel effect is enable or not.
  24146. */
  24147. isEnabled: boolean;
  24148. };
  24149. /**
  24150. * This represents all the required information to add a fresnel effect on a material:
  24151. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24152. */
  24153. export class FresnelParameters {
  24154. private _isEnabled;
  24155. /**
  24156. * Define if the fresnel effect is enable or not.
  24157. */
  24158. get isEnabled(): boolean;
  24159. set isEnabled(value: boolean);
  24160. /**
  24161. * Define the color used on edges (grazing angle)
  24162. */
  24163. leftColor: Color3;
  24164. /**
  24165. * Define the color used on center
  24166. */
  24167. rightColor: Color3;
  24168. /**
  24169. * Define bias applied to computed fresnel term
  24170. */
  24171. bias: number;
  24172. /**
  24173. * Defined the power exponent applied to fresnel term
  24174. */
  24175. power: number;
  24176. /**
  24177. * Creates a new FresnelParameters object.
  24178. *
  24179. * @param options provide your own settings to optionally to override defaults
  24180. */
  24181. constructor(options?: IFresnelParametersCreationOptions);
  24182. /**
  24183. * Clones the current fresnel and its valuues
  24184. * @returns a clone fresnel configuration
  24185. */
  24186. clone(): FresnelParameters;
  24187. /**
  24188. * Determines equality between FresnelParameters objects
  24189. * @param otherFresnelParameters defines the second operand
  24190. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  24191. */
  24192. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  24193. /**
  24194. * Serializes the current fresnel parameters to a JSON representation.
  24195. * @return the JSON serialization
  24196. */
  24197. serialize(): IFresnelParametersSerialized;
  24198. /**
  24199. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  24200. * @param parsedFresnelParameters Define the JSON representation
  24201. * @returns the parsed parameters
  24202. */
  24203. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  24204. }
  24205. }
  24206. declare module "babylonjs/Materials/materialFlags" {
  24207. /**
  24208. * This groups all the flags used to control the materials channel.
  24209. */
  24210. export class MaterialFlags {
  24211. private static _DiffuseTextureEnabled;
  24212. /**
  24213. * Are diffuse textures enabled in the application.
  24214. */
  24215. static get DiffuseTextureEnabled(): boolean;
  24216. static set DiffuseTextureEnabled(value: boolean);
  24217. private static _DetailTextureEnabled;
  24218. /**
  24219. * Are detail textures enabled in the application.
  24220. */
  24221. static get DetailTextureEnabled(): boolean;
  24222. static set DetailTextureEnabled(value: boolean);
  24223. private static _AmbientTextureEnabled;
  24224. /**
  24225. * Are ambient textures enabled in the application.
  24226. */
  24227. static get AmbientTextureEnabled(): boolean;
  24228. static set AmbientTextureEnabled(value: boolean);
  24229. private static _OpacityTextureEnabled;
  24230. /**
  24231. * Are opacity textures enabled in the application.
  24232. */
  24233. static get OpacityTextureEnabled(): boolean;
  24234. static set OpacityTextureEnabled(value: boolean);
  24235. private static _ReflectionTextureEnabled;
  24236. /**
  24237. * Are reflection textures enabled in the application.
  24238. */
  24239. static get ReflectionTextureEnabled(): boolean;
  24240. static set ReflectionTextureEnabled(value: boolean);
  24241. private static _EmissiveTextureEnabled;
  24242. /**
  24243. * Are emissive textures enabled in the application.
  24244. */
  24245. static get EmissiveTextureEnabled(): boolean;
  24246. static set EmissiveTextureEnabled(value: boolean);
  24247. private static _SpecularTextureEnabled;
  24248. /**
  24249. * Are specular textures enabled in the application.
  24250. */
  24251. static get SpecularTextureEnabled(): boolean;
  24252. static set SpecularTextureEnabled(value: boolean);
  24253. private static _BumpTextureEnabled;
  24254. /**
  24255. * Are bump textures enabled in the application.
  24256. */
  24257. static get BumpTextureEnabled(): boolean;
  24258. static set BumpTextureEnabled(value: boolean);
  24259. private static _LightmapTextureEnabled;
  24260. /**
  24261. * Are lightmap textures enabled in the application.
  24262. */
  24263. static get LightmapTextureEnabled(): boolean;
  24264. static set LightmapTextureEnabled(value: boolean);
  24265. private static _RefractionTextureEnabled;
  24266. /**
  24267. * Are refraction textures enabled in the application.
  24268. */
  24269. static get RefractionTextureEnabled(): boolean;
  24270. static set RefractionTextureEnabled(value: boolean);
  24271. private static _ColorGradingTextureEnabled;
  24272. /**
  24273. * Are color grading textures enabled in the application.
  24274. */
  24275. static get ColorGradingTextureEnabled(): boolean;
  24276. static set ColorGradingTextureEnabled(value: boolean);
  24277. private static _FresnelEnabled;
  24278. /**
  24279. * Are fresnels enabled in the application.
  24280. */
  24281. static get FresnelEnabled(): boolean;
  24282. static set FresnelEnabled(value: boolean);
  24283. private static _ClearCoatTextureEnabled;
  24284. /**
  24285. * Are clear coat textures enabled in the application.
  24286. */
  24287. static get ClearCoatTextureEnabled(): boolean;
  24288. static set ClearCoatTextureEnabled(value: boolean);
  24289. private static _ClearCoatBumpTextureEnabled;
  24290. /**
  24291. * Are clear coat bump textures enabled in the application.
  24292. */
  24293. static get ClearCoatBumpTextureEnabled(): boolean;
  24294. static set ClearCoatBumpTextureEnabled(value: boolean);
  24295. private static _ClearCoatTintTextureEnabled;
  24296. /**
  24297. * Are clear coat tint textures enabled in the application.
  24298. */
  24299. static get ClearCoatTintTextureEnabled(): boolean;
  24300. static set ClearCoatTintTextureEnabled(value: boolean);
  24301. private static _SheenTextureEnabled;
  24302. /**
  24303. * Are sheen textures enabled in the application.
  24304. */
  24305. static get SheenTextureEnabled(): boolean;
  24306. static set SheenTextureEnabled(value: boolean);
  24307. private static _AnisotropicTextureEnabled;
  24308. /**
  24309. * Are anisotropic textures enabled in the application.
  24310. */
  24311. static get AnisotropicTextureEnabled(): boolean;
  24312. static set AnisotropicTextureEnabled(value: boolean);
  24313. private static _ThicknessTextureEnabled;
  24314. /**
  24315. * Are thickness textures enabled in the application.
  24316. */
  24317. static get ThicknessTextureEnabled(): boolean;
  24318. static set ThicknessTextureEnabled(value: boolean);
  24319. }
  24320. }
  24321. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  24322. /** @hidden */
  24323. export var defaultFragmentDeclaration: {
  24324. name: string;
  24325. shader: string;
  24326. };
  24327. }
  24328. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  24329. /** @hidden */
  24330. export var defaultUboDeclaration: {
  24331. name: string;
  24332. shader: string;
  24333. };
  24334. }
  24335. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  24336. /** @hidden */
  24337. export var prePassDeclaration: {
  24338. name: string;
  24339. shader: string;
  24340. };
  24341. }
  24342. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  24343. /** @hidden */
  24344. export var lightFragmentDeclaration: {
  24345. name: string;
  24346. shader: string;
  24347. };
  24348. }
  24349. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  24350. /** @hidden */
  24351. export var lightUboDeclaration: {
  24352. name: string;
  24353. shader: string;
  24354. };
  24355. }
  24356. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  24357. /** @hidden */
  24358. export var lightsFragmentFunctions: {
  24359. name: string;
  24360. shader: string;
  24361. };
  24362. }
  24363. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  24364. /** @hidden */
  24365. export var shadowsFragmentFunctions: {
  24366. name: string;
  24367. shader: string;
  24368. };
  24369. }
  24370. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  24371. /** @hidden */
  24372. export var fresnelFunction: {
  24373. name: string;
  24374. shader: string;
  24375. };
  24376. }
  24377. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  24378. /** @hidden */
  24379. export var bumpFragmentMainFunctions: {
  24380. name: string;
  24381. shader: string;
  24382. };
  24383. }
  24384. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  24385. /** @hidden */
  24386. export var bumpFragmentFunctions: {
  24387. name: string;
  24388. shader: string;
  24389. };
  24390. }
  24391. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  24392. /** @hidden */
  24393. export var logDepthDeclaration: {
  24394. name: string;
  24395. shader: string;
  24396. };
  24397. }
  24398. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  24399. /** @hidden */
  24400. export var bumpFragment: {
  24401. name: string;
  24402. shader: string;
  24403. };
  24404. }
  24405. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  24406. /** @hidden */
  24407. export var depthPrePass: {
  24408. name: string;
  24409. shader: string;
  24410. };
  24411. }
  24412. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  24413. /** @hidden */
  24414. export var lightFragment: {
  24415. name: string;
  24416. shader: string;
  24417. };
  24418. }
  24419. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  24420. /** @hidden */
  24421. export var logDepthFragment: {
  24422. name: string;
  24423. shader: string;
  24424. };
  24425. }
  24426. declare module "babylonjs/Shaders/default.fragment" {
  24427. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  24428. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24429. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  24430. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24431. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24432. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24433. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  24434. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  24435. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  24436. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  24437. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24438. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24439. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  24440. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  24441. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  24442. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24443. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24444. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  24445. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  24446. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  24447. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  24448. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  24449. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24450. /** @hidden */
  24451. export var defaultPixelShader: {
  24452. name: string;
  24453. shader: string;
  24454. };
  24455. }
  24456. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  24457. /** @hidden */
  24458. export var defaultVertexDeclaration: {
  24459. name: string;
  24460. shader: string;
  24461. };
  24462. }
  24463. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  24464. /** @hidden */
  24465. export var prePassVertexDeclaration: {
  24466. name: string;
  24467. shader: string;
  24468. };
  24469. }
  24470. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  24471. /** @hidden */
  24472. export var bumpVertexDeclaration: {
  24473. name: string;
  24474. shader: string;
  24475. };
  24476. }
  24477. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  24478. /** @hidden */
  24479. export var prePassVertex: {
  24480. name: string;
  24481. shader: string;
  24482. };
  24483. }
  24484. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  24485. /** @hidden */
  24486. export var bumpVertex: {
  24487. name: string;
  24488. shader: string;
  24489. };
  24490. }
  24491. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  24492. /** @hidden */
  24493. export var fogVertex: {
  24494. name: string;
  24495. shader: string;
  24496. };
  24497. }
  24498. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  24499. /** @hidden */
  24500. export var shadowsVertex: {
  24501. name: string;
  24502. shader: string;
  24503. };
  24504. }
  24505. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  24506. /** @hidden */
  24507. export var pointCloudVertex: {
  24508. name: string;
  24509. shader: string;
  24510. };
  24511. }
  24512. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  24513. /** @hidden */
  24514. export var logDepthVertex: {
  24515. name: string;
  24516. shader: string;
  24517. };
  24518. }
  24519. declare module "babylonjs/Shaders/default.vertex" {
  24520. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  24521. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24522. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24523. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  24524. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  24525. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  24526. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  24527. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  24528. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24529. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24530. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24531. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  24532. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  24533. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24534. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  24535. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  24536. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  24537. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  24538. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  24539. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  24540. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  24541. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  24542. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  24543. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  24544. /** @hidden */
  24545. export var defaultVertexShader: {
  24546. name: string;
  24547. shader: string;
  24548. };
  24549. }
  24550. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  24551. import { Nullable } from "babylonjs/types";
  24552. import { Scene } from "babylonjs/scene";
  24553. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24554. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24555. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24556. /**
  24557. * @hidden
  24558. */
  24559. export interface IMaterialDetailMapDefines {
  24560. DETAIL: boolean;
  24561. DETAILDIRECTUV: number;
  24562. DETAIL_NORMALBLENDMETHOD: number;
  24563. /** @hidden */
  24564. _areTexturesDirty: boolean;
  24565. }
  24566. /**
  24567. * Define the code related to the detail map parameters of a material
  24568. *
  24569. * Inspired from:
  24570. * 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
  24571. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  24572. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  24573. */
  24574. export class DetailMapConfiguration {
  24575. private _texture;
  24576. /**
  24577. * The detail texture of the material.
  24578. */
  24579. texture: Nullable<BaseTexture>;
  24580. /**
  24581. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  24582. * Bigger values mean stronger blending
  24583. */
  24584. diffuseBlendLevel: number;
  24585. /**
  24586. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  24587. * Bigger values mean stronger blending. Only used with PBR materials
  24588. */
  24589. roughnessBlendLevel: number;
  24590. /**
  24591. * Defines how strong the bump effect from the detail map is
  24592. * Bigger values mean stronger effect
  24593. */
  24594. bumpLevel: number;
  24595. private _normalBlendMethod;
  24596. /**
  24597. * The method used to blend the bump and detail normals together
  24598. */
  24599. normalBlendMethod: number;
  24600. private _isEnabled;
  24601. /**
  24602. * Enable or disable the detail map on this material
  24603. */
  24604. isEnabled: boolean;
  24605. /** @hidden */
  24606. private _internalMarkAllSubMeshesAsTexturesDirty;
  24607. /** @hidden */
  24608. _markAllSubMeshesAsTexturesDirty(): void;
  24609. /**
  24610. * Instantiate a new detail map
  24611. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24612. */
  24613. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24614. /**
  24615. * Gets whether the submesh is ready to be used or not.
  24616. * @param defines the list of "defines" to update.
  24617. * @param scene defines the scene the material belongs to.
  24618. * @returns - boolean indicating that the submesh is ready or not.
  24619. */
  24620. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  24621. /**
  24622. * Update the defines for detail map usage
  24623. * @param defines the list of "defines" to update.
  24624. * @param scene defines the scene the material belongs to.
  24625. */
  24626. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  24627. /**
  24628. * Binds the material data.
  24629. * @param uniformBuffer defines the Uniform buffer to fill in.
  24630. * @param scene defines the scene the material belongs to.
  24631. * @param isFrozen defines whether the material is frozen or not.
  24632. */
  24633. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24634. /**
  24635. * Checks to see if a texture is used in the material.
  24636. * @param texture - Base texture to use.
  24637. * @returns - Boolean specifying if a texture is used in the material.
  24638. */
  24639. hasTexture(texture: BaseTexture): boolean;
  24640. /**
  24641. * Returns an array of the actively used textures.
  24642. * @param activeTextures Array of BaseTextures
  24643. */
  24644. getActiveTextures(activeTextures: BaseTexture[]): void;
  24645. /**
  24646. * Returns the animatable textures.
  24647. * @param animatables Array of animatable textures.
  24648. */
  24649. getAnimatables(animatables: IAnimatable[]): void;
  24650. /**
  24651. * Disposes the resources of the material.
  24652. * @param forceDisposeTextures - Forces the disposal of all textures.
  24653. */
  24654. dispose(forceDisposeTextures?: boolean): void;
  24655. /**
  24656. * Get the current class name useful for serialization or dynamic coding.
  24657. * @returns "DetailMap"
  24658. */
  24659. getClassName(): string;
  24660. /**
  24661. * Add the required uniforms to the current list.
  24662. * @param uniforms defines the current uniform list.
  24663. */
  24664. static AddUniforms(uniforms: string[]): void;
  24665. /**
  24666. * Add the required samplers to the current list.
  24667. * @param samplers defines the current sampler list.
  24668. */
  24669. static AddSamplers(samplers: string[]): void;
  24670. /**
  24671. * Add the required uniforms to the current buffer.
  24672. * @param uniformBuffer defines the current uniform buffer.
  24673. */
  24674. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24675. /**
  24676. * Makes a duplicate of the current instance into another one.
  24677. * @param detailMap define the instance where to copy the info
  24678. */
  24679. copyTo(detailMap: DetailMapConfiguration): void;
  24680. /**
  24681. * Serializes this detail map instance
  24682. * @returns - An object with the serialized instance.
  24683. */
  24684. serialize(): any;
  24685. /**
  24686. * Parses a detail map setting from a serialized object.
  24687. * @param source - Serialized object.
  24688. * @param scene Defines the scene we are parsing for
  24689. * @param rootUrl Defines the rootUrl to load from
  24690. */
  24691. parse(source: any, scene: Scene, rootUrl: string): void;
  24692. }
  24693. }
  24694. declare module "babylonjs/Materials/standardMaterial" {
  24695. import { SmartArray } from "babylonjs/Misc/smartArray";
  24696. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24697. import { Nullable } from "babylonjs/types";
  24698. import { Scene } from "babylonjs/scene";
  24699. import { Matrix } from "babylonjs/Maths/math.vector";
  24700. import { Color3 } from "babylonjs/Maths/math.color";
  24701. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24703. import { Mesh } from "babylonjs/Meshes/mesh";
  24704. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  24705. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  24706. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24707. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  24708. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24709. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  24710. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24711. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24712. import "babylonjs/Shaders/default.fragment";
  24713. import "babylonjs/Shaders/default.vertex";
  24714. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  24715. /** @hidden */
  24716. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  24717. MAINUV1: boolean;
  24718. MAINUV2: boolean;
  24719. DIFFUSE: boolean;
  24720. DIFFUSEDIRECTUV: number;
  24721. DETAIL: boolean;
  24722. DETAILDIRECTUV: number;
  24723. DETAIL_NORMALBLENDMETHOD: number;
  24724. AMBIENT: boolean;
  24725. AMBIENTDIRECTUV: number;
  24726. OPACITY: boolean;
  24727. OPACITYDIRECTUV: number;
  24728. OPACITYRGB: boolean;
  24729. REFLECTION: boolean;
  24730. EMISSIVE: boolean;
  24731. EMISSIVEDIRECTUV: number;
  24732. SPECULAR: boolean;
  24733. SPECULARDIRECTUV: number;
  24734. BUMP: boolean;
  24735. BUMPDIRECTUV: number;
  24736. PARALLAX: boolean;
  24737. PARALLAXOCCLUSION: boolean;
  24738. SPECULAROVERALPHA: boolean;
  24739. CLIPPLANE: boolean;
  24740. CLIPPLANE2: boolean;
  24741. CLIPPLANE3: boolean;
  24742. CLIPPLANE4: boolean;
  24743. CLIPPLANE5: boolean;
  24744. CLIPPLANE6: boolean;
  24745. ALPHATEST: boolean;
  24746. DEPTHPREPASS: boolean;
  24747. ALPHAFROMDIFFUSE: boolean;
  24748. POINTSIZE: boolean;
  24749. FOG: boolean;
  24750. SPECULARTERM: boolean;
  24751. DIFFUSEFRESNEL: boolean;
  24752. OPACITYFRESNEL: boolean;
  24753. REFLECTIONFRESNEL: boolean;
  24754. REFRACTIONFRESNEL: boolean;
  24755. EMISSIVEFRESNEL: boolean;
  24756. FRESNEL: boolean;
  24757. NORMAL: boolean;
  24758. UV1: boolean;
  24759. UV2: boolean;
  24760. VERTEXCOLOR: boolean;
  24761. VERTEXALPHA: boolean;
  24762. NUM_BONE_INFLUENCERS: number;
  24763. BonesPerMesh: number;
  24764. BONETEXTURE: boolean;
  24765. BONES_VELOCITY_ENABLED: boolean;
  24766. INSTANCES: boolean;
  24767. THIN_INSTANCES: boolean;
  24768. GLOSSINESS: boolean;
  24769. ROUGHNESS: boolean;
  24770. EMISSIVEASILLUMINATION: boolean;
  24771. LINKEMISSIVEWITHDIFFUSE: boolean;
  24772. REFLECTIONFRESNELFROMSPECULAR: boolean;
  24773. LIGHTMAP: boolean;
  24774. LIGHTMAPDIRECTUV: number;
  24775. OBJECTSPACE_NORMALMAP: boolean;
  24776. USELIGHTMAPASSHADOWMAP: boolean;
  24777. REFLECTIONMAP_3D: boolean;
  24778. REFLECTIONMAP_SPHERICAL: boolean;
  24779. REFLECTIONMAP_PLANAR: boolean;
  24780. REFLECTIONMAP_CUBIC: boolean;
  24781. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  24782. REFLECTIONMAP_PROJECTION: boolean;
  24783. REFLECTIONMAP_SKYBOX: boolean;
  24784. REFLECTIONMAP_EXPLICIT: boolean;
  24785. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  24786. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  24787. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  24788. INVERTCUBICMAP: boolean;
  24789. LOGARITHMICDEPTH: boolean;
  24790. REFRACTION: boolean;
  24791. REFRACTIONMAP_3D: boolean;
  24792. REFLECTIONOVERALPHA: boolean;
  24793. TWOSIDEDLIGHTING: boolean;
  24794. SHADOWFLOAT: boolean;
  24795. MORPHTARGETS: boolean;
  24796. MORPHTARGETS_NORMAL: boolean;
  24797. MORPHTARGETS_TANGENT: boolean;
  24798. MORPHTARGETS_UV: boolean;
  24799. NUM_MORPH_INFLUENCERS: number;
  24800. NONUNIFORMSCALING: boolean;
  24801. PREMULTIPLYALPHA: boolean;
  24802. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  24803. ALPHABLEND: boolean;
  24804. PREPASS: boolean;
  24805. PREPASS_IRRADIANCE: boolean;
  24806. PREPASS_IRRADIANCE_INDEX: number;
  24807. PREPASS_ALBEDO: boolean;
  24808. PREPASS_ALBEDO_INDEX: number;
  24809. PREPASS_DEPTHNORMAL: boolean;
  24810. PREPASS_DEPTHNORMAL_INDEX: number;
  24811. PREPASS_POSITION: boolean;
  24812. PREPASS_POSITION_INDEX: number;
  24813. PREPASS_VELOCITY: boolean;
  24814. PREPASS_VELOCITY_INDEX: number;
  24815. PREPASS_REFLECTIVITY: boolean;
  24816. PREPASS_REFLECTIVITY_INDEX: number;
  24817. SCENE_MRT_COUNT: number;
  24818. RGBDLIGHTMAP: boolean;
  24819. RGBDREFLECTION: boolean;
  24820. RGBDREFRACTION: boolean;
  24821. IMAGEPROCESSING: boolean;
  24822. VIGNETTE: boolean;
  24823. VIGNETTEBLENDMODEMULTIPLY: boolean;
  24824. VIGNETTEBLENDMODEOPAQUE: boolean;
  24825. TONEMAPPING: boolean;
  24826. TONEMAPPING_ACES: boolean;
  24827. CONTRAST: boolean;
  24828. COLORCURVES: boolean;
  24829. COLORGRADING: boolean;
  24830. COLORGRADING3D: boolean;
  24831. SAMPLER3DGREENDEPTH: boolean;
  24832. SAMPLER3DBGRMAP: boolean;
  24833. IMAGEPROCESSINGPOSTPROCESS: boolean;
  24834. MULTIVIEW: boolean;
  24835. /**
  24836. * If the reflection texture on this material is in linear color space
  24837. * @hidden
  24838. */
  24839. IS_REFLECTION_LINEAR: boolean;
  24840. /**
  24841. * If the refraction texture on this material is in linear color space
  24842. * @hidden
  24843. */
  24844. IS_REFRACTION_LINEAR: boolean;
  24845. EXPOSURE: boolean;
  24846. constructor();
  24847. setReflectionMode(modeToEnable: string): void;
  24848. }
  24849. /**
  24850. * This is the default material used in Babylon. It is the best trade off between quality
  24851. * and performances.
  24852. * @see https://doc.babylonjs.com/babylon101/materials
  24853. */
  24854. export class StandardMaterial extends PushMaterial {
  24855. private _diffuseTexture;
  24856. /**
  24857. * The basic texture of the material as viewed under a light.
  24858. */
  24859. diffuseTexture: Nullable<BaseTexture>;
  24860. private _ambientTexture;
  24861. /**
  24862. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  24863. */
  24864. ambientTexture: Nullable<BaseTexture>;
  24865. private _opacityTexture;
  24866. /**
  24867. * Define the transparency of the material from a texture.
  24868. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  24869. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  24870. */
  24871. opacityTexture: Nullable<BaseTexture>;
  24872. private _reflectionTexture;
  24873. /**
  24874. * Define the texture used to display the reflection.
  24875. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24876. */
  24877. reflectionTexture: Nullable<BaseTexture>;
  24878. private _emissiveTexture;
  24879. /**
  24880. * Define texture of the material as if self lit.
  24881. * This will be mixed in the final result even in the absence of light.
  24882. */
  24883. emissiveTexture: Nullable<BaseTexture>;
  24884. private _specularTexture;
  24885. /**
  24886. * Define how the color and intensity of the highlight given by the light in the material.
  24887. */
  24888. specularTexture: Nullable<BaseTexture>;
  24889. private _bumpTexture;
  24890. /**
  24891. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  24892. * 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.
  24893. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  24894. */
  24895. bumpTexture: Nullable<BaseTexture>;
  24896. private _lightmapTexture;
  24897. /**
  24898. * Complex lighting can be computationally expensive to compute at runtime.
  24899. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  24900. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  24901. */
  24902. lightmapTexture: Nullable<BaseTexture>;
  24903. private _refractionTexture;
  24904. /**
  24905. * Define the texture used to display the refraction.
  24906. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24907. */
  24908. refractionTexture: Nullable<BaseTexture>;
  24909. /**
  24910. * The color of the material lit by the environmental background lighting.
  24911. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  24912. */
  24913. ambientColor: Color3;
  24914. /**
  24915. * The basic color of the material as viewed under a light.
  24916. */
  24917. diffuseColor: Color3;
  24918. /**
  24919. * Define how the color and intensity of the highlight given by the light in the material.
  24920. */
  24921. specularColor: Color3;
  24922. /**
  24923. * Define the color of the material as if self lit.
  24924. * This will be mixed in the final result even in the absence of light.
  24925. */
  24926. emissiveColor: Color3;
  24927. /**
  24928. * Defines how sharp are the highlights in the material.
  24929. * The bigger the value the sharper giving a more glossy feeling to the result.
  24930. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24931. */
  24932. specularPower: number;
  24933. private _useAlphaFromDiffuseTexture;
  24934. /**
  24935. * Does the transparency come from the diffuse texture alpha channel.
  24936. */
  24937. useAlphaFromDiffuseTexture: boolean;
  24938. private _useEmissiveAsIllumination;
  24939. /**
  24940. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24941. */
  24942. useEmissiveAsIllumination: boolean;
  24943. private _linkEmissiveWithDiffuse;
  24944. /**
  24945. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24946. * the emissive level when the final color is close to one.
  24947. */
  24948. linkEmissiveWithDiffuse: boolean;
  24949. private _useSpecularOverAlpha;
  24950. /**
  24951. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24952. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24953. */
  24954. useSpecularOverAlpha: boolean;
  24955. private _useReflectionOverAlpha;
  24956. /**
  24957. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24958. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24959. */
  24960. useReflectionOverAlpha: boolean;
  24961. private _disableLighting;
  24962. /**
  24963. * Does lights from the scene impacts this material.
  24964. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24965. */
  24966. disableLighting: boolean;
  24967. private _useObjectSpaceNormalMap;
  24968. /**
  24969. * Allows using an object space normal map (instead of tangent space).
  24970. */
  24971. useObjectSpaceNormalMap: boolean;
  24972. private _useParallax;
  24973. /**
  24974. * Is parallax enabled or not.
  24975. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24976. */
  24977. useParallax: boolean;
  24978. private _useParallaxOcclusion;
  24979. /**
  24980. * Is parallax occlusion enabled or not.
  24981. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24982. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24983. */
  24984. useParallaxOcclusion: boolean;
  24985. /**
  24986. * 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.
  24987. */
  24988. parallaxScaleBias: number;
  24989. private _roughness;
  24990. /**
  24991. * Helps to define how blurry the reflections should appears in the material.
  24992. */
  24993. roughness: number;
  24994. /**
  24995. * In case of refraction, define the value of the index of refraction.
  24996. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24997. */
  24998. indexOfRefraction: number;
  24999. /**
  25000. * Invert the refraction texture alongside the y axis.
  25001. * It can be useful with procedural textures or probe for instance.
  25002. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  25003. */
  25004. invertRefractionY: boolean;
  25005. /**
  25006. * Defines the alpha limits in alpha test mode.
  25007. */
  25008. alphaCutOff: number;
  25009. private _useLightmapAsShadowmap;
  25010. /**
  25011. * In case of light mapping, define whether the map contains light or shadow informations.
  25012. */
  25013. useLightmapAsShadowmap: boolean;
  25014. private _diffuseFresnelParameters;
  25015. /**
  25016. * Define the diffuse fresnel parameters of the material.
  25017. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25018. */
  25019. diffuseFresnelParameters: FresnelParameters;
  25020. private _opacityFresnelParameters;
  25021. /**
  25022. * Define the opacity fresnel parameters of the material.
  25023. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25024. */
  25025. opacityFresnelParameters: FresnelParameters;
  25026. private _reflectionFresnelParameters;
  25027. /**
  25028. * Define the reflection fresnel parameters of the material.
  25029. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25030. */
  25031. reflectionFresnelParameters: FresnelParameters;
  25032. private _refractionFresnelParameters;
  25033. /**
  25034. * Define the refraction fresnel parameters of the material.
  25035. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25036. */
  25037. refractionFresnelParameters: FresnelParameters;
  25038. private _emissiveFresnelParameters;
  25039. /**
  25040. * Define the emissive fresnel parameters of the material.
  25041. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25042. */
  25043. emissiveFresnelParameters: FresnelParameters;
  25044. private _useReflectionFresnelFromSpecular;
  25045. /**
  25046. * If true automatically deducts the fresnels values from the material specularity.
  25047. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25048. */
  25049. useReflectionFresnelFromSpecular: boolean;
  25050. private _useGlossinessFromSpecularMapAlpha;
  25051. /**
  25052. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  25053. */
  25054. useGlossinessFromSpecularMapAlpha: boolean;
  25055. private _maxSimultaneousLights;
  25056. /**
  25057. * Defines the maximum number of lights that can be used in the material
  25058. */
  25059. maxSimultaneousLights: number;
  25060. private _invertNormalMapX;
  25061. /**
  25062. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  25063. */
  25064. invertNormalMapX: boolean;
  25065. private _invertNormalMapY;
  25066. /**
  25067. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  25068. */
  25069. invertNormalMapY: boolean;
  25070. private _twoSidedLighting;
  25071. /**
  25072. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25073. */
  25074. twoSidedLighting: boolean;
  25075. /**
  25076. * Default configuration related to image processing available in the standard Material.
  25077. */
  25078. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25079. /**
  25080. * Gets the image processing configuration used either in this material.
  25081. */
  25082. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25083. /**
  25084. * Sets the Default image processing configuration used either in the this material.
  25085. *
  25086. * If sets to null, the scene one is in use.
  25087. */
  25088. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25089. /**
  25090. * Keep track of the image processing observer to allow dispose and replace.
  25091. */
  25092. private _imageProcessingObserver;
  25093. /**
  25094. * Attaches a new image processing configuration to the Standard Material.
  25095. * @param configuration
  25096. */
  25097. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  25098. /**
  25099. * Defines additionnal PrePass parameters for the material.
  25100. */
  25101. readonly prePassConfiguration: PrePassConfiguration;
  25102. /**
  25103. * Gets wether the color curves effect is enabled.
  25104. */
  25105. get cameraColorCurvesEnabled(): boolean;
  25106. /**
  25107. * Sets wether the color curves effect is enabled.
  25108. */
  25109. set cameraColorCurvesEnabled(value: boolean);
  25110. /**
  25111. * Gets wether the color grading effect is enabled.
  25112. */
  25113. get cameraColorGradingEnabled(): boolean;
  25114. /**
  25115. * Gets wether the color grading effect is enabled.
  25116. */
  25117. set cameraColorGradingEnabled(value: boolean);
  25118. /**
  25119. * Gets wether tonemapping is enabled or not.
  25120. */
  25121. get cameraToneMappingEnabled(): boolean;
  25122. /**
  25123. * Sets wether tonemapping is enabled or not
  25124. */
  25125. set cameraToneMappingEnabled(value: boolean);
  25126. /**
  25127. * The camera exposure used on this material.
  25128. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25129. * This corresponds to a photographic exposure.
  25130. */
  25131. get cameraExposure(): number;
  25132. /**
  25133. * The camera exposure used on this material.
  25134. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25135. * This corresponds to a photographic exposure.
  25136. */
  25137. set cameraExposure(value: number);
  25138. /**
  25139. * Gets The camera contrast used on this material.
  25140. */
  25141. get cameraContrast(): number;
  25142. /**
  25143. * Sets The camera contrast used on this material.
  25144. */
  25145. set cameraContrast(value: number);
  25146. /**
  25147. * Gets the Color Grading 2D Lookup Texture.
  25148. */
  25149. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  25150. /**
  25151. * Sets the Color Grading 2D Lookup Texture.
  25152. */
  25153. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  25154. /**
  25155. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25156. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25157. * 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;
  25158. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25159. */
  25160. get cameraColorCurves(): Nullable<ColorCurves>;
  25161. /**
  25162. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25163. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25164. * 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;
  25165. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25166. */
  25167. set cameraColorCurves(value: Nullable<ColorCurves>);
  25168. /**
  25169. * Can this material render to several textures at once
  25170. */
  25171. get canRenderToMRT(): boolean;
  25172. /**
  25173. * Defines the detail map parameters for the material.
  25174. */
  25175. readonly detailMap: DetailMapConfiguration;
  25176. protected _renderTargets: SmartArray<RenderTargetTexture>;
  25177. protected _worldViewProjectionMatrix: Matrix;
  25178. protected _globalAmbientColor: Color3;
  25179. protected _useLogarithmicDepth: boolean;
  25180. protected _rebuildInParallel: boolean;
  25181. /**
  25182. * Instantiates a new standard material.
  25183. * This is the default material used in Babylon. It is the best trade off between quality
  25184. * and performances.
  25185. * @see https://doc.babylonjs.com/babylon101/materials
  25186. * @param name Define the name of the material in the scene
  25187. * @param scene Define the scene the material belong to
  25188. */
  25189. constructor(name: string, scene: Scene);
  25190. /**
  25191. * Gets a boolean indicating that current material needs to register RTT
  25192. */
  25193. get hasRenderTargetTextures(): boolean;
  25194. /**
  25195. * Gets the current class name of the material e.g. "StandardMaterial"
  25196. * Mainly use in serialization.
  25197. * @returns the class name
  25198. */
  25199. getClassName(): string;
  25200. /**
  25201. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  25202. * You can try switching to logarithmic depth.
  25203. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  25204. */
  25205. get useLogarithmicDepth(): boolean;
  25206. set useLogarithmicDepth(value: boolean);
  25207. /**
  25208. * Specifies if the material will require alpha blending
  25209. * @returns a boolean specifying if alpha blending is needed
  25210. */
  25211. needAlphaBlending(): boolean;
  25212. /**
  25213. * Specifies if this material should be rendered in alpha test mode
  25214. * @returns a boolean specifying if an alpha test is needed.
  25215. */
  25216. needAlphaTesting(): boolean;
  25217. /**
  25218. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  25219. */
  25220. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  25221. /**
  25222. * Specifies whether or not there is a usable alpha channel for transparency.
  25223. */
  25224. protected _hasAlphaChannel(): boolean;
  25225. /**
  25226. * Get the texture used for alpha test purpose.
  25227. * @returns the diffuse texture in case of the standard material.
  25228. */
  25229. getAlphaTestTexture(): Nullable<BaseTexture>;
  25230. /**
  25231. * Get if the submesh is ready to be used and all its information available.
  25232. * Child classes can use it to update shaders
  25233. * @param mesh defines the mesh to check
  25234. * @param subMesh defines which submesh to check
  25235. * @param useInstances specifies that instances should be used
  25236. * @returns a boolean indicating that the submesh is ready or not
  25237. */
  25238. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25239. /**
  25240. * Builds the material UBO layouts.
  25241. * Used internally during the effect preparation.
  25242. */
  25243. buildUniformLayout(): void;
  25244. /**
  25245. * Unbinds the material from the mesh
  25246. */
  25247. unbind(): void;
  25248. /**
  25249. * Binds the submesh to this material by preparing the effect and shader to draw
  25250. * @param world defines the world transformation matrix
  25251. * @param mesh defines the mesh containing the submesh
  25252. * @param subMesh defines the submesh to bind the material to
  25253. */
  25254. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25255. /**
  25256. * Get the list of animatables in the material.
  25257. * @returns the list of animatables object used in the material
  25258. */
  25259. getAnimatables(): IAnimatable[];
  25260. /**
  25261. * Gets the active textures from the material
  25262. * @returns an array of textures
  25263. */
  25264. getActiveTextures(): BaseTexture[];
  25265. /**
  25266. * Specifies if the material uses a texture
  25267. * @param texture defines the texture to check against the material
  25268. * @returns a boolean specifying if the material uses the texture
  25269. */
  25270. hasTexture(texture: BaseTexture): boolean;
  25271. /**
  25272. * Disposes the material
  25273. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25274. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25275. */
  25276. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  25277. /**
  25278. * Makes a duplicate of the material, and gives it a new name
  25279. * @param name defines the new name for the duplicated material
  25280. * @returns the cloned material
  25281. */
  25282. clone(name: string): StandardMaterial;
  25283. /**
  25284. * Serializes this material in a JSON representation
  25285. * @returns the serialized material object
  25286. */
  25287. serialize(): any;
  25288. /**
  25289. * Creates a standard material from parsed material data
  25290. * @param source defines the JSON representation of the material
  25291. * @param scene defines the hosting scene
  25292. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25293. * @returns a new standard material
  25294. */
  25295. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  25296. /**
  25297. * Are diffuse textures enabled in the application.
  25298. */
  25299. static get DiffuseTextureEnabled(): boolean;
  25300. static set DiffuseTextureEnabled(value: boolean);
  25301. /**
  25302. * Are detail textures enabled in the application.
  25303. */
  25304. static get DetailTextureEnabled(): boolean;
  25305. static set DetailTextureEnabled(value: boolean);
  25306. /**
  25307. * Are ambient textures enabled in the application.
  25308. */
  25309. static get AmbientTextureEnabled(): boolean;
  25310. static set AmbientTextureEnabled(value: boolean);
  25311. /**
  25312. * Are opacity textures enabled in the application.
  25313. */
  25314. static get OpacityTextureEnabled(): boolean;
  25315. static set OpacityTextureEnabled(value: boolean);
  25316. /**
  25317. * Are reflection textures enabled in the application.
  25318. */
  25319. static get ReflectionTextureEnabled(): boolean;
  25320. static set ReflectionTextureEnabled(value: boolean);
  25321. /**
  25322. * Are emissive textures enabled in the application.
  25323. */
  25324. static get EmissiveTextureEnabled(): boolean;
  25325. static set EmissiveTextureEnabled(value: boolean);
  25326. /**
  25327. * Are specular textures enabled in the application.
  25328. */
  25329. static get SpecularTextureEnabled(): boolean;
  25330. static set SpecularTextureEnabled(value: boolean);
  25331. /**
  25332. * Are bump textures enabled in the application.
  25333. */
  25334. static get BumpTextureEnabled(): boolean;
  25335. static set BumpTextureEnabled(value: boolean);
  25336. /**
  25337. * Are lightmap textures enabled in the application.
  25338. */
  25339. static get LightmapTextureEnabled(): boolean;
  25340. static set LightmapTextureEnabled(value: boolean);
  25341. /**
  25342. * Are refraction textures enabled in the application.
  25343. */
  25344. static get RefractionTextureEnabled(): boolean;
  25345. static set RefractionTextureEnabled(value: boolean);
  25346. /**
  25347. * Are color grading textures enabled in the application.
  25348. */
  25349. static get ColorGradingTextureEnabled(): boolean;
  25350. static set ColorGradingTextureEnabled(value: boolean);
  25351. /**
  25352. * Are fresnels enabled in the application.
  25353. */
  25354. static get FresnelEnabled(): boolean;
  25355. static set FresnelEnabled(value: boolean);
  25356. }
  25357. }
  25358. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  25359. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25360. /** @hidden */
  25361. export var rgbdDecodePixelShader: {
  25362. name: string;
  25363. shader: string;
  25364. };
  25365. }
  25366. declare module "babylonjs/Misc/rgbdTextureTools" {
  25367. import "babylonjs/Shaders/rgbdDecode.fragment";
  25368. import "babylonjs/Engines/Extensions/engine.renderTarget";
  25369. import { Texture } from "babylonjs/Materials/Textures/texture";
  25370. /**
  25371. * Class used to host RGBD texture specific utilities
  25372. */
  25373. export class RGBDTextureTools {
  25374. /**
  25375. * Expand the RGBD Texture from RGBD to Half Float if possible.
  25376. * @param texture the texture to expand.
  25377. */
  25378. static ExpandRGBDTexture(texture: Texture): void;
  25379. }
  25380. }
  25381. declare module "babylonjs/Misc/brdfTextureTools" {
  25382. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25383. import { Scene } from "babylonjs/scene";
  25384. /**
  25385. * Class used to host texture specific utilities
  25386. */
  25387. export class BRDFTextureTools {
  25388. /**
  25389. * Prevents texture cache collision
  25390. */
  25391. private static _instanceNumber;
  25392. /**
  25393. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  25394. * @param scene defines the hosting scene
  25395. * @returns the environment BRDF texture
  25396. */
  25397. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  25398. private static _environmentBRDFBase64Texture;
  25399. }
  25400. }
  25401. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  25402. import { Nullable } from "babylonjs/types";
  25403. import { Color3 } from "babylonjs/Maths/math.color";
  25404. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25405. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25406. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25407. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25408. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25409. import { Engine } from "babylonjs/Engines/engine";
  25410. import { Scene } from "babylonjs/scene";
  25411. /**
  25412. * @hidden
  25413. */
  25414. export interface IMaterialClearCoatDefines {
  25415. CLEARCOAT: boolean;
  25416. CLEARCOAT_DEFAULTIOR: boolean;
  25417. CLEARCOAT_TEXTURE: boolean;
  25418. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  25419. CLEARCOAT_TEXTUREDIRECTUV: number;
  25420. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  25421. CLEARCOAT_BUMP: boolean;
  25422. CLEARCOAT_BUMPDIRECTUV: number;
  25423. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25424. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25425. CLEARCOAT_REMAP_F0: boolean;
  25426. CLEARCOAT_TINT: boolean;
  25427. CLEARCOAT_TINT_TEXTURE: boolean;
  25428. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  25429. /** @hidden */
  25430. _areTexturesDirty: boolean;
  25431. }
  25432. /**
  25433. * Define the code related to the clear coat parameters of the pbr material.
  25434. */
  25435. export class PBRClearCoatConfiguration {
  25436. /**
  25437. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25438. * The default fits with a polyurethane material.
  25439. */
  25440. private static readonly _DefaultIndexOfRefraction;
  25441. private _isEnabled;
  25442. /**
  25443. * Defines if the clear coat is enabled in the material.
  25444. */
  25445. isEnabled: boolean;
  25446. /**
  25447. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  25448. */
  25449. intensity: number;
  25450. /**
  25451. * Defines the clear coat layer roughness.
  25452. */
  25453. roughness: number;
  25454. private _indexOfRefraction;
  25455. /**
  25456. * Defines the index of refraction of the clear coat.
  25457. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25458. * The default fits with a polyurethane material.
  25459. * Changing the default value is more performance intensive.
  25460. */
  25461. indexOfRefraction: number;
  25462. private _texture;
  25463. /**
  25464. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  25465. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  25466. * if textureRoughness is not empty, else no texture roughness is used
  25467. */
  25468. texture: Nullable<BaseTexture>;
  25469. private _useRoughnessFromMainTexture;
  25470. /**
  25471. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  25472. * If false, the green channel from textureRoughness is used for roughness
  25473. */
  25474. useRoughnessFromMainTexture: boolean;
  25475. private _textureRoughness;
  25476. /**
  25477. * Stores the clear coat roughness in a texture (green channel)
  25478. * Not used if useRoughnessFromMainTexture is true
  25479. */
  25480. textureRoughness: Nullable<BaseTexture>;
  25481. private _remapF0OnInterfaceChange;
  25482. /**
  25483. * Defines if the F0 value should be remapped to account for the interface change in the material.
  25484. */
  25485. remapF0OnInterfaceChange: boolean;
  25486. private _bumpTexture;
  25487. /**
  25488. * Define the clear coat specific bump texture.
  25489. */
  25490. bumpTexture: Nullable<BaseTexture>;
  25491. private _isTintEnabled;
  25492. /**
  25493. * Defines if the clear coat tint is enabled in the material.
  25494. */
  25495. isTintEnabled: boolean;
  25496. /**
  25497. * Defines the clear coat tint of the material.
  25498. * This is only use if tint is enabled
  25499. */
  25500. tintColor: Color3;
  25501. /**
  25502. * Defines the distance at which the tint color should be found in the
  25503. * clear coat media.
  25504. * This is only use if tint is enabled
  25505. */
  25506. tintColorAtDistance: number;
  25507. /**
  25508. * Defines the clear coat layer thickness.
  25509. * This is only use if tint is enabled
  25510. */
  25511. tintThickness: number;
  25512. private _tintTexture;
  25513. /**
  25514. * Stores the clear tint values in a texture.
  25515. * rgb is tint
  25516. * a is a thickness factor
  25517. */
  25518. tintTexture: Nullable<BaseTexture>;
  25519. /** @hidden */
  25520. private _internalMarkAllSubMeshesAsTexturesDirty;
  25521. /** @hidden */
  25522. _markAllSubMeshesAsTexturesDirty(): void;
  25523. /**
  25524. * Instantiate a new istance of clear coat configuration.
  25525. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25526. */
  25527. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25528. /**
  25529. * Gets wehter the submesh is ready to be used or not.
  25530. * @param defines the list of "defines" to update.
  25531. * @param scene defines the scene the material belongs to.
  25532. * @param engine defines the engine the material belongs to.
  25533. * @param disableBumpMap defines wether the material disables bump or not.
  25534. * @returns - boolean indicating that the submesh is ready or not.
  25535. */
  25536. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  25537. /**
  25538. * Checks to see if a texture is used in the material.
  25539. * @param defines the list of "defines" to update.
  25540. * @param scene defines the scene to the material belongs to.
  25541. */
  25542. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  25543. /**
  25544. * Binds the material data.
  25545. * @param uniformBuffer defines the Uniform buffer to fill in.
  25546. * @param scene defines the scene the material belongs to.
  25547. * @param engine defines the engine the material belongs to.
  25548. * @param disableBumpMap defines wether the material disables bump or not.
  25549. * @param isFrozen defines wether the material is frozen or not.
  25550. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  25551. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  25552. * @param subMesh the submesh to bind data for
  25553. */
  25554. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  25555. /**
  25556. * Checks to see if a texture is used in the material.
  25557. * @param texture - Base texture to use.
  25558. * @returns - Boolean specifying if a texture is used in the material.
  25559. */
  25560. hasTexture(texture: BaseTexture): boolean;
  25561. /**
  25562. * Returns an array of the actively used textures.
  25563. * @param activeTextures Array of BaseTextures
  25564. */
  25565. getActiveTextures(activeTextures: BaseTexture[]): void;
  25566. /**
  25567. * Returns the animatable textures.
  25568. * @param animatables Array of animatable textures.
  25569. */
  25570. getAnimatables(animatables: IAnimatable[]): void;
  25571. /**
  25572. * Disposes the resources of the material.
  25573. * @param forceDisposeTextures - Forces the disposal of all textures.
  25574. */
  25575. dispose(forceDisposeTextures?: boolean): void;
  25576. /**
  25577. * Get the current class name of the texture useful for serialization or dynamic coding.
  25578. * @returns "PBRClearCoatConfiguration"
  25579. */
  25580. getClassName(): string;
  25581. /**
  25582. * Add fallbacks to the effect fallbacks list.
  25583. * @param defines defines the Base texture to use.
  25584. * @param fallbacks defines the current fallback list.
  25585. * @param currentRank defines the current fallback rank.
  25586. * @returns the new fallback rank.
  25587. */
  25588. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25589. /**
  25590. * Add the required uniforms to the current list.
  25591. * @param uniforms defines the current uniform list.
  25592. */
  25593. static AddUniforms(uniforms: string[]): void;
  25594. /**
  25595. * Add the required samplers to the current list.
  25596. * @param samplers defines the current sampler list.
  25597. */
  25598. static AddSamplers(samplers: string[]): void;
  25599. /**
  25600. * Add the required uniforms to the current buffer.
  25601. * @param uniformBuffer defines the current uniform buffer.
  25602. */
  25603. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25604. /**
  25605. * Makes a duplicate of the current configuration into another one.
  25606. * @param clearCoatConfiguration define the config where to copy the info
  25607. */
  25608. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  25609. /**
  25610. * Serializes this clear coat configuration.
  25611. * @returns - An object with the serialized config.
  25612. */
  25613. serialize(): any;
  25614. /**
  25615. * Parses a anisotropy Configuration from a serialized object.
  25616. * @param source - Serialized object.
  25617. * @param scene Defines the scene we are parsing for
  25618. * @param rootUrl Defines the rootUrl to load from
  25619. */
  25620. parse(source: any, scene: Scene, rootUrl: string): void;
  25621. }
  25622. }
  25623. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  25624. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25626. import { Vector2 } from "babylonjs/Maths/math.vector";
  25627. import { Scene } from "babylonjs/scene";
  25628. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25629. import { Nullable } from "babylonjs/types";
  25630. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25631. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25632. /**
  25633. * @hidden
  25634. */
  25635. export interface IMaterialAnisotropicDefines {
  25636. ANISOTROPIC: boolean;
  25637. ANISOTROPIC_TEXTURE: boolean;
  25638. ANISOTROPIC_TEXTUREDIRECTUV: number;
  25639. MAINUV1: boolean;
  25640. _areTexturesDirty: boolean;
  25641. _needUVs: boolean;
  25642. }
  25643. /**
  25644. * Define the code related to the anisotropic parameters of the pbr material.
  25645. */
  25646. export class PBRAnisotropicConfiguration {
  25647. private _isEnabled;
  25648. /**
  25649. * Defines if the anisotropy is enabled in the material.
  25650. */
  25651. isEnabled: boolean;
  25652. /**
  25653. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  25654. */
  25655. intensity: number;
  25656. /**
  25657. * Defines if the effect is along the tangents, bitangents or in between.
  25658. * By default, the effect is "strectching" the highlights along the tangents.
  25659. */
  25660. direction: Vector2;
  25661. private _texture;
  25662. /**
  25663. * Stores the anisotropy values in a texture.
  25664. * rg is direction (like normal from -1 to 1)
  25665. * b is a intensity
  25666. */
  25667. texture: Nullable<BaseTexture>;
  25668. /** @hidden */
  25669. private _internalMarkAllSubMeshesAsTexturesDirty;
  25670. /** @hidden */
  25671. _markAllSubMeshesAsTexturesDirty(): void;
  25672. /**
  25673. * Instantiate a new istance of anisotropy configuration.
  25674. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25675. */
  25676. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25677. /**
  25678. * Specifies that the submesh is ready to be used.
  25679. * @param defines the list of "defines" to update.
  25680. * @param scene defines the scene the material belongs to.
  25681. * @returns - boolean indicating that the submesh is ready or not.
  25682. */
  25683. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  25684. /**
  25685. * Checks to see if a texture is used in the material.
  25686. * @param defines the list of "defines" to update.
  25687. * @param mesh the mesh we are preparing the defines for.
  25688. * @param scene defines the scene the material belongs to.
  25689. */
  25690. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  25691. /**
  25692. * Binds the material data.
  25693. * @param uniformBuffer defines the Uniform buffer to fill in.
  25694. * @param scene defines the scene the material belongs to.
  25695. * @param isFrozen defines wether the material is frozen or not.
  25696. */
  25697. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25698. /**
  25699. * Checks to see if a texture is used in the material.
  25700. * @param texture - Base texture to use.
  25701. * @returns - Boolean specifying if a texture is used in the material.
  25702. */
  25703. hasTexture(texture: BaseTexture): boolean;
  25704. /**
  25705. * Returns an array of the actively used textures.
  25706. * @param activeTextures Array of BaseTextures
  25707. */
  25708. getActiveTextures(activeTextures: BaseTexture[]): void;
  25709. /**
  25710. * Returns the animatable textures.
  25711. * @param animatables Array of animatable textures.
  25712. */
  25713. getAnimatables(animatables: IAnimatable[]): void;
  25714. /**
  25715. * Disposes the resources of the material.
  25716. * @param forceDisposeTextures - Forces the disposal of all textures.
  25717. */
  25718. dispose(forceDisposeTextures?: boolean): void;
  25719. /**
  25720. * Get the current class name of the texture useful for serialization or dynamic coding.
  25721. * @returns "PBRAnisotropicConfiguration"
  25722. */
  25723. getClassName(): string;
  25724. /**
  25725. * Add fallbacks to the effect fallbacks list.
  25726. * @param defines defines the Base texture to use.
  25727. * @param fallbacks defines the current fallback list.
  25728. * @param currentRank defines the current fallback rank.
  25729. * @returns the new fallback rank.
  25730. */
  25731. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25732. /**
  25733. * Add the required uniforms to the current list.
  25734. * @param uniforms defines the current uniform list.
  25735. */
  25736. static AddUniforms(uniforms: string[]): void;
  25737. /**
  25738. * Add the required uniforms to the current buffer.
  25739. * @param uniformBuffer defines the current uniform buffer.
  25740. */
  25741. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25742. /**
  25743. * Add the required samplers to the current list.
  25744. * @param samplers defines the current sampler list.
  25745. */
  25746. static AddSamplers(samplers: string[]): void;
  25747. /**
  25748. * Makes a duplicate of the current configuration into another one.
  25749. * @param anisotropicConfiguration define the config where to copy the info
  25750. */
  25751. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  25752. /**
  25753. * Serializes this anisotropy configuration.
  25754. * @returns - An object with the serialized config.
  25755. */
  25756. serialize(): any;
  25757. /**
  25758. * Parses a anisotropy Configuration from a serialized object.
  25759. * @param source - Serialized object.
  25760. * @param scene Defines the scene we are parsing for
  25761. * @param rootUrl Defines the rootUrl to load from
  25762. */
  25763. parse(source: any, scene: Scene, rootUrl: string): void;
  25764. }
  25765. }
  25766. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  25767. import { Scene } from "babylonjs/scene";
  25768. /**
  25769. * @hidden
  25770. */
  25771. export interface IMaterialBRDFDefines {
  25772. BRDF_V_HEIGHT_CORRELATED: boolean;
  25773. MS_BRDF_ENERGY_CONSERVATION: boolean;
  25774. SPHERICAL_HARMONICS: boolean;
  25775. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  25776. /** @hidden */
  25777. _areMiscDirty: boolean;
  25778. }
  25779. /**
  25780. * Define the code related to the BRDF parameters of the pbr material.
  25781. */
  25782. export class PBRBRDFConfiguration {
  25783. /**
  25784. * Default value used for the energy conservation.
  25785. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25786. */
  25787. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  25788. /**
  25789. * Default value used for the Smith Visibility Height Correlated mode.
  25790. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25791. */
  25792. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  25793. /**
  25794. * Default value used for the IBL diffuse part.
  25795. * This can help switching back to the polynomials mode globally which is a tiny bit
  25796. * less GPU intensive at the drawback of a lower quality.
  25797. */
  25798. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  25799. /**
  25800. * Default value used for activating energy conservation for the specular workflow.
  25801. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25802. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25803. */
  25804. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  25805. private _useEnergyConservation;
  25806. /**
  25807. * Defines if the material uses energy conservation.
  25808. */
  25809. useEnergyConservation: boolean;
  25810. private _useSmithVisibilityHeightCorrelated;
  25811. /**
  25812. * LEGACY Mode set to false
  25813. * Defines if the material uses height smith correlated visibility term.
  25814. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  25815. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  25816. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  25817. * Not relying on height correlated will also disable energy conservation.
  25818. */
  25819. useSmithVisibilityHeightCorrelated: boolean;
  25820. private _useSphericalHarmonics;
  25821. /**
  25822. * LEGACY Mode set to false
  25823. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  25824. * diffuse part of the IBL.
  25825. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  25826. * to the ground truth.
  25827. */
  25828. useSphericalHarmonics: boolean;
  25829. private _useSpecularGlossinessInputEnergyConservation;
  25830. /**
  25831. * Defines if the material uses energy conservation, when the specular workflow is active.
  25832. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25833. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25834. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  25835. */
  25836. useSpecularGlossinessInputEnergyConservation: boolean;
  25837. /** @hidden */
  25838. private _internalMarkAllSubMeshesAsMiscDirty;
  25839. /** @hidden */
  25840. _markAllSubMeshesAsMiscDirty(): void;
  25841. /**
  25842. * Instantiate a new istance of clear coat configuration.
  25843. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  25844. */
  25845. constructor(markAllSubMeshesAsMiscDirty: () => void);
  25846. /**
  25847. * Checks to see if a texture is used in the material.
  25848. * @param defines the list of "defines" to update.
  25849. */
  25850. prepareDefines(defines: IMaterialBRDFDefines): void;
  25851. /**
  25852. * Get the current class name of the texture useful for serialization or dynamic coding.
  25853. * @returns "PBRClearCoatConfiguration"
  25854. */
  25855. getClassName(): string;
  25856. /**
  25857. * Makes a duplicate of the current configuration into another one.
  25858. * @param brdfConfiguration define the config where to copy the info
  25859. */
  25860. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  25861. /**
  25862. * Serializes this BRDF configuration.
  25863. * @returns - An object with the serialized config.
  25864. */
  25865. serialize(): any;
  25866. /**
  25867. * Parses a anisotropy Configuration from a serialized object.
  25868. * @param source - Serialized object.
  25869. * @param scene Defines the scene we are parsing for
  25870. * @param rootUrl Defines the rootUrl to load from
  25871. */
  25872. parse(source: any, scene: Scene, rootUrl: string): void;
  25873. }
  25874. }
  25875. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  25876. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25877. import { Color3 } from "babylonjs/Maths/math.color";
  25878. import { Scene } from "babylonjs/scene";
  25879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25880. import { Nullable } from "babylonjs/types";
  25881. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25882. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25883. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25884. /**
  25885. * @hidden
  25886. */
  25887. export interface IMaterialSheenDefines {
  25888. SHEEN: boolean;
  25889. SHEEN_TEXTURE: boolean;
  25890. SHEEN_TEXTURE_ROUGHNESS: boolean;
  25891. SHEEN_TEXTUREDIRECTUV: number;
  25892. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  25893. SHEEN_LINKWITHALBEDO: boolean;
  25894. SHEEN_ROUGHNESS: boolean;
  25895. SHEEN_ALBEDOSCALING: boolean;
  25896. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25897. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25898. /** @hidden */
  25899. _areTexturesDirty: boolean;
  25900. }
  25901. /**
  25902. * Define the code related to the Sheen parameters of the pbr material.
  25903. */
  25904. export class PBRSheenConfiguration {
  25905. private _isEnabled;
  25906. /**
  25907. * Defines if the material uses sheen.
  25908. */
  25909. isEnabled: boolean;
  25910. private _linkSheenWithAlbedo;
  25911. /**
  25912. * Defines if the sheen is linked to the sheen color.
  25913. */
  25914. linkSheenWithAlbedo: boolean;
  25915. /**
  25916. * Defines the sheen intensity.
  25917. */
  25918. intensity: number;
  25919. /**
  25920. * Defines the sheen color.
  25921. */
  25922. color: Color3;
  25923. private _texture;
  25924. /**
  25925. * Stores the sheen tint values in a texture.
  25926. * rgb is tint
  25927. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  25928. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  25929. */
  25930. texture: Nullable<BaseTexture>;
  25931. private _useRoughnessFromMainTexture;
  25932. /**
  25933. * Indicates that the alpha channel of the texture property will be used for roughness.
  25934. * Has no effect if the roughness (and texture!) property is not defined
  25935. */
  25936. useRoughnessFromMainTexture: boolean;
  25937. private _roughness;
  25938. /**
  25939. * Defines the sheen roughness.
  25940. * It is not taken into account if linkSheenWithAlbedo is true.
  25941. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  25942. */
  25943. roughness: Nullable<number>;
  25944. private _textureRoughness;
  25945. /**
  25946. * Stores the sheen roughness in a texture.
  25947. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  25948. */
  25949. textureRoughness: Nullable<BaseTexture>;
  25950. private _albedoScaling;
  25951. /**
  25952. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  25953. * It allows the strength of the sheen effect to not depend on the base color of the material,
  25954. * making it easier to setup and tweak the effect
  25955. */
  25956. albedoScaling: boolean;
  25957. /** @hidden */
  25958. private _internalMarkAllSubMeshesAsTexturesDirty;
  25959. /** @hidden */
  25960. _markAllSubMeshesAsTexturesDirty(): void;
  25961. /**
  25962. * Instantiate a new istance of clear coat configuration.
  25963. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25964. */
  25965. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25966. /**
  25967. * Specifies that the submesh is ready to be used.
  25968. * @param defines the list of "defines" to update.
  25969. * @param scene defines the scene the material belongs to.
  25970. * @returns - boolean indicating that the submesh is ready or not.
  25971. */
  25972. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  25973. /**
  25974. * Checks to see if a texture is used in the material.
  25975. * @param defines the list of "defines" to update.
  25976. * @param scene defines the scene the material belongs to.
  25977. */
  25978. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  25979. /**
  25980. * Binds the material data.
  25981. * @param uniformBuffer defines the Uniform buffer to fill in.
  25982. * @param scene defines the scene the material belongs to.
  25983. * @param isFrozen defines wether the material is frozen or not.
  25984. * @param subMesh the submesh to bind data for
  25985. */
  25986. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  25987. /**
  25988. * Checks to see if a texture is used in the material.
  25989. * @param texture - Base texture to use.
  25990. * @returns - Boolean specifying if a texture is used in the material.
  25991. */
  25992. hasTexture(texture: BaseTexture): boolean;
  25993. /**
  25994. * Returns an array of the actively used textures.
  25995. * @param activeTextures Array of BaseTextures
  25996. */
  25997. getActiveTextures(activeTextures: BaseTexture[]): void;
  25998. /**
  25999. * Returns the animatable textures.
  26000. * @param animatables Array of animatable textures.
  26001. */
  26002. getAnimatables(animatables: IAnimatable[]): void;
  26003. /**
  26004. * Disposes the resources of the material.
  26005. * @param forceDisposeTextures - Forces the disposal of all textures.
  26006. */
  26007. dispose(forceDisposeTextures?: boolean): void;
  26008. /**
  26009. * Get the current class name of the texture useful for serialization or dynamic coding.
  26010. * @returns "PBRSheenConfiguration"
  26011. */
  26012. getClassName(): string;
  26013. /**
  26014. * Add fallbacks to the effect fallbacks list.
  26015. * @param defines defines the Base texture to use.
  26016. * @param fallbacks defines the current fallback list.
  26017. * @param currentRank defines the current fallback rank.
  26018. * @returns the new fallback rank.
  26019. */
  26020. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26021. /**
  26022. * Add the required uniforms to the current list.
  26023. * @param uniforms defines the current uniform list.
  26024. */
  26025. static AddUniforms(uniforms: string[]): void;
  26026. /**
  26027. * Add the required uniforms to the current buffer.
  26028. * @param uniformBuffer defines the current uniform buffer.
  26029. */
  26030. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26031. /**
  26032. * Add the required samplers to the current list.
  26033. * @param samplers defines the current sampler list.
  26034. */
  26035. static AddSamplers(samplers: string[]): void;
  26036. /**
  26037. * Makes a duplicate of the current configuration into another one.
  26038. * @param sheenConfiguration define the config where to copy the info
  26039. */
  26040. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  26041. /**
  26042. * Serializes this BRDF configuration.
  26043. * @returns - An object with the serialized config.
  26044. */
  26045. serialize(): any;
  26046. /**
  26047. * Parses a anisotropy Configuration from a serialized object.
  26048. * @param source - Serialized object.
  26049. * @param scene Defines the scene we are parsing for
  26050. * @param rootUrl Defines the rootUrl to load from
  26051. */
  26052. parse(source: any, scene: Scene, rootUrl: string): void;
  26053. }
  26054. }
  26055. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  26056. import { Nullable } from "babylonjs/types";
  26057. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26058. import { Color3 } from "babylonjs/Maths/math.color";
  26059. import { SmartArray } from "babylonjs/Misc/smartArray";
  26060. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26061. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26062. import { Effect } from "babylonjs/Materials/effect";
  26063. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26064. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  26065. import { Engine } from "babylonjs/Engines/engine";
  26066. import { Scene } from "babylonjs/scene";
  26067. /**
  26068. * @hidden
  26069. */
  26070. export interface IMaterialSubSurfaceDefines {
  26071. SUBSURFACE: boolean;
  26072. SS_REFRACTION: boolean;
  26073. SS_TRANSLUCENCY: boolean;
  26074. SS_SCATTERING: boolean;
  26075. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26076. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26077. SS_REFRACTIONMAP_3D: boolean;
  26078. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26079. SS_LODINREFRACTIONALPHA: boolean;
  26080. SS_GAMMAREFRACTION: boolean;
  26081. SS_RGBDREFRACTION: boolean;
  26082. SS_LINEARSPECULARREFRACTION: boolean;
  26083. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26084. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26085. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26086. /** @hidden */
  26087. _areTexturesDirty: boolean;
  26088. }
  26089. /**
  26090. * Define the code related to the sub surface parameters of the pbr material.
  26091. */
  26092. export class PBRSubSurfaceConfiguration {
  26093. private _isRefractionEnabled;
  26094. /**
  26095. * Defines if the refraction is enabled in the material.
  26096. */
  26097. isRefractionEnabled: boolean;
  26098. private _isTranslucencyEnabled;
  26099. /**
  26100. * Defines if the translucency is enabled in the material.
  26101. */
  26102. isTranslucencyEnabled: boolean;
  26103. private _isScatteringEnabled;
  26104. /**
  26105. * Defines if the sub surface scattering is enabled in the material.
  26106. */
  26107. isScatteringEnabled: boolean;
  26108. private _scatteringDiffusionProfileIndex;
  26109. /**
  26110. * Diffusion profile for subsurface scattering.
  26111. * Useful for better scattering in the skins or foliages.
  26112. */
  26113. get scatteringDiffusionProfile(): Nullable<Color3>;
  26114. set scatteringDiffusionProfile(c: Nullable<Color3>);
  26115. /**
  26116. * Defines the refraction intensity of the material.
  26117. * The refraction when enabled replaces the Diffuse part of the material.
  26118. * The intensity helps transitionning between diffuse and refraction.
  26119. */
  26120. refractionIntensity: number;
  26121. /**
  26122. * Defines the translucency intensity of the material.
  26123. * When translucency has been enabled, this defines how much of the "translucency"
  26124. * is addded to the diffuse part of the material.
  26125. */
  26126. translucencyIntensity: number;
  26127. /**
  26128. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  26129. */
  26130. useAlbedoToTintRefraction: boolean;
  26131. private _thicknessTexture;
  26132. /**
  26133. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  26134. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  26135. * 0 would mean minimumThickness
  26136. * 1 would mean maximumThickness
  26137. * The other channels might be use as a mask to vary the different effects intensity.
  26138. */
  26139. thicknessTexture: Nullable<BaseTexture>;
  26140. private _refractionTexture;
  26141. /**
  26142. * Defines the texture to use for refraction.
  26143. */
  26144. refractionTexture: Nullable<BaseTexture>;
  26145. private _indexOfRefraction;
  26146. /**
  26147. * Index of refraction of the material base layer.
  26148. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26149. *
  26150. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  26151. *
  26152. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  26153. */
  26154. indexOfRefraction: number;
  26155. private _volumeIndexOfRefraction;
  26156. /**
  26157. * Index of refraction of the material's volume.
  26158. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26159. *
  26160. * This ONLY impacts refraction. If not provided or given a non-valid value,
  26161. * the volume will use the same IOR as the surface.
  26162. */
  26163. get volumeIndexOfRefraction(): number;
  26164. set volumeIndexOfRefraction(value: number);
  26165. private _invertRefractionY;
  26166. /**
  26167. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  26168. */
  26169. invertRefractionY: boolean;
  26170. private _linkRefractionWithTransparency;
  26171. /**
  26172. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26173. * Materials half opaque for instance using refraction could benefit from this control.
  26174. */
  26175. linkRefractionWithTransparency: boolean;
  26176. /**
  26177. * Defines the minimum thickness stored in the thickness map.
  26178. * If no thickness map is defined, this value will be used to simulate thickness.
  26179. */
  26180. minimumThickness: number;
  26181. /**
  26182. * Defines the maximum thickness stored in the thickness map.
  26183. */
  26184. maximumThickness: number;
  26185. /**
  26186. * Defines the volume tint of the material.
  26187. * This is used for both translucency and scattering.
  26188. */
  26189. tintColor: Color3;
  26190. /**
  26191. * Defines the distance at which the tint color should be found in the media.
  26192. * This is used for refraction only.
  26193. */
  26194. tintColorAtDistance: number;
  26195. /**
  26196. * Defines how far each channel transmit through the media.
  26197. * It is defined as a color to simplify it selection.
  26198. */
  26199. diffusionDistance: Color3;
  26200. private _useMaskFromThicknessTexture;
  26201. /**
  26202. * Stores the intensity of the different subsurface effects in the thickness texture.
  26203. * * the green channel is the translucency intensity.
  26204. * * the blue channel is the scattering intensity.
  26205. * * the alpha channel is the refraction intensity.
  26206. */
  26207. useMaskFromThicknessTexture: boolean;
  26208. private _scene;
  26209. /** @hidden */
  26210. private _internalMarkAllSubMeshesAsTexturesDirty;
  26211. private _internalMarkScenePrePassDirty;
  26212. /** @hidden */
  26213. _markAllSubMeshesAsTexturesDirty(): void;
  26214. /** @hidden */
  26215. _markScenePrePassDirty(): void;
  26216. /**
  26217. * Instantiate a new istance of sub surface configuration.
  26218. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  26219. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  26220. * @param scene The scene
  26221. */
  26222. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  26223. /**
  26224. * Gets wehter the submesh is ready to be used or not.
  26225. * @param defines the list of "defines" to update.
  26226. * @param scene defines the scene the material belongs to.
  26227. * @returns - boolean indicating that the submesh is ready or not.
  26228. */
  26229. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  26230. /**
  26231. * Checks to see if a texture is used in the material.
  26232. * @param defines the list of "defines" to update.
  26233. * @param scene defines the scene to the material belongs to.
  26234. */
  26235. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  26236. /**
  26237. * Binds the material data.
  26238. * @param uniformBuffer defines the Uniform buffer to fill in.
  26239. * @param scene defines the scene the material belongs to.
  26240. * @param engine defines the engine the material belongs to.
  26241. * @param isFrozen defines whether the material is frozen or not.
  26242. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  26243. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  26244. */
  26245. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  26246. /**
  26247. * Unbinds the material from the mesh.
  26248. * @param activeEffect defines the effect that should be unbound from.
  26249. * @returns true if unbound, otherwise false
  26250. */
  26251. unbind(activeEffect: Effect): boolean;
  26252. /**
  26253. * Returns the texture used for refraction or null if none is used.
  26254. * @param scene defines the scene the material belongs to.
  26255. * @returns - Refraction texture if present. If no refraction texture and refraction
  26256. * is linked with transparency, returns environment texture. Otherwise, returns null.
  26257. */
  26258. private _getRefractionTexture;
  26259. /**
  26260. * Returns true if alpha blending should be disabled.
  26261. */
  26262. get disableAlphaBlending(): boolean;
  26263. /**
  26264. * Fills the list of render target textures.
  26265. * @param renderTargets the list of render targets to update
  26266. */
  26267. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  26268. /**
  26269. * Checks to see if a texture is used in the material.
  26270. * @param texture - Base texture to use.
  26271. * @returns - Boolean specifying if a texture is used in the material.
  26272. */
  26273. hasTexture(texture: BaseTexture): boolean;
  26274. /**
  26275. * Gets a boolean indicating that current material needs to register RTT
  26276. * @returns true if this uses a render target otherwise false.
  26277. */
  26278. hasRenderTargetTextures(): boolean;
  26279. /**
  26280. * Returns an array of the actively used textures.
  26281. * @param activeTextures Array of BaseTextures
  26282. */
  26283. getActiveTextures(activeTextures: BaseTexture[]): void;
  26284. /**
  26285. * Returns the animatable textures.
  26286. * @param animatables Array of animatable textures.
  26287. */
  26288. getAnimatables(animatables: IAnimatable[]): void;
  26289. /**
  26290. * Disposes the resources of the material.
  26291. * @param forceDisposeTextures - Forces the disposal of all textures.
  26292. */
  26293. dispose(forceDisposeTextures?: boolean): void;
  26294. /**
  26295. * Get the current class name of the texture useful for serialization or dynamic coding.
  26296. * @returns "PBRSubSurfaceConfiguration"
  26297. */
  26298. getClassName(): string;
  26299. /**
  26300. * Add fallbacks to the effect fallbacks list.
  26301. * @param defines defines the Base texture to use.
  26302. * @param fallbacks defines the current fallback list.
  26303. * @param currentRank defines the current fallback rank.
  26304. * @returns the new fallback rank.
  26305. */
  26306. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26307. /**
  26308. * Add the required uniforms to the current list.
  26309. * @param uniforms defines the current uniform list.
  26310. */
  26311. static AddUniforms(uniforms: string[]): void;
  26312. /**
  26313. * Add the required samplers to the current list.
  26314. * @param samplers defines the current sampler list.
  26315. */
  26316. static AddSamplers(samplers: string[]): void;
  26317. /**
  26318. * Add the required uniforms to the current buffer.
  26319. * @param uniformBuffer defines the current uniform buffer.
  26320. */
  26321. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26322. /**
  26323. * Makes a duplicate of the current configuration into another one.
  26324. * @param configuration define the config where to copy the info
  26325. */
  26326. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  26327. /**
  26328. * Serializes this Sub Surface configuration.
  26329. * @returns - An object with the serialized config.
  26330. */
  26331. serialize(): any;
  26332. /**
  26333. * Parses a anisotropy Configuration from a serialized object.
  26334. * @param source - Serialized object.
  26335. * @param scene Defines the scene we are parsing for
  26336. * @param rootUrl Defines the rootUrl to load from
  26337. */
  26338. parse(source: any, scene: Scene, rootUrl: string): void;
  26339. }
  26340. }
  26341. declare module "babylonjs/Maths/sphericalPolynomial" {
  26342. import { Vector3 } from "babylonjs/Maths/math.vector";
  26343. import { Color3 } from "babylonjs/Maths/math.color";
  26344. /**
  26345. * Class representing spherical harmonics coefficients to the 3rd degree
  26346. */
  26347. export class SphericalHarmonics {
  26348. /**
  26349. * Defines whether or not the harmonics have been prescaled for rendering.
  26350. */
  26351. preScaled: boolean;
  26352. /**
  26353. * The l0,0 coefficients of the spherical harmonics
  26354. */
  26355. l00: Vector3;
  26356. /**
  26357. * The l1,-1 coefficients of the spherical harmonics
  26358. */
  26359. l1_1: Vector3;
  26360. /**
  26361. * The l1,0 coefficients of the spherical harmonics
  26362. */
  26363. l10: Vector3;
  26364. /**
  26365. * The l1,1 coefficients of the spherical harmonics
  26366. */
  26367. l11: Vector3;
  26368. /**
  26369. * The l2,-2 coefficients of the spherical harmonics
  26370. */
  26371. l2_2: Vector3;
  26372. /**
  26373. * The l2,-1 coefficients of the spherical harmonics
  26374. */
  26375. l2_1: Vector3;
  26376. /**
  26377. * The l2,0 coefficients of the spherical harmonics
  26378. */
  26379. l20: Vector3;
  26380. /**
  26381. * The l2,1 coefficients of the spherical harmonics
  26382. */
  26383. l21: Vector3;
  26384. /**
  26385. * The l2,2 coefficients of the spherical harmonics
  26386. */
  26387. l22: Vector3;
  26388. /**
  26389. * Adds a light to the spherical harmonics
  26390. * @param direction the direction of the light
  26391. * @param color the color of the light
  26392. * @param deltaSolidAngle the delta solid angle of the light
  26393. */
  26394. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  26395. /**
  26396. * Scales the spherical harmonics by the given amount
  26397. * @param scale the amount to scale
  26398. */
  26399. scaleInPlace(scale: number): void;
  26400. /**
  26401. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  26402. *
  26403. * ```
  26404. * E_lm = A_l * L_lm
  26405. * ```
  26406. *
  26407. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  26408. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  26409. * the scaling factors are given in equation 9.
  26410. */
  26411. convertIncidentRadianceToIrradiance(): void;
  26412. /**
  26413. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  26414. *
  26415. * ```
  26416. * L = (1/pi) * E * rho
  26417. * ```
  26418. *
  26419. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  26420. */
  26421. convertIrradianceToLambertianRadiance(): void;
  26422. /**
  26423. * Integrates the reconstruction coefficients directly in to the SH preventing further
  26424. * required operations at run time.
  26425. *
  26426. * This is simply done by scaling back the SH with Ylm constants parameter.
  26427. * The trigonometric part being applied by the shader at run time.
  26428. */
  26429. preScaleForRendering(): void;
  26430. /**
  26431. * Constructs a spherical harmonics from an array.
  26432. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  26433. * @returns the spherical harmonics
  26434. */
  26435. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  26436. /**
  26437. * Gets the spherical harmonics from polynomial
  26438. * @param polynomial the spherical polynomial
  26439. * @returns the spherical harmonics
  26440. */
  26441. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  26442. }
  26443. /**
  26444. * Class representing spherical polynomial coefficients to the 3rd degree
  26445. */
  26446. export class SphericalPolynomial {
  26447. private _harmonics;
  26448. /**
  26449. * The spherical harmonics used to create the polynomials.
  26450. */
  26451. get preScaledHarmonics(): SphericalHarmonics;
  26452. /**
  26453. * The x coefficients of the spherical polynomial
  26454. */
  26455. x: Vector3;
  26456. /**
  26457. * The y coefficients of the spherical polynomial
  26458. */
  26459. y: Vector3;
  26460. /**
  26461. * The z coefficients of the spherical polynomial
  26462. */
  26463. z: Vector3;
  26464. /**
  26465. * The xx coefficients of the spherical polynomial
  26466. */
  26467. xx: Vector3;
  26468. /**
  26469. * The yy coefficients of the spherical polynomial
  26470. */
  26471. yy: Vector3;
  26472. /**
  26473. * The zz coefficients of the spherical polynomial
  26474. */
  26475. zz: Vector3;
  26476. /**
  26477. * The xy coefficients of the spherical polynomial
  26478. */
  26479. xy: Vector3;
  26480. /**
  26481. * The yz coefficients of the spherical polynomial
  26482. */
  26483. yz: Vector3;
  26484. /**
  26485. * The zx coefficients of the spherical polynomial
  26486. */
  26487. zx: Vector3;
  26488. /**
  26489. * Adds an ambient color to the spherical polynomial
  26490. * @param color the color to add
  26491. */
  26492. addAmbient(color: Color3): void;
  26493. /**
  26494. * Scales the spherical polynomial by the given amount
  26495. * @param scale the amount to scale
  26496. */
  26497. scaleInPlace(scale: number): void;
  26498. /**
  26499. * Gets the spherical polynomial from harmonics
  26500. * @param harmonics the spherical harmonics
  26501. * @returns the spherical polynomial
  26502. */
  26503. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  26504. /**
  26505. * Constructs a spherical polynomial from an array.
  26506. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  26507. * @returns the spherical polynomial
  26508. */
  26509. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  26510. }
  26511. }
  26512. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  26513. import { Nullable } from "babylonjs/types";
  26514. /**
  26515. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  26516. */
  26517. export interface CubeMapInfo {
  26518. /**
  26519. * The pixel array for the front face.
  26520. * This is stored in format, left to right, up to down format.
  26521. */
  26522. front: Nullable<ArrayBufferView>;
  26523. /**
  26524. * The pixel array for the back face.
  26525. * This is stored in format, left to right, up to down format.
  26526. */
  26527. back: Nullable<ArrayBufferView>;
  26528. /**
  26529. * The pixel array for the left face.
  26530. * This is stored in format, left to right, up to down format.
  26531. */
  26532. left: Nullable<ArrayBufferView>;
  26533. /**
  26534. * The pixel array for the right face.
  26535. * This is stored in format, left to right, up to down format.
  26536. */
  26537. right: Nullable<ArrayBufferView>;
  26538. /**
  26539. * The pixel array for the up face.
  26540. * This is stored in format, left to right, up to down format.
  26541. */
  26542. up: Nullable<ArrayBufferView>;
  26543. /**
  26544. * The pixel array for the down face.
  26545. * This is stored in format, left to right, up to down format.
  26546. */
  26547. down: Nullable<ArrayBufferView>;
  26548. /**
  26549. * The size of the cubemap stored.
  26550. *
  26551. * Each faces will be size * size pixels.
  26552. */
  26553. size: number;
  26554. /**
  26555. * The format of the texture.
  26556. *
  26557. * RGBA, RGB.
  26558. */
  26559. format: number;
  26560. /**
  26561. * The type of the texture data.
  26562. *
  26563. * UNSIGNED_INT, FLOAT.
  26564. */
  26565. type: number;
  26566. /**
  26567. * Specifies whether the texture is in gamma space.
  26568. */
  26569. gammaSpace: boolean;
  26570. }
  26571. /**
  26572. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  26573. */
  26574. export class PanoramaToCubeMapTools {
  26575. private static FACE_LEFT;
  26576. private static FACE_RIGHT;
  26577. private static FACE_FRONT;
  26578. private static FACE_BACK;
  26579. private static FACE_DOWN;
  26580. private static FACE_UP;
  26581. /**
  26582. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  26583. *
  26584. * @param float32Array The source data.
  26585. * @param inputWidth The width of the input panorama.
  26586. * @param inputHeight The height of the input panorama.
  26587. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  26588. * @return The cubemap data
  26589. */
  26590. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  26591. private static CreateCubemapTexture;
  26592. private static CalcProjectionSpherical;
  26593. }
  26594. }
  26595. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  26596. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26597. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26598. import { Nullable } from "babylonjs/types";
  26599. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  26600. /**
  26601. * Helper class dealing with the extraction of spherical polynomial dataArray
  26602. * from a cube map.
  26603. */
  26604. export class CubeMapToSphericalPolynomialTools {
  26605. private static FileFaces;
  26606. /**
  26607. * Converts a texture to the according Spherical Polynomial data.
  26608. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26609. *
  26610. * @param texture The texture to extract the information from.
  26611. * @return The Spherical Polynomial data.
  26612. */
  26613. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  26614. /**
  26615. * Converts a cubemap to the according Spherical Polynomial data.
  26616. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26617. *
  26618. * @param cubeInfo The Cube map to extract the information from.
  26619. * @return The Spherical Polynomial data.
  26620. */
  26621. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  26622. }
  26623. }
  26624. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  26625. import { Nullable } from "babylonjs/types";
  26626. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26627. module "babylonjs/Materials/Textures/baseTexture" {
  26628. interface BaseTexture {
  26629. /**
  26630. * Get the polynomial representation of the texture data.
  26631. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26632. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26633. */
  26634. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26635. }
  26636. }
  26637. }
  26638. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  26639. /** @hidden */
  26640. export var pbrFragmentDeclaration: {
  26641. name: string;
  26642. shader: string;
  26643. };
  26644. }
  26645. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  26646. /** @hidden */
  26647. export var pbrUboDeclaration: {
  26648. name: string;
  26649. shader: string;
  26650. };
  26651. }
  26652. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  26653. /** @hidden */
  26654. export var pbrFragmentExtraDeclaration: {
  26655. name: string;
  26656. shader: string;
  26657. };
  26658. }
  26659. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  26660. /** @hidden */
  26661. export var pbrFragmentSamplersDeclaration: {
  26662. name: string;
  26663. shader: string;
  26664. };
  26665. }
  26666. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  26667. /** @hidden */
  26668. export var subSurfaceScatteringFunctions: {
  26669. name: string;
  26670. shader: string;
  26671. };
  26672. }
  26673. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  26674. /** @hidden */
  26675. export var importanceSampling: {
  26676. name: string;
  26677. shader: string;
  26678. };
  26679. }
  26680. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  26681. /** @hidden */
  26682. export var pbrHelperFunctions: {
  26683. name: string;
  26684. shader: string;
  26685. };
  26686. }
  26687. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  26688. /** @hidden */
  26689. export var harmonicsFunctions: {
  26690. name: string;
  26691. shader: string;
  26692. };
  26693. }
  26694. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  26695. /** @hidden */
  26696. export var pbrDirectLightingSetupFunctions: {
  26697. name: string;
  26698. shader: string;
  26699. };
  26700. }
  26701. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  26702. /** @hidden */
  26703. export var pbrDirectLightingFalloffFunctions: {
  26704. name: string;
  26705. shader: string;
  26706. };
  26707. }
  26708. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  26709. /** @hidden */
  26710. export var pbrBRDFFunctions: {
  26711. name: string;
  26712. shader: string;
  26713. };
  26714. }
  26715. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  26716. /** @hidden */
  26717. export var hdrFilteringFunctions: {
  26718. name: string;
  26719. shader: string;
  26720. };
  26721. }
  26722. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  26723. /** @hidden */
  26724. export var pbrDirectLightingFunctions: {
  26725. name: string;
  26726. shader: string;
  26727. };
  26728. }
  26729. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  26730. /** @hidden */
  26731. export var pbrIBLFunctions: {
  26732. name: string;
  26733. shader: string;
  26734. };
  26735. }
  26736. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  26737. /** @hidden */
  26738. export var pbrBlockAlbedoOpacity: {
  26739. name: string;
  26740. shader: string;
  26741. };
  26742. }
  26743. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  26744. /** @hidden */
  26745. export var pbrBlockReflectivity: {
  26746. name: string;
  26747. shader: string;
  26748. };
  26749. }
  26750. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  26751. /** @hidden */
  26752. export var pbrBlockAmbientOcclusion: {
  26753. name: string;
  26754. shader: string;
  26755. };
  26756. }
  26757. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  26758. /** @hidden */
  26759. export var pbrBlockAlphaFresnel: {
  26760. name: string;
  26761. shader: string;
  26762. };
  26763. }
  26764. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  26765. /** @hidden */
  26766. export var pbrBlockAnisotropic: {
  26767. name: string;
  26768. shader: string;
  26769. };
  26770. }
  26771. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  26772. /** @hidden */
  26773. export var pbrBlockReflection: {
  26774. name: string;
  26775. shader: string;
  26776. };
  26777. }
  26778. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  26779. /** @hidden */
  26780. export var pbrBlockSheen: {
  26781. name: string;
  26782. shader: string;
  26783. };
  26784. }
  26785. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  26786. /** @hidden */
  26787. export var pbrBlockClearcoat: {
  26788. name: string;
  26789. shader: string;
  26790. };
  26791. }
  26792. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  26793. /** @hidden */
  26794. export var pbrBlockSubSurface: {
  26795. name: string;
  26796. shader: string;
  26797. };
  26798. }
  26799. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  26800. /** @hidden */
  26801. export var pbrBlockNormalGeometric: {
  26802. name: string;
  26803. shader: string;
  26804. };
  26805. }
  26806. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  26807. /** @hidden */
  26808. export var pbrBlockNormalFinal: {
  26809. name: string;
  26810. shader: string;
  26811. };
  26812. }
  26813. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  26814. /** @hidden */
  26815. export var pbrBlockLightmapInit: {
  26816. name: string;
  26817. shader: string;
  26818. };
  26819. }
  26820. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  26821. /** @hidden */
  26822. export var pbrBlockGeometryInfo: {
  26823. name: string;
  26824. shader: string;
  26825. };
  26826. }
  26827. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  26828. /** @hidden */
  26829. export var pbrBlockReflectance0: {
  26830. name: string;
  26831. shader: string;
  26832. };
  26833. }
  26834. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  26835. /** @hidden */
  26836. export var pbrBlockReflectance: {
  26837. name: string;
  26838. shader: string;
  26839. };
  26840. }
  26841. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  26842. /** @hidden */
  26843. export var pbrBlockDirectLighting: {
  26844. name: string;
  26845. shader: string;
  26846. };
  26847. }
  26848. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  26849. /** @hidden */
  26850. export var pbrBlockFinalLitComponents: {
  26851. name: string;
  26852. shader: string;
  26853. };
  26854. }
  26855. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  26856. /** @hidden */
  26857. export var pbrBlockFinalUnlitComponents: {
  26858. name: string;
  26859. shader: string;
  26860. };
  26861. }
  26862. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  26863. /** @hidden */
  26864. export var pbrBlockFinalColorComposition: {
  26865. name: string;
  26866. shader: string;
  26867. };
  26868. }
  26869. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  26870. /** @hidden */
  26871. export var pbrBlockImageProcessing: {
  26872. name: string;
  26873. shader: string;
  26874. };
  26875. }
  26876. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  26877. /** @hidden */
  26878. export var pbrDebug: {
  26879. name: string;
  26880. shader: string;
  26881. };
  26882. }
  26883. declare module "babylonjs/Shaders/pbr.fragment" {
  26884. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  26885. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  26886. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  26887. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  26888. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26889. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26890. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  26891. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26892. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26893. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26894. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26895. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26896. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  26897. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  26898. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  26899. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26900. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26901. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  26902. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  26903. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  26904. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  26905. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  26906. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  26907. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  26908. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  26909. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26910. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26911. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  26912. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  26913. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  26914. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  26915. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  26916. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  26917. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  26918. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  26919. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  26920. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26921. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  26922. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26923. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  26924. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26925. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  26926. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  26927. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  26928. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  26929. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  26930. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26931. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  26932. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  26933. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  26934. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26935. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26936. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  26937. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  26938. /** @hidden */
  26939. export var pbrPixelShader: {
  26940. name: string;
  26941. shader: string;
  26942. };
  26943. }
  26944. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  26945. /** @hidden */
  26946. export var pbrVertexDeclaration: {
  26947. name: string;
  26948. shader: string;
  26949. };
  26950. }
  26951. declare module "babylonjs/Shaders/pbr.vertex" {
  26952. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  26953. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  26954. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26955. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26956. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26957. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  26958. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  26959. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26960. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26961. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26962. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26963. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26964. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26965. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26966. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26967. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26968. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26969. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26970. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  26971. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26972. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26973. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26974. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26975. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26976. /** @hidden */
  26977. export var pbrVertexShader: {
  26978. name: string;
  26979. shader: string;
  26980. };
  26981. }
  26982. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  26983. import { Nullable } from "babylonjs/types";
  26984. import { Scene } from "babylonjs/scene";
  26985. import { Matrix } from "babylonjs/Maths/math.vector";
  26986. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26988. import { Mesh } from "babylonjs/Meshes/mesh";
  26989. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  26990. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  26991. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  26992. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  26993. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  26994. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  26995. import { Color3 } from "babylonjs/Maths/math.color";
  26996. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26997. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  26998. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26999. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27000. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27001. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27002. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  27003. import "babylonjs/Shaders/pbr.fragment";
  27004. import "babylonjs/Shaders/pbr.vertex";
  27005. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  27006. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  27007. /**
  27008. * Manages the defines for the PBR Material.
  27009. * @hidden
  27010. */
  27011. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  27012. PBR: boolean;
  27013. NUM_SAMPLES: string;
  27014. REALTIME_FILTERING: boolean;
  27015. MAINUV1: boolean;
  27016. MAINUV2: boolean;
  27017. UV1: boolean;
  27018. UV2: boolean;
  27019. ALBEDO: boolean;
  27020. GAMMAALBEDO: boolean;
  27021. ALBEDODIRECTUV: number;
  27022. VERTEXCOLOR: boolean;
  27023. DETAIL: boolean;
  27024. DETAILDIRECTUV: number;
  27025. DETAIL_NORMALBLENDMETHOD: number;
  27026. AMBIENT: boolean;
  27027. AMBIENTDIRECTUV: number;
  27028. AMBIENTINGRAYSCALE: boolean;
  27029. OPACITY: boolean;
  27030. VERTEXALPHA: boolean;
  27031. OPACITYDIRECTUV: number;
  27032. OPACITYRGB: boolean;
  27033. ALPHATEST: boolean;
  27034. DEPTHPREPASS: boolean;
  27035. ALPHABLEND: boolean;
  27036. ALPHAFROMALBEDO: boolean;
  27037. ALPHATESTVALUE: string;
  27038. SPECULAROVERALPHA: boolean;
  27039. RADIANCEOVERALPHA: boolean;
  27040. ALPHAFRESNEL: boolean;
  27041. LINEARALPHAFRESNEL: boolean;
  27042. PREMULTIPLYALPHA: boolean;
  27043. EMISSIVE: boolean;
  27044. EMISSIVEDIRECTUV: number;
  27045. REFLECTIVITY: boolean;
  27046. REFLECTIVITYDIRECTUV: number;
  27047. SPECULARTERM: boolean;
  27048. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  27049. MICROSURFACEAUTOMATIC: boolean;
  27050. LODBASEDMICROSFURACE: boolean;
  27051. MICROSURFACEMAP: boolean;
  27052. MICROSURFACEMAPDIRECTUV: number;
  27053. METALLICWORKFLOW: boolean;
  27054. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  27055. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  27056. METALLNESSSTOREINMETALMAPBLUE: boolean;
  27057. AOSTOREINMETALMAPRED: boolean;
  27058. METALLIC_REFLECTANCE: boolean;
  27059. METALLIC_REFLECTANCEDIRECTUV: number;
  27060. ENVIRONMENTBRDF: boolean;
  27061. ENVIRONMENTBRDF_RGBD: boolean;
  27062. NORMAL: boolean;
  27063. TANGENT: boolean;
  27064. BUMP: boolean;
  27065. BUMPDIRECTUV: number;
  27066. OBJECTSPACE_NORMALMAP: boolean;
  27067. PARALLAX: boolean;
  27068. PARALLAXOCCLUSION: boolean;
  27069. NORMALXYSCALE: boolean;
  27070. LIGHTMAP: boolean;
  27071. LIGHTMAPDIRECTUV: number;
  27072. USELIGHTMAPASSHADOWMAP: boolean;
  27073. GAMMALIGHTMAP: boolean;
  27074. RGBDLIGHTMAP: boolean;
  27075. REFLECTION: boolean;
  27076. REFLECTIONMAP_3D: boolean;
  27077. REFLECTIONMAP_SPHERICAL: boolean;
  27078. REFLECTIONMAP_PLANAR: boolean;
  27079. REFLECTIONMAP_CUBIC: boolean;
  27080. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27081. REFLECTIONMAP_PROJECTION: boolean;
  27082. REFLECTIONMAP_SKYBOX: boolean;
  27083. REFLECTIONMAP_EXPLICIT: boolean;
  27084. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27085. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27086. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27087. INVERTCUBICMAP: boolean;
  27088. USESPHERICALFROMREFLECTIONMAP: boolean;
  27089. USEIRRADIANCEMAP: boolean;
  27090. SPHERICAL_HARMONICS: boolean;
  27091. USESPHERICALINVERTEX: boolean;
  27092. REFLECTIONMAP_OPPOSITEZ: boolean;
  27093. LODINREFLECTIONALPHA: boolean;
  27094. GAMMAREFLECTION: boolean;
  27095. RGBDREFLECTION: boolean;
  27096. LINEARSPECULARREFLECTION: boolean;
  27097. RADIANCEOCCLUSION: boolean;
  27098. HORIZONOCCLUSION: boolean;
  27099. INSTANCES: boolean;
  27100. THIN_INSTANCES: boolean;
  27101. PREPASS: boolean;
  27102. PREPASS_IRRADIANCE: boolean;
  27103. PREPASS_IRRADIANCE_INDEX: number;
  27104. PREPASS_ALBEDO: boolean;
  27105. PREPASS_ALBEDO_INDEX: number;
  27106. PREPASS_DEPTHNORMAL: boolean;
  27107. PREPASS_DEPTHNORMAL_INDEX: number;
  27108. PREPASS_POSITION: boolean;
  27109. PREPASS_POSITION_INDEX: number;
  27110. PREPASS_VELOCITY: boolean;
  27111. PREPASS_VELOCITY_INDEX: number;
  27112. PREPASS_REFLECTIVITY: boolean;
  27113. PREPASS_REFLECTIVITY_INDEX: number;
  27114. SCENE_MRT_COUNT: number;
  27115. NUM_BONE_INFLUENCERS: number;
  27116. BonesPerMesh: number;
  27117. BONETEXTURE: boolean;
  27118. BONES_VELOCITY_ENABLED: boolean;
  27119. NONUNIFORMSCALING: boolean;
  27120. MORPHTARGETS: boolean;
  27121. MORPHTARGETS_NORMAL: boolean;
  27122. MORPHTARGETS_TANGENT: boolean;
  27123. MORPHTARGETS_UV: boolean;
  27124. NUM_MORPH_INFLUENCERS: number;
  27125. IMAGEPROCESSING: boolean;
  27126. VIGNETTE: boolean;
  27127. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27128. VIGNETTEBLENDMODEOPAQUE: boolean;
  27129. TONEMAPPING: boolean;
  27130. TONEMAPPING_ACES: boolean;
  27131. CONTRAST: boolean;
  27132. COLORCURVES: boolean;
  27133. COLORGRADING: boolean;
  27134. COLORGRADING3D: boolean;
  27135. SAMPLER3DGREENDEPTH: boolean;
  27136. SAMPLER3DBGRMAP: boolean;
  27137. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27138. EXPOSURE: boolean;
  27139. MULTIVIEW: boolean;
  27140. USEPHYSICALLIGHTFALLOFF: boolean;
  27141. USEGLTFLIGHTFALLOFF: boolean;
  27142. TWOSIDEDLIGHTING: boolean;
  27143. SHADOWFLOAT: boolean;
  27144. CLIPPLANE: boolean;
  27145. CLIPPLANE2: boolean;
  27146. CLIPPLANE3: boolean;
  27147. CLIPPLANE4: boolean;
  27148. CLIPPLANE5: boolean;
  27149. CLIPPLANE6: boolean;
  27150. POINTSIZE: boolean;
  27151. FOG: boolean;
  27152. LOGARITHMICDEPTH: boolean;
  27153. FORCENORMALFORWARD: boolean;
  27154. SPECULARAA: boolean;
  27155. CLEARCOAT: boolean;
  27156. CLEARCOAT_DEFAULTIOR: boolean;
  27157. CLEARCOAT_TEXTURE: boolean;
  27158. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  27159. CLEARCOAT_TEXTUREDIRECTUV: number;
  27160. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  27161. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  27162. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  27163. CLEARCOAT_BUMP: boolean;
  27164. CLEARCOAT_BUMPDIRECTUV: number;
  27165. CLEARCOAT_REMAP_F0: boolean;
  27166. CLEARCOAT_TINT: boolean;
  27167. CLEARCOAT_TINT_TEXTURE: boolean;
  27168. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  27169. ANISOTROPIC: boolean;
  27170. ANISOTROPIC_TEXTURE: boolean;
  27171. ANISOTROPIC_TEXTUREDIRECTUV: number;
  27172. BRDF_V_HEIGHT_CORRELATED: boolean;
  27173. MS_BRDF_ENERGY_CONSERVATION: boolean;
  27174. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  27175. SHEEN: boolean;
  27176. SHEEN_TEXTURE: boolean;
  27177. SHEEN_TEXTURE_ROUGHNESS: boolean;
  27178. SHEEN_TEXTUREDIRECTUV: number;
  27179. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  27180. SHEEN_LINKWITHALBEDO: boolean;
  27181. SHEEN_ROUGHNESS: boolean;
  27182. SHEEN_ALBEDOSCALING: boolean;
  27183. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  27184. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  27185. SUBSURFACE: boolean;
  27186. SS_REFRACTION: boolean;
  27187. SS_TRANSLUCENCY: boolean;
  27188. SS_SCATTERING: boolean;
  27189. SS_THICKNESSANDMASK_TEXTURE: boolean;
  27190. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  27191. SS_REFRACTIONMAP_3D: boolean;
  27192. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  27193. SS_LODINREFRACTIONALPHA: boolean;
  27194. SS_GAMMAREFRACTION: boolean;
  27195. SS_RGBDREFRACTION: boolean;
  27196. SS_LINEARSPECULARREFRACTION: boolean;
  27197. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  27198. SS_ALBEDOFORREFRACTIONTINT: boolean;
  27199. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  27200. UNLIT: boolean;
  27201. DEBUGMODE: number;
  27202. /**
  27203. * Initializes the PBR Material defines.
  27204. */
  27205. constructor();
  27206. /**
  27207. * Resets the PBR Material defines.
  27208. */
  27209. reset(): void;
  27210. }
  27211. /**
  27212. * The Physically based material base class of BJS.
  27213. *
  27214. * This offers the main features of a standard PBR material.
  27215. * For more information, please refer to the documentation :
  27216. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27217. */
  27218. export abstract class PBRBaseMaterial extends PushMaterial {
  27219. /**
  27220. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27221. */
  27222. static readonly PBRMATERIAL_OPAQUE: number;
  27223. /**
  27224. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27225. */
  27226. static readonly PBRMATERIAL_ALPHATEST: number;
  27227. /**
  27228. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27229. */
  27230. static readonly PBRMATERIAL_ALPHABLEND: number;
  27231. /**
  27232. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27233. * They are also discarded below the alpha cutoff threshold to improve performances.
  27234. */
  27235. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27236. /**
  27237. * Defines the default value of how much AO map is occluding the analytical lights
  27238. * (point spot...).
  27239. */
  27240. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27241. /**
  27242. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  27243. */
  27244. static readonly LIGHTFALLOFF_PHYSICAL: number;
  27245. /**
  27246. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  27247. * to enhance interoperability with other engines.
  27248. */
  27249. static readonly LIGHTFALLOFF_GLTF: number;
  27250. /**
  27251. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  27252. * to enhance interoperability with other materials.
  27253. */
  27254. static readonly LIGHTFALLOFF_STANDARD: number;
  27255. /**
  27256. * Intensity of the direct lights e.g. the four lights available in your scene.
  27257. * This impacts both the direct diffuse and specular highlights.
  27258. */
  27259. protected _directIntensity: number;
  27260. /**
  27261. * Intensity of the emissive part of the material.
  27262. * This helps controlling the emissive effect without modifying the emissive color.
  27263. */
  27264. protected _emissiveIntensity: number;
  27265. /**
  27266. * Intensity of the environment e.g. how much the environment will light the object
  27267. * either through harmonics for rough material or through the refelction for shiny ones.
  27268. */
  27269. protected _environmentIntensity: number;
  27270. /**
  27271. * This is a special control allowing the reduction of the specular highlights coming from the
  27272. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27273. */
  27274. protected _specularIntensity: number;
  27275. /**
  27276. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  27277. */
  27278. private _lightingInfos;
  27279. /**
  27280. * Debug Control allowing disabling the bump map on this material.
  27281. */
  27282. protected _disableBumpMap: boolean;
  27283. /**
  27284. * AKA Diffuse Texture in standard nomenclature.
  27285. */
  27286. protected _albedoTexture: Nullable<BaseTexture>;
  27287. /**
  27288. * AKA Occlusion Texture in other nomenclature.
  27289. */
  27290. protected _ambientTexture: Nullable<BaseTexture>;
  27291. /**
  27292. * AKA Occlusion Texture Intensity in other nomenclature.
  27293. */
  27294. protected _ambientTextureStrength: number;
  27295. /**
  27296. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27297. * 1 means it completely occludes it
  27298. * 0 mean it has no impact
  27299. */
  27300. protected _ambientTextureImpactOnAnalyticalLights: number;
  27301. /**
  27302. * Stores the alpha values in a texture.
  27303. */
  27304. protected _opacityTexture: Nullable<BaseTexture>;
  27305. /**
  27306. * Stores the reflection values in a texture.
  27307. */
  27308. protected _reflectionTexture: Nullable<BaseTexture>;
  27309. /**
  27310. * Stores the emissive values in a texture.
  27311. */
  27312. protected _emissiveTexture: Nullable<BaseTexture>;
  27313. /**
  27314. * AKA Specular texture in other nomenclature.
  27315. */
  27316. protected _reflectivityTexture: Nullable<BaseTexture>;
  27317. /**
  27318. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27319. */
  27320. protected _metallicTexture: Nullable<BaseTexture>;
  27321. /**
  27322. * Specifies the metallic scalar of the metallic/roughness workflow.
  27323. * Can also be used to scale the metalness values of the metallic texture.
  27324. */
  27325. protected _metallic: Nullable<number>;
  27326. /**
  27327. * Specifies the roughness scalar of the metallic/roughness workflow.
  27328. * Can also be used to scale the roughness values of the metallic texture.
  27329. */
  27330. protected _roughness: Nullable<number>;
  27331. /**
  27332. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27333. * By default the indexOfrefraction is used to compute F0;
  27334. *
  27335. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27336. *
  27337. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27338. * F90 = metallicReflectanceColor;
  27339. */
  27340. protected _metallicF0Factor: number;
  27341. /**
  27342. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27343. * By default the F90 is always 1;
  27344. *
  27345. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27346. *
  27347. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27348. * F90 = metallicReflectanceColor;
  27349. */
  27350. protected _metallicReflectanceColor: Color3;
  27351. /**
  27352. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27353. * This is multiply against the scalar values defined in the material.
  27354. */
  27355. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  27356. /**
  27357. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27358. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27359. */
  27360. protected _microSurfaceTexture: Nullable<BaseTexture>;
  27361. /**
  27362. * Stores surface normal data used to displace a mesh in a texture.
  27363. */
  27364. protected _bumpTexture: Nullable<BaseTexture>;
  27365. /**
  27366. * Stores the pre-calculated light information of a mesh in a texture.
  27367. */
  27368. protected _lightmapTexture: Nullable<BaseTexture>;
  27369. /**
  27370. * The color of a material in ambient lighting.
  27371. */
  27372. protected _ambientColor: Color3;
  27373. /**
  27374. * AKA Diffuse Color in other nomenclature.
  27375. */
  27376. protected _albedoColor: Color3;
  27377. /**
  27378. * AKA Specular Color in other nomenclature.
  27379. */
  27380. protected _reflectivityColor: Color3;
  27381. /**
  27382. * The color applied when light is reflected from a material.
  27383. */
  27384. protected _reflectionColor: Color3;
  27385. /**
  27386. * The color applied when light is emitted from a material.
  27387. */
  27388. protected _emissiveColor: Color3;
  27389. /**
  27390. * AKA Glossiness in other nomenclature.
  27391. */
  27392. protected _microSurface: number;
  27393. /**
  27394. * Specifies that the material will use the light map as a show map.
  27395. */
  27396. protected _useLightmapAsShadowmap: boolean;
  27397. /**
  27398. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27399. * makes the reflect vector face the model (under horizon).
  27400. */
  27401. protected _useHorizonOcclusion: boolean;
  27402. /**
  27403. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27404. * too much the area relying on ambient texture to define their ambient occlusion.
  27405. */
  27406. protected _useRadianceOcclusion: boolean;
  27407. /**
  27408. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27409. */
  27410. protected _useAlphaFromAlbedoTexture: boolean;
  27411. /**
  27412. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  27413. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27414. */
  27415. protected _useSpecularOverAlpha: boolean;
  27416. /**
  27417. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27418. */
  27419. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27420. /**
  27421. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27422. */
  27423. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  27424. /**
  27425. * Specifies if the metallic texture contains the roughness information in its green channel.
  27426. */
  27427. protected _useRoughnessFromMetallicTextureGreen: boolean;
  27428. /**
  27429. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27430. */
  27431. protected _useMetallnessFromMetallicTextureBlue: boolean;
  27432. /**
  27433. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27434. */
  27435. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  27436. /**
  27437. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27438. */
  27439. protected _useAmbientInGrayScale: boolean;
  27440. /**
  27441. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27442. * The material will try to infer what glossiness each pixel should be.
  27443. */
  27444. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  27445. /**
  27446. * Defines the falloff type used in this material.
  27447. * It by default is Physical.
  27448. */
  27449. protected _lightFalloff: number;
  27450. /**
  27451. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27452. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27453. */
  27454. protected _useRadianceOverAlpha: boolean;
  27455. /**
  27456. * Allows using an object space normal map (instead of tangent space).
  27457. */
  27458. protected _useObjectSpaceNormalMap: boolean;
  27459. /**
  27460. * Allows using the bump map in parallax mode.
  27461. */
  27462. protected _useParallax: boolean;
  27463. /**
  27464. * Allows using the bump map in parallax occlusion mode.
  27465. */
  27466. protected _useParallaxOcclusion: boolean;
  27467. /**
  27468. * Controls the scale bias of the parallax mode.
  27469. */
  27470. protected _parallaxScaleBias: number;
  27471. /**
  27472. * If sets to true, disables all the lights affecting the material.
  27473. */
  27474. protected _disableLighting: boolean;
  27475. /**
  27476. * Number of Simultaneous lights allowed on the material.
  27477. */
  27478. protected _maxSimultaneousLights: number;
  27479. /**
  27480. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  27481. */
  27482. protected _invertNormalMapX: boolean;
  27483. /**
  27484. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  27485. */
  27486. protected _invertNormalMapY: boolean;
  27487. /**
  27488. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27489. */
  27490. protected _twoSidedLighting: boolean;
  27491. /**
  27492. * Defines the alpha limits in alpha test mode.
  27493. */
  27494. protected _alphaCutOff: number;
  27495. /**
  27496. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27497. */
  27498. protected _forceAlphaTest: boolean;
  27499. /**
  27500. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27501. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27502. */
  27503. protected _useAlphaFresnel: boolean;
  27504. /**
  27505. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27506. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27507. */
  27508. protected _useLinearAlphaFresnel: boolean;
  27509. /**
  27510. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  27511. * from cos thetav and roughness:
  27512. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  27513. */
  27514. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  27515. /**
  27516. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27517. */
  27518. protected _forceIrradianceInFragment: boolean;
  27519. private _realTimeFiltering;
  27520. /**
  27521. * Enables realtime filtering on the texture.
  27522. */
  27523. get realTimeFiltering(): boolean;
  27524. set realTimeFiltering(b: boolean);
  27525. private _realTimeFilteringQuality;
  27526. /**
  27527. * Quality switch for realtime filtering
  27528. */
  27529. get realTimeFilteringQuality(): number;
  27530. set realTimeFilteringQuality(n: number);
  27531. /**
  27532. * Can this material render to several textures at once
  27533. */
  27534. get canRenderToMRT(): boolean;
  27535. /**
  27536. * Force normal to face away from face.
  27537. */
  27538. protected _forceNormalForward: boolean;
  27539. /**
  27540. * Enables specular anti aliasing in the PBR shader.
  27541. * It will both interacts on the Geometry for analytical and IBL lighting.
  27542. * It also prefilter the roughness map based on the bump values.
  27543. */
  27544. protected _enableSpecularAntiAliasing: boolean;
  27545. /**
  27546. * Default configuration related to image processing available in the PBR Material.
  27547. */
  27548. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27549. /**
  27550. * Keep track of the image processing observer to allow dispose and replace.
  27551. */
  27552. private _imageProcessingObserver;
  27553. /**
  27554. * Attaches a new image processing configuration to the PBR Material.
  27555. * @param configuration
  27556. */
  27557. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27558. /**
  27559. * Stores the available render targets.
  27560. */
  27561. private _renderTargets;
  27562. /**
  27563. * Sets the global ambient color for the material used in lighting calculations.
  27564. */
  27565. private _globalAmbientColor;
  27566. /**
  27567. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  27568. */
  27569. private _useLogarithmicDepth;
  27570. /**
  27571. * If set to true, no lighting calculations will be applied.
  27572. */
  27573. private _unlit;
  27574. private _debugMode;
  27575. /**
  27576. * @hidden
  27577. * This is reserved for the inspector.
  27578. * Defines the material debug mode.
  27579. * It helps seeing only some components of the material while troubleshooting.
  27580. */
  27581. debugMode: number;
  27582. /**
  27583. * @hidden
  27584. * This is reserved for the inspector.
  27585. * Specify from where on screen the debug mode should start.
  27586. * The value goes from -1 (full screen) to 1 (not visible)
  27587. * It helps with side by side comparison against the final render
  27588. * This defaults to -1
  27589. */
  27590. private debugLimit;
  27591. /**
  27592. * @hidden
  27593. * This is reserved for the inspector.
  27594. * As the default viewing range might not be enough (if the ambient is really small for instance)
  27595. * You can use the factor to better multiply the final value.
  27596. */
  27597. private debugFactor;
  27598. /**
  27599. * Defines the clear coat layer parameters for the material.
  27600. */
  27601. readonly clearCoat: PBRClearCoatConfiguration;
  27602. /**
  27603. * Defines the anisotropic parameters for the material.
  27604. */
  27605. readonly anisotropy: PBRAnisotropicConfiguration;
  27606. /**
  27607. * Defines the BRDF parameters for the material.
  27608. */
  27609. readonly brdf: PBRBRDFConfiguration;
  27610. /**
  27611. * Defines the Sheen parameters for the material.
  27612. */
  27613. readonly sheen: PBRSheenConfiguration;
  27614. /**
  27615. * Defines the SubSurface parameters for the material.
  27616. */
  27617. readonly subSurface: PBRSubSurfaceConfiguration;
  27618. /**
  27619. * Defines additionnal PrePass parameters for the material.
  27620. */
  27621. readonly prePassConfiguration: PrePassConfiguration;
  27622. /**
  27623. * Defines the detail map parameters for the material.
  27624. */
  27625. readonly detailMap: DetailMapConfiguration;
  27626. protected _rebuildInParallel: boolean;
  27627. /**
  27628. * Instantiates a new PBRMaterial instance.
  27629. *
  27630. * @param name The material name
  27631. * @param scene The scene the material will be use in.
  27632. */
  27633. constructor(name: string, scene: Scene);
  27634. /**
  27635. * Gets a boolean indicating that current material needs to register RTT
  27636. */
  27637. get hasRenderTargetTextures(): boolean;
  27638. /**
  27639. * Gets the name of the material class.
  27640. */
  27641. getClassName(): string;
  27642. /**
  27643. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27644. */
  27645. get useLogarithmicDepth(): boolean;
  27646. /**
  27647. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27648. */
  27649. set useLogarithmicDepth(value: boolean);
  27650. /**
  27651. * Returns true if alpha blending should be disabled.
  27652. */
  27653. protected get _disableAlphaBlending(): boolean;
  27654. /**
  27655. * Specifies whether or not this material should be rendered in alpha blend mode.
  27656. */
  27657. needAlphaBlending(): boolean;
  27658. /**
  27659. * Specifies whether or not this material should be rendered in alpha test mode.
  27660. */
  27661. needAlphaTesting(): boolean;
  27662. /**
  27663. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  27664. */
  27665. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  27666. /**
  27667. * Specifies whether or not there is a usable alpha channel for transparency.
  27668. */
  27669. protected _hasAlphaChannel(): boolean;
  27670. /**
  27671. * Gets the texture used for the alpha test.
  27672. */
  27673. getAlphaTestTexture(): Nullable<BaseTexture>;
  27674. /**
  27675. * Specifies that the submesh is ready to be used.
  27676. * @param mesh - BJS mesh.
  27677. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  27678. * @param useInstances - Specifies that instances should be used.
  27679. * @returns - boolean indicating that the submesh is ready or not.
  27680. */
  27681. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27682. /**
  27683. * Specifies if the material uses metallic roughness workflow.
  27684. * @returns boolean specifiying if the material uses metallic roughness workflow.
  27685. */
  27686. isMetallicWorkflow(): boolean;
  27687. private _prepareEffect;
  27688. private _prepareDefines;
  27689. /**
  27690. * Force shader compilation
  27691. */
  27692. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  27693. /**
  27694. * Initializes the uniform buffer layout for the shader.
  27695. */
  27696. buildUniformLayout(): void;
  27697. /**
  27698. * Unbinds the material from the mesh
  27699. */
  27700. unbind(): void;
  27701. /**
  27702. * Binds the submesh data.
  27703. * @param world - The world matrix.
  27704. * @param mesh - The BJS mesh.
  27705. * @param subMesh - A submesh of the BJS mesh.
  27706. */
  27707. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27708. /**
  27709. * Returns the animatable textures.
  27710. * @returns - Array of animatable textures.
  27711. */
  27712. getAnimatables(): IAnimatable[];
  27713. /**
  27714. * Returns the texture used for reflections.
  27715. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  27716. */
  27717. private _getReflectionTexture;
  27718. /**
  27719. * Returns an array of the actively used textures.
  27720. * @returns - Array of BaseTextures
  27721. */
  27722. getActiveTextures(): BaseTexture[];
  27723. /**
  27724. * Checks to see if a texture is used in the material.
  27725. * @param texture - Base texture to use.
  27726. * @returns - Boolean specifying if a texture is used in the material.
  27727. */
  27728. hasTexture(texture: BaseTexture): boolean;
  27729. /**
  27730. * Sets the required values to the prepass renderer.
  27731. * @param prePassRenderer defines the prepass renderer to setup
  27732. */
  27733. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  27734. /**
  27735. * Disposes the resources of the material.
  27736. * @param forceDisposeEffect - Forces the disposal of effects.
  27737. * @param forceDisposeTextures - Forces the disposal of all textures.
  27738. */
  27739. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27740. }
  27741. }
  27742. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  27743. import { Nullable } from "babylonjs/types";
  27744. import { Scene } from "babylonjs/scene";
  27745. import { Color3 } from "babylonjs/Maths/math.color";
  27746. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  27747. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27748. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27749. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  27750. /**
  27751. * The Physically based material of BJS.
  27752. *
  27753. * This offers the main features of a standard PBR material.
  27754. * For more information, please refer to the documentation :
  27755. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27756. */
  27757. export class PBRMaterial extends PBRBaseMaterial {
  27758. /**
  27759. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27760. */
  27761. static readonly PBRMATERIAL_OPAQUE: number;
  27762. /**
  27763. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27764. */
  27765. static readonly PBRMATERIAL_ALPHATEST: number;
  27766. /**
  27767. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27768. */
  27769. static readonly PBRMATERIAL_ALPHABLEND: number;
  27770. /**
  27771. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27772. * They are also discarded below the alpha cutoff threshold to improve performances.
  27773. */
  27774. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27775. /**
  27776. * Defines the default value of how much AO map is occluding the analytical lights
  27777. * (point spot...).
  27778. */
  27779. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27780. /**
  27781. * Intensity of the direct lights e.g. the four lights available in your scene.
  27782. * This impacts both the direct diffuse and specular highlights.
  27783. */
  27784. directIntensity: number;
  27785. /**
  27786. * Intensity of the emissive part of the material.
  27787. * This helps controlling the emissive effect without modifying the emissive color.
  27788. */
  27789. emissiveIntensity: number;
  27790. /**
  27791. * Intensity of the environment e.g. how much the environment will light the object
  27792. * either through harmonics for rough material or through the refelction for shiny ones.
  27793. */
  27794. environmentIntensity: number;
  27795. /**
  27796. * This is a special control allowing the reduction of the specular highlights coming from the
  27797. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27798. */
  27799. specularIntensity: number;
  27800. /**
  27801. * Debug Control allowing disabling the bump map on this material.
  27802. */
  27803. disableBumpMap: boolean;
  27804. /**
  27805. * AKA Diffuse Texture in standard nomenclature.
  27806. */
  27807. albedoTexture: BaseTexture;
  27808. /**
  27809. * AKA Occlusion Texture in other nomenclature.
  27810. */
  27811. ambientTexture: BaseTexture;
  27812. /**
  27813. * AKA Occlusion Texture Intensity in other nomenclature.
  27814. */
  27815. ambientTextureStrength: number;
  27816. /**
  27817. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27818. * 1 means it completely occludes it
  27819. * 0 mean it has no impact
  27820. */
  27821. ambientTextureImpactOnAnalyticalLights: number;
  27822. /**
  27823. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  27824. */
  27825. opacityTexture: BaseTexture;
  27826. /**
  27827. * Stores the reflection values in a texture.
  27828. */
  27829. reflectionTexture: Nullable<BaseTexture>;
  27830. /**
  27831. * Stores the emissive values in a texture.
  27832. */
  27833. emissiveTexture: BaseTexture;
  27834. /**
  27835. * AKA Specular texture in other nomenclature.
  27836. */
  27837. reflectivityTexture: BaseTexture;
  27838. /**
  27839. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27840. */
  27841. metallicTexture: BaseTexture;
  27842. /**
  27843. * Specifies the metallic scalar of the metallic/roughness workflow.
  27844. * Can also be used to scale the metalness values of the metallic texture.
  27845. */
  27846. metallic: Nullable<number>;
  27847. /**
  27848. * Specifies the roughness scalar of the metallic/roughness workflow.
  27849. * Can also be used to scale the roughness values of the metallic texture.
  27850. */
  27851. roughness: Nullable<number>;
  27852. /**
  27853. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27854. * By default the indexOfrefraction is used to compute F0;
  27855. *
  27856. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27857. *
  27858. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27859. * F90 = metallicReflectanceColor;
  27860. */
  27861. metallicF0Factor: number;
  27862. /**
  27863. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27864. * By default the F90 is always 1;
  27865. *
  27866. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27867. *
  27868. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27869. * F90 = metallicReflectanceColor;
  27870. */
  27871. metallicReflectanceColor: Color3;
  27872. /**
  27873. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27874. * This is multiply against the scalar values defined in the material.
  27875. */
  27876. metallicReflectanceTexture: Nullable<BaseTexture>;
  27877. /**
  27878. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27879. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27880. */
  27881. microSurfaceTexture: BaseTexture;
  27882. /**
  27883. * Stores surface normal data used to displace a mesh in a texture.
  27884. */
  27885. bumpTexture: BaseTexture;
  27886. /**
  27887. * Stores the pre-calculated light information of a mesh in a texture.
  27888. */
  27889. lightmapTexture: BaseTexture;
  27890. /**
  27891. * Stores the refracted light information in a texture.
  27892. */
  27893. get refractionTexture(): Nullable<BaseTexture>;
  27894. set refractionTexture(value: Nullable<BaseTexture>);
  27895. /**
  27896. * The color of a material in ambient lighting.
  27897. */
  27898. ambientColor: Color3;
  27899. /**
  27900. * AKA Diffuse Color in other nomenclature.
  27901. */
  27902. albedoColor: Color3;
  27903. /**
  27904. * AKA Specular Color in other nomenclature.
  27905. */
  27906. reflectivityColor: Color3;
  27907. /**
  27908. * The color reflected from the material.
  27909. */
  27910. reflectionColor: Color3;
  27911. /**
  27912. * The color emitted from the material.
  27913. */
  27914. emissiveColor: Color3;
  27915. /**
  27916. * AKA Glossiness in other nomenclature.
  27917. */
  27918. microSurface: number;
  27919. /**
  27920. * Index of refraction of the material base layer.
  27921. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  27922. *
  27923. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  27924. *
  27925. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  27926. */
  27927. get indexOfRefraction(): number;
  27928. set indexOfRefraction(value: number);
  27929. /**
  27930. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  27931. */
  27932. get invertRefractionY(): boolean;
  27933. set invertRefractionY(value: boolean);
  27934. /**
  27935. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  27936. * Materials half opaque for instance using refraction could benefit from this control.
  27937. */
  27938. get linkRefractionWithTransparency(): boolean;
  27939. set linkRefractionWithTransparency(value: boolean);
  27940. /**
  27941. * If true, the light map contains occlusion information instead of lighting info.
  27942. */
  27943. useLightmapAsShadowmap: boolean;
  27944. /**
  27945. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27946. */
  27947. useAlphaFromAlbedoTexture: boolean;
  27948. /**
  27949. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27950. */
  27951. forceAlphaTest: boolean;
  27952. /**
  27953. * Defines the alpha limits in alpha test mode.
  27954. */
  27955. alphaCutOff: number;
  27956. /**
  27957. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27958. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27959. */
  27960. useSpecularOverAlpha: boolean;
  27961. /**
  27962. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27963. */
  27964. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27965. /**
  27966. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27967. */
  27968. useRoughnessFromMetallicTextureAlpha: boolean;
  27969. /**
  27970. * Specifies if the metallic texture contains the roughness information in its green channel.
  27971. */
  27972. useRoughnessFromMetallicTextureGreen: boolean;
  27973. /**
  27974. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27975. */
  27976. useMetallnessFromMetallicTextureBlue: boolean;
  27977. /**
  27978. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27979. */
  27980. useAmbientOcclusionFromMetallicTextureRed: boolean;
  27981. /**
  27982. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27983. */
  27984. useAmbientInGrayScale: boolean;
  27985. /**
  27986. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27987. * The material will try to infer what glossiness each pixel should be.
  27988. */
  27989. useAutoMicroSurfaceFromReflectivityMap: boolean;
  27990. /**
  27991. * BJS is using an harcoded light falloff based on a manually sets up range.
  27992. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27993. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27994. */
  27995. get usePhysicalLightFalloff(): boolean;
  27996. /**
  27997. * BJS is using an harcoded light falloff based on a manually sets up range.
  27998. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27999. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  28000. */
  28001. set usePhysicalLightFalloff(value: boolean);
  28002. /**
  28003. * In order to support the falloff compatibility with gltf, a special mode has been added
  28004. * to reproduce the gltf light falloff.
  28005. */
  28006. get useGLTFLightFalloff(): boolean;
  28007. /**
  28008. * In order to support the falloff compatibility with gltf, a special mode has been added
  28009. * to reproduce the gltf light falloff.
  28010. */
  28011. set useGLTFLightFalloff(value: boolean);
  28012. /**
  28013. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  28014. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  28015. */
  28016. useRadianceOverAlpha: boolean;
  28017. /**
  28018. * Allows using an object space normal map (instead of tangent space).
  28019. */
  28020. useObjectSpaceNormalMap: boolean;
  28021. /**
  28022. * Allows using the bump map in parallax mode.
  28023. */
  28024. useParallax: boolean;
  28025. /**
  28026. * Allows using the bump map in parallax occlusion mode.
  28027. */
  28028. useParallaxOcclusion: boolean;
  28029. /**
  28030. * Controls the scale bias of the parallax mode.
  28031. */
  28032. parallaxScaleBias: number;
  28033. /**
  28034. * If sets to true, disables all the lights affecting the material.
  28035. */
  28036. disableLighting: boolean;
  28037. /**
  28038. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  28039. */
  28040. forceIrradianceInFragment: boolean;
  28041. /**
  28042. * Number of Simultaneous lights allowed on the material.
  28043. */
  28044. maxSimultaneousLights: number;
  28045. /**
  28046. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  28047. */
  28048. invertNormalMapX: boolean;
  28049. /**
  28050. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  28051. */
  28052. invertNormalMapY: boolean;
  28053. /**
  28054. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  28055. */
  28056. twoSidedLighting: boolean;
  28057. /**
  28058. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28059. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  28060. */
  28061. useAlphaFresnel: boolean;
  28062. /**
  28063. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28064. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  28065. */
  28066. useLinearAlphaFresnel: boolean;
  28067. /**
  28068. * Let user defines the brdf lookup texture used for IBL.
  28069. * A default 8bit version is embedded but you could point at :
  28070. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  28071. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  28072. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  28073. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  28074. */
  28075. environmentBRDFTexture: Nullable<BaseTexture>;
  28076. /**
  28077. * Force normal to face away from face.
  28078. */
  28079. forceNormalForward: boolean;
  28080. /**
  28081. * Enables specular anti aliasing in the PBR shader.
  28082. * It will both interacts on the Geometry for analytical and IBL lighting.
  28083. * It also prefilter the roughness map based on the bump values.
  28084. */
  28085. enableSpecularAntiAliasing: boolean;
  28086. /**
  28087. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  28088. * makes the reflect vector face the model (under horizon).
  28089. */
  28090. useHorizonOcclusion: boolean;
  28091. /**
  28092. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  28093. * too much the area relying on ambient texture to define their ambient occlusion.
  28094. */
  28095. useRadianceOcclusion: boolean;
  28096. /**
  28097. * If set to true, no lighting calculations will be applied.
  28098. */
  28099. unlit: boolean;
  28100. /**
  28101. * Gets the image processing configuration used either in this material.
  28102. */
  28103. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  28104. /**
  28105. * Sets the Default image processing configuration used either in the this material.
  28106. *
  28107. * If sets to null, the scene one is in use.
  28108. */
  28109. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  28110. /**
  28111. * Gets wether the color curves effect is enabled.
  28112. */
  28113. get cameraColorCurvesEnabled(): boolean;
  28114. /**
  28115. * Sets wether the color curves effect is enabled.
  28116. */
  28117. set cameraColorCurvesEnabled(value: boolean);
  28118. /**
  28119. * Gets wether the color grading effect is enabled.
  28120. */
  28121. get cameraColorGradingEnabled(): boolean;
  28122. /**
  28123. * Gets wether the color grading effect is enabled.
  28124. */
  28125. set cameraColorGradingEnabled(value: boolean);
  28126. /**
  28127. * Gets wether tonemapping is enabled or not.
  28128. */
  28129. get cameraToneMappingEnabled(): boolean;
  28130. /**
  28131. * Sets wether tonemapping is enabled or not
  28132. */
  28133. set cameraToneMappingEnabled(value: boolean);
  28134. /**
  28135. * The camera exposure used on this material.
  28136. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28137. * This corresponds to a photographic exposure.
  28138. */
  28139. get cameraExposure(): number;
  28140. /**
  28141. * The camera exposure used on this material.
  28142. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28143. * This corresponds to a photographic exposure.
  28144. */
  28145. set cameraExposure(value: number);
  28146. /**
  28147. * Gets The camera contrast used on this material.
  28148. */
  28149. get cameraContrast(): number;
  28150. /**
  28151. * Sets The camera contrast used on this material.
  28152. */
  28153. set cameraContrast(value: number);
  28154. /**
  28155. * Gets the Color Grading 2D Lookup Texture.
  28156. */
  28157. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  28158. /**
  28159. * Sets the Color Grading 2D Lookup Texture.
  28160. */
  28161. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  28162. /**
  28163. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28164. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28165. * 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;
  28166. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28167. */
  28168. get cameraColorCurves(): Nullable<ColorCurves>;
  28169. /**
  28170. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28171. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28172. * 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;
  28173. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28174. */
  28175. set cameraColorCurves(value: Nullable<ColorCurves>);
  28176. /**
  28177. * Instantiates a new PBRMaterial instance.
  28178. *
  28179. * @param name The material name
  28180. * @param scene The scene the material will be use in.
  28181. */
  28182. constructor(name: string, scene: Scene);
  28183. /**
  28184. * Returns the name of this material class.
  28185. */
  28186. getClassName(): string;
  28187. /**
  28188. * Makes a duplicate of the current material.
  28189. * @param name - name to use for the new material.
  28190. */
  28191. clone(name: string): PBRMaterial;
  28192. /**
  28193. * Serializes this PBR Material.
  28194. * @returns - An object with the serialized material.
  28195. */
  28196. serialize(): any;
  28197. /**
  28198. * Parses a PBR Material from a serialized object.
  28199. * @param source - Serialized object.
  28200. * @param scene - BJS scene instance.
  28201. * @param rootUrl - url for the scene object
  28202. * @returns - PBRMaterial
  28203. */
  28204. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  28205. }
  28206. }
  28207. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  28208. /** @hidden */
  28209. export var mrtFragmentDeclaration: {
  28210. name: string;
  28211. shader: string;
  28212. };
  28213. }
  28214. declare module "babylonjs/Shaders/geometry.fragment" {
  28215. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  28216. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  28217. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  28218. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  28219. /** @hidden */
  28220. export var geometryPixelShader: {
  28221. name: string;
  28222. shader: string;
  28223. };
  28224. }
  28225. declare module "babylonjs/Shaders/geometry.vertex" {
  28226. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  28227. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  28228. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  28229. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  28230. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  28231. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  28232. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  28233. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  28234. /** @hidden */
  28235. export var geometryVertexShader: {
  28236. name: string;
  28237. shader: string;
  28238. };
  28239. }
  28240. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  28241. import { Matrix } from "babylonjs/Maths/math.vector";
  28242. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28243. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28244. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28245. import { Effect } from "babylonjs/Materials/effect";
  28246. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28247. import { Scene } from "babylonjs/scene";
  28248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28249. import { Nullable } from "babylonjs/types";
  28250. import "babylonjs/Shaders/geometry.fragment";
  28251. import "babylonjs/Shaders/geometry.vertex";
  28252. /** @hidden */
  28253. interface ISavedTransformationMatrix {
  28254. world: Matrix;
  28255. viewProjection: Matrix;
  28256. }
  28257. /**
  28258. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  28259. */
  28260. export class GeometryBufferRenderer {
  28261. /**
  28262. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  28263. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  28264. */
  28265. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  28266. /**
  28267. * Constant used to retrieve the position texture index in the G-Buffer textures array
  28268. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  28269. */
  28270. static readonly POSITION_TEXTURE_TYPE: number;
  28271. /**
  28272. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  28273. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  28274. */
  28275. static readonly VELOCITY_TEXTURE_TYPE: number;
  28276. /**
  28277. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  28278. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  28279. */
  28280. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  28281. /**
  28282. * Dictionary used to store the previous transformation matrices of each rendered mesh
  28283. * in order to compute objects velocities when enableVelocity is set to "true"
  28284. * @hidden
  28285. */
  28286. _previousTransformationMatrices: {
  28287. [index: number]: ISavedTransformationMatrix;
  28288. };
  28289. /**
  28290. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  28291. * in order to compute objects velocities when enableVelocity is set to "true"
  28292. * @hidden
  28293. */
  28294. _previousBonesTransformationMatrices: {
  28295. [index: number]: Float32Array;
  28296. };
  28297. /**
  28298. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  28299. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  28300. */
  28301. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  28302. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  28303. renderTransparentMeshes: boolean;
  28304. private _scene;
  28305. private _resizeObserver;
  28306. private _multiRenderTarget;
  28307. private _ratio;
  28308. private _enablePosition;
  28309. private _enableVelocity;
  28310. private _enableReflectivity;
  28311. private _positionIndex;
  28312. private _velocityIndex;
  28313. private _reflectivityIndex;
  28314. private _depthNormalIndex;
  28315. private _linkedWithPrePass;
  28316. private _prePassRenderer;
  28317. private _attachments;
  28318. protected _effect: Effect;
  28319. protected _cachedDefines: string;
  28320. /**
  28321. * @hidden
  28322. * Sets up internal structures to share outputs with PrePassRenderer
  28323. * This method should only be called by the PrePassRenderer itself
  28324. */
  28325. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  28326. /**
  28327. * @hidden
  28328. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  28329. * This method should only be called by the PrePassRenderer itself
  28330. */
  28331. _unlinkPrePassRenderer(): void;
  28332. /**
  28333. * @hidden
  28334. * Resets the geometry buffer layout
  28335. */
  28336. _resetLayout(): void;
  28337. /**
  28338. * @hidden
  28339. * Replaces a texture in the geometry buffer renderer
  28340. * Useful when linking textures of the prepass renderer
  28341. */
  28342. _forceTextureType(geometryBufferType: number, index: number): void;
  28343. /**
  28344. * @hidden
  28345. * Sets texture attachments
  28346. * Useful when linking textures of the prepass renderer
  28347. */
  28348. _setAttachments(attachments: number[]): void;
  28349. /**
  28350. * @hidden
  28351. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  28352. * Useful when linking textures of the prepass renderer
  28353. */
  28354. _linkInternalTexture(internalTexture: InternalTexture): void;
  28355. /**
  28356. * Gets the render list (meshes to be rendered) used in the G buffer.
  28357. */
  28358. get renderList(): Nullable<AbstractMesh[]>;
  28359. /**
  28360. * Set the render list (meshes to be rendered) used in the G buffer.
  28361. */
  28362. set renderList(meshes: Nullable<AbstractMesh[]>);
  28363. /**
  28364. * Gets wether or not G buffer are supported by the running hardware.
  28365. * This requires draw buffer supports
  28366. */
  28367. get isSupported(): boolean;
  28368. /**
  28369. * Returns the index of the given texture type in the G-Buffer textures array
  28370. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  28371. * @returns the index of the given texture type in the G-Buffer textures array
  28372. */
  28373. getTextureIndex(textureType: number): number;
  28374. /**
  28375. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  28376. */
  28377. get enablePosition(): boolean;
  28378. /**
  28379. * Sets whether or not objects positions are enabled for the G buffer.
  28380. */
  28381. set enablePosition(enable: boolean);
  28382. /**
  28383. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  28384. */
  28385. get enableVelocity(): boolean;
  28386. /**
  28387. * Sets wether or not objects velocities are enabled for the G buffer.
  28388. */
  28389. set enableVelocity(enable: boolean);
  28390. /**
  28391. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  28392. */
  28393. get enableReflectivity(): boolean;
  28394. /**
  28395. * Sets wether or not objects roughness are enabled for the G buffer.
  28396. */
  28397. set enableReflectivity(enable: boolean);
  28398. /**
  28399. * Gets the scene associated with the buffer.
  28400. */
  28401. get scene(): Scene;
  28402. /**
  28403. * Gets the ratio used by the buffer during its creation.
  28404. * How big is the buffer related to the main canvas.
  28405. */
  28406. get ratio(): number;
  28407. /** @hidden */
  28408. static _SceneComponentInitialization: (scene: Scene) => void;
  28409. /**
  28410. * Creates a new G Buffer for the scene
  28411. * @param scene The scene the buffer belongs to
  28412. * @param ratio How big is the buffer related to the main canvas.
  28413. */
  28414. constructor(scene: Scene, ratio?: number);
  28415. /**
  28416. * Checks wether everything is ready to render a submesh to the G buffer.
  28417. * @param subMesh the submesh to check readiness for
  28418. * @param useInstances is the mesh drawn using instance or not
  28419. * @returns true if ready otherwise false
  28420. */
  28421. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28422. /**
  28423. * Gets the current underlying G Buffer.
  28424. * @returns the buffer
  28425. */
  28426. getGBuffer(): MultiRenderTarget;
  28427. /**
  28428. * Gets the number of samples used to render the buffer (anti aliasing).
  28429. */
  28430. get samples(): number;
  28431. /**
  28432. * Sets the number of samples used to render the buffer (anti aliasing).
  28433. */
  28434. set samples(value: number);
  28435. /**
  28436. * Disposes the renderer and frees up associated resources.
  28437. */
  28438. dispose(): void;
  28439. private _assignRenderTargetIndices;
  28440. protected _createRenderTargets(): void;
  28441. private _copyBonesTransformationMatrices;
  28442. }
  28443. }
  28444. declare module "babylonjs/Rendering/prePassRenderer" {
  28445. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28446. import { Scene } from "babylonjs/scene";
  28447. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  28448. import { Effect } from "babylonjs/Materials/effect";
  28449. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28451. import { Material } from "babylonjs/Materials/material";
  28452. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28453. /**
  28454. * Renders a pre pass of the scene
  28455. * This means every mesh in the scene will be rendered to a render target texture
  28456. * And then this texture will be composited to the rendering canvas with post processes
  28457. * It is necessary for effects like subsurface scattering or deferred shading
  28458. */
  28459. export class PrePassRenderer {
  28460. /** @hidden */
  28461. static _SceneComponentInitialization: (scene: Scene) => void;
  28462. private _textureFormats;
  28463. /**
  28464. * To save performance, we can excluded skinned meshes from the prepass
  28465. */
  28466. excludedSkinnedMesh: AbstractMesh[];
  28467. /**
  28468. * Force material to be excluded from the prepass
  28469. * Can be useful when `useGeometryBufferFallback` is set to `true`
  28470. * and you don't want a material to show in the effect.
  28471. */
  28472. excludedMaterials: Material[];
  28473. private _textureIndices;
  28474. private _scene;
  28475. private _engine;
  28476. private _isDirty;
  28477. /**
  28478. * Number of textures in the multi render target texture where the scene is directly rendered
  28479. */
  28480. mrtCount: number;
  28481. /**
  28482. * The render target where the scene is directly rendered
  28483. */
  28484. prePassRT: MultiRenderTarget;
  28485. private _multiRenderAttachments;
  28486. private _defaultAttachments;
  28487. private _clearAttachments;
  28488. private _postProcesses;
  28489. private readonly _clearColor;
  28490. /**
  28491. * Image processing post process for composition
  28492. */
  28493. imageProcessingPostProcess: ImageProcessingPostProcess;
  28494. /**
  28495. * Configuration for prepass effects
  28496. */
  28497. private _effectConfigurations;
  28498. private _mrtFormats;
  28499. private _mrtLayout;
  28500. private _enabled;
  28501. /**
  28502. * Indicates if the prepass is enabled
  28503. */
  28504. get enabled(): boolean;
  28505. /**
  28506. * How many samples are used for MSAA of the scene render target
  28507. */
  28508. get samples(): number;
  28509. set samples(n: number);
  28510. private _geometryBuffer;
  28511. private _useGeometryBufferFallback;
  28512. /**
  28513. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  28514. */
  28515. get useGeometryBufferFallback(): boolean;
  28516. set useGeometryBufferFallback(value: boolean);
  28517. /**
  28518. * Instanciates a prepass renderer
  28519. * @param scene The scene
  28520. */
  28521. constructor(scene: Scene);
  28522. private _initializeAttachments;
  28523. private _createCompositionEffect;
  28524. /**
  28525. * Indicates if rendering a prepass is supported
  28526. */
  28527. get isSupported(): boolean;
  28528. /**
  28529. * Sets the proper output textures to draw in the engine.
  28530. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  28531. * @param subMesh Submesh on which the effect is applied
  28532. */
  28533. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  28534. /**
  28535. * @hidden
  28536. */
  28537. _beforeCameraDraw(): void;
  28538. /**
  28539. * @hidden
  28540. */
  28541. _afterCameraDraw(): void;
  28542. private _checkRTSize;
  28543. private _bindFrameBuffer;
  28544. /**
  28545. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  28546. */
  28547. clear(): void;
  28548. private _setState;
  28549. private _updateGeometryBufferLayout;
  28550. /**
  28551. * Adds an effect configuration to the prepass.
  28552. * If an effect has already been added, it won't add it twice and will return the configuration
  28553. * already present.
  28554. * @param cfg the effect configuration
  28555. * @return the effect configuration now used by the prepass
  28556. */
  28557. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  28558. /**
  28559. * Returns the index of a texture in the multi render target texture array.
  28560. * @param type Texture type
  28561. * @return The index
  28562. */
  28563. getIndex(type: number): number;
  28564. private _enable;
  28565. private _disable;
  28566. private _resetLayout;
  28567. private _resetPostProcessChain;
  28568. private _bindPostProcessChain;
  28569. /**
  28570. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  28571. */
  28572. markAsDirty(): void;
  28573. /**
  28574. * Enables a texture on the MultiRenderTarget for prepass
  28575. */
  28576. private _enableTextures;
  28577. private _update;
  28578. private _markAllMaterialsAsPrePassDirty;
  28579. /**
  28580. * Disposes the prepass renderer.
  28581. */
  28582. dispose(): void;
  28583. }
  28584. }
  28585. declare module "babylonjs/PostProcesses/postProcess" {
  28586. import { Nullable } from "babylonjs/types";
  28587. import { SmartArray } from "babylonjs/Misc/smartArray";
  28588. import { Observable } from "babylonjs/Misc/observable";
  28589. import { Vector2 } from "babylonjs/Maths/math.vector";
  28590. import { Camera } from "babylonjs/Cameras/camera";
  28591. import { Effect } from "babylonjs/Materials/effect";
  28592. import "babylonjs/Shaders/postprocess.vertex";
  28593. import { IInspectable } from "babylonjs/Misc/iInspectable";
  28594. import { Engine } from "babylonjs/Engines/engine";
  28595. import { Color4 } from "babylonjs/Maths/math.color";
  28596. import "babylonjs/Engines/Extensions/engine.renderTarget";
  28597. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  28598. import { Scene } from "babylonjs/scene";
  28599. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28600. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28601. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28602. /**
  28603. * Size options for a post process
  28604. */
  28605. export type PostProcessOptions = {
  28606. width: number;
  28607. height: number;
  28608. };
  28609. /**
  28610. * PostProcess can be used to apply a shader to a texture after it has been rendered
  28611. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28612. */
  28613. export class PostProcess {
  28614. /**
  28615. * Gets or sets the unique id of the post process
  28616. */
  28617. uniqueId: number;
  28618. /** Name of the PostProcess. */
  28619. name: string;
  28620. /**
  28621. * Width of the texture to apply the post process on
  28622. */
  28623. width: number;
  28624. /**
  28625. * Height of the texture to apply the post process on
  28626. */
  28627. height: number;
  28628. /**
  28629. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  28630. */
  28631. nodeMaterialSource: Nullable<NodeMaterial>;
  28632. /**
  28633. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  28634. * @hidden
  28635. */
  28636. _outputTexture: Nullable<InternalTexture>;
  28637. /**
  28638. * Sampling mode used by the shader
  28639. * See https://doc.babylonjs.com/classes/3.1/texture
  28640. */
  28641. renderTargetSamplingMode: number;
  28642. /**
  28643. * Clear color to use when screen clearing
  28644. */
  28645. clearColor: Color4;
  28646. /**
  28647. * If the buffer needs to be cleared before applying the post process. (default: true)
  28648. * Should be set to false if shader will overwrite all previous pixels.
  28649. */
  28650. autoClear: boolean;
  28651. /**
  28652. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  28653. */
  28654. alphaMode: number;
  28655. /**
  28656. * Sets the setAlphaBlendConstants of the babylon engine
  28657. */
  28658. alphaConstants: Color4;
  28659. /**
  28660. * Animations to be used for the post processing
  28661. */
  28662. animations: import("babylonjs/Animations/animation").Animation[];
  28663. /**
  28664. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  28665. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  28666. */
  28667. enablePixelPerfectMode: boolean;
  28668. /**
  28669. * Force the postprocess to be applied without taking in account viewport
  28670. */
  28671. forceFullscreenViewport: boolean;
  28672. /**
  28673. * List of inspectable custom properties (used by the Inspector)
  28674. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28675. */
  28676. inspectableCustomProperties: IInspectable[];
  28677. /**
  28678. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  28679. *
  28680. * | Value | Type | Description |
  28681. * | ----- | ----------------------------------- | ----------- |
  28682. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  28683. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  28684. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  28685. *
  28686. */
  28687. scaleMode: number;
  28688. /**
  28689. * Force textures to be a power of two (default: false)
  28690. */
  28691. alwaysForcePOT: boolean;
  28692. private _samples;
  28693. /**
  28694. * Number of sample textures (default: 1)
  28695. */
  28696. get samples(): number;
  28697. set samples(n: number);
  28698. /**
  28699. * Modify the scale of the post process to be the same as the viewport (default: false)
  28700. */
  28701. adaptScaleToCurrentViewport: boolean;
  28702. private _camera;
  28703. protected _scene: Scene;
  28704. private _engine;
  28705. private _options;
  28706. private _reusable;
  28707. private _textureType;
  28708. private _textureFormat;
  28709. /**
  28710. * Smart array of input and output textures for the post process.
  28711. * @hidden
  28712. */
  28713. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  28714. /**
  28715. * The index in _textures that corresponds to the output texture.
  28716. * @hidden
  28717. */
  28718. _currentRenderTextureInd: number;
  28719. private _effect;
  28720. private _samplers;
  28721. private _fragmentUrl;
  28722. private _vertexUrl;
  28723. private _parameters;
  28724. private _scaleRatio;
  28725. protected _indexParameters: any;
  28726. private _shareOutputWithPostProcess;
  28727. private _texelSize;
  28728. private _forcedOutputTexture;
  28729. /**
  28730. * Prepass configuration in case this post process needs a texture from prepass
  28731. * @hidden
  28732. */
  28733. _prePassEffectConfiguration: PrePassEffectConfiguration;
  28734. /**
  28735. * Returns the fragment url or shader name used in the post process.
  28736. * @returns the fragment url or name in the shader store.
  28737. */
  28738. getEffectName(): string;
  28739. /**
  28740. * An event triggered when the postprocess is activated.
  28741. */
  28742. onActivateObservable: Observable<Camera>;
  28743. private _onActivateObserver;
  28744. /**
  28745. * A function that is added to the onActivateObservable
  28746. */
  28747. set onActivate(callback: Nullable<(camera: Camera) => void>);
  28748. /**
  28749. * An event triggered when the postprocess changes its size.
  28750. */
  28751. onSizeChangedObservable: Observable<PostProcess>;
  28752. private _onSizeChangedObserver;
  28753. /**
  28754. * A function that is added to the onSizeChangedObservable
  28755. */
  28756. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  28757. /**
  28758. * An event triggered when the postprocess applies its effect.
  28759. */
  28760. onApplyObservable: Observable<Effect>;
  28761. private _onApplyObserver;
  28762. /**
  28763. * A function that is added to the onApplyObservable
  28764. */
  28765. set onApply(callback: (effect: Effect) => void);
  28766. /**
  28767. * An event triggered before rendering the postprocess
  28768. */
  28769. onBeforeRenderObservable: Observable<Effect>;
  28770. private _onBeforeRenderObserver;
  28771. /**
  28772. * A function that is added to the onBeforeRenderObservable
  28773. */
  28774. set onBeforeRender(callback: (effect: Effect) => void);
  28775. /**
  28776. * An event triggered after rendering the postprocess
  28777. */
  28778. onAfterRenderObservable: Observable<Effect>;
  28779. private _onAfterRenderObserver;
  28780. /**
  28781. * A function that is added to the onAfterRenderObservable
  28782. */
  28783. set onAfterRender(callback: (efect: Effect) => void);
  28784. /**
  28785. * 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
  28786. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  28787. */
  28788. get inputTexture(): InternalTexture;
  28789. set inputTexture(value: InternalTexture);
  28790. /**
  28791. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  28792. * the only way to unset it is to use this function to restore its internal state
  28793. */
  28794. restoreDefaultInputTexture(): void;
  28795. /**
  28796. * Gets the camera which post process is applied to.
  28797. * @returns The camera the post process is applied to.
  28798. */
  28799. getCamera(): Camera;
  28800. /**
  28801. * Gets the texel size of the postprocess.
  28802. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  28803. */
  28804. get texelSize(): Vector2;
  28805. /**
  28806. * Creates a new instance PostProcess
  28807. * @param name The name of the PostProcess.
  28808. * @param fragmentUrl The url of the fragment shader to be used.
  28809. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  28810. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  28811. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28812. * @param camera The camera to apply the render pass to.
  28813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28814. * @param engine The engine which the post process will be applied. (default: current engine)
  28815. * @param reusable If the post process can be reused on the same frame. (default: false)
  28816. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  28817. * @param textureType Type of textures used when performing the post process. (default: 0)
  28818. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  28819. * @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
  28820. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  28821. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  28822. */
  28823. 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);
  28824. /**
  28825. * Gets a string identifying the name of the class
  28826. * @returns "PostProcess" string
  28827. */
  28828. getClassName(): string;
  28829. /**
  28830. * Gets the engine which this post process belongs to.
  28831. * @returns The engine the post process was enabled with.
  28832. */
  28833. getEngine(): Engine;
  28834. /**
  28835. * The effect that is created when initializing the post process.
  28836. * @returns The created effect corresponding the the postprocess.
  28837. */
  28838. getEffect(): Effect;
  28839. /**
  28840. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  28841. * @param postProcess The post process to share the output with.
  28842. * @returns This post process.
  28843. */
  28844. shareOutputWith(postProcess: PostProcess): PostProcess;
  28845. /**
  28846. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28847. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28848. */
  28849. useOwnOutput(): void;
  28850. /**
  28851. * Updates the effect with the current post process compile time values and recompiles the shader.
  28852. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28853. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28854. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28855. * @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
  28856. * @param onCompiled Called when the shader has been compiled.
  28857. * @param onError Called if there is an error when compiling a shader.
  28858. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  28859. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  28860. */
  28861. 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;
  28862. /**
  28863. * The post process is reusable if it can be used multiple times within one frame.
  28864. * @returns If the post process is reusable
  28865. */
  28866. isReusable(): boolean;
  28867. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28868. markTextureDirty(): void;
  28869. /**
  28870. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28871. * 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.
  28872. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28873. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28874. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28875. * @returns The target texture that was bound to be written to.
  28876. */
  28877. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28878. /**
  28879. * If the post process is supported.
  28880. */
  28881. get isSupported(): boolean;
  28882. /**
  28883. * The aspect ratio of the output texture.
  28884. */
  28885. get aspectRatio(): number;
  28886. /**
  28887. * Get a value indicating if the post-process is ready to be used
  28888. * @returns true if the post-process is ready (shader is compiled)
  28889. */
  28890. isReady(): boolean;
  28891. /**
  28892. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28893. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  28894. */
  28895. apply(): Nullable<Effect>;
  28896. private _disposeTextures;
  28897. /**
  28898. * Sets the required values to the prepass renderer.
  28899. * @param prePassRenderer defines the prepass renderer to setup.
  28900. * @returns true if the pre pass is needed.
  28901. */
  28902. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  28903. /**
  28904. * Disposes the post process.
  28905. * @param camera The camera to dispose the post process on.
  28906. */
  28907. dispose(camera?: Camera): void;
  28908. /**
  28909. * Serializes the particle system to a JSON object
  28910. * @returns the JSON object
  28911. */
  28912. serialize(): any;
  28913. /**
  28914. * Creates a material from parsed material data
  28915. * @param parsedPostProcess defines parsed post process data
  28916. * @param scene defines the hosting scene
  28917. * @param rootUrl defines the root URL to use to load textures
  28918. * @returns a new post process
  28919. */
  28920. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  28921. }
  28922. }
  28923. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  28924. /** @hidden */
  28925. export var kernelBlurVaryingDeclaration: {
  28926. name: string;
  28927. shader: string;
  28928. };
  28929. }
  28930. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  28931. /** @hidden */
  28932. export var kernelBlurFragment: {
  28933. name: string;
  28934. shader: string;
  28935. };
  28936. }
  28937. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  28938. /** @hidden */
  28939. export var kernelBlurFragment2: {
  28940. name: string;
  28941. shader: string;
  28942. };
  28943. }
  28944. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  28945. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  28946. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  28947. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  28948. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  28949. /** @hidden */
  28950. export var kernelBlurPixelShader: {
  28951. name: string;
  28952. shader: string;
  28953. };
  28954. }
  28955. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  28956. /** @hidden */
  28957. export var kernelBlurVertex: {
  28958. name: string;
  28959. shader: string;
  28960. };
  28961. }
  28962. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  28963. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  28964. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  28965. /** @hidden */
  28966. export var kernelBlurVertexShader: {
  28967. name: string;
  28968. shader: string;
  28969. };
  28970. }
  28971. declare module "babylonjs/PostProcesses/blurPostProcess" {
  28972. import { Vector2 } from "babylonjs/Maths/math.vector";
  28973. import { Nullable } from "babylonjs/types";
  28974. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  28975. import { Camera } from "babylonjs/Cameras/camera";
  28976. import { Effect } from "babylonjs/Materials/effect";
  28977. import { Engine } from "babylonjs/Engines/engine";
  28978. import "babylonjs/Shaders/kernelBlur.fragment";
  28979. import "babylonjs/Shaders/kernelBlur.vertex";
  28980. import { Scene } from "babylonjs/scene";
  28981. /**
  28982. * The Blur Post Process which blurs an image based on a kernel and direction.
  28983. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  28984. */
  28985. export class BlurPostProcess extends PostProcess {
  28986. private blockCompilation;
  28987. protected _kernel: number;
  28988. protected _idealKernel: number;
  28989. protected _packedFloat: boolean;
  28990. private _staticDefines;
  28991. /** The direction in which to blur the image. */
  28992. direction: Vector2;
  28993. /**
  28994. * Sets the length in pixels of the blur sample region
  28995. */
  28996. set kernel(v: number);
  28997. /**
  28998. * Gets the length in pixels of the blur sample region
  28999. */
  29000. get kernel(): number;
  29001. /**
  29002. * Sets wether or not the blur needs to unpack/repack floats
  29003. */
  29004. set packedFloat(v: boolean);
  29005. /**
  29006. * Gets wether or not the blur is unpacking/repacking floats
  29007. */
  29008. get packedFloat(): boolean;
  29009. /**
  29010. * Gets a string identifying the name of the class
  29011. * @returns "BlurPostProcess" string
  29012. */
  29013. getClassName(): string;
  29014. /**
  29015. * Creates a new instance BlurPostProcess
  29016. * @param name The name of the effect.
  29017. * @param direction The direction in which to blur the image.
  29018. * @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.
  29019. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  29020. * @param camera The camera to apply the render pass to.
  29021. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  29022. * @param engine The engine which the post process will be applied. (default: current engine)
  29023. * @param reusable If the post process can be reused on the same frame. (default: false)
  29024. * @param textureType Type of textures used when performing the post process. (default: 0)
  29025. * @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)
  29026. */
  29027. 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);
  29028. /**
  29029. * Updates the effect with the current post process compile time values and recompiles the shader.
  29030. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  29031. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  29032. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  29033. * @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
  29034. * @param onCompiled Called when the shader has been compiled.
  29035. * @param onError Called if there is an error when compiling a shader.
  29036. */
  29037. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  29038. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  29039. /**
  29040. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  29041. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  29042. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  29043. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  29044. * The gaps between physical kernels are compensated for in the weighting of the samples
  29045. * @param idealKernel Ideal blur kernel.
  29046. * @return Nearest best kernel.
  29047. */
  29048. protected _nearestBestKernel(idealKernel: number): number;
  29049. /**
  29050. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  29051. * @param x The point on the Gaussian distribution to sample.
  29052. * @return the value of the Gaussian function at x.
  29053. */
  29054. protected _gaussianWeight(x: number): number;
  29055. /**
  29056. * Generates a string that can be used as a floating point number in GLSL.
  29057. * @param x Value to print.
  29058. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  29059. * @return GLSL float string.
  29060. */
  29061. protected _glslFloat(x: number, decimalFigures?: number): string;
  29062. /** @hidden */
  29063. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  29064. }
  29065. }
  29066. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  29067. import { Scene } from "babylonjs/scene";
  29068. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29069. import { Plane } from "babylonjs/Maths/math.plane";
  29070. /**
  29071. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29072. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29073. * You can then easily use it as a reflectionTexture on a flat surface.
  29074. * In case the surface is not a plane, please consider relying on reflection probes.
  29075. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29076. */
  29077. export class MirrorTexture extends RenderTargetTexture {
  29078. private scene;
  29079. /**
  29080. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  29081. * 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.
  29082. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29083. */
  29084. mirrorPlane: Plane;
  29085. /**
  29086. * Define the blur ratio used to blur the reflection if needed.
  29087. */
  29088. set blurRatio(value: number);
  29089. get blurRatio(): number;
  29090. /**
  29091. * Define the adaptive blur kernel used to blur the reflection if needed.
  29092. * This will autocompute the closest best match for the `blurKernel`
  29093. */
  29094. set adaptiveBlurKernel(value: number);
  29095. /**
  29096. * Define the blur kernel used to blur the reflection if needed.
  29097. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29098. */
  29099. set blurKernel(value: number);
  29100. /**
  29101. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  29102. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29103. */
  29104. set blurKernelX(value: number);
  29105. get blurKernelX(): number;
  29106. /**
  29107. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  29108. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29109. */
  29110. set blurKernelY(value: number);
  29111. get blurKernelY(): number;
  29112. private _autoComputeBlurKernel;
  29113. protected _onRatioRescale(): void;
  29114. private _updateGammaSpace;
  29115. private _imageProcessingConfigChangeObserver;
  29116. private _transformMatrix;
  29117. private _mirrorMatrix;
  29118. private _savedViewMatrix;
  29119. private _blurX;
  29120. private _blurY;
  29121. private _adaptiveBlurKernel;
  29122. private _blurKernelX;
  29123. private _blurKernelY;
  29124. private _blurRatio;
  29125. /**
  29126. * Instantiates a Mirror Texture.
  29127. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29128. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29129. * You can then easily use it as a reflectionTexture on a flat surface.
  29130. * In case the surface is not a plane, please consider relying on reflection probes.
  29131. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29132. * @param name
  29133. * @param size
  29134. * @param scene
  29135. * @param generateMipMaps
  29136. * @param type
  29137. * @param samplingMode
  29138. * @param generateDepthBuffer
  29139. */
  29140. constructor(name: string, size: number | {
  29141. width: number;
  29142. height: number;
  29143. } | {
  29144. ratio: number;
  29145. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  29146. private _preparePostProcesses;
  29147. /**
  29148. * Clone the mirror texture.
  29149. * @returns the cloned texture
  29150. */
  29151. clone(): MirrorTexture;
  29152. /**
  29153. * Serialize the texture to a JSON representation you could use in Parse later on
  29154. * @returns the serialized JSON representation
  29155. */
  29156. serialize(): any;
  29157. /**
  29158. * Dispose the texture and release its associated resources.
  29159. */
  29160. dispose(): void;
  29161. }
  29162. }
  29163. declare module "babylonjs/Materials/Textures/texture" {
  29164. import { Observable } from "babylonjs/Misc/observable";
  29165. import { Nullable } from "babylonjs/types";
  29166. import { Matrix } from "babylonjs/Maths/math.vector";
  29167. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29168. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29169. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29170. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  29171. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  29172. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29173. import { Scene } from "babylonjs/scene";
  29174. /**
  29175. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29176. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29177. */
  29178. export class Texture extends BaseTexture {
  29179. /**
  29180. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  29181. */
  29182. static SerializeBuffers: boolean;
  29183. /** @hidden */
  29184. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  29185. /** @hidden */
  29186. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  29187. /** @hidden */
  29188. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  29189. /** nearest is mag = nearest and min = nearest and mip = linear */
  29190. static readonly NEAREST_SAMPLINGMODE: number;
  29191. /** nearest is mag = nearest and min = nearest and mip = linear */
  29192. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  29193. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29194. static readonly BILINEAR_SAMPLINGMODE: number;
  29195. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29196. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  29197. /** Trilinear is mag = linear and min = linear and mip = linear */
  29198. static readonly TRILINEAR_SAMPLINGMODE: number;
  29199. /** Trilinear is mag = linear and min = linear and mip = linear */
  29200. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  29201. /** mag = nearest and min = nearest and mip = nearest */
  29202. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  29203. /** mag = nearest and min = linear and mip = nearest */
  29204. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  29205. /** mag = nearest and min = linear and mip = linear */
  29206. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  29207. /** mag = nearest and min = linear and mip = none */
  29208. static readonly NEAREST_LINEAR: number;
  29209. /** mag = nearest and min = nearest and mip = none */
  29210. static readonly NEAREST_NEAREST: number;
  29211. /** mag = linear and min = nearest and mip = nearest */
  29212. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  29213. /** mag = linear and min = nearest and mip = linear */
  29214. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  29215. /** mag = linear and min = linear and mip = none */
  29216. static readonly LINEAR_LINEAR: number;
  29217. /** mag = linear and min = nearest and mip = none */
  29218. static readonly LINEAR_NEAREST: number;
  29219. /** Explicit coordinates mode */
  29220. static readonly EXPLICIT_MODE: number;
  29221. /** Spherical coordinates mode */
  29222. static readonly SPHERICAL_MODE: number;
  29223. /** Planar coordinates mode */
  29224. static readonly PLANAR_MODE: number;
  29225. /** Cubic coordinates mode */
  29226. static readonly CUBIC_MODE: number;
  29227. /** Projection coordinates mode */
  29228. static readonly PROJECTION_MODE: number;
  29229. /** Inverse Cubic coordinates mode */
  29230. static readonly SKYBOX_MODE: number;
  29231. /** Inverse Cubic coordinates mode */
  29232. static readonly INVCUBIC_MODE: number;
  29233. /** Equirectangular coordinates mode */
  29234. static readonly EQUIRECTANGULAR_MODE: number;
  29235. /** Equirectangular Fixed coordinates mode */
  29236. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  29237. /** Equirectangular Fixed Mirrored coordinates mode */
  29238. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29239. /** Texture is not repeating outside of 0..1 UVs */
  29240. static readonly CLAMP_ADDRESSMODE: number;
  29241. /** Texture is repeating outside of 0..1 UVs */
  29242. static readonly WRAP_ADDRESSMODE: number;
  29243. /** Texture is repeating and mirrored */
  29244. static readonly MIRROR_ADDRESSMODE: number;
  29245. /**
  29246. * 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
  29247. */
  29248. static UseSerializedUrlIfAny: boolean;
  29249. /**
  29250. * Define the url of the texture.
  29251. */
  29252. url: Nullable<string>;
  29253. /**
  29254. * Define an offset on the texture to offset the u coordinates of the UVs
  29255. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29256. */
  29257. uOffset: number;
  29258. /**
  29259. * Define an offset on the texture to offset the v coordinates of the UVs
  29260. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29261. */
  29262. vOffset: number;
  29263. /**
  29264. * Define an offset on the texture to scale the u coordinates of the UVs
  29265. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29266. */
  29267. uScale: number;
  29268. /**
  29269. * Define an offset on the texture to scale the v coordinates of the UVs
  29270. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29271. */
  29272. vScale: number;
  29273. /**
  29274. * Define an offset on the texture to rotate around the u coordinates of the UVs
  29275. * @see https://doc.babylonjs.com/how_to/more_materials
  29276. */
  29277. uAng: number;
  29278. /**
  29279. * Define an offset on the texture to rotate around the v coordinates of the UVs
  29280. * @see https://doc.babylonjs.com/how_to/more_materials
  29281. */
  29282. vAng: number;
  29283. /**
  29284. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  29285. * @see https://doc.babylonjs.com/how_to/more_materials
  29286. */
  29287. wAng: number;
  29288. /**
  29289. * Defines the center of rotation (U)
  29290. */
  29291. uRotationCenter: number;
  29292. /**
  29293. * Defines the center of rotation (V)
  29294. */
  29295. vRotationCenter: number;
  29296. /**
  29297. * Defines the center of rotation (W)
  29298. */
  29299. wRotationCenter: number;
  29300. /**
  29301. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  29302. */
  29303. homogeneousRotationInUVTransform: boolean;
  29304. /**
  29305. * Are mip maps generated for this texture or not.
  29306. */
  29307. get noMipmap(): boolean;
  29308. /**
  29309. * List of inspectable custom properties (used by the Inspector)
  29310. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29311. */
  29312. inspectableCustomProperties: Nullable<IInspectable[]>;
  29313. private _noMipmap;
  29314. /** @hidden */
  29315. _invertY: boolean;
  29316. private _rowGenerationMatrix;
  29317. private _cachedTextureMatrix;
  29318. private _projectionModeMatrix;
  29319. private _t0;
  29320. private _t1;
  29321. private _t2;
  29322. private _cachedUOffset;
  29323. private _cachedVOffset;
  29324. private _cachedUScale;
  29325. private _cachedVScale;
  29326. private _cachedUAng;
  29327. private _cachedVAng;
  29328. private _cachedWAng;
  29329. private _cachedProjectionMatrixId;
  29330. private _cachedURotationCenter;
  29331. private _cachedVRotationCenter;
  29332. private _cachedWRotationCenter;
  29333. private _cachedHomogeneousRotationInUVTransform;
  29334. private _cachedCoordinatesMode;
  29335. /** @hidden */
  29336. protected _initialSamplingMode: number;
  29337. /** @hidden */
  29338. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  29339. private _deleteBuffer;
  29340. protected _format: Nullable<number>;
  29341. private _delayedOnLoad;
  29342. private _delayedOnError;
  29343. private _mimeType?;
  29344. private _loaderOptions?;
  29345. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  29346. get mimeType(): string | undefined;
  29347. /**
  29348. * Observable triggered once the texture has been loaded.
  29349. */
  29350. onLoadObservable: Observable<Texture>;
  29351. protected _isBlocking: boolean;
  29352. /**
  29353. * Is the texture preventing material to render while loading.
  29354. * If false, a default texture will be used instead of the loading one during the preparation step.
  29355. */
  29356. set isBlocking(value: boolean);
  29357. get isBlocking(): boolean;
  29358. /**
  29359. * Get the current sampling mode associated with the texture.
  29360. */
  29361. get samplingMode(): number;
  29362. /**
  29363. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  29364. */
  29365. get invertY(): boolean;
  29366. /**
  29367. * Instantiates a new texture.
  29368. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29369. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29370. * @param url defines the url of the picture to load as a texture
  29371. * @param sceneOrEngine defines the scene or engine the texture will belong to
  29372. * @param noMipmap defines if the texture will require mip maps or not
  29373. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  29374. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29375. * @param onLoad defines a callback triggered when the texture has been loaded
  29376. * @param onError defines a callback triggered when an error occurred during the loading session
  29377. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  29378. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  29379. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29380. * @param mimeType defines an optional mime type information
  29381. * @param loaderOptions options to be passed to the loader
  29382. */
  29383. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string, loaderOptions?: any);
  29384. /**
  29385. * Update the url (and optional buffer) of this texture if url was null during construction.
  29386. * @param url the url of the texture
  29387. * @param buffer the buffer of the texture (defaults to null)
  29388. * @param onLoad callback called when the texture is loaded (defaults to null)
  29389. */
  29390. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  29391. /**
  29392. * Finish the loading sequence of a texture flagged as delayed load.
  29393. * @hidden
  29394. */
  29395. delayLoad(): void;
  29396. private _prepareRowForTextureGeneration;
  29397. /**
  29398. * Checks if the texture has the same transform matrix than another texture
  29399. * @param texture texture to check against
  29400. * @returns true if the transforms are the same, else false
  29401. */
  29402. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  29403. /**
  29404. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  29405. * @returns the transform matrix of the texture.
  29406. */
  29407. getTextureMatrix(uBase?: number): Matrix;
  29408. /**
  29409. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  29410. * @returns The reflection texture transform
  29411. */
  29412. getReflectionTextureMatrix(): Matrix;
  29413. /**
  29414. * Clones the texture.
  29415. * @returns the cloned texture
  29416. */
  29417. clone(): Texture;
  29418. /**
  29419. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29420. * @returns The JSON representation of the texture
  29421. */
  29422. serialize(): any;
  29423. /**
  29424. * Get the current class name of the texture useful for serialization or dynamic coding.
  29425. * @returns "Texture"
  29426. */
  29427. getClassName(): string;
  29428. /**
  29429. * Dispose the texture and release its associated resources.
  29430. */
  29431. dispose(): void;
  29432. /**
  29433. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  29434. * @param parsedTexture Define the JSON representation of the texture
  29435. * @param scene Define the scene the parsed texture should be instantiated in
  29436. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  29437. * @returns The parsed texture if successful
  29438. */
  29439. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  29440. /**
  29441. * Creates a texture from its base 64 representation.
  29442. * @param data Define the base64 payload without the data: prefix
  29443. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29444. * @param scene Define the scene the texture should belong to
  29445. * @param noMipmap Forces the texture to not create mip map information if true
  29446. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29447. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29448. * @param onLoad define a callback triggered when the texture has been loaded
  29449. * @param onError define a callback triggered when an error occurred during the loading session
  29450. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29451. * @returns the created texture
  29452. */
  29453. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  29454. /**
  29455. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  29456. * @param data Define the base64 payload without the data: prefix
  29457. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29458. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  29459. * @param scene Define the scene the texture should belong to
  29460. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  29461. * @param noMipmap Forces the texture to not create mip map information if true
  29462. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29463. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29464. * @param onLoad define a callback triggered when the texture has been loaded
  29465. * @param onError define a callback triggered when an error occurred during the loading session
  29466. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29467. * @returns the created texture
  29468. */
  29469. 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;
  29470. }
  29471. }
  29472. declare module "babylonjs/PostProcesses/postProcessManager" {
  29473. import { Nullable } from "babylonjs/types";
  29474. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29475. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29476. import { Scene } from "babylonjs/scene";
  29477. /**
  29478. * PostProcessManager is used to manage one or more post processes or post process pipelines
  29479. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  29480. */
  29481. export class PostProcessManager {
  29482. private _scene;
  29483. private _indexBuffer;
  29484. private _vertexBuffers;
  29485. /**
  29486. * Creates a new instance PostProcess
  29487. * @param scene The scene that the post process is associated with.
  29488. */
  29489. constructor(scene: Scene);
  29490. private _prepareBuffers;
  29491. private _buildIndexBuffer;
  29492. /**
  29493. * Rebuilds the vertex buffers of the manager.
  29494. * @hidden
  29495. */
  29496. _rebuild(): void;
  29497. /**
  29498. * Prepares a frame to be run through a post process.
  29499. * @param sourceTexture The input texture to the post procesess. (default: null)
  29500. * @param postProcesses An array of post processes to be run. (default: null)
  29501. * @returns True if the post processes were able to be run.
  29502. * @hidden
  29503. */
  29504. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  29505. /**
  29506. * Manually render a set of post processes to a texture.
  29507. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  29508. * @param postProcesses An array of post processes to be run.
  29509. * @param targetTexture The target texture to render to.
  29510. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  29511. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  29512. * @param lodLevel defines which lod of the texture to render to
  29513. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  29514. */
  29515. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  29516. /**
  29517. * Finalize the result of the output of the postprocesses.
  29518. * @param doNotPresent If true the result will not be displayed to the screen.
  29519. * @param targetTexture The target texture to render to.
  29520. * @param faceIndex The index of the face to bind the target texture to.
  29521. * @param postProcesses The array of post processes to render.
  29522. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  29523. * @hidden
  29524. */
  29525. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  29526. /**
  29527. * Disposes of the post process manager.
  29528. */
  29529. dispose(): void;
  29530. }
  29531. }
  29532. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  29533. import { Observable } from "babylonjs/Misc/observable";
  29534. import { SmartArray } from "babylonjs/Misc/smartArray";
  29535. import { Nullable, Immutable } from "babylonjs/types";
  29536. import { Camera } from "babylonjs/Cameras/camera";
  29537. import { Scene } from "babylonjs/scene";
  29538. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29539. import { Color4 } from "babylonjs/Maths/math.color";
  29540. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  29541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29542. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29543. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29544. import { Texture } from "babylonjs/Materials/Textures/texture";
  29545. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29546. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  29547. import "babylonjs/Engines/Extensions/engine.renderTarget";
  29548. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  29549. import { Engine } from "babylonjs/Engines/engine";
  29550. /**
  29551. * This Helps creating a texture that will be created from a camera in your scene.
  29552. * It is basically a dynamic texture that could be used to create special effects for instance.
  29553. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  29554. */
  29555. export class RenderTargetTexture extends Texture {
  29556. /**
  29557. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  29558. */
  29559. static readonly REFRESHRATE_RENDER_ONCE: number;
  29560. /**
  29561. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  29562. */
  29563. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  29564. /**
  29565. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  29566. * the central point of your effect and can save a lot of performances.
  29567. */
  29568. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  29569. /**
  29570. * Use this predicate to dynamically define the list of mesh you want to render.
  29571. * If set, the renderList property will be overwritten.
  29572. */
  29573. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  29574. private _renderList;
  29575. /**
  29576. * Use this list to define the list of mesh you want to render.
  29577. */
  29578. get renderList(): Nullable<Array<AbstractMesh>>;
  29579. set renderList(value: Nullable<Array<AbstractMesh>>);
  29580. /**
  29581. * Use this function to overload the renderList array at rendering time.
  29582. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  29583. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  29584. * the cube (if the RTT is a cube, else layerOrFace=0).
  29585. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  29586. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  29587. * hold dummy elements!
  29588. */
  29589. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  29590. private _hookArray;
  29591. /**
  29592. * Define if particles should be rendered in your texture.
  29593. */
  29594. renderParticles: boolean;
  29595. /**
  29596. * Define if sprites should be rendered in your texture.
  29597. */
  29598. renderSprites: boolean;
  29599. /**
  29600. * Define the camera used to render the texture.
  29601. */
  29602. activeCamera: Nullable<Camera>;
  29603. /**
  29604. * Override the mesh isReady function with your own one.
  29605. */
  29606. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  29607. /**
  29608. * Override the render function of the texture with your own one.
  29609. */
  29610. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  29611. /**
  29612. * Define if camera post processes should be use while rendering the texture.
  29613. */
  29614. useCameraPostProcesses: boolean;
  29615. /**
  29616. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  29617. */
  29618. ignoreCameraViewport: boolean;
  29619. private _postProcessManager;
  29620. private _postProcesses;
  29621. private _resizeObserver;
  29622. /**
  29623. * An event triggered when the texture is unbind.
  29624. */
  29625. onBeforeBindObservable: Observable<RenderTargetTexture>;
  29626. /**
  29627. * An event triggered when the texture is unbind.
  29628. */
  29629. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  29630. private _onAfterUnbindObserver;
  29631. /**
  29632. * Set a after unbind callback in the texture.
  29633. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  29634. */
  29635. set onAfterUnbind(callback: () => void);
  29636. /**
  29637. * An event triggered before rendering the texture
  29638. */
  29639. onBeforeRenderObservable: Observable<number>;
  29640. private _onBeforeRenderObserver;
  29641. /**
  29642. * Set a before render callback in the texture.
  29643. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  29644. */
  29645. set onBeforeRender(callback: (faceIndex: number) => void);
  29646. /**
  29647. * An event triggered after rendering the texture
  29648. */
  29649. onAfterRenderObservable: Observable<number>;
  29650. private _onAfterRenderObserver;
  29651. /**
  29652. * Set a after render callback in the texture.
  29653. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  29654. */
  29655. set onAfterRender(callback: (faceIndex: number) => void);
  29656. /**
  29657. * An event triggered after the texture clear
  29658. */
  29659. onClearObservable: Observable<Engine>;
  29660. private _onClearObserver;
  29661. /**
  29662. * Set a clear callback in the texture.
  29663. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  29664. */
  29665. set onClear(callback: (Engine: Engine) => void);
  29666. /**
  29667. * An event triggered when the texture is resized.
  29668. */
  29669. onResizeObservable: Observable<RenderTargetTexture>;
  29670. /**
  29671. * Define the clear color of the Render Target if it should be different from the scene.
  29672. */
  29673. clearColor: Color4;
  29674. protected _size: number | {
  29675. width: number;
  29676. height: number;
  29677. layers?: number;
  29678. };
  29679. protected _initialSizeParameter: number | {
  29680. width: number;
  29681. height: number;
  29682. } | {
  29683. ratio: number;
  29684. };
  29685. protected _sizeRatio: Nullable<number>;
  29686. /** @hidden */
  29687. _generateMipMaps: boolean;
  29688. protected _renderingManager: RenderingManager;
  29689. /** @hidden */
  29690. _waitingRenderList?: string[];
  29691. protected _doNotChangeAspectRatio: boolean;
  29692. protected _currentRefreshId: number;
  29693. protected _refreshRate: number;
  29694. protected _textureMatrix: Matrix;
  29695. protected _samples: number;
  29696. protected _renderTargetOptions: RenderTargetCreationOptions;
  29697. /**
  29698. * Gets render target creation options that were used.
  29699. */
  29700. get renderTargetOptions(): RenderTargetCreationOptions;
  29701. protected _onRatioRescale(): void;
  29702. /**
  29703. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  29704. * It must define where the camera used to render the texture is set
  29705. */
  29706. boundingBoxPosition: Vector3;
  29707. private _boundingBoxSize;
  29708. /**
  29709. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  29710. * When defined, the cubemap will switch to local mode
  29711. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  29712. * @example https://www.babylonjs-playground.com/#RNASML
  29713. */
  29714. set boundingBoxSize(value: Vector3);
  29715. get boundingBoxSize(): Vector3;
  29716. /**
  29717. * In case the RTT has been created with a depth texture, get the associated
  29718. * depth texture.
  29719. * Otherwise, return null.
  29720. */
  29721. get depthStencilTexture(): Nullable<InternalTexture>;
  29722. /**
  29723. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  29724. * or used a shadow, depth texture...
  29725. * @param name The friendly name of the texture
  29726. * @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)
  29727. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  29728. * @param generateMipMaps True if mip maps need to be generated after render.
  29729. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  29730. * @param type The type of the buffer in the RTT (int, half float, float...)
  29731. * @param isCube True if a cube texture needs to be created
  29732. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  29733. * @param generateDepthBuffer True to generate a depth buffer
  29734. * @param generateStencilBuffer True to generate a stencil buffer
  29735. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  29736. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  29737. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29738. */
  29739. constructor(name: string, size: number | {
  29740. width: number;
  29741. height: number;
  29742. layers?: number;
  29743. } | {
  29744. ratio: number;
  29745. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  29746. /**
  29747. * Creates a depth stencil texture.
  29748. * This is only available in WebGL 2 or with the depth texture extension available.
  29749. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  29750. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  29751. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  29752. */
  29753. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  29754. private _processSizeParameter;
  29755. /**
  29756. * Define the number of samples to use in case of MSAA.
  29757. * It defaults to one meaning no MSAA has been enabled.
  29758. */
  29759. get samples(): number;
  29760. set samples(value: number);
  29761. /**
  29762. * Resets the refresh counter of the texture and start bak from scratch.
  29763. * Could be useful to regenerate the texture if it is setup to render only once.
  29764. */
  29765. resetRefreshCounter(): void;
  29766. /**
  29767. * Define the refresh rate of the texture or the rendering frequency.
  29768. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  29769. */
  29770. get refreshRate(): number;
  29771. set refreshRate(value: number);
  29772. /**
  29773. * Adds a post process to the render target rendering passes.
  29774. * @param postProcess define the post process to add
  29775. */
  29776. addPostProcess(postProcess: PostProcess): void;
  29777. /**
  29778. * Clear all the post processes attached to the render target
  29779. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  29780. */
  29781. clearPostProcesses(dispose?: boolean): void;
  29782. /**
  29783. * Remove one of the post process from the list of attached post processes to the texture
  29784. * @param postProcess define the post process to remove from the list
  29785. */
  29786. removePostProcess(postProcess: PostProcess): void;
  29787. /** @hidden */
  29788. _shouldRender(): boolean;
  29789. /**
  29790. * Gets the actual render size of the texture.
  29791. * @returns the width of the render size
  29792. */
  29793. getRenderSize(): number;
  29794. /**
  29795. * Gets the actual render width of the texture.
  29796. * @returns the width of the render size
  29797. */
  29798. getRenderWidth(): number;
  29799. /**
  29800. * Gets the actual render height of the texture.
  29801. * @returns the height of the render size
  29802. */
  29803. getRenderHeight(): number;
  29804. /**
  29805. * Gets the actual number of layers of the texture.
  29806. * @returns the number of layers
  29807. */
  29808. getRenderLayers(): number;
  29809. /**
  29810. * Get if the texture can be rescaled or not.
  29811. */
  29812. get canRescale(): boolean;
  29813. /**
  29814. * Resize the texture using a ratio.
  29815. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  29816. */
  29817. scale(ratio: number): void;
  29818. /**
  29819. * Get the texture reflection matrix used to rotate/transform the reflection.
  29820. * @returns the reflection matrix
  29821. */
  29822. getReflectionTextureMatrix(): Matrix;
  29823. /**
  29824. * Resize the texture to a new desired size.
  29825. * Be carrefull as it will recreate all the data in the new texture.
  29826. * @param size Define the new size. It can be:
  29827. * - a number for squared texture,
  29828. * - an object containing { width: number, height: number }
  29829. * - or an object containing a ratio { ratio: number }
  29830. */
  29831. resize(size: number | {
  29832. width: number;
  29833. height: number;
  29834. } | {
  29835. ratio: number;
  29836. }): void;
  29837. private _defaultRenderListPrepared;
  29838. /**
  29839. * Renders all the objects from the render list into the texture.
  29840. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  29841. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  29842. */
  29843. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  29844. private _bestReflectionRenderTargetDimension;
  29845. private _prepareRenderingManager;
  29846. /**
  29847. * @hidden
  29848. * @param faceIndex face index to bind to if this is a cubetexture
  29849. * @param layer defines the index of the texture to bind in the array
  29850. */
  29851. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  29852. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  29853. private renderToTarget;
  29854. /**
  29855. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29856. * This allowed control for front to back rendering or reversly depending of the special needs.
  29857. *
  29858. * @param renderingGroupId The rendering group id corresponding to its index
  29859. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29860. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29861. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29862. */
  29863. 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;
  29864. /**
  29865. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29866. *
  29867. * @param renderingGroupId The rendering group id corresponding to its index
  29868. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29869. */
  29870. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  29871. /**
  29872. * Clones the texture.
  29873. * @returns the cloned texture
  29874. */
  29875. clone(): RenderTargetTexture;
  29876. /**
  29877. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29878. * @returns The JSON representation of the texture
  29879. */
  29880. serialize(): any;
  29881. /**
  29882. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  29883. */
  29884. disposeFramebufferObjects(): void;
  29885. /**
  29886. * Dispose the texture and release its associated resources.
  29887. */
  29888. dispose(): void;
  29889. /** @hidden */
  29890. _rebuild(): void;
  29891. /**
  29892. * Clear the info related to rendering groups preventing retention point in material dispose.
  29893. */
  29894. freeRenderingGroups(): void;
  29895. /**
  29896. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  29897. * @returns the view count
  29898. */
  29899. getViewCount(): number;
  29900. }
  29901. }
  29902. declare module "babylonjs/Misc/guid" {
  29903. /**
  29904. * Class used to manipulate GUIDs
  29905. */
  29906. export class GUID {
  29907. /**
  29908. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29909. * Be aware Math.random() could cause collisions, but:
  29910. * "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"
  29911. * @returns a pseudo random id
  29912. */
  29913. static RandomId(): string;
  29914. }
  29915. }
  29916. declare module "babylonjs/Materials/shadowDepthWrapper" {
  29917. import { Nullable } from "babylonjs/types";
  29918. import { Scene } from "babylonjs/scene";
  29919. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29920. import { Material } from "babylonjs/Materials/material";
  29921. import { Effect } from "babylonjs/Materials/effect";
  29922. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  29923. /**
  29924. * Options to be used when creating a shadow depth material
  29925. */
  29926. export interface IIOptionShadowDepthMaterial {
  29927. /** Variables in the vertex shader code that need to have their names remapped.
  29928. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29929. * "var_name" should be either: worldPos or vNormalW
  29930. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29931. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29932. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29933. */
  29934. remappedVariables?: string[];
  29935. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29936. standalone?: boolean;
  29937. }
  29938. /**
  29939. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29940. */
  29941. export class ShadowDepthWrapper {
  29942. private _scene;
  29943. private _options?;
  29944. private _baseMaterial;
  29945. private _onEffectCreatedObserver;
  29946. private _subMeshToEffect;
  29947. private _subMeshToDepthEffect;
  29948. private _meshes;
  29949. /** @hidden */
  29950. _matriceNames: any;
  29951. /** Gets the standalone status of the wrapper */
  29952. get standalone(): boolean;
  29953. /** Gets the base material the wrapper is built upon */
  29954. get baseMaterial(): Material;
  29955. /**
  29956. * Instantiate a new shadow depth wrapper.
  29957. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29958. * generate the shadow depth map. For more information, please refer to the documentation:
  29959. * https://doc.babylonjs.com/babylon101/shadows
  29960. * @param baseMaterial Material to wrap
  29961. * @param scene Define the scene the material belongs to
  29962. * @param options Options used to create the wrapper
  29963. */
  29964. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29965. /**
  29966. * Gets the effect to use to generate the depth map
  29967. * @param subMesh subMesh to get the effect for
  29968. * @param shadowGenerator shadow generator to get the effect for
  29969. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29970. */
  29971. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29972. /**
  29973. * Specifies that the submesh is ready to be used for depth rendering
  29974. * @param subMesh submesh to check
  29975. * @param defines the list of defines to take into account when checking the effect
  29976. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29977. * @param useInstances specifies that instances should be used
  29978. * @returns a boolean indicating that the submesh is ready or not
  29979. */
  29980. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29981. /**
  29982. * Disposes the resources
  29983. */
  29984. dispose(): void;
  29985. private _makeEffect;
  29986. }
  29987. }
  29988. declare module "babylonjs/Materials/material" {
  29989. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29990. import { SmartArray } from "babylonjs/Misc/smartArray";
  29991. import { Observable } from "babylonjs/Misc/observable";
  29992. import { Nullable } from "babylonjs/types";
  29993. import { Scene } from "babylonjs/scene";
  29994. import { Matrix } from "babylonjs/Maths/math.vector";
  29995. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29997. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29998. import { Effect } from "babylonjs/Materials/effect";
  29999. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30000. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30001. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30002. import { IInspectable } from "babylonjs/Misc/iInspectable";
  30003. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  30004. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  30005. import { Mesh } from "babylonjs/Meshes/mesh";
  30006. import { Animation } from "babylonjs/Animations/animation";
  30007. /**
  30008. * Options for compiling materials.
  30009. */
  30010. export interface IMaterialCompilationOptions {
  30011. /**
  30012. * Defines whether clip planes are enabled.
  30013. */
  30014. clipPlane: boolean;
  30015. /**
  30016. * Defines whether instances are enabled.
  30017. */
  30018. useInstances: boolean;
  30019. }
  30020. /**
  30021. * Options passed when calling customShaderNameResolve
  30022. */
  30023. export interface ICustomShaderNameResolveOptions {
  30024. /**
  30025. * 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
  30026. */
  30027. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30028. }
  30029. /**
  30030. * Base class for the main features of a material in Babylon.js
  30031. */
  30032. export class Material implements IAnimatable {
  30033. /**
  30034. * Returns the triangle fill mode
  30035. */
  30036. static readonly TriangleFillMode: number;
  30037. /**
  30038. * Returns the wireframe mode
  30039. */
  30040. static readonly WireFrameFillMode: number;
  30041. /**
  30042. * Returns the point fill mode
  30043. */
  30044. static readonly PointFillMode: number;
  30045. /**
  30046. * Returns the point list draw mode
  30047. */
  30048. static readonly PointListDrawMode: number;
  30049. /**
  30050. * Returns the line list draw mode
  30051. */
  30052. static readonly LineListDrawMode: number;
  30053. /**
  30054. * Returns the line loop draw mode
  30055. */
  30056. static readonly LineLoopDrawMode: number;
  30057. /**
  30058. * Returns the line strip draw mode
  30059. */
  30060. static readonly LineStripDrawMode: number;
  30061. /**
  30062. * Returns the triangle strip draw mode
  30063. */
  30064. static readonly TriangleStripDrawMode: number;
  30065. /**
  30066. * Returns the triangle fan draw mode
  30067. */
  30068. static readonly TriangleFanDrawMode: number;
  30069. /**
  30070. * Stores the clock-wise side orientation
  30071. */
  30072. static readonly ClockWiseSideOrientation: number;
  30073. /**
  30074. * Stores the counter clock-wise side orientation
  30075. */
  30076. static readonly CounterClockWiseSideOrientation: number;
  30077. /**
  30078. * The dirty texture flag value
  30079. */
  30080. static readonly TextureDirtyFlag: number;
  30081. /**
  30082. * The dirty light flag value
  30083. */
  30084. static readonly LightDirtyFlag: number;
  30085. /**
  30086. * The dirty fresnel flag value
  30087. */
  30088. static readonly FresnelDirtyFlag: number;
  30089. /**
  30090. * The dirty attribute flag value
  30091. */
  30092. static readonly AttributesDirtyFlag: number;
  30093. /**
  30094. * The dirty misc flag value
  30095. */
  30096. static readonly MiscDirtyFlag: number;
  30097. /**
  30098. * The dirty prepass flag value
  30099. */
  30100. static readonly PrePassDirtyFlag: number;
  30101. /**
  30102. * The all dirty flag value
  30103. */
  30104. static readonly AllDirtyFlag: number;
  30105. /**
  30106. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30107. */
  30108. static readonly MATERIAL_OPAQUE: number;
  30109. /**
  30110. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30111. */
  30112. static readonly MATERIAL_ALPHATEST: number;
  30113. /**
  30114. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30115. */
  30116. static readonly MATERIAL_ALPHABLEND: number;
  30117. /**
  30118. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30119. * They are also discarded below the alpha cutoff threshold to improve performances.
  30120. */
  30121. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30122. /**
  30123. * The Whiteout method is used to blend normals.
  30124. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30125. */
  30126. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30127. /**
  30128. * The Reoriented Normal Mapping method is used to blend normals.
  30129. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30130. */
  30131. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30132. /**
  30133. * Custom callback helping to override the default shader used in the material.
  30134. */
  30135. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30136. /**
  30137. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30138. */
  30139. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30140. /**
  30141. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30142. * This means that the material can keep using a previous shader while a new one is being compiled.
  30143. * This is mostly used when shader parallel compilation is supported (true by default)
  30144. */
  30145. allowShaderHotSwapping: boolean;
  30146. /**
  30147. * The ID of the material
  30148. */
  30149. id: string;
  30150. /**
  30151. * Gets or sets the unique id of the material
  30152. */
  30153. uniqueId: number;
  30154. /**
  30155. * The name of the material
  30156. */
  30157. name: string;
  30158. /**
  30159. * Gets or sets user defined metadata
  30160. */
  30161. metadata: any;
  30162. /**
  30163. * For internal use only. Please do not use.
  30164. */
  30165. reservedDataStore: any;
  30166. /**
  30167. * Specifies if the ready state should be checked on each call
  30168. */
  30169. checkReadyOnEveryCall: boolean;
  30170. /**
  30171. * Specifies if the ready state should be checked once
  30172. */
  30173. checkReadyOnlyOnce: boolean;
  30174. /**
  30175. * The state of the material
  30176. */
  30177. state: string;
  30178. /**
  30179. * If the material can be rendered to several textures with MRT extension
  30180. */
  30181. get canRenderToMRT(): boolean;
  30182. /**
  30183. * The alpha value of the material
  30184. */
  30185. protected _alpha: number;
  30186. /**
  30187. * List of inspectable custom properties (used by the Inspector)
  30188. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30189. */
  30190. inspectableCustomProperties: IInspectable[];
  30191. /**
  30192. * Sets the alpha value of the material
  30193. */
  30194. set alpha(value: number);
  30195. /**
  30196. * Gets the alpha value of the material
  30197. */
  30198. get alpha(): number;
  30199. /**
  30200. * Specifies if back face culling is enabled
  30201. */
  30202. protected _backFaceCulling: boolean;
  30203. /**
  30204. * Sets the back-face culling state
  30205. */
  30206. set backFaceCulling(value: boolean);
  30207. /**
  30208. * Gets the back-face culling state
  30209. */
  30210. get backFaceCulling(): boolean;
  30211. /**
  30212. * Stores the value for side orientation
  30213. */
  30214. sideOrientation: number;
  30215. /**
  30216. * Callback triggered when the material is compiled
  30217. */
  30218. onCompiled: Nullable<(effect: Effect) => void>;
  30219. /**
  30220. * Callback triggered when an error occurs
  30221. */
  30222. onError: Nullable<(effect: Effect, errors: string) => void>;
  30223. /**
  30224. * Callback triggered to get the render target textures
  30225. */
  30226. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30227. /**
  30228. * Gets a boolean indicating that current material needs to register RTT
  30229. */
  30230. get hasRenderTargetTextures(): boolean;
  30231. /**
  30232. * Specifies if the material should be serialized
  30233. */
  30234. doNotSerialize: boolean;
  30235. /**
  30236. * @hidden
  30237. */
  30238. _storeEffectOnSubMeshes: boolean;
  30239. /**
  30240. * Stores the animations for the material
  30241. */
  30242. animations: Nullable<Array<Animation>>;
  30243. /**
  30244. * An event triggered when the material is disposed
  30245. */
  30246. onDisposeObservable: Observable<Material>;
  30247. /**
  30248. * An observer which watches for dispose events
  30249. */
  30250. private _onDisposeObserver;
  30251. private _onUnBindObservable;
  30252. /**
  30253. * Called during a dispose event
  30254. */
  30255. set onDispose(callback: () => void);
  30256. private _onBindObservable;
  30257. /**
  30258. * An event triggered when the material is bound
  30259. */
  30260. get onBindObservable(): Observable<AbstractMesh>;
  30261. /**
  30262. * An observer which watches for bind events
  30263. */
  30264. private _onBindObserver;
  30265. /**
  30266. * Called during a bind event
  30267. */
  30268. set onBind(callback: (Mesh: AbstractMesh) => void);
  30269. /**
  30270. * An event triggered when the material is unbound
  30271. */
  30272. get onUnBindObservable(): Observable<Material>;
  30273. protected _onEffectCreatedObservable: Nullable<Observable<{
  30274. effect: Effect;
  30275. subMesh: Nullable<SubMesh>;
  30276. }>>;
  30277. /**
  30278. * An event triggered when the effect is (re)created
  30279. */
  30280. get onEffectCreatedObservable(): Observable<{
  30281. effect: Effect;
  30282. subMesh: Nullable<SubMesh>;
  30283. }>;
  30284. /**
  30285. * Stores the value of the alpha mode
  30286. */
  30287. private _alphaMode;
  30288. /**
  30289. * Sets the value of the alpha mode.
  30290. *
  30291. * | Value | Type | Description |
  30292. * | --- | --- | --- |
  30293. * | 0 | ALPHA_DISABLE | |
  30294. * | 1 | ALPHA_ADD | |
  30295. * | 2 | ALPHA_COMBINE | |
  30296. * | 3 | ALPHA_SUBTRACT | |
  30297. * | 4 | ALPHA_MULTIPLY | |
  30298. * | 5 | ALPHA_MAXIMIZED | |
  30299. * | 6 | ALPHA_ONEONE | |
  30300. * | 7 | ALPHA_PREMULTIPLIED | |
  30301. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30302. * | 9 | ALPHA_INTERPOLATE | |
  30303. * | 10 | ALPHA_SCREENMODE | |
  30304. *
  30305. */
  30306. set alphaMode(value: number);
  30307. /**
  30308. * Gets the value of the alpha mode
  30309. */
  30310. get alphaMode(): number;
  30311. /**
  30312. * Stores the state of the need depth pre-pass value
  30313. */
  30314. private _needDepthPrePass;
  30315. /**
  30316. * Sets the need depth pre-pass value
  30317. */
  30318. set needDepthPrePass(value: boolean);
  30319. /**
  30320. * Gets the depth pre-pass value
  30321. */
  30322. get needDepthPrePass(): boolean;
  30323. /**
  30324. * Specifies if depth writing should be disabled
  30325. */
  30326. disableDepthWrite: boolean;
  30327. /**
  30328. * Specifies if color writing should be disabled
  30329. */
  30330. disableColorWrite: boolean;
  30331. /**
  30332. * Specifies if depth writing should be forced
  30333. */
  30334. forceDepthWrite: boolean;
  30335. /**
  30336. * Specifies the depth function that should be used. 0 means the default engine function
  30337. */
  30338. depthFunction: number;
  30339. /**
  30340. * Specifies if there should be a separate pass for culling
  30341. */
  30342. separateCullingPass: boolean;
  30343. /**
  30344. * Stores the state specifing if fog should be enabled
  30345. */
  30346. private _fogEnabled;
  30347. /**
  30348. * Sets the state for enabling fog
  30349. */
  30350. set fogEnabled(value: boolean);
  30351. /**
  30352. * Gets the value of the fog enabled state
  30353. */
  30354. get fogEnabled(): boolean;
  30355. /**
  30356. * Stores the size of points
  30357. */
  30358. pointSize: number;
  30359. /**
  30360. * Stores the z offset value
  30361. */
  30362. zOffset: number;
  30363. get wireframe(): boolean;
  30364. /**
  30365. * Sets the state of wireframe mode
  30366. */
  30367. set wireframe(value: boolean);
  30368. /**
  30369. * Gets the value specifying if point clouds are enabled
  30370. */
  30371. get pointsCloud(): boolean;
  30372. /**
  30373. * Sets the state of point cloud mode
  30374. */
  30375. set pointsCloud(value: boolean);
  30376. /**
  30377. * Gets the material fill mode
  30378. */
  30379. get fillMode(): number;
  30380. /**
  30381. * Sets the material fill mode
  30382. */
  30383. set fillMode(value: number);
  30384. /**
  30385. * @hidden
  30386. * Stores the effects for the material
  30387. */
  30388. _effect: Nullable<Effect>;
  30389. /**
  30390. * Specifies if uniform buffers should be used
  30391. */
  30392. private _useUBO;
  30393. /**
  30394. * Stores a reference to the scene
  30395. */
  30396. private _scene;
  30397. /**
  30398. * Stores the fill mode state
  30399. */
  30400. private _fillMode;
  30401. /**
  30402. * Specifies if the depth write state should be cached
  30403. */
  30404. private _cachedDepthWriteState;
  30405. /**
  30406. * Specifies if the color write state should be cached
  30407. */
  30408. private _cachedColorWriteState;
  30409. /**
  30410. * Specifies if the depth function state should be cached
  30411. */
  30412. private _cachedDepthFunctionState;
  30413. /**
  30414. * Stores the uniform buffer
  30415. */
  30416. protected _uniformBuffer: UniformBuffer;
  30417. /** @hidden */
  30418. _indexInSceneMaterialArray: number;
  30419. /** @hidden */
  30420. meshMap: Nullable<{
  30421. [id: string]: AbstractMesh | undefined;
  30422. }>;
  30423. /**
  30424. * Creates a material instance
  30425. * @param name defines the name of the material
  30426. * @param scene defines the scene to reference
  30427. * @param doNotAdd specifies if the material should be added to the scene
  30428. */
  30429. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30430. /**
  30431. * Returns a string representation of the current material
  30432. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30433. * @returns a string with material information
  30434. */
  30435. toString(fullDetails?: boolean): string;
  30436. /**
  30437. * Gets the class name of the material
  30438. * @returns a string with the class name of the material
  30439. */
  30440. getClassName(): string;
  30441. /**
  30442. * Specifies if updates for the material been locked
  30443. */
  30444. get isFrozen(): boolean;
  30445. /**
  30446. * Locks updates for the material
  30447. */
  30448. freeze(): void;
  30449. /**
  30450. * Unlocks updates for the material
  30451. */
  30452. unfreeze(): void;
  30453. /**
  30454. * Specifies if the material is ready to be used
  30455. * @param mesh defines the mesh to check
  30456. * @param useInstances specifies if instances should be used
  30457. * @returns a boolean indicating if the material is ready to be used
  30458. */
  30459. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30460. /**
  30461. * Specifies that the submesh is ready to be used
  30462. * @param mesh defines the mesh to check
  30463. * @param subMesh defines which submesh to check
  30464. * @param useInstances specifies that instances should be used
  30465. * @returns a boolean indicating that the submesh is ready or not
  30466. */
  30467. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30468. /**
  30469. * Returns the material effect
  30470. * @returns the effect associated with the material
  30471. */
  30472. getEffect(): Nullable<Effect>;
  30473. /**
  30474. * Returns the current scene
  30475. * @returns a Scene
  30476. */
  30477. getScene(): Scene;
  30478. /**
  30479. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30480. */
  30481. protected _forceAlphaTest: boolean;
  30482. /**
  30483. * The transparency mode of the material.
  30484. */
  30485. protected _transparencyMode: Nullable<number>;
  30486. /**
  30487. * Gets the current transparency mode.
  30488. */
  30489. get transparencyMode(): Nullable<number>;
  30490. /**
  30491. * Sets the transparency mode of the material.
  30492. *
  30493. * | Value | Type | Description |
  30494. * | ----- | ----------------------------------- | ----------- |
  30495. * | 0 | OPAQUE | |
  30496. * | 1 | ALPHATEST | |
  30497. * | 2 | ALPHABLEND | |
  30498. * | 3 | ALPHATESTANDBLEND | |
  30499. *
  30500. */
  30501. set transparencyMode(value: Nullable<number>);
  30502. /**
  30503. * Returns true if alpha blending should be disabled.
  30504. */
  30505. protected get _disableAlphaBlending(): boolean;
  30506. /**
  30507. * Specifies whether or not this material should be rendered in alpha blend mode.
  30508. * @returns a boolean specifying if alpha blending is needed
  30509. */
  30510. needAlphaBlending(): boolean;
  30511. /**
  30512. * Specifies if the mesh will require alpha blending
  30513. * @param mesh defines the mesh to check
  30514. * @returns a boolean specifying if alpha blending is needed for the mesh
  30515. */
  30516. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30517. /**
  30518. * Specifies whether or not this material should be rendered in alpha test mode.
  30519. * @returns a boolean specifying if an alpha test is needed.
  30520. */
  30521. needAlphaTesting(): boolean;
  30522. /**
  30523. * Specifies if material alpha testing should be turned on for the mesh
  30524. * @param mesh defines the mesh to check
  30525. */
  30526. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30527. /**
  30528. * Gets the texture used for the alpha test
  30529. * @returns the texture to use for alpha testing
  30530. */
  30531. getAlphaTestTexture(): Nullable<BaseTexture>;
  30532. /**
  30533. * Marks the material to indicate that it needs to be re-calculated
  30534. */
  30535. markDirty(): void;
  30536. /** @hidden */
  30537. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30538. /**
  30539. * Binds the material to the mesh
  30540. * @param world defines the world transformation matrix
  30541. * @param mesh defines the mesh to bind the material to
  30542. */
  30543. bind(world: Matrix, mesh?: Mesh): void;
  30544. /**
  30545. * Binds the submesh to the material
  30546. * @param world defines the world transformation matrix
  30547. * @param mesh defines the mesh containing the submesh
  30548. * @param subMesh defines the submesh to bind the material to
  30549. */
  30550. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30551. /**
  30552. * Binds the world matrix to the material
  30553. * @param world defines the world transformation matrix
  30554. */
  30555. bindOnlyWorldMatrix(world: Matrix): void;
  30556. /**
  30557. * Binds the scene's uniform buffer to the effect.
  30558. * @param effect defines the effect to bind to the scene uniform buffer
  30559. * @param sceneUbo defines the uniform buffer storing scene data
  30560. */
  30561. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30562. /**
  30563. * Binds the view matrix to the effect
  30564. * @param effect defines the effect to bind the view matrix to
  30565. */
  30566. bindView(effect: Effect): void;
  30567. /**
  30568. * Binds the view projection matrix to the effect
  30569. * @param effect defines the effect to bind the view projection matrix to
  30570. */
  30571. bindViewProjection(effect: Effect): void;
  30572. /**
  30573. * Processes to execute after binding the material to a mesh
  30574. * @param mesh defines the rendered mesh
  30575. */
  30576. protected _afterBind(mesh?: Mesh): void;
  30577. /**
  30578. * Unbinds the material from the mesh
  30579. */
  30580. unbind(): void;
  30581. /**
  30582. * Gets the active textures from the material
  30583. * @returns an array of textures
  30584. */
  30585. getActiveTextures(): BaseTexture[];
  30586. /**
  30587. * Specifies if the material uses a texture
  30588. * @param texture defines the texture to check against the material
  30589. * @returns a boolean specifying if the material uses the texture
  30590. */
  30591. hasTexture(texture: BaseTexture): boolean;
  30592. /**
  30593. * Makes a duplicate of the material, and gives it a new name
  30594. * @param name defines the new name for the duplicated material
  30595. * @returns the cloned material
  30596. */
  30597. clone(name: string): Nullable<Material>;
  30598. /**
  30599. * Gets the meshes bound to the material
  30600. * @returns an array of meshes bound to the material
  30601. */
  30602. getBindedMeshes(): AbstractMesh[];
  30603. /**
  30604. * Force shader compilation
  30605. * @param mesh defines the mesh associated with this material
  30606. * @param onCompiled defines a function to execute once the material is compiled
  30607. * @param options defines the options to configure the compilation
  30608. * @param onError defines a function to execute if the material fails compiling
  30609. */
  30610. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30611. /**
  30612. * Force shader compilation
  30613. * @param mesh defines the mesh that will use this material
  30614. * @param options defines additional options for compiling the shaders
  30615. * @returns a promise that resolves when the compilation completes
  30616. */
  30617. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30618. private static readonly _AllDirtyCallBack;
  30619. private static readonly _ImageProcessingDirtyCallBack;
  30620. private static readonly _TextureDirtyCallBack;
  30621. private static readonly _FresnelDirtyCallBack;
  30622. private static readonly _MiscDirtyCallBack;
  30623. private static readonly _PrePassDirtyCallBack;
  30624. private static readonly _LightsDirtyCallBack;
  30625. private static readonly _AttributeDirtyCallBack;
  30626. private static _FresnelAndMiscDirtyCallBack;
  30627. private static _TextureAndMiscDirtyCallBack;
  30628. private static readonly _DirtyCallbackArray;
  30629. private static readonly _RunDirtyCallBacks;
  30630. /**
  30631. * Marks a define in the material to indicate that it needs to be re-computed
  30632. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30633. */
  30634. markAsDirty(flag: number): void;
  30635. /**
  30636. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30637. * @param func defines a function which checks material defines against the submeshes
  30638. */
  30639. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30640. /**
  30641. * Indicates that the scene should check if the rendering now needs a prepass
  30642. */
  30643. protected _markScenePrePassDirty(): void;
  30644. /**
  30645. * Indicates that we need to re-calculated for all submeshes
  30646. */
  30647. protected _markAllSubMeshesAsAllDirty(): void;
  30648. /**
  30649. * Indicates that image processing needs to be re-calculated for all submeshes
  30650. */
  30651. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30652. /**
  30653. * Indicates that textures need to be re-calculated for all submeshes
  30654. */
  30655. protected _markAllSubMeshesAsTexturesDirty(): void;
  30656. /**
  30657. * Indicates that fresnel needs to be re-calculated for all submeshes
  30658. */
  30659. protected _markAllSubMeshesAsFresnelDirty(): void;
  30660. /**
  30661. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30662. */
  30663. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30664. /**
  30665. * Indicates that lights need to be re-calculated for all submeshes
  30666. */
  30667. protected _markAllSubMeshesAsLightsDirty(): void;
  30668. /**
  30669. * Indicates that attributes need to be re-calculated for all submeshes
  30670. */
  30671. protected _markAllSubMeshesAsAttributesDirty(): void;
  30672. /**
  30673. * Indicates that misc needs to be re-calculated for all submeshes
  30674. */
  30675. protected _markAllSubMeshesAsMiscDirty(): void;
  30676. /**
  30677. * Indicates that prepass needs to be re-calculated for all submeshes
  30678. */
  30679. protected _markAllSubMeshesAsPrePassDirty(): void;
  30680. /**
  30681. * Indicates that textures and misc need to be re-calculated for all submeshes
  30682. */
  30683. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30684. /**
  30685. * Sets the required values to the prepass renderer.
  30686. * @param prePassRenderer defines the prepass renderer to setup.
  30687. * @returns true if the pre pass is needed.
  30688. */
  30689. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30690. /**
  30691. * Disposes the material
  30692. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30693. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30694. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30695. */
  30696. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30697. /** @hidden */
  30698. private releaseVertexArrayObject;
  30699. /**
  30700. * Serializes this material
  30701. * @returns the serialized material object
  30702. */
  30703. serialize(): any;
  30704. /**
  30705. * Creates a material from parsed material data
  30706. * @param parsedMaterial defines parsed material data
  30707. * @param scene defines the hosting scene
  30708. * @param rootUrl defines the root URL to use to load textures
  30709. * @returns a new material
  30710. */
  30711. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30712. }
  30713. }
  30714. declare module "babylonjs/Materials/multiMaterial" {
  30715. import { Nullable } from "babylonjs/types";
  30716. import { Scene } from "babylonjs/scene";
  30717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30718. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30719. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30720. import { Material } from "babylonjs/Materials/material";
  30721. /**
  30722. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30723. * separate meshes. This can be use to improve performances.
  30724. * @see https://doc.babylonjs.com/how_to/multi_materials
  30725. */
  30726. export class MultiMaterial extends Material {
  30727. private _subMaterials;
  30728. /**
  30729. * Gets or Sets the list of Materials used within the multi material.
  30730. * They need to be ordered according to the submeshes order in the associated mesh
  30731. */
  30732. get subMaterials(): Nullable<Material>[];
  30733. set subMaterials(value: Nullable<Material>[]);
  30734. /**
  30735. * Function used to align with Node.getChildren()
  30736. * @returns the list of Materials used within the multi material
  30737. */
  30738. getChildren(): Nullable<Material>[];
  30739. /**
  30740. * Instantiates a new Multi Material
  30741. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30742. * separate meshes. This can be use to improve performances.
  30743. * @see https://doc.babylonjs.com/how_to/multi_materials
  30744. * @param name Define the name in the scene
  30745. * @param scene Define the scene the material belongs to
  30746. */
  30747. constructor(name: string, scene: Scene);
  30748. private _hookArray;
  30749. /**
  30750. * Get one of the submaterial by its index in the submaterials array
  30751. * @param index The index to look the sub material at
  30752. * @returns The Material if the index has been defined
  30753. */
  30754. getSubMaterial(index: number): Nullable<Material>;
  30755. /**
  30756. * Get the list of active textures for the whole sub materials list.
  30757. * @returns All the textures that will be used during the rendering
  30758. */
  30759. getActiveTextures(): BaseTexture[];
  30760. /**
  30761. * Gets the current class name of the material e.g. "MultiMaterial"
  30762. * Mainly use in serialization.
  30763. * @returns the class name
  30764. */
  30765. getClassName(): string;
  30766. /**
  30767. * Checks if the material is ready to render the requested sub mesh
  30768. * @param mesh Define the mesh the submesh belongs to
  30769. * @param subMesh Define the sub mesh to look readyness for
  30770. * @param useInstances Define whether or not the material is used with instances
  30771. * @returns true if ready, otherwise false
  30772. */
  30773. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30774. /**
  30775. * Clones the current material and its related sub materials
  30776. * @param name Define the name of the newly cloned material
  30777. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30778. * @returns the cloned material
  30779. */
  30780. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30781. /**
  30782. * Serializes the materials into a JSON representation.
  30783. * @returns the JSON representation
  30784. */
  30785. serialize(): any;
  30786. /**
  30787. * Dispose the material and release its associated resources
  30788. * @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)
  30789. * @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)
  30790. * @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)
  30791. */
  30792. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30793. /**
  30794. * Creates a MultiMaterial from parsed MultiMaterial data.
  30795. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30796. * @param scene defines the hosting scene
  30797. * @returns a new MultiMaterial
  30798. */
  30799. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30800. }
  30801. }
  30802. declare module "babylonjs/Meshes/subMesh" {
  30803. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  30804. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30805. import { Engine } from "babylonjs/Engines/engine";
  30806. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  30807. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  30808. import { Effect } from "babylonjs/Materials/effect";
  30809. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30810. import { Plane } from "babylonjs/Maths/math.plane";
  30811. import { Collider } from "babylonjs/Collisions/collider";
  30812. import { Material } from "babylonjs/Materials/material";
  30813. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30815. import { Mesh } from "babylonjs/Meshes/mesh";
  30816. import { Ray } from "babylonjs/Culling/ray";
  30817. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  30818. /**
  30819. * Defines a subdivision inside a mesh
  30820. */
  30821. export class SubMesh implements ICullable {
  30822. /** the material index to use */
  30823. materialIndex: number;
  30824. /** vertex index start */
  30825. verticesStart: number;
  30826. /** vertices count */
  30827. verticesCount: number;
  30828. /** index start */
  30829. indexStart: number;
  30830. /** indices count */
  30831. indexCount: number;
  30832. /** @hidden */
  30833. _materialDefines: Nullable<MaterialDefines>;
  30834. /** @hidden */
  30835. _materialEffect: Nullable<Effect>;
  30836. /** @hidden */
  30837. _effectOverride: Nullable<Effect>;
  30838. /**
  30839. * Gets material defines used by the effect associated to the sub mesh
  30840. */
  30841. get materialDefines(): Nullable<MaterialDefines>;
  30842. /**
  30843. * Sets material defines used by the effect associated to the sub mesh
  30844. */
  30845. set materialDefines(defines: Nullable<MaterialDefines>);
  30846. /**
  30847. * Gets associated effect
  30848. */
  30849. get effect(): Nullable<Effect>;
  30850. /**
  30851. * Sets associated effect (effect used to render this submesh)
  30852. * @param effect defines the effect to associate with
  30853. * @param defines defines the set of defines used to compile this effect
  30854. */
  30855. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30856. /** @hidden */
  30857. _linesIndexCount: number;
  30858. private _mesh;
  30859. private _renderingMesh;
  30860. private _boundingInfo;
  30861. private _linesIndexBuffer;
  30862. /** @hidden */
  30863. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30864. /** @hidden */
  30865. _trianglePlanes: Plane[];
  30866. /** @hidden */
  30867. _lastColliderTransformMatrix: Nullable<Matrix>;
  30868. /** @hidden */
  30869. _renderId: number;
  30870. /** @hidden */
  30871. _alphaIndex: number;
  30872. /** @hidden */
  30873. _distanceToCamera: number;
  30874. /** @hidden */
  30875. _id: number;
  30876. private _currentMaterial;
  30877. /**
  30878. * Add a new submesh to a mesh
  30879. * @param materialIndex defines the material index to use
  30880. * @param verticesStart defines vertex index start
  30881. * @param verticesCount defines vertices count
  30882. * @param indexStart defines index start
  30883. * @param indexCount defines indices count
  30884. * @param mesh defines the parent mesh
  30885. * @param renderingMesh defines an optional rendering mesh
  30886. * @param createBoundingBox defines if bounding box should be created for this submesh
  30887. * @returns the new submesh
  30888. */
  30889. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30890. /**
  30891. * Creates a new submesh
  30892. * @param materialIndex defines the material index to use
  30893. * @param verticesStart defines vertex index start
  30894. * @param verticesCount defines vertices count
  30895. * @param indexStart defines index start
  30896. * @param indexCount defines indices count
  30897. * @param mesh defines the parent mesh
  30898. * @param renderingMesh defines an optional rendering mesh
  30899. * @param createBoundingBox defines if bounding box should be created for this submesh
  30900. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30901. */
  30902. constructor(
  30903. /** the material index to use */
  30904. materialIndex: number,
  30905. /** vertex index start */
  30906. verticesStart: number,
  30907. /** vertices count */
  30908. verticesCount: number,
  30909. /** index start */
  30910. indexStart: number,
  30911. /** indices count */
  30912. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30913. /**
  30914. * Returns true if this submesh covers the entire parent mesh
  30915. * @ignorenaming
  30916. */
  30917. get IsGlobal(): boolean;
  30918. /**
  30919. * Returns the submesh BoudingInfo object
  30920. * @returns current bounding info (or mesh's one if the submesh is global)
  30921. */
  30922. getBoundingInfo(): BoundingInfo;
  30923. /**
  30924. * Sets the submesh BoundingInfo
  30925. * @param boundingInfo defines the new bounding info to use
  30926. * @returns the SubMesh
  30927. */
  30928. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30929. /**
  30930. * Returns the mesh of the current submesh
  30931. * @return the parent mesh
  30932. */
  30933. getMesh(): AbstractMesh;
  30934. /**
  30935. * Returns the rendering mesh of the submesh
  30936. * @returns the rendering mesh (could be different from parent mesh)
  30937. */
  30938. getRenderingMesh(): Mesh;
  30939. /**
  30940. * Returns the replacement mesh of the submesh
  30941. * @returns the replacement mesh (could be different from parent mesh)
  30942. */
  30943. getReplacementMesh(): Nullable<AbstractMesh>;
  30944. /**
  30945. * Returns the effective mesh of the submesh
  30946. * @returns the effective mesh (could be different from parent mesh)
  30947. */
  30948. getEffectiveMesh(): AbstractMesh;
  30949. /**
  30950. * Returns the submesh material
  30951. * @returns null or the current material
  30952. */
  30953. getMaterial(): Nullable<Material>;
  30954. private _IsMultiMaterial;
  30955. /**
  30956. * Sets a new updated BoundingInfo object to the submesh
  30957. * @param data defines an optional position array to use to determine the bounding info
  30958. * @returns the SubMesh
  30959. */
  30960. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30961. /** @hidden */
  30962. _checkCollision(collider: Collider): boolean;
  30963. /**
  30964. * Updates the submesh BoundingInfo
  30965. * @param world defines the world matrix to use to update the bounding info
  30966. * @returns the submesh
  30967. */
  30968. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30969. /**
  30970. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30971. * @param frustumPlanes defines the frustum planes
  30972. * @returns true if the submesh is intersecting with the frustum
  30973. */
  30974. isInFrustum(frustumPlanes: Plane[]): boolean;
  30975. /**
  30976. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30977. * @param frustumPlanes defines the frustum planes
  30978. * @returns true if the submesh is inside the frustum
  30979. */
  30980. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30981. /**
  30982. * Renders the submesh
  30983. * @param enableAlphaMode defines if alpha needs to be used
  30984. * @returns the submesh
  30985. */
  30986. render(enableAlphaMode: boolean): SubMesh;
  30987. /**
  30988. * @hidden
  30989. */
  30990. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30991. /**
  30992. * Checks if the submesh intersects with a ray
  30993. * @param ray defines the ray to test
  30994. * @returns true is the passed ray intersects the submesh bounding box
  30995. */
  30996. canIntersects(ray: Ray): boolean;
  30997. /**
  30998. * Intersects current submesh with a ray
  30999. * @param ray defines the ray to test
  31000. * @param positions defines mesh's positions array
  31001. * @param indices defines mesh's indices array
  31002. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31003. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31004. * @returns intersection info or null if no intersection
  31005. */
  31006. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31007. /** @hidden */
  31008. private _intersectLines;
  31009. /** @hidden */
  31010. private _intersectUnIndexedLines;
  31011. /** @hidden */
  31012. private _intersectTriangles;
  31013. /** @hidden */
  31014. private _intersectUnIndexedTriangles;
  31015. /** @hidden */
  31016. _rebuild(): void;
  31017. /**
  31018. * Creates a new submesh from the passed mesh
  31019. * @param newMesh defines the new hosting mesh
  31020. * @param newRenderingMesh defines an optional rendering mesh
  31021. * @returns the new submesh
  31022. */
  31023. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31024. /**
  31025. * Release associated resources
  31026. */
  31027. dispose(): void;
  31028. /**
  31029. * Gets the class name
  31030. * @returns the string "SubMesh".
  31031. */
  31032. getClassName(): string;
  31033. /**
  31034. * Creates a new submesh from indices data
  31035. * @param materialIndex the index of the main mesh material
  31036. * @param startIndex the index where to start the copy in the mesh indices array
  31037. * @param indexCount the number of indices to copy then from the startIndex
  31038. * @param mesh the main mesh to create the submesh from
  31039. * @param renderingMesh the optional rendering mesh
  31040. * @returns a new submesh
  31041. */
  31042. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31043. }
  31044. }
  31045. declare module "babylonjs/Loading/sceneLoaderFlags" {
  31046. /**
  31047. * Class used to represent data loading progression
  31048. */
  31049. export class SceneLoaderFlags {
  31050. private static _ForceFullSceneLoadingForIncremental;
  31051. private static _ShowLoadingScreen;
  31052. private static _CleanBoneMatrixWeights;
  31053. private static _loggingLevel;
  31054. /**
  31055. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31056. */
  31057. static get ForceFullSceneLoadingForIncremental(): boolean;
  31058. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31059. /**
  31060. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31061. */
  31062. static get ShowLoadingScreen(): boolean;
  31063. static set ShowLoadingScreen(value: boolean);
  31064. /**
  31065. * Defines the current logging level (while loading the scene)
  31066. * @ignorenaming
  31067. */
  31068. static get loggingLevel(): number;
  31069. static set loggingLevel(value: number);
  31070. /**
  31071. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31072. */
  31073. static get CleanBoneMatrixWeights(): boolean;
  31074. static set CleanBoneMatrixWeights(value: boolean);
  31075. }
  31076. }
  31077. declare module "babylonjs/Meshes/geometry" {
  31078. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  31079. import { Scene } from "babylonjs/scene";
  31080. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31081. import { Engine } from "babylonjs/Engines/engine";
  31082. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  31083. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31084. import { Effect } from "babylonjs/Materials/effect";
  31085. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31086. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31087. import { Mesh } from "babylonjs/Meshes/mesh";
  31088. /**
  31089. * Class used to store geometry data (vertex buffers + index buffer)
  31090. */
  31091. export class Geometry implements IGetSetVerticesData {
  31092. /**
  31093. * Gets or sets the ID of the geometry
  31094. */
  31095. id: string;
  31096. /**
  31097. * Gets or sets the unique ID of the geometry
  31098. */
  31099. uniqueId: number;
  31100. /**
  31101. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31102. */
  31103. delayLoadState: number;
  31104. /**
  31105. * Gets the file containing the data to load when running in delay load state
  31106. */
  31107. delayLoadingFile: Nullable<string>;
  31108. /**
  31109. * Callback called when the geometry is updated
  31110. */
  31111. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31112. private _scene;
  31113. private _engine;
  31114. private _meshes;
  31115. private _totalVertices;
  31116. /** @hidden */
  31117. _indices: IndicesArray;
  31118. /** @hidden */
  31119. _vertexBuffers: {
  31120. [key: string]: VertexBuffer;
  31121. };
  31122. private _isDisposed;
  31123. private _extend;
  31124. private _boundingBias;
  31125. /** @hidden */
  31126. _delayInfo: Array<string>;
  31127. private _indexBuffer;
  31128. private _indexBufferIsUpdatable;
  31129. /** @hidden */
  31130. _boundingInfo: Nullable<BoundingInfo>;
  31131. /** @hidden */
  31132. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31133. /** @hidden */
  31134. _softwareSkinningFrameId: number;
  31135. private _vertexArrayObjects;
  31136. private _updatable;
  31137. /** @hidden */
  31138. _positions: Nullable<Vector3[]>;
  31139. private _positionsCache;
  31140. /**
  31141. * 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
  31142. */
  31143. get boundingBias(): Vector2;
  31144. /**
  31145. * 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
  31146. */
  31147. set boundingBias(value: Vector2);
  31148. /**
  31149. * Static function used to attach a new empty geometry to a mesh
  31150. * @param mesh defines the mesh to attach the geometry to
  31151. * @returns the new Geometry
  31152. */
  31153. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31154. /** Get the list of meshes using this geometry */
  31155. get meshes(): Mesh[];
  31156. /**
  31157. * 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
  31158. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31159. */
  31160. useBoundingInfoFromGeometry: boolean;
  31161. /**
  31162. * Creates a new geometry
  31163. * @param id defines the unique ID
  31164. * @param scene defines the hosting scene
  31165. * @param vertexData defines the VertexData used to get geometry data
  31166. * @param updatable defines if geometry must be updatable (false by default)
  31167. * @param mesh defines the mesh that will be associated with the geometry
  31168. */
  31169. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31170. /**
  31171. * Gets the current extend of the geometry
  31172. */
  31173. get extend(): {
  31174. minimum: Vector3;
  31175. maximum: Vector3;
  31176. };
  31177. /**
  31178. * Gets the hosting scene
  31179. * @returns the hosting Scene
  31180. */
  31181. getScene(): Scene;
  31182. /**
  31183. * Gets the hosting engine
  31184. * @returns the hosting Engine
  31185. */
  31186. getEngine(): Engine;
  31187. /**
  31188. * Defines if the geometry is ready to use
  31189. * @returns true if the geometry is ready to be used
  31190. */
  31191. isReady(): boolean;
  31192. /**
  31193. * Gets a value indicating that the geometry should not be serialized
  31194. */
  31195. get doNotSerialize(): boolean;
  31196. /** @hidden */
  31197. _rebuild(): void;
  31198. /**
  31199. * Affects all geometry data in one call
  31200. * @param vertexData defines the geometry data
  31201. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31202. */
  31203. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31204. /**
  31205. * Set specific vertex data
  31206. * @param kind defines the data kind (Position, normal, etc...)
  31207. * @param data defines the vertex data to use
  31208. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31209. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31210. */
  31211. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31212. /**
  31213. * Removes a specific vertex data
  31214. * @param kind defines the data kind (Position, normal, etc...)
  31215. */
  31216. removeVerticesData(kind: string): void;
  31217. /**
  31218. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31219. * @param buffer defines the vertex buffer to use
  31220. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31221. */
  31222. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31223. /**
  31224. * Update a specific vertex buffer
  31225. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31226. * It will do nothing if the buffer is not updatable
  31227. * @param kind defines the data kind (Position, normal, etc...)
  31228. * @param data defines the data to use
  31229. * @param offset defines the offset in the target buffer where to store the data
  31230. * @param useBytes set to true if the offset is in bytes
  31231. */
  31232. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31233. /**
  31234. * Update a specific vertex buffer
  31235. * This function will create a new buffer if the current one is not updatable
  31236. * @param kind defines the data kind (Position, normal, etc...)
  31237. * @param data defines the data to use
  31238. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31239. */
  31240. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31241. private _updateBoundingInfo;
  31242. /** @hidden */
  31243. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31244. /**
  31245. * Gets total number of vertices
  31246. * @returns the total number of vertices
  31247. */
  31248. getTotalVertices(): number;
  31249. /**
  31250. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31251. * @param kind defines the data kind (Position, normal, etc...)
  31252. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31253. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31254. * @returns a float array containing vertex data
  31255. */
  31256. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31257. /**
  31258. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31259. * @param kind defines the data kind (Position, normal, etc...)
  31260. * @returns true if the vertex buffer with the specified kind is updatable
  31261. */
  31262. isVertexBufferUpdatable(kind: string): boolean;
  31263. /**
  31264. * Gets a specific vertex buffer
  31265. * @param kind defines the data kind (Position, normal, etc...)
  31266. * @returns a VertexBuffer
  31267. */
  31268. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31269. /**
  31270. * Returns all vertex buffers
  31271. * @return an object holding all vertex buffers indexed by kind
  31272. */
  31273. getVertexBuffers(): Nullable<{
  31274. [key: string]: VertexBuffer;
  31275. }>;
  31276. /**
  31277. * Gets a boolean indicating if specific vertex buffer is present
  31278. * @param kind defines the data kind (Position, normal, etc...)
  31279. * @returns true if data is present
  31280. */
  31281. isVerticesDataPresent(kind: string): boolean;
  31282. /**
  31283. * Gets a list of all attached data kinds (Position, normal, etc...)
  31284. * @returns a list of string containing all kinds
  31285. */
  31286. getVerticesDataKinds(): string[];
  31287. /**
  31288. * Update index buffer
  31289. * @param indices defines the indices to store in the index buffer
  31290. * @param offset defines the offset in the target buffer where to store the data
  31291. * @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)
  31292. */
  31293. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31294. /**
  31295. * Creates a new index buffer
  31296. * @param indices defines the indices to store in the index buffer
  31297. * @param totalVertices defines the total number of vertices (could be null)
  31298. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31299. */
  31300. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31301. /**
  31302. * Return the total number of indices
  31303. * @returns the total number of indices
  31304. */
  31305. getTotalIndices(): number;
  31306. /**
  31307. * Gets the index buffer array
  31308. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31309. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31310. * @returns the index buffer array
  31311. */
  31312. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31313. /**
  31314. * Gets the index buffer
  31315. * @return the index buffer
  31316. */
  31317. getIndexBuffer(): Nullable<DataBuffer>;
  31318. /** @hidden */
  31319. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31320. /**
  31321. * Release the associated resources for a specific mesh
  31322. * @param mesh defines the source mesh
  31323. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31324. */
  31325. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31326. /**
  31327. * Apply current geometry to a given mesh
  31328. * @param mesh defines the mesh to apply geometry to
  31329. */
  31330. applyToMesh(mesh: Mesh): void;
  31331. private _updateExtend;
  31332. private _applyToMesh;
  31333. private notifyUpdate;
  31334. /**
  31335. * Load the geometry if it was flagged as delay loaded
  31336. * @param scene defines the hosting scene
  31337. * @param onLoaded defines a callback called when the geometry is loaded
  31338. */
  31339. load(scene: Scene, onLoaded?: () => void): void;
  31340. private _queueLoad;
  31341. /**
  31342. * Invert the geometry to move from a right handed system to a left handed one.
  31343. */
  31344. toLeftHanded(): void;
  31345. /** @hidden */
  31346. _resetPointsArrayCache(): void;
  31347. /** @hidden */
  31348. _generatePointsArray(): boolean;
  31349. /**
  31350. * Gets a value indicating if the geometry is disposed
  31351. * @returns true if the geometry was disposed
  31352. */
  31353. isDisposed(): boolean;
  31354. private _disposeVertexArrayObjects;
  31355. /**
  31356. * Free all associated resources
  31357. */
  31358. dispose(): void;
  31359. /**
  31360. * Clone the current geometry into a new geometry
  31361. * @param id defines the unique ID of the new geometry
  31362. * @returns a new geometry object
  31363. */
  31364. copy(id: string): Geometry;
  31365. /**
  31366. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31367. * @return a JSON representation of the current geometry data (without the vertices data)
  31368. */
  31369. serialize(): any;
  31370. private toNumberArray;
  31371. /**
  31372. * Serialize all vertices data into a JSON oject
  31373. * @returns a JSON representation of the current geometry data
  31374. */
  31375. serializeVerticeData(): any;
  31376. /**
  31377. * Extracts a clone of a mesh geometry
  31378. * @param mesh defines the source mesh
  31379. * @param id defines the unique ID of the new geometry object
  31380. * @returns the new geometry object
  31381. */
  31382. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31383. /**
  31384. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31385. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31386. * Be aware Math.random() could cause collisions, but:
  31387. * "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"
  31388. * @returns a string containing a new GUID
  31389. */
  31390. static RandomId(): string;
  31391. /** @hidden */
  31392. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31393. private static _CleanMatricesWeights;
  31394. /**
  31395. * Create a new geometry from persisted data (Using .babylon file format)
  31396. * @param parsedVertexData defines the persisted data
  31397. * @param scene defines the hosting scene
  31398. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31399. * @returns the new geometry object
  31400. */
  31401. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31402. }
  31403. }
  31404. declare module "babylonjs/Meshes/mesh.vertexData" {
  31405. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  31406. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  31407. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  31408. import { Geometry } from "babylonjs/Meshes/geometry";
  31409. import { Mesh } from "babylonjs/Meshes/mesh";
  31410. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  31411. /**
  31412. * Define an interface for all classes that will get and set the data on vertices
  31413. */
  31414. export interface IGetSetVerticesData {
  31415. /**
  31416. * Gets a boolean indicating if specific vertex data is present
  31417. * @param kind defines the vertex data kind to use
  31418. * @returns true is data kind is present
  31419. */
  31420. isVerticesDataPresent(kind: string): boolean;
  31421. /**
  31422. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31423. * @param kind defines the data kind (Position, normal, etc...)
  31424. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31425. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31426. * @returns a float array containing vertex data
  31427. */
  31428. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31429. /**
  31430. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  31431. * @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.
  31432. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31433. * @returns the indices array or an empty array if the mesh has no geometry
  31434. */
  31435. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31436. /**
  31437. * Set specific vertex data
  31438. * @param kind defines the data kind (Position, normal, etc...)
  31439. * @param data defines the vertex data to use
  31440. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31441. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31442. */
  31443. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  31444. /**
  31445. * Update a specific associated vertex buffer
  31446. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  31447. * - VertexBuffer.PositionKind
  31448. * - VertexBuffer.UVKind
  31449. * - VertexBuffer.UV2Kind
  31450. * - VertexBuffer.UV3Kind
  31451. * - VertexBuffer.UV4Kind
  31452. * - VertexBuffer.UV5Kind
  31453. * - VertexBuffer.UV6Kind
  31454. * - VertexBuffer.ColorKind
  31455. * - VertexBuffer.MatricesIndicesKind
  31456. * - VertexBuffer.MatricesIndicesExtraKind
  31457. * - VertexBuffer.MatricesWeightsKind
  31458. * - VertexBuffer.MatricesWeightsExtraKind
  31459. * @param data defines the data source
  31460. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  31461. * @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)
  31462. */
  31463. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  31464. /**
  31465. * Creates a new index buffer
  31466. * @param indices defines the indices to store in the index buffer
  31467. * @param totalVertices defines the total number of vertices (could be null)
  31468. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31469. */
  31470. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  31471. }
  31472. /**
  31473. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  31474. */
  31475. export class VertexData {
  31476. /**
  31477. * Mesh side orientation : usually the external or front surface
  31478. */
  31479. static readonly FRONTSIDE: number;
  31480. /**
  31481. * Mesh side orientation : usually the internal or back surface
  31482. */
  31483. static readonly BACKSIDE: number;
  31484. /**
  31485. * Mesh side orientation : both internal and external or front and back surfaces
  31486. */
  31487. static readonly DOUBLESIDE: number;
  31488. /**
  31489. * Mesh side orientation : by default, `FRONTSIDE`
  31490. */
  31491. static readonly DEFAULTSIDE: number;
  31492. /**
  31493. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  31494. */
  31495. positions: Nullable<FloatArray>;
  31496. /**
  31497. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  31498. */
  31499. normals: Nullable<FloatArray>;
  31500. /**
  31501. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  31502. */
  31503. tangents: Nullable<FloatArray>;
  31504. /**
  31505. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31506. */
  31507. uvs: Nullable<FloatArray>;
  31508. /**
  31509. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31510. */
  31511. uvs2: Nullable<FloatArray>;
  31512. /**
  31513. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31514. */
  31515. uvs3: Nullable<FloatArray>;
  31516. /**
  31517. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31518. */
  31519. uvs4: Nullable<FloatArray>;
  31520. /**
  31521. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31522. */
  31523. uvs5: Nullable<FloatArray>;
  31524. /**
  31525. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31526. */
  31527. uvs6: Nullable<FloatArray>;
  31528. /**
  31529. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  31530. */
  31531. colors: Nullable<FloatArray>;
  31532. /**
  31533. * 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).
  31534. */
  31535. matricesIndices: Nullable<FloatArray>;
  31536. /**
  31537. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  31538. */
  31539. matricesWeights: Nullable<FloatArray>;
  31540. /**
  31541. * An array extending the number of possible indices
  31542. */
  31543. matricesIndicesExtra: Nullable<FloatArray>;
  31544. /**
  31545. * An array extending the number of possible weights when the number of indices is extended
  31546. */
  31547. matricesWeightsExtra: Nullable<FloatArray>;
  31548. /**
  31549. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  31550. */
  31551. indices: Nullable<IndicesArray>;
  31552. /**
  31553. * Uses the passed data array to set the set the values for the specified kind of data
  31554. * @param data a linear array of floating numbers
  31555. * @param kind the type of data that is being set, eg positions, colors etc
  31556. */
  31557. set(data: FloatArray, kind: string): void;
  31558. /**
  31559. * Associates the vertexData to the passed Mesh.
  31560. * Sets it as updatable or not (default `false`)
  31561. * @param mesh the mesh the vertexData is applied to
  31562. * @param updatable when used and having the value true allows new data to update the vertexData
  31563. * @returns the VertexData
  31564. */
  31565. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  31566. /**
  31567. * Associates the vertexData to the passed Geometry.
  31568. * Sets it as updatable or not (default `false`)
  31569. * @param geometry the geometry the vertexData is applied to
  31570. * @param updatable when used and having the value true allows new data to update the vertexData
  31571. * @returns VertexData
  31572. */
  31573. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  31574. /**
  31575. * Updates the associated mesh
  31576. * @param mesh the mesh to be updated
  31577. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31578. * @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
  31579. * @returns VertexData
  31580. */
  31581. updateMesh(mesh: Mesh): VertexData;
  31582. /**
  31583. * Updates the associated geometry
  31584. * @param geometry the geometry to be updated
  31585. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31586. * @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
  31587. * @returns VertexData.
  31588. */
  31589. updateGeometry(geometry: Geometry): VertexData;
  31590. private _applyTo;
  31591. private _update;
  31592. /**
  31593. * Transforms each position and each normal of the vertexData according to the passed Matrix
  31594. * @param matrix the transforming matrix
  31595. * @returns the VertexData
  31596. */
  31597. transform(matrix: Matrix): VertexData;
  31598. /**
  31599. * Merges the passed VertexData into the current one
  31600. * @param other the VertexData to be merged into the current one
  31601. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  31602. * @returns the modified VertexData
  31603. */
  31604. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  31605. private _mergeElement;
  31606. private _validate;
  31607. /**
  31608. * Serializes the VertexData
  31609. * @returns a serialized object
  31610. */
  31611. serialize(): any;
  31612. /**
  31613. * Extracts the vertexData from a mesh
  31614. * @param mesh the mesh from which to extract the VertexData
  31615. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  31616. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31617. * @returns the object VertexData associated to the passed mesh
  31618. */
  31619. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31620. /**
  31621. * Extracts the vertexData from the geometry
  31622. * @param geometry the geometry from which to extract the VertexData
  31623. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  31624. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31625. * @returns the object VertexData associated to the passed mesh
  31626. */
  31627. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31628. private static _ExtractFrom;
  31629. /**
  31630. * Creates the VertexData for a Ribbon
  31631. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  31632. * * pathArray array of paths, each of which an array of successive Vector3
  31633. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  31634. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  31635. * * 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
  31636. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31637. * * 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)
  31638. * * 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)
  31639. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  31640. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  31641. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  31642. * @returns the VertexData of the ribbon
  31643. */
  31644. static CreateRibbon(options: {
  31645. pathArray: Vector3[][];
  31646. closeArray?: boolean;
  31647. closePath?: boolean;
  31648. offset?: number;
  31649. sideOrientation?: number;
  31650. frontUVs?: Vector4;
  31651. backUVs?: Vector4;
  31652. invertUV?: boolean;
  31653. uvs?: Vector2[];
  31654. colors?: Color4[];
  31655. }): VertexData;
  31656. /**
  31657. * Creates the VertexData for a box
  31658. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31659. * * size sets the width, height and depth of the box to the value of size, optional default 1
  31660. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  31661. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  31662. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  31663. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31664. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31665. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31666. * * 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)
  31667. * * 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)
  31668. * @returns the VertexData of the box
  31669. */
  31670. static CreateBox(options: {
  31671. size?: number;
  31672. width?: number;
  31673. height?: number;
  31674. depth?: number;
  31675. faceUV?: Vector4[];
  31676. faceColors?: Color4[];
  31677. sideOrientation?: number;
  31678. frontUVs?: Vector4;
  31679. backUVs?: Vector4;
  31680. }): VertexData;
  31681. /**
  31682. * Creates the VertexData for a tiled box
  31683. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31684. * * faceTiles sets the pattern, tile size and number of tiles for a face
  31685. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31686. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31687. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31688. * @returns the VertexData of the box
  31689. */
  31690. static CreateTiledBox(options: {
  31691. pattern?: number;
  31692. width?: number;
  31693. height?: number;
  31694. depth?: number;
  31695. tileSize?: number;
  31696. tileWidth?: number;
  31697. tileHeight?: number;
  31698. alignHorizontal?: number;
  31699. alignVertical?: number;
  31700. faceUV?: Vector4[];
  31701. faceColors?: Color4[];
  31702. sideOrientation?: number;
  31703. }): VertexData;
  31704. /**
  31705. * Creates the VertexData for a tiled plane
  31706. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31707. * * pattern a limited pattern arrangement depending on the number
  31708. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  31709. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  31710. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  31711. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31712. * * 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)
  31713. * * 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)
  31714. * @returns the VertexData of the tiled plane
  31715. */
  31716. static CreateTiledPlane(options: {
  31717. pattern?: number;
  31718. tileSize?: number;
  31719. tileWidth?: number;
  31720. tileHeight?: number;
  31721. size?: number;
  31722. width?: number;
  31723. height?: number;
  31724. alignHorizontal?: number;
  31725. alignVertical?: number;
  31726. sideOrientation?: number;
  31727. frontUVs?: Vector4;
  31728. backUVs?: Vector4;
  31729. }): VertexData;
  31730. /**
  31731. * Creates the VertexData for an ellipsoid, defaults to a sphere
  31732. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31733. * * segments sets the number of horizontal strips optional, default 32
  31734. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  31735. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  31736. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  31737. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  31738. * * 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
  31739. * * 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
  31740. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31741. * * 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)
  31742. * * 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)
  31743. * @returns the VertexData of the ellipsoid
  31744. */
  31745. static CreateSphere(options: {
  31746. segments?: number;
  31747. diameter?: number;
  31748. diameterX?: number;
  31749. diameterY?: number;
  31750. diameterZ?: number;
  31751. arc?: number;
  31752. slice?: number;
  31753. sideOrientation?: number;
  31754. frontUVs?: Vector4;
  31755. backUVs?: Vector4;
  31756. }): VertexData;
  31757. /**
  31758. * Creates the VertexData for a cylinder, cone or prism
  31759. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31760. * * height sets the height (y direction) of the cylinder, optional, default 2
  31761. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  31762. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  31763. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  31764. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  31765. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  31766. * * 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
  31767. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31768. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31769. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  31770. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  31771. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31772. * * 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)
  31773. * * 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)
  31774. * @returns the VertexData of the cylinder, cone or prism
  31775. */
  31776. static CreateCylinder(options: {
  31777. height?: number;
  31778. diameterTop?: number;
  31779. diameterBottom?: number;
  31780. diameter?: number;
  31781. tessellation?: number;
  31782. subdivisions?: number;
  31783. arc?: number;
  31784. faceColors?: Color4[];
  31785. faceUV?: Vector4[];
  31786. hasRings?: boolean;
  31787. enclose?: boolean;
  31788. sideOrientation?: number;
  31789. frontUVs?: Vector4;
  31790. backUVs?: Vector4;
  31791. }): VertexData;
  31792. /**
  31793. * Creates the VertexData for a torus
  31794. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31795. * * diameter the diameter of the torus, optional default 1
  31796. * * thickness the diameter of the tube forming the torus, optional default 0.5
  31797. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  31798. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31799. * * 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)
  31800. * * 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)
  31801. * @returns the VertexData of the torus
  31802. */
  31803. static CreateTorus(options: {
  31804. diameter?: number;
  31805. thickness?: number;
  31806. tessellation?: number;
  31807. sideOrientation?: number;
  31808. frontUVs?: Vector4;
  31809. backUVs?: Vector4;
  31810. }): VertexData;
  31811. /**
  31812. * Creates the VertexData of the LineSystem
  31813. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  31814. * - lines an array of lines, each line being an array of successive Vector3
  31815. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  31816. * @returns the VertexData of the LineSystem
  31817. */
  31818. static CreateLineSystem(options: {
  31819. lines: Vector3[][];
  31820. colors?: Nullable<Color4[][]>;
  31821. }): VertexData;
  31822. /**
  31823. * Create the VertexData for a DashedLines
  31824. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  31825. * - points an array successive Vector3
  31826. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  31827. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  31828. * - dashNb the intended total number of dashes, optional, default 200
  31829. * @returns the VertexData for the DashedLines
  31830. */
  31831. static CreateDashedLines(options: {
  31832. points: Vector3[];
  31833. dashSize?: number;
  31834. gapSize?: number;
  31835. dashNb?: number;
  31836. }): VertexData;
  31837. /**
  31838. * Creates the VertexData for a Ground
  31839. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  31840. * - width the width (x direction) of the ground, optional, default 1
  31841. * - height the height (z direction) of the ground, optional, default 1
  31842. * - subdivisions the number of subdivisions per side, optional, default 1
  31843. * @returns the VertexData of the Ground
  31844. */
  31845. static CreateGround(options: {
  31846. width?: number;
  31847. height?: number;
  31848. subdivisions?: number;
  31849. subdivisionsX?: number;
  31850. subdivisionsY?: number;
  31851. }): VertexData;
  31852. /**
  31853. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  31854. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  31855. * * xmin the ground minimum X coordinate, optional, default -1
  31856. * * zmin the ground minimum Z coordinate, optional, default -1
  31857. * * xmax the ground maximum X coordinate, optional, default 1
  31858. * * zmax the ground maximum Z coordinate, optional, default 1
  31859. * * 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}
  31860. * * 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}
  31861. * @returns the VertexData of the TiledGround
  31862. */
  31863. static CreateTiledGround(options: {
  31864. xmin: number;
  31865. zmin: number;
  31866. xmax: number;
  31867. zmax: number;
  31868. subdivisions?: {
  31869. w: number;
  31870. h: number;
  31871. };
  31872. precision?: {
  31873. w: number;
  31874. h: number;
  31875. };
  31876. }): VertexData;
  31877. /**
  31878. * Creates the VertexData of the Ground designed from a heightmap
  31879. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  31880. * * width the width (x direction) of the ground
  31881. * * height the height (z direction) of the ground
  31882. * * subdivisions the number of subdivisions per side
  31883. * * minHeight the minimum altitude on the ground, optional, default 0
  31884. * * maxHeight the maximum altitude on the ground, optional default 1
  31885. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  31886. * * buffer the array holding the image color data
  31887. * * bufferWidth the width of image
  31888. * * bufferHeight the height of image
  31889. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  31890. * @returns the VertexData of the Ground designed from a heightmap
  31891. */
  31892. static CreateGroundFromHeightMap(options: {
  31893. width: number;
  31894. height: number;
  31895. subdivisions: number;
  31896. minHeight: number;
  31897. maxHeight: number;
  31898. colorFilter: Color3;
  31899. buffer: Uint8Array;
  31900. bufferWidth: number;
  31901. bufferHeight: number;
  31902. alphaFilter: number;
  31903. }): VertexData;
  31904. /**
  31905. * Creates the VertexData for a Plane
  31906. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  31907. * * size sets the width and height of the plane to the value of size, optional default 1
  31908. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  31909. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  31910. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31911. * * 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)
  31912. * * 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)
  31913. * @returns the VertexData of the box
  31914. */
  31915. static CreatePlane(options: {
  31916. size?: number;
  31917. width?: number;
  31918. height?: number;
  31919. sideOrientation?: number;
  31920. frontUVs?: Vector4;
  31921. backUVs?: Vector4;
  31922. }): VertexData;
  31923. /**
  31924. * Creates the VertexData of the Disc or regular Polygon
  31925. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  31926. * * radius the radius of the disc, optional default 0.5
  31927. * * tessellation the number of polygon sides, optional, default 64
  31928. * * 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
  31929. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31930. * * 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)
  31931. * * 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)
  31932. * @returns the VertexData of the box
  31933. */
  31934. static CreateDisc(options: {
  31935. radius?: number;
  31936. tessellation?: number;
  31937. arc?: number;
  31938. sideOrientation?: number;
  31939. frontUVs?: Vector4;
  31940. backUVs?: Vector4;
  31941. }): VertexData;
  31942. /**
  31943. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  31944. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  31945. * @param polygon a mesh built from polygonTriangulation.build()
  31946. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31947. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31948. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31949. * @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)
  31950. * @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)
  31951. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  31952. * @returns the VertexData of the Polygon
  31953. */
  31954. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  31955. /**
  31956. * Creates the VertexData of the IcoSphere
  31957. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  31958. * * radius the radius of the IcoSphere, optional default 1
  31959. * * radiusX allows stretching in the x direction, optional, default radius
  31960. * * radiusY allows stretching in the y direction, optional, default radius
  31961. * * radiusZ allows stretching in the z direction, optional, default radius
  31962. * * flat when true creates a flat shaded mesh, optional, default true
  31963. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31964. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31965. * * 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)
  31966. * * 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)
  31967. * @returns the VertexData of the IcoSphere
  31968. */
  31969. static CreateIcoSphere(options: {
  31970. radius?: number;
  31971. radiusX?: number;
  31972. radiusY?: number;
  31973. radiusZ?: number;
  31974. flat?: boolean;
  31975. subdivisions?: number;
  31976. sideOrientation?: number;
  31977. frontUVs?: Vector4;
  31978. backUVs?: Vector4;
  31979. }): VertexData;
  31980. /**
  31981. * Creates the VertexData for a Polyhedron
  31982. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  31983. * * type provided types are:
  31984. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  31985. * * 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)
  31986. * * size the size of the IcoSphere, optional default 1
  31987. * * sizeX allows stretching in the x direction, optional, default size
  31988. * * sizeY allows stretching in the y direction, optional, default size
  31989. * * sizeZ allows stretching in the z direction, optional, default size
  31990. * * 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
  31991. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31992. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31993. * * flat when true creates a flat shaded mesh, optional, default true
  31994. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31995. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31996. * * 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)
  31997. * * 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)
  31998. * @returns the VertexData of the Polyhedron
  31999. */
  32000. static CreatePolyhedron(options: {
  32001. type?: number;
  32002. size?: number;
  32003. sizeX?: number;
  32004. sizeY?: number;
  32005. sizeZ?: number;
  32006. custom?: any;
  32007. faceUV?: Vector4[];
  32008. faceColors?: Color4[];
  32009. flat?: boolean;
  32010. sideOrientation?: number;
  32011. frontUVs?: Vector4;
  32012. backUVs?: Vector4;
  32013. }): VertexData;
  32014. /**
  32015. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  32016. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  32017. * @returns the VertexData of the Capsule
  32018. */
  32019. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  32020. /**
  32021. * Creates the VertexData for a TorusKnot
  32022. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  32023. * * radius the radius of the torus knot, optional, default 2
  32024. * * tube the thickness of the tube, optional, default 0.5
  32025. * * radialSegments the number of sides on each tube segments, optional, default 32
  32026. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  32027. * * p the number of windings around the z axis, optional, default 2
  32028. * * q the number of windings around the x axis, optional, default 3
  32029. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32030. * * 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)
  32031. * * 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)
  32032. * @returns the VertexData of the Torus Knot
  32033. */
  32034. static CreateTorusKnot(options: {
  32035. radius?: number;
  32036. tube?: number;
  32037. radialSegments?: number;
  32038. tubularSegments?: number;
  32039. p?: number;
  32040. q?: number;
  32041. sideOrientation?: number;
  32042. frontUVs?: Vector4;
  32043. backUVs?: Vector4;
  32044. }): VertexData;
  32045. /**
  32046. * Compute normals for given positions and indices
  32047. * @param positions an array of vertex positions, [...., x, y, z, ......]
  32048. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  32049. * @param normals an array of vertex normals, [...., x, y, z, ......]
  32050. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  32051. * * facetNormals : optional array of facet normals (vector3)
  32052. * * facetPositions : optional array of facet positions (vector3)
  32053. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  32054. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  32055. * * bInfo : optional bounding info, required for facetPartitioning computation
  32056. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  32057. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  32058. * * useRightHandedSystem: optional boolean to for right handed system computation
  32059. * * depthSort : optional boolean to enable the facet depth sort computation
  32060. * * distanceTo : optional Vector3 to compute the facet depth from this location
  32061. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  32062. */
  32063. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  32064. facetNormals?: any;
  32065. facetPositions?: any;
  32066. facetPartitioning?: any;
  32067. ratio?: number;
  32068. bInfo?: any;
  32069. bbSize?: Vector3;
  32070. subDiv?: any;
  32071. useRightHandedSystem?: boolean;
  32072. depthSort?: boolean;
  32073. distanceTo?: Vector3;
  32074. depthSortedFacets?: any;
  32075. }): void;
  32076. /** @hidden */
  32077. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  32078. /**
  32079. * Applies VertexData created from the imported parameters to the geometry
  32080. * @param parsedVertexData the parsed data from an imported file
  32081. * @param geometry the geometry to apply the VertexData to
  32082. */
  32083. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  32084. }
  32085. }
  32086. declare module "babylonjs/Morph/morphTarget" {
  32087. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  32088. import { Observable } from "babylonjs/Misc/observable";
  32089. import { Nullable, FloatArray } from "babylonjs/types";
  32090. import { Scene } from "babylonjs/scene";
  32091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32092. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32093. /**
  32094. * Defines a target to use with MorphTargetManager
  32095. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32096. */
  32097. export class MorphTarget implements IAnimatable {
  32098. /** defines the name of the target */
  32099. name: string;
  32100. /**
  32101. * Gets or sets the list of animations
  32102. */
  32103. animations: import("babylonjs/Animations/animation").Animation[];
  32104. private _scene;
  32105. private _positions;
  32106. private _normals;
  32107. private _tangents;
  32108. private _uvs;
  32109. private _influence;
  32110. private _uniqueId;
  32111. /**
  32112. * Observable raised when the influence changes
  32113. */
  32114. onInfluenceChanged: Observable<boolean>;
  32115. /** @hidden */
  32116. _onDataLayoutChanged: Observable<void>;
  32117. /**
  32118. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  32119. */
  32120. get influence(): number;
  32121. set influence(influence: number);
  32122. /**
  32123. * Gets or sets the id of the morph Target
  32124. */
  32125. id: string;
  32126. private _animationPropertiesOverride;
  32127. /**
  32128. * Gets or sets the animation properties override
  32129. */
  32130. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32131. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32132. /**
  32133. * Creates a new MorphTarget
  32134. * @param name defines the name of the target
  32135. * @param influence defines the influence to use
  32136. * @param scene defines the scene the morphtarget belongs to
  32137. */
  32138. constructor(
  32139. /** defines the name of the target */
  32140. name: string, influence?: number, scene?: Nullable<Scene>);
  32141. /**
  32142. * Gets the unique ID of this manager
  32143. */
  32144. get uniqueId(): number;
  32145. /**
  32146. * Gets a boolean defining if the target contains position data
  32147. */
  32148. get hasPositions(): boolean;
  32149. /**
  32150. * Gets a boolean defining if the target contains normal data
  32151. */
  32152. get hasNormals(): boolean;
  32153. /**
  32154. * Gets a boolean defining if the target contains tangent data
  32155. */
  32156. get hasTangents(): boolean;
  32157. /**
  32158. * Gets a boolean defining if the target contains texture coordinates data
  32159. */
  32160. get hasUVs(): boolean;
  32161. /**
  32162. * Affects position data to this target
  32163. * @param data defines the position data to use
  32164. */
  32165. setPositions(data: Nullable<FloatArray>): void;
  32166. /**
  32167. * Gets the position data stored in this target
  32168. * @returns a FloatArray containing the position data (or null if not present)
  32169. */
  32170. getPositions(): Nullable<FloatArray>;
  32171. /**
  32172. * Affects normal data to this target
  32173. * @param data defines the normal data to use
  32174. */
  32175. setNormals(data: Nullable<FloatArray>): void;
  32176. /**
  32177. * Gets the normal data stored in this target
  32178. * @returns a FloatArray containing the normal data (or null if not present)
  32179. */
  32180. getNormals(): Nullable<FloatArray>;
  32181. /**
  32182. * Affects tangent data to this target
  32183. * @param data defines the tangent data to use
  32184. */
  32185. setTangents(data: Nullable<FloatArray>): void;
  32186. /**
  32187. * Gets the tangent data stored in this target
  32188. * @returns a FloatArray containing the tangent data (or null if not present)
  32189. */
  32190. getTangents(): Nullable<FloatArray>;
  32191. /**
  32192. * Affects texture coordinates data to this target
  32193. * @param data defines the texture coordinates data to use
  32194. */
  32195. setUVs(data: Nullable<FloatArray>): void;
  32196. /**
  32197. * Gets the texture coordinates data stored in this target
  32198. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  32199. */
  32200. getUVs(): Nullable<FloatArray>;
  32201. /**
  32202. * Clone the current target
  32203. * @returns a new MorphTarget
  32204. */
  32205. clone(): MorphTarget;
  32206. /**
  32207. * Serializes the current target into a Serialization object
  32208. * @returns the serialized object
  32209. */
  32210. serialize(): any;
  32211. /**
  32212. * Returns the string "MorphTarget"
  32213. * @returns "MorphTarget"
  32214. */
  32215. getClassName(): string;
  32216. /**
  32217. * Creates a new target from serialized data
  32218. * @param serializationObject defines the serialized data to use
  32219. * @returns a new MorphTarget
  32220. */
  32221. static Parse(serializationObject: any): MorphTarget;
  32222. /**
  32223. * Creates a MorphTarget from mesh data
  32224. * @param mesh defines the source mesh
  32225. * @param name defines the name to use for the new target
  32226. * @param influence defines the influence to attach to the target
  32227. * @returns a new MorphTarget
  32228. */
  32229. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32230. }
  32231. }
  32232. declare module "babylonjs/Morph/morphTargetManager" {
  32233. import { Nullable } from "babylonjs/types";
  32234. import { Scene } from "babylonjs/scene";
  32235. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32236. /**
  32237. * This class is used to deform meshes using morphing between different targets
  32238. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32239. */
  32240. export class MorphTargetManager {
  32241. private _targets;
  32242. private _targetInfluenceChangedObservers;
  32243. private _targetDataLayoutChangedObservers;
  32244. private _activeTargets;
  32245. private _scene;
  32246. private _influences;
  32247. private _supportsNormals;
  32248. private _supportsTangents;
  32249. private _supportsUVs;
  32250. private _vertexCount;
  32251. private _uniqueId;
  32252. private _tempInfluences;
  32253. /**
  32254. * Gets or sets a boolean indicating if normals must be morphed
  32255. */
  32256. enableNormalMorphing: boolean;
  32257. /**
  32258. * Gets or sets a boolean indicating if tangents must be morphed
  32259. */
  32260. enableTangentMorphing: boolean;
  32261. /**
  32262. * Gets or sets a boolean indicating if UV must be morphed
  32263. */
  32264. enableUVMorphing: boolean;
  32265. /**
  32266. * Creates a new MorphTargetManager
  32267. * @param scene defines the current scene
  32268. */
  32269. constructor(scene?: Nullable<Scene>);
  32270. /**
  32271. * Gets the unique ID of this manager
  32272. */
  32273. get uniqueId(): number;
  32274. /**
  32275. * Gets the number of vertices handled by this manager
  32276. */
  32277. get vertexCount(): number;
  32278. /**
  32279. * Gets a boolean indicating if this manager supports morphing of normals
  32280. */
  32281. get supportsNormals(): boolean;
  32282. /**
  32283. * Gets a boolean indicating if this manager supports morphing of tangents
  32284. */
  32285. get supportsTangents(): boolean;
  32286. /**
  32287. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32288. */
  32289. get supportsUVs(): boolean;
  32290. /**
  32291. * Gets the number of targets stored in this manager
  32292. */
  32293. get numTargets(): number;
  32294. /**
  32295. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32296. */
  32297. get numInfluencers(): number;
  32298. /**
  32299. * Gets the list of influences (one per target)
  32300. */
  32301. get influences(): Float32Array;
  32302. /**
  32303. * Gets the active target at specified index. An active target is a target with an influence > 0
  32304. * @param index defines the index to check
  32305. * @returns the requested target
  32306. */
  32307. getActiveTarget(index: number): MorphTarget;
  32308. /**
  32309. * Gets the target at specified index
  32310. * @param index defines the index to check
  32311. * @returns the requested target
  32312. */
  32313. getTarget(index: number): MorphTarget;
  32314. /**
  32315. * Add a new target to this manager
  32316. * @param target defines the target to add
  32317. */
  32318. addTarget(target: MorphTarget): void;
  32319. /**
  32320. * Removes a target from the manager
  32321. * @param target defines the target to remove
  32322. */
  32323. removeTarget(target: MorphTarget): void;
  32324. /**
  32325. * Clone the current manager
  32326. * @returns a new MorphTargetManager
  32327. */
  32328. clone(): MorphTargetManager;
  32329. /**
  32330. * Serializes the current manager into a Serialization object
  32331. * @returns the serialized object
  32332. */
  32333. serialize(): any;
  32334. private _syncActiveTargets;
  32335. /**
  32336. * Syncrhonize the targets with all the meshes using this morph target manager
  32337. */
  32338. synchronize(): void;
  32339. /**
  32340. * Creates a new MorphTargetManager from serialized data
  32341. * @param serializationObject defines the serialized data
  32342. * @param scene defines the hosting scene
  32343. * @returns the new MorphTargetManager
  32344. */
  32345. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32346. }
  32347. }
  32348. declare module "babylonjs/Meshes/meshLODLevel" {
  32349. import { Mesh } from "babylonjs/Meshes/mesh";
  32350. import { Nullable } from "babylonjs/types";
  32351. /**
  32352. * Class used to represent a specific level of detail of a mesh
  32353. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32354. */
  32355. export class MeshLODLevel {
  32356. /** Defines the distance where this level should start being displayed */
  32357. distance: number;
  32358. /** Defines the mesh to use to render this level */
  32359. mesh: Nullable<Mesh>;
  32360. /**
  32361. * Creates a new LOD level
  32362. * @param distance defines the distance where this level should star being displayed
  32363. * @param mesh defines the mesh to use to render this level
  32364. */
  32365. constructor(
  32366. /** Defines the distance where this level should start being displayed */
  32367. distance: number,
  32368. /** Defines the mesh to use to render this level */
  32369. mesh: Nullable<Mesh>);
  32370. }
  32371. }
  32372. declare module "babylonjs/Misc/canvasGenerator" {
  32373. /**
  32374. * Helper class used to generate a canvas to manipulate images
  32375. */
  32376. export class CanvasGenerator {
  32377. /**
  32378. * Create a new canvas (or offscreen canvas depending on the context)
  32379. * @param width defines the expected width
  32380. * @param height defines the expected height
  32381. * @return a new canvas or offscreen canvas
  32382. */
  32383. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32384. }
  32385. }
  32386. declare module "babylonjs/Meshes/groundMesh" {
  32387. import { Scene } from "babylonjs/scene";
  32388. import { Vector3 } from "babylonjs/Maths/math.vector";
  32389. import { Mesh } from "babylonjs/Meshes/mesh";
  32390. /**
  32391. * Mesh representing the gorund
  32392. */
  32393. export class GroundMesh extends Mesh {
  32394. /** If octree should be generated */
  32395. generateOctree: boolean;
  32396. private _heightQuads;
  32397. /** @hidden */
  32398. _subdivisionsX: number;
  32399. /** @hidden */
  32400. _subdivisionsY: number;
  32401. /** @hidden */
  32402. _width: number;
  32403. /** @hidden */
  32404. _height: number;
  32405. /** @hidden */
  32406. _minX: number;
  32407. /** @hidden */
  32408. _maxX: number;
  32409. /** @hidden */
  32410. _minZ: number;
  32411. /** @hidden */
  32412. _maxZ: number;
  32413. constructor(name: string, scene: Scene);
  32414. /**
  32415. * "GroundMesh"
  32416. * @returns "GroundMesh"
  32417. */
  32418. getClassName(): string;
  32419. /**
  32420. * The minimum of x and y subdivisions
  32421. */
  32422. get subdivisions(): number;
  32423. /**
  32424. * X subdivisions
  32425. */
  32426. get subdivisionsX(): number;
  32427. /**
  32428. * Y subdivisions
  32429. */
  32430. get subdivisionsY(): number;
  32431. /**
  32432. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32433. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32434. * @param chunksCount the number of subdivisions for x and y
  32435. * @param octreeBlocksSize (Default: 32)
  32436. */
  32437. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32438. /**
  32439. * Returns a height (y) value in the Worl system :
  32440. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32441. * @param x x coordinate
  32442. * @param z z coordinate
  32443. * @returns the ground y position if (x, z) are outside the ground surface.
  32444. */
  32445. getHeightAtCoordinates(x: number, z: number): number;
  32446. /**
  32447. * Returns a normalized vector (Vector3) orthogonal to the ground
  32448. * at the ground coordinates (x, z) expressed in the World system.
  32449. * @param x x coordinate
  32450. * @param z z coordinate
  32451. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32452. */
  32453. getNormalAtCoordinates(x: number, z: number): Vector3;
  32454. /**
  32455. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32456. * at the ground coordinates (x, z) expressed in the World system.
  32457. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  32458. * @param x x coordinate
  32459. * @param z z coordinate
  32460. * @param ref vector to store the result
  32461. * @returns the GroundMesh.
  32462. */
  32463. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32464. /**
  32465. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32466. * if the ground has been updated.
  32467. * This can be used in the render loop.
  32468. * @returns the GroundMesh.
  32469. */
  32470. updateCoordinateHeights(): GroundMesh;
  32471. private _getFacetAt;
  32472. private _initHeightQuads;
  32473. private _computeHeightQuads;
  32474. /**
  32475. * Serializes this ground mesh
  32476. * @param serializationObject object to write serialization to
  32477. */
  32478. serialize(serializationObject: any): void;
  32479. /**
  32480. * Parses a serialized ground mesh
  32481. * @param parsedMesh the serialized mesh
  32482. * @param scene the scene to create the ground mesh in
  32483. * @returns the created ground mesh
  32484. */
  32485. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32486. }
  32487. }
  32488. declare module "babylonjs/Physics/physicsJoint" {
  32489. import { Vector3 } from "babylonjs/Maths/math.vector";
  32490. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  32491. /**
  32492. * Interface for Physics-Joint data
  32493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32494. */
  32495. export interface PhysicsJointData {
  32496. /**
  32497. * The main pivot of the joint
  32498. */
  32499. mainPivot?: Vector3;
  32500. /**
  32501. * The connected pivot of the joint
  32502. */
  32503. connectedPivot?: Vector3;
  32504. /**
  32505. * The main axis of the joint
  32506. */
  32507. mainAxis?: Vector3;
  32508. /**
  32509. * The connected axis of the joint
  32510. */
  32511. connectedAxis?: Vector3;
  32512. /**
  32513. * The collision of the joint
  32514. */
  32515. collision?: boolean;
  32516. /**
  32517. * Native Oimo/Cannon/Energy data
  32518. */
  32519. nativeParams?: any;
  32520. }
  32521. /**
  32522. * This is a holder class for the physics joint created by the physics plugin
  32523. * It holds a set of functions to control the underlying joint
  32524. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32525. */
  32526. export class PhysicsJoint {
  32527. /**
  32528. * The type of the physics joint
  32529. */
  32530. type: number;
  32531. /**
  32532. * The data for the physics joint
  32533. */
  32534. jointData: PhysicsJointData;
  32535. private _physicsJoint;
  32536. protected _physicsPlugin: IPhysicsEnginePlugin;
  32537. /**
  32538. * Initializes the physics joint
  32539. * @param type The type of the physics joint
  32540. * @param jointData The data for the physics joint
  32541. */
  32542. constructor(
  32543. /**
  32544. * The type of the physics joint
  32545. */
  32546. type: number,
  32547. /**
  32548. * The data for the physics joint
  32549. */
  32550. jointData: PhysicsJointData);
  32551. /**
  32552. * Gets the physics joint
  32553. */
  32554. get physicsJoint(): any;
  32555. /**
  32556. * Sets the physics joint
  32557. */
  32558. set physicsJoint(newJoint: any);
  32559. /**
  32560. * Sets the physics plugin
  32561. */
  32562. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32563. /**
  32564. * Execute a function that is physics-plugin specific.
  32565. * @param {Function} func the function that will be executed.
  32566. * It accepts two parameters: the physics world and the physics joint
  32567. */
  32568. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32569. /**
  32570. * Distance-Joint type
  32571. */
  32572. static DistanceJoint: number;
  32573. /**
  32574. * Hinge-Joint type
  32575. */
  32576. static HingeJoint: number;
  32577. /**
  32578. * Ball-and-Socket joint type
  32579. */
  32580. static BallAndSocketJoint: number;
  32581. /**
  32582. * Wheel-Joint type
  32583. */
  32584. static WheelJoint: number;
  32585. /**
  32586. * Slider-Joint type
  32587. */
  32588. static SliderJoint: number;
  32589. /**
  32590. * Prismatic-Joint type
  32591. */
  32592. static PrismaticJoint: number;
  32593. /**
  32594. * Universal-Joint type
  32595. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32596. */
  32597. static UniversalJoint: number;
  32598. /**
  32599. * Hinge-Joint 2 type
  32600. */
  32601. static Hinge2Joint: number;
  32602. /**
  32603. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32604. */
  32605. static PointToPointJoint: number;
  32606. /**
  32607. * Spring-Joint type
  32608. */
  32609. static SpringJoint: number;
  32610. /**
  32611. * Lock-Joint type
  32612. */
  32613. static LockJoint: number;
  32614. }
  32615. /**
  32616. * A class representing a physics distance joint
  32617. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32618. */
  32619. export class DistanceJoint extends PhysicsJoint {
  32620. /**
  32621. *
  32622. * @param jointData The data for the Distance-Joint
  32623. */
  32624. constructor(jointData: DistanceJointData);
  32625. /**
  32626. * Update the predefined distance.
  32627. * @param maxDistance The maximum preferred distance
  32628. * @param minDistance The minimum preferred distance
  32629. */
  32630. updateDistance(maxDistance: number, minDistance?: number): void;
  32631. }
  32632. /**
  32633. * Represents a Motor-Enabled Joint
  32634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32635. */
  32636. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32637. /**
  32638. * Initializes the Motor-Enabled Joint
  32639. * @param type The type of the joint
  32640. * @param jointData The physica joint data for the joint
  32641. */
  32642. constructor(type: number, jointData: PhysicsJointData);
  32643. /**
  32644. * Set the motor values.
  32645. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32646. * @param force the force to apply
  32647. * @param maxForce max force for this motor.
  32648. */
  32649. setMotor(force?: number, maxForce?: number): void;
  32650. /**
  32651. * Set the motor's limits.
  32652. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32653. * @param upperLimit The upper limit of the motor
  32654. * @param lowerLimit The lower limit of the motor
  32655. */
  32656. setLimit(upperLimit: number, lowerLimit?: number): void;
  32657. }
  32658. /**
  32659. * This class represents a single physics Hinge-Joint
  32660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32661. */
  32662. export class HingeJoint extends MotorEnabledJoint {
  32663. /**
  32664. * Initializes the Hinge-Joint
  32665. * @param jointData The joint data for the Hinge-Joint
  32666. */
  32667. constructor(jointData: PhysicsJointData);
  32668. /**
  32669. * Set the motor values.
  32670. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32671. * @param {number} force the force to apply
  32672. * @param {number} maxForce max force for this motor.
  32673. */
  32674. setMotor(force?: number, maxForce?: number): void;
  32675. /**
  32676. * Set the motor's limits.
  32677. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32678. * @param upperLimit The upper limit of the motor
  32679. * @param lowerLimit The lower limit of the motor
  32680. */
  32681. setLimit(upperLimit: number, lowerLimit?: number): void;
  32682. }
  32683. /**
  32684. * This class represents a dual hinge physics joint (same as wheel joint)
  32685. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32686. */
  32687. export class Hinge2Joint extends MotorEnabledJoint {
  32688. /**
  32689. * Initializes the Hinge2-Joint
  32690. * @param jointData The joint data for the Hinge2-Joint
  32691. */
  32692. constructor(jointData: PhysicsJointData);
  32693. /**
  32694. * Set the motor values.
  32695. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32696. * @param {number} targetSpeed the speed the motor is to reach
  32697. * @param {number} maxForce max force for this motor.
  32698. * @param {motorIndex} the motor's index, 0 or 1.
  32699. */
  32700. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32701. /**
  32702. * Set the motor limits.
  32703. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32704. * @param {number} upperLimit the upper limit
  32705. * @param {number} lowerLimit lower limit
  32706. * @param {motorIndex} the motor's index, 0 or 1.
  32707. */
  32708. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32709. }
  32710. /**
  32711. * Interface for a motor enabled joint
  32712. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32713. */
  32714. export interface IMotorEnabledJoint {
  32715. /**
  32716. * Physics joint
  32717. */
  32718. physicsJoint: any;
  32719. /**
  32720. * Sets the motor of the motor-enabled joint
  32721. * @param force The force of the motor
  32722. * @param maxForce The maximum force of the motor
  32723. * @param motorIndex The index of the motor
  32724. */
  32725. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32726. /**
  32727. * Sets the limit of the motor
  32728. * @param upperLimit The upper limit of the motor
  32729. * @param lowerLimit The lower limit of the motor
  32730. * @param motorIndex The index of the motor
  32731. */
  32732. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32733. }
  32734. /**
  32735. * Joint data for a Distance-Joint
  32736. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32737. */
  32738. export interface DistanceJointData extends PhysicsJointData {
  32739. /**
  32740. * Max distance the 2 joint objects can be apart
  32741. */
  32742. maxDistance: number;
  32743. }
  32744. /**
  32745. * Joint data from a spring joint
  32746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32747. */
  32748. export interface SpringJointData extends PhysicsJointData {
  32749. /**
  32750. * Length of the spring
  32751. */
  32752. length: number;
  32753. /**
  32754. * Stiffness of the spring
  32755. */
  32756. stiffness: number;
  32757. /**
  32758. * Damping of the spring
  32759. */
  32760. damping: number;
  32761. /** this callback will be called when applying the force to the impostors. */
  32762. forceApplicationCallback: () => void;
  32763. }
  32764. }
  32765. declare module "babylonjs/Physics/physicsRaycastResult" {
  32766. import { Vector3 } from "babylonjs/Maths/math.vector";
  32767. /**
  32768. * Holds the data for the raycast result
  32769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32770. */
  32771. export class PhysicsRaycastResult {
  32772. private _hasHit;
  32773. private _hitDistance;
  32774. private _hitNormalWorld;
  32775. private _hitPointWorld;
  32776. private _rayFromWorld;
  32777. private _rayToWorld;
  32778. /**
  32779. * Gets if there was a hit
  32780. */
  32781. get hasHit(): boolean;
  32782. /**
  32783. * Gets the distance from the hit
  32784. */
  32785. get hitDistance(): number;
  32786. /**
  32787. * Gets the hit normal/direction in the world
  32788. */
  32789. get hitNormalWorld(): Vector3;
  32790. /**
  32791. * Gets the hit point in the world
  32792. */
  32793. get hitPointWorld(): Vector3;
  32794. /**
  32795. * Gets the ray "start point" of the ray in the world
  32796. */
  32797. get rayFromWorld(): Vector3;
  32798. /**
  32799. * Gets the ray "end point" of the ray in the world
  32800. */
  32801. get rayToWorld(): Vector3;
  32802. /**
  32803. * Sets the hit data (normal & point in world space)
  32804. * @param hitNormalWorld defines the normal in world space
  32805. * @param hitPointWorld defines the point in world space
  32806. */
  32807. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32808. /**
  32809. * Sets the distance from the start point to the hit point
  32810. * @param distance
  32811. */
  32812. setHitDistance(distance: number): void;
  32813. /**
  32814. * Calculates the distance manually
  32815. */
  32816. calculateHitDistance(): void;
  32817. /**
  32818. * Resets all the values to default
  32819. * @param from The from point on world space
  32820. * @param to The to point on world space
  32821. */
  32822. reset(from?: Vector3, to?: Vector3): void;
  32823. }
  32824. /**
  32825. * Interface for the size containing width and height
  32826. */
  32827. interface IXYZ {
  32828. /**
  32829. * X
  32830. */
  32831. x: number;
  32832. /**
  32833. * Y
  32834. */
  32835. y: number;
  32836. /**
  32837. * Z
  32838. */
  32839. z: number;
  32840. }
  32841. }
  32842. declare module "babylonjs/Physics/IPhysicsEngine" {
  32843. import { Nullable } from "babylonjs/types";
  32844. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  32845. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32846. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  32847. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  32848. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  32849. /**
  32850. * Interface used to describe a physics joint
  32851. */
  32852. export interface PhysicsImpostorJoint {
  32853. /** Defines the main impostor to which the joint is linked */
  32854. mainImpostor: PhysicsImpostor;
  32855. /** Defines the impostor that is connected to the main impostor using this joint */
  32856. connectedImpostor: PhysicsImpostor;
  32857. /** Defines the joint itself */
  32858. joint: PhysicsJoint;
  32859. }
  32860. /** @hidden */
  32861. export interface IPhysicsEnginePlugin {
  32862. world: any;
  32863. name: string;
  32864. setGravity(gravity: Vector3): void;
  32865. setTimeStep(timeStep: number): void;
  32866. getTimeStep(): number;
  32867. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32868. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32869. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32870. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32871. removePhysicsBody(impostor: PhysicsImpostor): void;
  32872. generateJoint(joint: PhysicsImpostorJoint): void;
  32873. removeJoint(joint: PhysicsImpostorJoint): void;
  32874. isSupported(): boolean;
  32875. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32876. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32877. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32878. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32879. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32880. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32881. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32882. getBodyMass(impostor: PhysicsImpostor): number;
  32883. getBodyFriction(impostor: PhysicsImpostor): number;
  32884. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32885. getBodyRestitution(impostor: PhysicsImpostor): number;
  32886. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32887. getBodyPressure?(impostor: PhysicsImpostor): number;
  32888. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32889. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32890. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32891. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32892. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32893. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32894. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32895. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32896. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32897. sleepBody(impostor: PhysicsImpostor): void;
  32898. wakeUpBody(impostor: PhysicsImpostor): void;
  32899. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32900. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32901. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32902. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32903. getRadius(impostor: PhysicsImpostor): number;
  32904. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32905. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32906. dispose(): void;
  32907. }
  32908. /**
  32909. * Interface used to define a physics engine
  32910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32911. */
  32912. export interface IPhysicsEngine {
  32913. /**
  32914. * Gets the gravity vector used by the simulation
  32915. */
  32916. gravity: Vector3;
  32917. /**
  32918. * Sets the gravity vector used by the simulation
  32919. * @param gravity defines the gravity vector to use
  32920. */
  32921. setGravity(gravity: Vector3): void;
  32922. /**
  32923. * Set the time step of the physics engine.
  32924. * Default is 1/60.
  32925. * To slow it down, enter 1/600 for example.
  32926. * To speed it up, 1/30
  32927. * @param newTimeStep the new timestep to apply to this world.
  32928. */
  32929. setTimeStep(newTimeStep: number): void;
  32930. /**
  32931. * Get the time step of the physics engine.
  32932. * @returns the current time step
  32933. */
  32934. getTimeStep(): number;
  32935. /**
  32936. * Set the sub time step of the physics engine.
  32937. * Default is 0 meaning there is no sub steps
  32938. * To increase physics resolution precision, set a small value (like 1 ms)
  32939. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32940. */
  32941. setSubTimeStep(subTimeStep: number): void;
  32942. /**
  32943. * Get the sub time step of the physics engine.
  32944. * @returns the current sub time step
  32945. */
  32946. getSubTimeStep(): number;
  32947. /**
  32948. * Release all resources
  32949. */
  32950. dispose(): void;
  32951. /**
  32952. * Gets the name of the current physics plugin
  32953. * @returns the name of the plugin
  32954. */
  32955. getPhysicsPluginName(): string;
  32956. /**
  32957. * Adding a new impostor for the impostor tracking.
  32958. * This will be done by the impostor itself.
  32959. * @param impostor the impostor to add
  32960. */
  32961. addImpostor(impostor: PhysicsImpostor): void;
  32962. /**
  32963. * Remove an impostor from the engine.
  32964. * This impostor and its mesh will not longer be updated by the physics engine.
  32965. * @param impostor the impostor to remove
  32966. */
  32967. removeImpostor(impostor: PhysicsImpostor): void;
  32968. /**
  32969. * Add a joint to the physics engine
  32970. * @param mainImpostor defines the main impostor to which the joint is added.
  32971. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32972. * @param joint defines the joint that will connect both impostors.
  32973. */
  32974. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32975. /**
  32976. * Removes a joint from the simulation
  32977. * @param mainImpostor defines the impostor used with the joint
  32978. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32979. * @param joint defines the joint to remove
  32980. */
  32981. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32982. /**
  32983. * Gets the current plugin used to run the simulation
  32984. * @returns current plugin
  32985. */
  32986. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32987. /**
  32988. * Gets the list of physic impostors
  32989. * @returns an array of PhysicsImpostor
  32990. */
  32991. getImpostors(): Array<PhysicsImpostor>;
  32992. /**
  32993. * Gets the impostor for a physics enabled object
  32994. * @param object defines the object impersonated by the impostor
  32995. * @returns the PhysicsImpostor or null if not found
  32996. */
  32997. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32998. /**
  32999. * Gets the impostor for a physics body object
  33000. * @param body defines physics body used by the impostor
  33001. * @returns the PhysicsImpostor or null if not found
  33002. */
  33003. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33004. /**
  33005. * Does a raycast in the physics world
  33006. * @param from when should the ray start?
  33007. * @param to when should the ray end?
  33008. * @returns PhysicsRaycastResult
  33009. */
  33010. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33011. /**
  33012. * Called by the scene. No need to call it.
  33013. * @param delta defines the timespam between frames
  33014. */
  33015. _step(delta: number): void;
  33016. }
  33017. }
  33018. declare module "babylonjs/Physics/physicsImpostor" {
  33019. import { Nullable, IndicesArray } from "babylonjs/types";
  33020. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  33021. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33023. import { Scene } from "babylonjs/scene";
  33024. import { Bone } from "babylonjs/Bones/bone";
  33025. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33026. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  33027. import { Space } from "babylonjs/Maths/math.axis";
  33028. /**
  33029. * The interface for the physics imposter parameters
  33030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33031. */
  33032. export interface PhysicsImpostorParameters {
  33033. /**
  33034. * The mass of the physics imposter
  33035. */
  33036. mass: number;
  33037. /**
  33038. * The friction of the physics imposter
  33039. */
  33040. friction?: number;
  33041. /**
  33042. * The coefficient of restitution of the physics imposter
  33043. */
  33044. restitution?: number;
  33045. /**
  33046. * The native options of the physics imposter
  33047. */
  33048. nativeOptions?: any;
  33049. /**
  33050. * Specifies if the parent should be ignored
  33051. */
  33052. ignoreParent?: boolean;
  33053. /**
  33054. * Specifies if bi-directional transformations should be disabled
  33055. */
  33056. disableBidirectionalTransformation?: boolean;
  33057. /**
  33058. * The pressure inside the physics imposter, soft object only
  33059. */
  33060. pressure?: number;
  33061. /**
  33062. * The stiffness the physics imposter, soft object only
  33063. */
  33064. stiffness?: number;
  33065. /**
  33066. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  33067. */
  33068. velocityIterations?: number;
  33069. /**
  33070. * The number of iterations used in maintaining consistent vertex positions, soft object only
  33071. */
  33072. positionIterations?: number;
  33073. /**
  33074. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  33075. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  33076. * Add to fix multiple points
  33077. */
  33078. fixedPoints?: number;
  33079. /**
  33080. * The collision margin around a soft object
  33081. */
  33082. margin?: number;
  33083. /**
  33084. * The collision margin around a soft object
  33085. */
  33086. damping?: number;
  33087. /**
  33088. * The path for a rope based on an extrusion
  33089. */
  33090. path?: any;
  33091. /**
  33092. * The shape of an extrusion used for a rope based on an extrusion
  33093. */
  33094. shape?: any;
  33095. }
  33096. /**
  33097. * Interface for a physics-enabled object
  33098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33099. */
  33100. export interface IPhysicsEnabledObject {
  33101. /**
  33102. * The position of the physics-enabled object
  33103. */
  33104. position: Vector3;
  33105. /**
  33106. * The rotation of the physics-enabled object
  33107. */
  33108. rotationQuaternion: Nullable<Quaternion>;
  33109. /**
  33110. * The scale of the physics-enabled object
  33111. */
  33112. scaling: Vector3;
  33113. /**
  33114. * The rotation of the physics-enabled object
  33115. */
  33116. rotation?: Vector3;
  33117. /**
  33118. * The parent of the physics-enabled object
  33119. */
  33120. parent?: any;
  33121. /**
  33122. * The bounding info of the physics-enabled object
  33123. * @returns The bounding info of the physics-enabled object
  33124. */
  33125. getBoundingInfo(): BoundingInfo;
  33126. /**
  33127. * Computes the world matrix
  33128. * @param force Specifies if the world matrix should be computed by force
  33129. * @returns A world matrix
  33130. */
  33131. computeWorldMatrix(force: boolean): Matrix;
  33132. /**
  33133. * Gets the world matrix
  33134. * @returns A world matrix
  33135. */
  33136. getWorldMatrix?(): Matrix;
  33137. /**
  33138. * Gets the child meshes
  33139. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33140. * @returns An array of abstract meshes
  33141. */
  33142. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33143. /**
  33144. * Gets the vertex data
  33145. * @param kind The type of vertex data
  33146. * @returns A nullable array of numbers, or a float32 array
  33147. */
  33148. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33149. /**
  33150. * Gets the indices from the mesh
  33151. * @returns A nullable array of index arrays
  33152. */
  33153. getIndices?(): Nullable<IndicesArray>;
  33154. /**
  33155. * Gets the scene from the mesh
  33156. * @returns the indices array or null
  33157. */
  33158. getScene?(): Scene;
  33159. /**
  33160. * Gets the absolute position from the mesh
  33161. * @returns the absolute position
  33162. */
  33163. getAbsolutePosition(): Vector3;
  33164. /**
  33165. * Gets the absolute pivot point from the mesh
  33166. * @returns the absolute pivot point
  33167. */
  33168. getAbsolutePivotPoint(): Vector3;
  33169. /**
  33170. * Rotates the mesh
  33171. * @param axis The axis of rotation
  33172. * @param amount The amount of rotation
  33173. * @param space The space of the rotation
  33174. * @returns The rotation transform node
  33175. */
  33176. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33177. /**
  33178. * Translates the mesh
  33179. * @param axis The axis of translation
  33180. * @param distance The distance of translation
  33181. * @param space The space of the translation
  33182. * @returns The transform node
  33183. */
  33184. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33185. /**
  33186. * Sets the absolute position of the mesh
  33187. * @param absolutePosition The absolute position of the mesh
  33188. * @returns The transform node
  33189. */
  33190. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33191. /**
  33192. * Gets the class name of the mesh
  33193. * @returns The class name
  33194. */
  33195. getClassName(): string;
  33196. }
  33197. /**
  33198. * Represents a physics imposter
  33199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33200. */
  33201. export class PhysicsImpostor {
  33202. /**
  33203. * The physics-enabled object used as the physics imposter
  33204. */
  33205. object: IPhysicsEnabledObject;
  33206. /**
  33207. * The type of the physics imposter
  33208. */
  33209. type: number;
  33210. private _options;
  33211. private _scene?;
  33212. /**
  33213. * The default object size of the imposter
  33214. */
  33215. static DEFAULT_OBJECT_SIZE: Vector3;
  33216. /**
  33217. * The identity quaternion of the imposter
  33218. */
  33219. static IDENTITY_QUATERNION: Quaternion;
  33220. /** @hidden */
  33221. _pluginData: any;
  33222. private _physicsEngine;
  33223. private _physicsBody;
  33224. private _bodyUpdateRequired;
  33225. private _onBeforePhysicsStepCallbacks;
  33226. private _onAfterPhysicsStepCallbacks;
  33227. /** @hidden */
  33228. _onPhysicsCollideCallbacks: Array<{
  33229. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  33230. otherImpostors: Array<PhysicsImpostor>;
  33231. }>;
  33232. private _deltaPosition;
  33233. private _deltaRotation;
  33234. private _deltaRotationConjugated;
  33235. /** @hidden */
  33236. _isFromLine: boolean;
  33237. private _parent;
  33238. private _isDisposed;
  33239. private static _tmpVecs;
  33240. private static _tmpQuat;
  33241. /**
  33242. * Specifies if the physics imposter is disposed
  33243. */
  33244. get isDisposed(): boolean;
  33245. /**
  33246. * Gets the mass of the physics imposter
  33247. */
  33248. get mass(): number;
  33249. set mass(value: number);
  33250. /**
  33251. * Gets the coefficient of friction
  33252. */
  33253. get friction(): number;
  33254. /**
  33255. * Sets the coefficient of friction
  33256. */
  33257. set friction(value: number);
  33258. /**
  33259. * Gets the coefficient of restitution
  33260. */
  33261. get restitution(): number;
  33262. /**
  33263. * Sets the coefficient of restitution
  33264. */
  33265. set restitution(value: number);
  33266. /**
  33267. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33268. */
  33269. get pressure(): number;
  33270. /**
  33271. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33272. */
  33273. set pressure(value: number);
  33274. /**
  33275. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33276. */
  33277. get stiffness(): number;
  33278. /**
  33279. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33280. */
  33281. set stiffness(value: number);
  33282. /**
  33283. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33284. */
  33285. get velocityIterations(): number;
  33286. /**
  33287. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33288. */
  33289. set velocityIterations(value: number);
  33290. /**
  33291. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33292. */
  33293. get positionIterations(): number;
  33294. /**
  33295. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33296. */
  33297. set positionIterations(value: number);
  33298. /**
  33299. * The unique id of the physics imposter
  33300. * set by the physics engine when adding this impostor to the array
  33301. */
  33302. uniqueId: number;
  33303. /**
  33304. * @hidden
  33305. */
  33306. soft: boolean;
  33307. /**
  33308. * @hidden
  33309. */
  33310. segments: number;
  33311. private _joints;
  33312. /**
  33313. * Initializes the physics imposter
  33314. * @param object The physics-enabled object used as the physics imposter
  33315. * @param type The type of the physics imposter
  33316. * @param _options The options for the physics imposter
  33317. * @param _scene The Babylon scene
  33318. */
  33319. constructor(
  33320. /**
  33321. * The physics-enabled object used as the physics imposter
  33322. */
  33323. object: IPhysicsEnabledObject,
  33324. /**
  33325. * The type of the physics imposter
  33326. */
  33327. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33328. /**
  33329. * This function will completly initialize this impostor.
  33330. * It will create a new body - but only if this mesh has no parent.
  33331. * If it has, this impostor will not be used other than to define the impostor
  33332. * of the child mesh.
  33333. * @hidden
  33334. */
  33335. _init(): void;
  33336. private _getPhysicsParent;
  33337. /**
  33338. * Should a new body be generated.
  33339. * @returns boolean specifying if body initialization is required
  33340. */
  33341. isBodyInitRequired(): boolean;
  33342. /**
  33343. * Sets the updated scaling
  33344. * @param updated Specifies if the scaling is updated
  33345. */
  33346. setScalingUpdated(): void;
  33347. /**
  33348. * Force a regeneration of this or the parent's impostor's body.
  33349. * Use under cautious - This will remove all joints already implemented.
  33350. */
  33351. forceUpdate(): void;
  33352. /**
  33353. * Gets the body that holds this impostor. Either its own, or its parent.
  33354. */
  33355. get physicsBody(): any;
  33356. /**
  33357. * Get the parent of the physics imposter
  33358. * @returns Physics imposter or null
  33359. */
  33360. get parent(): Nullable<PhysicsImpostor>;
  33361. /**
  33362. * Sets the parent of the physics imposter
  33363. */
  33364. set parent(value: Nullable<PhysicsImpostor>);
  33365. /**
  33366. * Set the physics body. Used mainly by the physics engine/plugin
  33367. */
  33368. set physicsBody(physicsBody: any);
  33369. /**
  33370. * Resets the update flags
  33371. */
  33372. resetUpdateFlags(): void;
  33373. /**
  33374. * Gets the object extend size
  33375. * @returns the object extend size
  33376. */
  33377. getObjectExtendSize(): Vector3;
  33378. /**
  33379. * Gets the object center
  33380. * @returns The object center
  33381. */
  33382. getObjectCenter(): Vector3;
  33383. /**
  33384. * Get a specific parameter from the options parameters
  33385. * @param paramName The object parameter name
  33386. * @returns The object parameter
  33387. */
  33388. getParam(paramName: string): any;
  33389. /**
  33390. * Sets a specific parameter in the options given to the physics plugin
  33391. * @param paramName The parameter name
  33392. * @param value The value of the parameter
  33393. */
  33394. setParam(paramName: string, value: number): void;
  33395. /**
  33396. * Specifically change the body's mass option. Won't recreate the physics body object
  33397. * @param mass The mass of the physics imposter
  33398. */
  33399. setMass(mass: number): void;
  33400. /**
  33401. * Gets the linear velocity
  33402. * @returns linear velocity or null
  33403. */
  33404. getLinearVelocity(): Nullable<Vector3>;
  33405. /**
  33406. * Sets the linear velocity
  33407. * @param velocity linear velocity or null
  33408. */
  33409. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33410. /**
  33411. * Gets the angular velocity
  33412. * @returns angular velocity or null
  33413. */
  33414. getAngularVelocity(): Nullable<Vector3>;
  33415. /**
  33416. * Sets the angular velocity
  33417. * @param velocity The velocity or null
  33418. */
  33419. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33420. /**
  33421. * Execute a function with the physics plugin native code
  33422. * Provide a function the will have two variables - the world object and the physics body object
  33423. * @param func The function to execute with the physics plugin native code
  33424. */
  33425. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33426. /**
  33427. * Register a function that will be executed before the physics world is stepping forward
  33428. * @param func The function to execute before the physics world is stepped forward
  33429. */
  33430. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33431. /**
  33432. * Unregister a function that will be executed before the physics world is stepping forward
  33433. * @param func The function to execute before the physics world is stepped forward
  33434. */
  33435. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33436. /**
  33437. * Register a function that will be executed after the physics step
  33438. * @param func The function to execute after physics step
  33439. */
  33440. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33441. /**
  33442. * Unregisters a function that will be executed after the physics step
  33443. * @param func The function to execute after physics step
  33444. */
  33445. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33446. /**
  33447. * register a function that will be executed when this impostor collides against a different body
  33448. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33449. * @param func Callback that is executed on collision
  33450. */
  33451. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33452. /**
  33453. * Unregisters the physics imposter on contact
  33454. * @param collideAgainst The physics object to collide against
  33455. * @param func Callback to execute on collision
  33456. */
  33457. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33458. private _tmpQuat;
  33459. private _tmpQuat2;
  33460. /**
  33461. * Get the parent rotation
  33462. * @returns The parent rotation
  33463. */
  33464. getParentsRotation(): Quaternion;
  33465. /**
  33466. * this function is executed by the physics engine.
  33467. */
  33468. beforeStep: () => void;
  33469. /**
  33470. * this function is executed by the physics engine
  33471. */
  33472. afterStep: () => void;
  33473. /**
  33474. * Legacy collision detection event support
  33475. */
  33476. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33477. /**
  33478. * event and body object due to cannon's event-based architecture.
  33479. */
  33480. onCollide: (e: {
  33481. body: any;
  33482. point: Nullable<Vector3>;
  33483. }) => void;
  33484. /**
  33485. * Apply a force
  33486. * @param force The force to apply
  33487. * @param contactPoint The contact point for the force
  33488. * @returns The physics imposter
  33489. */
  33490. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33491. /**
  33492. * Apply an impulse
  33493. * @param force The impulse force
  33494. * @param contactPoint The contact point for the impulse force
  33495. * @returns The physics imposter
  33496. */
  33497. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33498. /**
  33499. * A help function to create a joint
  33500. * @param otherImpostor A physics imposter used to create a joint
  33501. * @param jointType The type of joint
  33502. * @param jointData The data for the joint
  33503. * @returns The physics imposter
  33504. */
  33505. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33506. /**
  33507. * Add a joint to this impostor with a different impostor
  33508. * @param otherImpostor A physics imposter used to add a joint
  33509. * @param joint The joint to add
  33510. * @returns The physics imposter
  33511. */
  33512. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33513. /**
  33514. * Add an anchor to a cloth impostor
  33515. * @param otherImpostor rigid impostor to anchor to
  33516. * @param width ratio across width from 0 to 1
  33517. * @param height ratio up height from 0 to 1
  33518. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  33519. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33520. * @returns impostor the soft imposter
  33521. */
  33522. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33523. /**
  33524. * Add a hook to a rope impostor
  33525. * @param otherImpostor rigid impostor to anchor to
  33526. * @param length ratio across rope from 0 to 1
  33527. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  33528. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33529. * @returns impostor the rope imposter
  33530. */
  33531. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33532. /**
  33533. * Will keep this body still, in a sleep mode.
  33534. * @returns the physics imposter
  33535. */
  33536. sleep(): PhysicsImpostor;
  33537. /**
  33538. * Wake the body up.
  33539. * @returns The physics imposter
  33540. */
  33541. wakeUp(): PhysicsImpostor;
  33542. /**
  33543. * Clones the physics imposter
  33544. * @param newObject The physics imposter clones to this physics-enabled object
  33545. * @returns A nullable physics imposter
  33546. */
  33547. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33548. /**
  33549. * Disposes the physics imposter
  33550. */
  33551. dispose(): void;
  33552. /**
  33553. * Sets the delta position
  33554. * @param position The delta position amount
  33555. */
  33556. setDeltaPosition(position: Vector3): void;
  33557. /**
  33558. * Sets the delta rotation
  33559. * @param rotation The delta rotation amount
  33560. */
  33561. setDeltaRotation(rotation: Quaternion): void;
  33562. /**
  33563. * Gets the box size of the physics imposter and stores the result in the input parameter
  33564. * @param result Stores the box size
  33565. * @returns The physics imposter
  33566. */
  33567. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33568. /**
  33569. * Gets the radius of the physics imposter
  33570. * @returns Radius of the physics imposter
  33571. */
  33572. getRadius(): number;
  33573. /**
  33574. * Sync a bone with this impostor
  33575. * @param bone The bone to sync to the impostor.
  33576. * @param boneMesh The mesh that the bone is influencing.
  33577. * @param jointPivot The pivot of the joint / bone in local space.
  33578. * @param distToJoint Optional distance from the impostor to the joint.
  33579. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33580. */
  33581. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33582. /**
  33583. * Sync impostor to a bone
  33584. * @param bone The bone that the impostor will be synced to.
  33585. * @param boneMesh The mesh that the bone is influencing.
  33586. * @param jointPivot The pivot of the joint / bone in local space.
  33587. * @param distToJoint Optional distance from the impostor to the joint.
  33588. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33589. * @param boneAxis Optional vector3 axis the bone is aligned with
  33590. */
  33591. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33592. /**
  33593. * No-Imposter type
  33594. */
  33595. static NoImpostor: number;
  33596. /**
  33597. * Sphere-Imposter type
  33598. */
  33599. static SphereImpostor: number;
  33600. /**
  33601. * Box-Imposter type
  33602. */
  33603. static BoxImpostor: number;
  33604. /**
  33605. * Plane-Imposter type
  33606. */
  33607. static PlaneImpostor: number;
  33608. /**
  33609. * Mesh-imposter type
  33610. */
  33611. static MeshImpostor: number;
  33612. /**
  33613. * Capsule-Impostor type (Ammo.js plugin only)
  33614. */
  33615. static CapsuleImpostor: number;
  33616. /**
  33617. * Cylinder-Imposter type
  33618. */
  33619. static CylinderImpostor: number;
  33620. /**
  33621. * Particle-Imposter type
  33622. */
  33623. static ParticleImpostor: number;
  33624. /**
  33625. * Heightmap-Imposter type
  33626. */
  33627. static HeightmapImpostor: number;
  33628. /**
  33629. * ConvexHull-Impostor type (Ammo.js plugin only)
  33630. */
  33631. static ConvexHullImpostor: number;
  33632. /**
  33633. * Custom-Imposter type (Ammo.js plugin only)
  33634. */
  33635. static CustomImpostor: number;
  33636. /**
  33637. * Rope-Imposter type
  33638. */
  33639. static RopeImpostor: number;
  33640. /**
  33641. * Cloth-Imposter type
  33642. */
  33643. static ClothImpostor: number;
  33644. /**
  33645. * Softbody-Imposter type
  33646. */
  33647. static SoftbodyImpostor: number;
  33648. }
  33649. }
  33650. declare module "babylonjs/Meshes/mesh" {
  33651. import { Observable } from "babylonjs/Misc/observable";
  33652. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33653. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  33654. import { Camera } from "babylonjs/Cameras/camera";
  33655. import { Scene } from "babylonjs/scene";
  33656. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  33657. import { Color4 } from "babylonjs/Maths/math.color";
  33658. import { Engine } from "babylonjs/Engines/engine";
  33659. import { Node } from "babylonjs/node";
  33660. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  33661. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33662. import { Buffer } from "babylonjs/Meshes/buffer";
  33663. import { Geometry } from "babylonjs/Meshes/geometry";
  33664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33665. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33666. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  33667. import { Effect } from "babylonjs/Materials/effect";
  33668. import { Material } from "babylonjs/Materials/material";
  33669. import { Skeleton } from "babylonjs/Bones/skeleton";
  33670. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33671. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  33672. import { Path3D } from "babylonjs/Maths/math.path";
  33673. import { Plane } from "babylonjs/Maths/math.plane";
  33674. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33675. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  33676. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  33677. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  33678. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  33679. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33680. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  33681. /**
  33682. * @hidden
  33683. **/
  33684. export class _CreationDataStorage {
  33685. closePath?: boolean;
  33686. closeArray?: boolean;
  33687. idx: number[];
  33688. dashSize: number;
  33689. gapSize: number;
  33690. path3D: Path3D;
  33691. pathArray: Vector3[][];
  33692. arc: number;
  33693. radius: number;
  33694. cap: number;
  33695. tessellation: number;
  33696. }
  33697. /**
  33698. * @hidden
  33699. **/
  33700. class _InstanceDataStorage {
  33701. visibleInstances: any;
  33702. batchCache: _InstancesBatch;
  33703. instancesBufferSize: number;
  33704. instancesBuffer: Nullable<Buffer>;
  33705. instancesData: Float32Array;
  33706. overridenInstanceCount: number;
  33707. isFrozen: boolean;
  33708. previousBatch: Nullable<_InstancesBatch>;
  33709. hardwareInstancedRendering: boolean;
  33710. sideOrientation: number;
  33711. manualUpdate: boolean;
  33712. previousRenderId: number;
  33713. }
  33714. /**
  33715. * @hidden
  33716. **/
  33717. export class _InstancesBatch {
  33718. mustReturn: boolean;
  33719. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  33720. renderSelf: boolean[];
  33721. hardwareInstancedRendering: boolean[];
  33722. }
  33723. /**
  33724. * @hidden
  33725. **/
  33726. class _ThinInstanceDataStorage {
  33727. instancesCount: number;
  33728. matrixBuffer: Nullable<Buffer>;
  33729. matrixBufferSize: number;
  33730. matrixData: Nullable<Float32Array>;
  33731. boundingVectors: Array<Vector3>;
  33732. worldMatrices: Nullable<Matrix[]>;
  33733. }
  33734. /**
  33735. * Class used to represent renderable models
  33736. */
  33737. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33738. /**
  33739. * Mesh side orientation : usually the external or front surface
  33740. */
  33741. static readonly FRONTSIDE: number;
  33742. /**
  33743. * Mesh side orientation : usually the internal or back surface
  33744. */
  33745. static readonly BACKSIDE: number;
  33746. /**
  33747. * Mesh side orientation : both internal and external or front and back surfaces
  33748. */
  33749. static readonly DOUBLESIDE: number;
  33750. /**
  33751. * Mesh side orientation : by default, `FRONTSIDE`
  33752. */
  33753. static readonly DEFAULTSIDE: number;
  33754. /**
  33755. * Mesh cap setting : no cap
  33756. */
  33757. static readonly NO_CAP: number;
  33758. /**
  33759. * Mesh cap setting : one cap at the beginning of the mesh
  33760. */
  33761. static readonly CAP_START: number;
  33762. /**
  33763. * Mesh cap setting : one cap at the end of the mesh
  33764. */
  33765. static readonly CAP_END: number;
  33766. /**
  33767. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33768. */
  33769. static readonly CAP_ALL: number;
  33770. /**
  33771. * Mesh pattern setting : no flip or rotate
  33772. */
  33773. static readonly NO_FLIP: number;
  33774. /**
  33775. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33776. */
  33777. static readonly FLIP_TILE: number;
  33778. /**
  33779. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33780. */
  33781. static readonly ROTATE_TILE: number;
  33782. /**
  33783. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33784. */
  33785. static readonly FLIP_ROW: number;
  33786. /**
  33787. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33788. */
  33789. static readonly ROTATE_ROW: number;
  33790. /**
  33791. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33792. */
  33793. static readonly FLIP_N_ROTATE_TILE: number;
  33794. /**
  33795. * Mesh pattern setting : rotate pattern and rotate
  33796. */
  33797. static readonly FLIP_N_ROTATE_ROW: number;
  33798. /**
  33799. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33800. */
  33801. static readonly CENTER: number;
  33802. /**
  33803. * Mesh tile positioning : part tiles on left
  33804. */
  33805. static readonly LEFT: number;
  33806. /**
  33807. * Mesh tile positioning : part tiles on right
  33808. */
  33809. static readonly RIGHT: number;
  33810. /**
  33811. * Mesh tile positioning : part tiles on top
  33812. */
  33813. static readonly TOP: number;
  33814. /**
  33815. * Mesh tile positioning : part tiles on bottom
  33816. */
  33817. static readonly BOTTOM: number;
  33818. /**
  33819. * Gets the default side orientation.
  33820. * @param orientation the orientation to value to attempt to get
  33821. * @returns the default orientation
  33822. * @hidden
  33823. */
  33824. static _GetDefaultSideOrientation(orientation?: number): number;
  33825. private _internalMeshDataInfo;
  33826. get computeBonesUsingShaders(): boolean;
  33827. set computeBonesUsingShaders(value: boolean);
  33828. /**
  33829. * An event triggered before rendering the mesh
  33830. */
  33831. get onBeforeRenderObservable(): Observable<Mesh>;
  33832. /**
  33833. * An event triggered before binding the mesh
  33834. */
  33835. get onBeforeBindObservable(): Observable<Mesh>;
  33836. /**
  33837. * An event triggered after rendering the mesh
  33838. */
  33839. get onAfterRenderObservable(): Observable<Mesh>;
  33840. /**
  33841. * An event triggered before drawing the mesh
  33842. */
  33843. get onBeforeDrawObservable(): Observable<Mesh>;
  33844. private _onBeforeDrawObserver;
  33845. /**
  33846. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33847. */
  33848. set onBeforeDraw(callback: () => void);
  33849. get hasInstances(): boolean;
  33850. get hasThinInstances(): boolean;
  33851. /**
  33852. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33853. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33854. */
  33855. delayLoadState: number;
  33856. /**
  33857. * Gets the list of instances created from this mesh
  33858. * it is not supposed to be modified manually.
  33859. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33860. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33861. */
  33862. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  33863. /**
  33864. * Gets the file containing delay loading data for this mesh
  33865. */
  33866. delayLoadingFile: string;
  33867. /** @hidden */
  33868. _binaryInfo: any;
  33869. /**
  33870. * User defined function used to change how LOD level selection is done
  33871. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33872. */
  33873. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33874. /**
  33875. * Gets or sets the morph target manager
  33876. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33877. */
  33878. get morphTargetManager(): Nullable<MorphTargetManager>;
  33879. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33880. /** @hidden */
  33881. _creationDataStorage: Nullable<_CreationDataStorage>;
  33882. /** @hidden */
  33883. _geometry: Nullable<Geometry>;
  33884. /** @hidden */
  33885. _delayInfo: Array<string>;
  33886. /** @hidden */
  33887. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33888. /** @hidden */
  33889. _instanceDataStorage: _InstanceDataStorage;
  33890. /** @hidden */
  33891. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33892. private _effectiveMaterial;
  33893. /** @hidden */
  33894. _shouldGenerateFlatShading: boolean;
  33895. /** @hidden */
  33896. _originalBuilderSideOrientation: number;
  33897. /**
  33898. * Use this property to change the original side orientation defined at construction time
  33899. */
  33900. overrideMaterialSideOrientation: Nullable<number>;
  33901. /**
  33902. * Gets the source mesh (the one used to clone this one from)
  33903. */
  33904. get source(): Nullable<Mesh>;
  33905. /**
  33906. * Gets the list of clones of this mesh
  33907. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33908. * Note that useClonedMeshMap=true is the default setting
  33909. */
  33910. get cloneMeshMap(): Nullable<{
  33911. [id: string]: Mesh | undefined;
  33912. }>;
  33913. /**
  33914. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33915. */
  33916. get isUnIndexed(): boolean;
  33917. set isUnIndexed(value: boolean);
  33918. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33919. get worldMatrixInstancedBuffer(): Float32Array;
  33920. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33921. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33922. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33923. /**
  33924. * @constructor
  33925. * @param name The value used by scene.getMeshByName() to do a lookup.
  33926. * @param scene The scene to add this mesh to.
  33927. * @param parent The parent of this mesh, if it has one
  33928. * @param source An optional Mesh from which geometry is shared, cloned.
  33929. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33930. * When false, achieved by calling a clone(), also passing False.
  33931. * This will make creation of children, recursive.
  33932. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33933. */
  33934. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33935. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33936. doNotInstantiate: boolean;
  33937. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33938. /**
  33939. * Gets the class name
  33940. * @returns the string "Mesh".
  33941. */
  33942. getClassName(): string;
  33943. /** @hidden */
  33944. get _isMesh(): boolean;
  33945. /**
  33946. * Returns a description of this mesh
  33947. * @param fullDetails define if full details about this mesh must be used
  33948. * @returns a descriptive string representing this mesh
  33949. */
  33950. toString(fullDetails?: boolean): string;
  33951. /** @hidden */
  33952. _unBindEffect(): void;
  33953. /**
  33954. * Gets a boolean indicating if this mesh has LOD
  33955. */
  33956. get hasLODLevels(): boolean;
  33957. /**
  33958. * Gets the list of MeshLODLevel associated with the current mesh
  33959. * @returns an array of MeshLODLevel
  33960. */
  33961. getLODLevels(): MeshLODLevel[];
  33962. private _sortLODLevels;
  33963. /**
  33964. * Add a mesh as LOD level triggered at the given distance.
  33965. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33966. * @param distance The distance from the center of the object to show this level
  33967. * @param mesh The mesh to be added as LOD level (can be null)
  33968. * @return This mesh (for chaining)
  33969. */
  33970. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33971. /**
  33972. * Returns the LOD level mesh at the passed distance or null if not found.
  33973. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33974. * @param distance The distance from the center of the object to show this level
  33975. * @returns a Mesh or `null`
  33976. */
  33977. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33978. /**
  33979. * Remove a mesh from the LOD array
  33980. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33981. * @param mesh defines the mesh to be removed
  33982. * @return This mesh (for chaining)
  33983. */
  33984. removeLODLevel(mesh: Mesh): Mesh;
  33985. /**
  33986. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33987. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33988. * @param camera defines the camera to use to compute distance
  33989. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33990. * @return This mesh (for chaining)
  33991. */
  33992. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33993. /**
  33994. * Gets the mesh internal Geometry object
  33995. */
  33996. get geometry(): Nullable<Geometry>;
  33997. /**
  33998. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33999. * @returns the total number of vertices
  34000. */
  34001. getTotalVertices(): number;
  34002. /**
  34003. * Returns the content of an associated vertex buffer
  34004. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34005. * - VertexBuffer.PositionKind
  34006. * - VertexBuffer.UVKind
  34007. * - VertexBuffer.UV2Kind
  34008. * - VertexBuffer.UV3Kind
  34009. * - VertexBuffer.UV4Kind
  34010. * - VertexBuffer.UV5Kind
  34011. * - VertexBuffer.UV6Kind
  34012. * - VertexBuffer.ColorKind
  34013. * - VertexBuffer.MatricesIndicesKind
  34014. * - VertexBuffer.MatricesIndicesExtraKind
  34015. * - VertexBuffer.MatricesWeightsKind
  34016. * - VertexBuffer.MatricesWeightsExtraKind
  34017. * @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
  34018. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  34019. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  34020. */
  34021. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34022. /**
  34023. * Returns the mesh VertexBuffer object from the requested `kind`
  34024. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34025. * - VertexBuffer.PositionKind
  34026. * - VertexBuffer.NormalKind
  34027. * - VertexBuffer.UVKind
  34028. * - VertexBuffer.UV2Kind
  34029. * - VertexBuffer.UV3Kind
  34030. * - VertexBuffer.UV4Kind
  34031. * - VertexBuffer.UV5Kind
  34032. * - VertexBuffer.UV6Kind
  34033. * - VertexBuffer.ColorKind
  34034. * - VertexBuffer.MatricesIndicesKind
  34035. * - VertexBuffer.MatricesIndicesExtraKind
  34036. * - VertexBuffer.MatricesWeightsKind
  34037. * - VertexBuffer.MatricesWeightsExtraKind
  34038. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  34039. */
  34040. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  34041. /**
  34042. * Tests if a specific vertex buffer is associated with this mesh
  34043. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34044. * - VertexBuffer.PositionKind
  34045. * - VertexBuffer.NormalKind
  34046. * - VertexBuffer.UVKind
  34047. * - VertexBuffer.UV2Kind
  34048. * - VertexBuffer.UV3Kind
  34049. * - VertexBuffer.UV4Kind
  34050. * - VertexBuffer.UV5Kind
  34051. * - VertexBuffer.UV6Kind
  34052. * - VertexBuffer.ColorKind
  34053. * - VertexBuffer.MatricesIndicesKind
  34054. * - VertexBuffer.MatricesIndicesExtraKind
  34055. * - VertexBuffer.MatricesWeightsKind
  34056. * - VertexBuffer.MatricesWeightsExtraKind
  34057. * @returns a boolean
  34058. */
  34059. isVerticesDataPresent(kind: string): boolean;
  34060. /**
  34061. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  34062. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34063. * - VertexBuffer.PositionKind
  34064. * - VertexBuffer.UVKind
  34065. * - VertexBuffer.UV2Kind
  34066. * - VertexBuffer.UV3Kind
  34067. * - VertexBuffer.UV4Kind
  34068. * - VertexBuffer.UV5Kind
  34069. * - VertexBuffer.UV6Kind
  34070. * - VertexBuffer.ColorKind
  34071. * - VertexBuffer.MatricesIndicesKind
  34072. * - VertexBuffer.MatricesIndicesExtraKind
  34073. * - VertexBuffer.MatricesWeightsKind
  34074. * - VertexBuffer.MatricesWeightsExtraKind
  34075. * @returns a boolean
  34076. */
  34077. isVertexBufferUpdatable(kind: string): boolean;
  34078. /**
  34079. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  34080. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34081. * - VertexBuffer.PositionKind
  34082. * - VertexBuffer.NormalKind
  34083. * - VertexBuffer.UVKind
  34084. * - VertexBuffer.UV2Kind
  34085. * - VertexBuffer.UV3Kind
  34086. * - VertexBuffer.UV4Kind
  34087. * - VertexBuffer.UV5Kind
  34088. * - VertexBuffer.UV6Kind
  34089. * - VertexBuffer.ColorKind
  34090. * - VertexBuffer.MatricesIndicesKind
  34091. * - VertexBuffer.MatricesIndicesExtraKind
  34092. * - VertexBuffer.MatricesWeightsKind
  34093. * - VertexBuffer.MatricesWeightsExtraKind
  34094. * @returns an array of strings
  34095. */
  34096. getVerticesDataKinds(): string[];
  34097. /**
  34098. * Returns a positive integer : the total number of indices in this mesh geometry.
  34099. * @returns the numner of indices or zero if the mesh has no geometry.
  34100. */
  34101. getTotalIndices(): number;
  34102. /**
  34103. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34104. * @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.
  34105. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34106. * @returns the indices array or an empty array if the mesh has no geometry
  34107. */
  34108. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34109. get isBlocked(): boolean;
  34110. /**
  34111. * Determine if the current mesh is ready to be rendered
  34112. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34113. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  34114. * @returns true if all associated assets are ready (material, textures, shaders)
  34115. */
  34116. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  34117. /**
  34118. * 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.
  34119. */
  34120. get areNormalsFrozen(): boolean;
  34121. /**
  34122. * 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.
  34123. * @returns the current mesh
  34124. */
  34125. freezeNormals(): Mesh;
  34126. /**
  34127. * 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
  34128. * @returns the current mesh
  34129. */
  34130. unfreezeNormals(): Mesh;
  34131. /**
  34132. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  34133. */
  34134. set overridenInstanceCount(count: number);
  34135. /** @hidden */
  34136. _preActivate(): Mesh;
  34137. /** @hidden */
  34138. _preActivateForIntermediateRendering(renderId: number): Mesh;
  34139. /** @hidden */
  34140. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  34141. protected _afterComputeWorldMatrix(): void;
  34142. /** @hidden */
  34143. _postActivate(): void;
  34144. /**
  34145. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  34146. * This means the mesh underlying bounding box and sphere are recomputed.
  34147. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  34148. * @returns the current mesh
  34149. */
  34150. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  34151. /** @hidden */
  34152. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  34153. /**
  34154. * This function will subdivide the mesh into multiple submeshes
  34155. * @param count defines the expected number of submeshes
  34156. */
  34157. subdivide(count: number): void;
  34158. /**
  34159. * Copy a FloatArray into a specific associated vertex buffer
  34160. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34161. * - VertexBuffer.PositionKind
  34162. * - VertexBuffer.UVKind
  34163. * - VertexBuffer.UV2Kind
  34164. * - VertexBuffer.UV3Kind
  34165. * - VertexBuffer.UV4Kind
  34166. * - VertexBuffer.UV5Kind
  34167. * - VertexBuffer.UV6Kind
  34168. * - VertexBuffer.ColorKind
  34169. * - VertexBuffer.MatricesIndicesKind
  34170. * - VertexBuffer.MatricesIndicesExtraKind
  34171. * - VertexBuffer.MatricesWeightsKind
  34172. * - VertexBuffer.MatricesWeightsExtraKind
  34173. * @param data defines the data source
  34174. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34175. * @param stride defines the data stride size (can be null)
  34176. * @returns the current mesh
  34177. */
  34178. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  34179. /**
  34180. * Delete a vertex buffer associated with this mesh
  34181. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  34182. * - VertexBuffer.PositionKind
  34183. * - VertexBuffer.UVKind
  34184. * - VertexBuffer.UV2Kind
  34185. * - VertexBuffer.UV3Kind
  34186. * - VertexBuffer.UV4Kind
  34187. * - VertexBuffer.UV5Kind
  34188. * - VertexBuffer.UV6Kind
  34189. * - VertexBuffer.ColorKind
  34190. * - VertexBuffer.MatricesIndicesKind
  34191. * - VertexBuffer.MatricesIndicesExtraKind
  34192. * - VertexBuffer.MatricesWeightsKind
  34193. * - VertexBuffer.MatricesWeightsExtraKind
  34194. */
  34195. removeVerticesData(kind: string): void;
  34196. /**
  34197. * Flags an associated vertex buffer as updatable
  34198. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  34199. * - VertexBuffer.PositionKind
  34200. * - VertexBuffer.UVKind
  34201. * - VertexBuffer.UV2Kind
  34202. * - VertexBuffer.UV3Kind
  34203. * - VertexBuffer.UV4Kind
  34204. * - VertexBuffer.UV5Kind
  34205. * - VertexBuffer.UV6Kind
  34206. * - VertexBuffer.ColorKind
  34207. * - VertexBuffer.MatricesIndicesKind
  34208. * - VertexBuffer.MatricesIndicesExtraKind
  34209. * - VertexBuffer.MatricesWeightsKind
  34210. * - VertexBuffer.MatricesWeightsExtraKind
  34211. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34212. */
  34213. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  34214. /**
  34215. * Sets the mesh global Vertex Buffer
  34216. * @param buffer defines the buffer to use
  34217. * @returns the current mesh
  34218. */
  34219. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34220. /**
  34221. * Update a specific associated vertex buffer
  34222. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34223. * - VertexBuffer.PositionKind
  34224. * - VertexBuffer.UVKind
  34225. * - VertexBuffer.UV2Kind
  34226. * - VertexBuffer.UV3Kind
  34227. * - VertexBuffer.UV4Kind
  34228. * - VertexBuffer.UV5Kind
  34229. * - VertexBuffer.UV6Kind
  34230. * - VertexBuffer.ColorKind
  34231. * - VertexBuffer.MatricesIndicesKind
  34232. * - VertexBuffer.MatricesIndicesExtraKind
  34233. * - VertexBuffer.MatricesWeightsKind
  34234. * - VertexBuffer.MatricesWeightsExtraKind
  34235. * @param data defines the data source
  34236. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34237. * @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)
  34238. * @returns the current mesh
  34239. */
  34240. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34241. /**
  34242. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34243. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34244. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34245. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34246. * @returns the current mesh
  34247. */
  34248. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34249. /**
  34250. * Creates a un-shared specific occurence of the geometry for the mesh.
  34251. * @returns the current mesh
  34252. */
  34253. makeGeometryUnique(): Mesh;
  34254. /**
  34255. * Set the index buffer of this mesh
  34256. * @param indices defines the source data
  34257. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34258. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34259. * @returns the current mesh
  34260. */
  34261. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34262. /**
  34263. * Update the current index buffer
  34264. * @param indices defines the source data
  34265. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34266. * @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)
  34267. * @returns the current mesh
  34268. */
  34269. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34270. /**
  34271. * Invert the geometry to move from a right handed system to a left handed one.
  34272. * @returns the current mesh
  34273. */
  34274. toLeftHanded(): Mesh;
  34275. /** @hidden */
  34276. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34277. /** @hidden */
  34278. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34279. /**
  34280. * Registers for this mesh a javascript function called just before the rendering process
  34281. * @param func defines the function to call before rendering this mesh
  34282. * @returns the current mesh
  34283. */
  34284. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34285. /**
  34286. * Disposes a previously registered javascript function called before the rendering
  34287. * @param func defines the function to remove
  34288. * @returns the current mesh
  34289. */
  34290. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34291. /**
  34292. * Registers for this mesh a javascript function called just after the rendering is complete
  34293. * @param func defines the function to call after rendering this mesh
  34294. * @returns the current mesh
  34295. */
  34296. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34297. /**
  34298. * Disposes a previously registered javascript function called after the rendering.
  34299. * @param func defines the function to remove
  34300. * @returns the current mesh
  34301. */
  34302. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34303. /** @hidden */
  34304. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34305. /** @hidden */
  34306. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34307. /** @hidden */
  34308. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34309. /** @hidden */
  34310. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34311. /** @hidden */
  34312. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34313. /** @hidden */
  34314. _rebuild(): void;
  34315. /** @hidden */
  34316. _freeze(): void;
  34317. /** @hidden */
  34318. _unFreeze(): void;
  34319. /**
  34320. * 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
  34321. * @param subMesh defines the subMesh to render
  34322. * @param enableAlphaMode defines if alpha mode can be changed
  34323. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34324. * @returns the current mesh
  34325. */
  34326. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34327. private _onBeforeDraw;
  34328. /**
  34329. * Renormalize the mesh and patch it up if there are no weights
  34330. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34331. * However in the case of zero weights then we set just a single influence to 1.
  34332. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34333. */
  34334. cleanMatrixWeights(): void;
  34335. private normalizeSkinFourWeights;
  34336. private normalizeSkinWeightsAndExtra;
  34337. /**
  34338. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34339. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34340. * the user know there was an issue with importing the mesh
  34341. * @returns a validation object with skinned, valid and report string
  34342. */
  34343. validateSkinning(): {
  34344. skinned: boolean;
  34345. valid: boolean;
  34346. report: string;
  34347. };
  34348. /** @hidden */
  34349. _checkDelayState(): Mesh;
  34350. private _queueLoad;
  34351. /**
  34352. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34353. * A mesh is in the frustum if its bounding box intersects the frustum
  34354. * @param frustumPlanes defines the frustum to test
  34355. * @returns true if the mesh is in the frustum planes
  34356. */
  34357. isInFrustum(frustumPlanes: Plane[]): boolean;
  34358. /**
  34359. * Sets the mesh material by the material or multiMaterial `id` property
  34360. * @param id is a string identifying the material or the multiMaterial
  34361. * @returns the current mesh
  34362. */
  34363. setMaterialByID(id: string): Mesh;
  34364. /**
  34365. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34366. * @returns an array of IAnimatable
  34367. */
  34368. getAnimatables(): IAnimatable[];
  34369. /**
  34370. * Modifies the mesh geometry according to the passed transformation matrix.
  34371. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34372. * The mesh normals are modified using the same transformation.
  34373. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34374. * @param transform defines the transform matrix to use
  34375. * @see https://doc.babylonjs.com/resources/baking_transformations
  34376. * @returns the current mesh
  34377. */
  34378. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34379. /**
  34380. * Modifies the mesh geometry according to its own current World Matrix.
  34381. * The mesh World Matrix is then reset.
  34382. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34383. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34384. * @see https://doc.babylonjs.com/resources/baking_transformations
  34385. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34386. * @returns the current mesh
  34387. */
  34388. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34389. /** @hidden */
  34390. get _positions(): Nullable<Vector3[]>;
  34391. /** @hidden */
  34392. _resetPointsArrayCache(): Mesh;
  34393. /** @hidden */
  34394. _generatePointsArray(): boolean;
  34395. /**
  34396. * Returns a new Mesh object generated from the current mesh properties.
  34397. * This method must not get confused with createInstance()
  34398. * @param name is a string, the name given to the new mesh
  34399. * @param newParent can be any Node object (default `null`)
  34400. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34401. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34402. * @returns a new mesh
  34403. */
  34404. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34405. /**
  34406. * Releases resources associated with this mesh.
  34407. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34408. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34409. */
  34410. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34411. /** @hidden */
  34412. _disposeInstanceSpecificData(): void;
  34413. /** @hidden */
  34414. _disposeThinInstanceSpecificData(): void;
  34415. /**
  34416. * Modifies the mesh geometry according to a displacement map.
  34417. * 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.
  34418. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34419. * @param url is a string, the URL from the image file is to be downloaded.
  34420. * @param minHeight is the lower limit of the displacement.
  34421. * @param maxHeight is the upper limit of the displacement.
  34422. * @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.
  34423. * @param uvOffset is an optional vector2 used to offset UV.
  34424. * @param uvScale is an optional vector2 used to scale UV.
  34425. * @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.
  34426. * @returns the Mesh.
  34427. */
  34428. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34429. /**
  34430. * Modifies the mesh geometry according to a displacementMap buffer.
  34431. * 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.
  34432. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34433. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34434. * @param heightMapWidth is the width of the buffer image.
  34435. * @param heightMapHeight is the height of the buffer image.
  34436. * @param minHeight is the lower limit of the displacement.
  34437. * @param maxHeight is the upper limit of the displacement.
  34438. * @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.
  34439. * @param uvOffset is an optional vector2 used to offset UV.
  34440. * @param uvScale is an optional vector2 used to scale UV.
  34441. * @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.
  34442. * @returns the Mesh.
  34443. */
  34444. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34445. /**
  34446. * Modify the mesh to get a flat shading rendering.
  34447. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34448. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34449. * @returns current mesh
  34450. */
  34451. convertToFlatShadedMesh(): Mesh;
  34452. /**
  34453. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34454. * In other words, more vertices, no more indices and a single bigger VBO.
  34455. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34456. * @returns current mesh
  34457. */
  34458. convertToUnIndexedMesh(): Mesh;
  34459. /**
  34460. * Inverses facet orientations.
  34461. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34462. * @param flipNormals will also inverts the normals
  34463. * @returns current mesh
  34464. */
  34465. flipFaces(flipNormals?: boolean): Mesh;
  34466. /**
  34467. * Increase the number of facets and hence vertices in a mesh
  34468. * Vertex normals are interpolated from existing vertex normals
  34469. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34470. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34471. */
  34472. increaseVertices(numberPerEdge: number): void;
  34473. /**
  34474. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34475. * This will undo any application of covertToFlatShadedMesh
  34476. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34477. */
  34478. forceSharedVertices(): void;
  34479. /** @hidden */
  34480. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34481. /** @hidden */
  34482. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34483. /**
  34484. * Creates a new InstancedMesh object from the mesh model.
  34485. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34486. * @param name defines the name of the new instance
  34487. * @returns a new InstancedMesh
  34488. */
  34489. createInstance(name: string): InstancedMesh;
  34490. /**
  34491. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34492. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34493. * @returns the current mesh
  34494. */
  34495. synchronizeInstances(): Mesh;
  34496. /**
  34497. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34498. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34499. * This should be used together with the simplification to avoid disappearing triangles.
  34500. * @param successCallback an optional success callback to be called after the optimization finished.
  34501. * @returns the current mesh
  34502. */
  34503. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34504. /**
  34505. * Serialize current mesh
  34506. * @param serializationObject defines the object which will receive the serialization data
  34507. */
  34508. serialize(serializationObject: any): void;
  34509. /** @hidden */
  34510. _syncGeometryWithMorphTargetManager(): void;
  34511. /** @hidden */
  34512. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34513. /**
  34514. * Returns a new Mesh object parsed from the source provided.
  34515. * @param parsedMesh is the source
  34516. * @param scene defines the hosting scene
  34517. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34518. * @returns a new Mesh
  34519. */
  34520. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34521. /**
  34522. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34523. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34524. * @param name defines the name of the mesh to create
  34525. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34526. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34527. * @param closePath creates a seam between the first and the last points of each path of the path array
  34528. * @param offset is taken in account only if the `pathArray` is containing a single path
  34529. * @param scene defines the hosting scene
  34530. * @param updatable defines if the mesh must be flagged as updatable
  34531. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34532. * @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)
  34533. * @returns a new Mesh
  34534. */
  34535. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34536. /**
  34537. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34538. * @param name defines the name of the mesh to create
  34539. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34540. * @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
  34541. * @param scene defines the hosting scene
  34542. * @param updatable defines if the mesh must be flagged as updatable
  34543. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34544. * @returns a new Mesh
  34545. */
  34546. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34547. /**
  34548. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34549. * @param name defines the name of the mesh to create
  34550. * @param size sets the size (float) of each box side (default 1)
  34551. * @param scene defines the hosting scene
  34552. * @param updatable defines if the mesh must be flagged as updatable
  34553. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34554. * @returns a new Mesh
  34555. */
  34556. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34557. /**
  34558. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34559. * @param name defines the name of the mesh to create
  34560. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34561. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34562. * @param scene defines the hosting scene
  34563. * @param updatable defines if the mesh must be flagged as updatable
  34564. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34565. * @returns a new Mesh
  34566. */
  34567. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34568. /**
  34569. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34570. * @param name defines the name of the mesh to create
  34571. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34572. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34573. * @param scene defines the hosting scene
  34574. * @returns a new Mesh
  34575. */
  34576. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34577. /**
  34578. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34579. * @param name defines the name of the mesh to create
  34580. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34581. * @param diameterTop set the top cap diameter (floats, default 1)
  34582. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34583. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34584. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34585. * @param scene defines the hosting scene
  34586. * @param updatable defines if the mesh must be flagged as updatable
  34587. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34588. * @returns a new Mesh
  34589. */
  34590. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34591. /**
  34592. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34593. * @param name defines the name of the mesh to create
  34594. * @param diameter sets the diameter size (float) of the torus (default 1)
  34595. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34596. * @param tessellation sets the number of torus sides (postive integer, default 16)
  34597. * @param scene defines the hosting scene
  34598. * @param updatable defines if the mesh must be flagged as updatable
  34599. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34600. * @returns a new Mesh
  34601. */
  34602. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34603. /**
  34604. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34605. * @param name defines the name of the mesh to create
  34606. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34607. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34608. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34609. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34610. * @param p the number of windings on X axis (positive integers, default 2)
  34611. * @param q the number of windings on Y axis (positive integers, default 3)
  34612. * @param scene defines the hosting scene
  34613. * @param updatable defines if the mesh must be flagged as updatable
  34614. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34615. * @returns a new Mesh
  34616. */
  34617. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34618. /**
  34619. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34620. * @param name defines the name of the mesh to create
  34621. * @param points is an array successive Vector3
  34622. * @param scene defines the hosting scene
  34623. * @param updatable defines if the mesh must be flagged as updatable
  34624. * @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).
  34625. * @returns a new Mesh
  34626. */
  34627. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34628. /**
  34629. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34630. * @param name defines the name of the mesh to create
  34631. * @param points is an array successive Vector3
  34632. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34633. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34634. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34635. * @param scene defines the hosting scene
  34636. * @param updatable defines if the mesh must be flagged as updatable
  34637. * @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)
  34638. * @returns a new Mesh
  34639. */
  34640. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34641. /**
  34642. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34643. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34644. * 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.
  34645. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34646. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34647. * Remember you can only change the shape positions, not their number when updating a polygon.
  34648. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34649. * @param name defines the name of the mesh to create
  34650. * @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
  34651. * @param scene defines the hosting scene
  34652. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34653. * @param updatable defines if the mesh must be flagged as updatable
  34654. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34655. * @param earcutInjection can be used to inject your own earcut reference
  34656. * @returns a new Mesh
  34657. */
  34658. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34659. /**
  34660. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34661. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34662. * @param name defines the name of the mesh to create
  34663. * @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
  34664. * @param depth defines the height of extrusion
  34665. * @param scene defines the hosting scene
  34666. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34667. * @param updatable defines if the mesh must be flagged as updatable
  34668. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34669. * @param earcutInjection can be used to inject your own earcut reference
  34670. * @returns a new Mesh
  34671. */
  34672. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34673. /**
  34674. * Creates an extruded shape mesh.
  34675. * 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
  34676. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34677. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34678. * @param name defines the name of the mesh to create
  34679. * @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
  34680. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34681. * @param scale is the value to scale the shape
  34682. * @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
  34683. * @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
  34684. * @param scene defines the hosting scene
  34685. * @param updatable defines if the mesh must be flagged as updatable
  34686. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34687. * @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)
  34688. * @returns a new Mesh
  34689. */
  34690. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34691. /**
  34692. * Creates an custom extruded shape mesh.
  34693. * The custom extrusion is a parametric shape.
  34694. * It has no predefined shape. Its final shape will depend on the input parameters.
  34695. * Please consider using the same method from the MeshBuilder class instead
  34696. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34697. * @param name defines the name of the mesh to create
  34698. * @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
  34699. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34700. * @param scaleFunction is a custom Javascript function called on each path point
  34701. * @param rotationFunction is a custom Javascript function called on each path point
  34702. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34703. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34704. * @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
  34705. * @param scene defines the hosting scene
  34706. * @param updatable defines if the mesh must be flagged as updatable
  34707. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34708. * @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)
  34709. * @returns a new Mesh
  34710. */
  34711. 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;
  34712. /**
  34713. * Creates lathe mesh.
  34714. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34715. * Please consider using the same method from the MeshBuilder class instead
  34716. * @param name defines the name of the mesh to create
  34717. * @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
  34718. * @param radius is the radius value of the lathe
  34719. * @param tessellation is the side number of the lathe.
  34720. * @param scene defines the hosting scene
  34721. * @param updatable defines if the mesh must be flagged as updatable
  34722. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34723. * @returns a new Mesh
  34724. */
  34725. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34726. /**
  34727. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34728. * @param name defines the name of the mesh to create
  34729. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34730. * @param scene defines the hosting scene
  34731. * @param updatable defines if the mesh must be flagged as updatable
  34732. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34733. * @returns a new Mesh
  34734. */
  34735. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34736. /**
  34737. * Creates a ground mesh.
  34738. * Please consider using the same method from the MeshBuilder class instead
  34739. * @param name defines the name of the mesh to create
  34740. * @param width set the width of the ground
  34741. * @param height set the height of the ground
  34742. * @param subdivisions sets the number of subdivisions per side
  34743. * @param scene defines the hosting scene
  34744. * @param updatable defines if the mesh must be flagged as updatable
  34745. * @returns a new Mesh
  34746. */
  34747. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34748. /**
  34749. * Creates a tiled ground mesh.
  34750. * Please consider using the same method from the MeshBuilder class instead
  34751. * @param name defines the name of the mesh to create
  34752. * @param xmin set the ground minimum X coordinate
  34753. * @param zmin set the ground minimum Y coordinate
  34754. * @param xmax set the ground maximum X coordinate
  34755. * @param zmax set the ground maximum Z coordinate
  34756. * @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
  34757. * @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
  34758. * @param scene defines the hosting scene
  34759. * @param updatable defines if the mesh must be flagged as updatable
  34760. * @returns a new Mesh
  34761. */
  34762. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34763. w: number;
  34764. h: number;
  34765. }, precision: {
  34766. w: number;
  34767. h: number;
  34768. }, scene: Scene, updatable?: boolean): Mesh;
  34769. /**
  34770. * Creates a ground mesh from a height map.
  34771. * Please consider using the same method from the MeshBuilder class instead
  34772. * @see https://doc.babylonjs.com/babylon101/height_map
  34773. * @param name defines the name of the mesh to create
  34774. * @param url sets the URL of the height map image resource
  34775. * @param width set the ground width size
  34776. * @param height set the ground height size
  34777. * @param subdivisions sets the number of subdivision per side
  34778. * @param minHeight is the minimum altitude on the ground
  34779. * @param maxHeight is the maximum altitude on the ground
  34780. * @param scene defines the hosting scene
  34781. * @param updatable defines if the mesh must be flagged as updatable
  34782. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34783. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34784. * @returns a new Mesh
  34785. */
  34786. 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;
  34787. /**
  34788. * Creates a tube mesh.
  34789. * The tube is a parametric shape.
  34790. * It has no predefined shape. Its final shape will depend on the input parameters.
  34791. * Please consider using the same method from the MeshBuilder class instead
  34792. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34793. * @param name defines the name of the mesh to create
  34794. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34795. * @param radius sets the tube radius size
  34796. * @param tessellation is the number of sides on the tubular surface
  34797. * @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
  34798. * @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
  34799. * @param scene defines the hosting scene
  34800. * @param updatable defines if the mesh must be flagged as updatable
  34801. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34802. * @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)
  34803. * @returns a new Mesh
  34804. */
  34805. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34806. (i: number, distance: number): number;
  34807. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34808. /**
  34809. * Creates a polyhedron mesh.
  34810. * Please consider using the same method from the MeshBuilder class instead.
  34811. * * 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
  34812. * * The parameter `size` (positive float, default 1) sets the polygon size
  34813. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34814. * * 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`
  34815. * * 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
  34816. * * 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)`)
  34817. * * 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
  34818. * * 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
  34819. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34820. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34822. * @param name defines the name of the mesh to create
  34823. * @param options defines the options used to create the mesh
  34824. * @param scene defines the hosting scene
  34825. * @returns a new Mesh
  34826. */
  34827. static CreatePolyhedron(name: string, options: {
  34828. type?: number;
  34829. size?: number;
  34830. sizeX?: number;
  34831. sizeY?: number;
  34832. sizeZ?: number;
  34833. custom?: any;
  34834. faceUV?: Vector4[];
  34835. faceColors?: Color4[];
  34836. updatable?: boolean;
  34837. sideOrientation?: number;
  34838. }, scene: Scene): Mesh;
  34839. /**
  34840. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34841. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34842. * * 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`)
  34843. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34844. * * 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
  34845. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34846. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34848. * @param name defines the name of the mesh
  34849. * @param options defines the options used to create the mesh
  34850. * @param scene defines the hosting scene
  34851. * @returns a new Mesh
  34852. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34853. */
  34854. static CreateIcoSphere(name: string, options: {
  34855. radius?: number;
  34856. flat?: boolean;
  34857. subdivisions?: number;
  34858. sideOrientation?: number;
  34859. updatable?: boolean;
  34860. }, scene: Scene): Mesh;
  34861. /**
  34862. * Creates a decal mesh.
  34863. * Please consider using the same method from the MeshBuilder class instead.
  34864. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34865. * @param name defines the name of the mesh
  34866. * @param sourceMesh defines the mesh receiving the decal
  34867. * @param position sets the position of the decal in world coordinates
  34868. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34869. * @param size sets the decal scaling
  34870. * @param angle sets the angle to rotate the decal
  34871. * @returns a new Mesh
  34872. */
  34873. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34874. /** Creates a Capsule Mesh
  34875. * @param name defines the name of the mesh.
  34876. * @param options the constructors options used to shape the mesh.
  34877. * @param scene defines the scene the mesh is scoped to.
  34878. * @returns the capsule mesh
  34879. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34880. */
  34881. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34882. /**
  34883. * Prepare internal position array for software CPU skinning
  34884. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34885. */
  34886. setPositionsForCPUSkinning(): Float32Array;
  34887. /**
  34888. * Prepare internal normal array for software CPU skinning
  34889. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34890. */
  34891. setNormalsForCPUSkinning(): Float32Array;
  34892. /**
  34893. * Updates the vertex buffer by applying transformation from the bones
  34894. * @param skeleton defines the skeleton to apply to current mesh
  34895. * @returns the current mesh
  34896. */
  34897. applySkeleton(skeleton: Skeleton): Mesh;
  34898. /**
  34899. * 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
  34900. * @param meshes defines the list of meshes to scan
  34901. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34902. */
  34903. static MinMax(meshes: AbstractMesh[]): {
  34904. min: Vector3;
  34905. max: Vector3;
  34906. };
  34907. /**
  34908. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34909. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34910. * @returns a vector3
  34911. */
  34912. static Center(meshesOrMinMaxVector: {
  34913. min: Vector3;
  34914. max: Vector3;
  34915. } | AbstractMesh[]): Vector3;
  34916. /**
  34917. * Merge the array of meshes into a single mesh for performance reasons.
  34918. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34919. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34920. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34921. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34922. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34923. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34924. * @returns a new mesh
  34925. */
  34926. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34927. /** @hidden */
  34928. addInstance(instance: InstancedMesh): void;
  34929. /** @hidden */
  34930. removeInstance(instance: InstancedMesh): void;
  34931. }
  34932. }
  34933. declare module "babylonjs/Cameras/camera" {
  34934. import { SmartArray } from "babylonjs/Misc/smartArray";
  34935. import { Observable } from "babylonjs/Misc/observable";
  34936. import { Nullable } from "babylonjs/types";
  34937. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  34938. import { Scene } from "babylonjs/scene";
  34939. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  34940. import { Node } from "babylonjs/node";
  34941. import { Mesh } from "babylonjs/Meshes/mesh";
  34942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34943. import { ICullable } from "babylonjs/Culling/boundingInfo";
  34944. import { Viewport } from "babylonjs/Maths/math.viewport";
  34945. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34946. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34947. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  34948. import { Ray } from "babylonjs/Culling/ray";
  34949. /**
  34950. * This is the base class of all the camera used in the application.
  34951. * @see https://doc.babylonjs.com/features/cameras
  34952. */
  34953. export class Camera extends Node {
  34954. /** @hidden */
  34955. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  34956. /**
  34957. * This is the default projection mode used by the cameras.
  34958. * It helps recreating a feeling of perspective and better appreciate depth.
  34959. * This is the best way to simulate real life cameras.
  34960. */
  34961. static readonly PERSPECTIVE_CAMERA: number;
  34962. /**
  34963. * This helps creating camera with an orthographic mode.
  34964. * 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.
  34965. */
  34966. static readonly ORTHOGRAPHIC_CAMERA: number;
  34967. /**
  34968. * This is the default FOV mode for perspective cameras.
  34969. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  34970. */
  34971. static readonly FOVMODE_VERTICAL_FIXED: number;
  34972. /**
  34973. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  34974. */
  34975. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  34976. /**
  34977. * This specifies ther is no need for a camera rig.
  34978. * Basically only one eye is rendered corresponding to the camera.
  34979. */
  34980. static readonly RIG_MODE_NONE: number;
  34981. /**
  34982. * Simulates a camera Rig with one blue eye and one red eye.
  34983. * This can be use with 3d blue and red glasses.
  34984. */
  34985. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  34986. /**
  34987. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  34988. */
  34989. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  34990. /**
  34991. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  34992. */
  34993. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  34994. /**
  34995. * Defines that both eyes of the camera will be rendered over under each other.
  34996. */
  34997. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  34998. /**
  34999. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  35000. */
  35001. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  35002. /**
  35003. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  35004. */
  35005. static readonly RIG_MODE_VR: number;
  35006. /**
  35007. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  35008. */
  35009. static readonly RIG_MODE_WEBVR: number;
  35010. /**
  35011. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  35012. */
  35013. static readonly RIG_MODE_CUSTOM: number;
  35014. /**
  35015. * Defines if by default attaching controls should prevent the default javascript event to continue.
  35016. */
  35017. static ForceAttachControlToAlwaysPreventDefault: boolean;
  35018. /**
  35019. * Define the input manager associated with the camera.
  35020. */
  35021. inputs: CameraInputsManager<Camera>;
  35022. /** @hidden */
  35023. _position: Vector3;
  35024. /**
  35025. * Define the current local position of the camera in the scene
  35026. */
  35027. get position(): Vector3;
  35028. set position(newPosition: Vector3);
  35029. protected _upVector: Vector3;
  35030. /**
  35031. * The vector the camera should consider as up.
  35032. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  35033. */
  35034. set upVector(vec: Vector3);
  35035. get upVector(): Vector3;
  35036. /**
  35037. * Define the current limit on the left side for an orthographic camera
  35038. * In scene unit
  35039. */
  35040. orthoLeft: Nullable<number>;
  35041. /**
  35042. * Define the current limit on the right side for an orthographic camera
  35043. * In scene unit
  35044. */
  35045. orthoRight: Nullable<number>;
  35046. /**
  35047. * Define the current limit on the bottom side for an orthographic camera
  35048. * In scene unit
  35049. */
  35050. orthoBottom: Nullable<number>;
  35051. /**
  35052. * Define the current limit on the top side for an orthographic camera
  35053. * In scene unit
  35054. */
  35055. orthoTop: Nullable<number>;
  35056. /**
  35057. * Field Of View is set in Radians. (default is 0.8)
  35058. */
  35059. fov: number;
  35060. /**
  35061. * Define the minimum distance the camera can see from.
  35062. * This is important to note that the depth buffer are not infinite and the closer it starts
  35063. * the more your scene might encounter depth fighting issue.
  35064. */
  35065. minZ: number;
  35066. /**
  35067. * Define the maximum distance the camera can see to.
  35068. * This is important to note that the depth buffer are not infinite and the further it end
  35069. * the more your scene might encounter depth fighting issue.
  35070. */
  35071. maxZ: number;
  35072. /**
  35073. * Define the default inertia of the camera.
  35074. * This helps giving a smooth feeling to the camera movement.
  35075. */
  35076. inertia: number;
  35077. /**
  35078. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  35079. */
  35080. mode: number;
  35081. /**
  35082. * Define whether the camera is intermediate.
  35083. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  35084. */
  35085. isIntermediate: boolean;
  35086. /**
  35087. * Define the viewport of the camera.
  35088. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  35089. */
  35090. viewport: Viewport;
  35091. /**
  35092. * Restricts the camera to viewing objects with the same layerMask.
  35093. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  35094. */
  35095. layerMask: number;
  35096. /**
  35097. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  35098. */
  35099. fovMode: number;
  35100. /**
  35101. * Rig mode of the camera.
  35102. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  35103. * This is normally controlled byt the camera themselves as internal use.
  35104. */
  35105. cameraRigMode: number;
  35106. /**
  35107. * Defines the distance between both "eyes" in case of a RIG
  35108. */
  35109. interaxialDistance: number;
  35110. /**
  35111. * Defines if stereoscopic rendering is done side by side or over under.
  35112. */
  35113. isStereoscopicSideBySide: boolean;
  35114. /**
  35115. * 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
  35116. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  35117. * else in the scene. (Eg. security camera)
  35118. *
  35119. * 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)
  35120. */
  35121. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  35122. /**
  35123. * When set, the camera will render to this render target instead of the default canvas
  35124. *
  35125. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  35126. */
  35127. outputRenderTarget: Nullable<RenderTargetTexture>;
  35128. /**
  35129. * Observable triggered when the camera view matrix has changed.
  35130. */
  35131. onViewMatrixChangedObservable: Observable<Camera>;
  35132. /**
  35133. * Observable triggered when the camera Projection matrix has changed.
  35134. */
  35135. onProjectionMatrixChangedObservable: Observable<Camera>;
  35136. /**
  35137. * Observable triggered when the inputs have been processed.
  35138. */
  35139. onAfterCheckInputsObservable: Observable<Camera>;
  35140. /**
  35141. * Observable triggered when reset has been called and applied to the camera.
  35142. */
  35143. onRestoreStateObservable: Observable<Camera>;
  35144. /**
  35145. * Is this camera a part of a rig system?
  35146. */
  35147. isRigCamera: boolean;
  35148. /**
  35149. * If isRigCamera set to true this will be set with the parent camera.
  35150. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  35151. */
  35152. rigParent?: Camera;
  35153. /** @hidden */
  35154. _cameraRigParams: any;
  35155. /** @hidden */
  35156. _rigCameras: Camera[];
  35157. /** @hidden */
  35158. _rigPostProcess: Nullable<PostProcess>;
  35159. protected _webvrViewMatrix: Matrix;
  35160. /** @hidden */
  35161. _skipRendering: boolean;
  35162. /** @hidden */
  35163. _projectionMatrix: Matrix;
  35164. /** @hidden */
  35165. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  35166. /** @hidden */
  35167. _activeMeshes: SmartArray<AbstractMesh>;
  35168. protected _globalPosition: Vector3;
  35169. /** @hidden */
  35170. _computedViewMatrix: Matrix;
  35171. private _doNotComputeProjectionMatrix;
  35172. private _transformMatrix;
  35173. private _frustumPlanes;
  35174. private _refreshFrustumPlanes;
  35175. private _storedFov;
  35176. private _stateStored;
  35177. /**
  35178. * Instantiates a new camera object.
  35179. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  35180. * @see https://doc.babylonjs.com/features/cameras
  35181. * @param name Defines the name of the camera in the scene
  35182. * @param position Defines the position of the camera
  35183. * @param scene Defines the scene the camera belongs too
  35184. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  35185. */
  35186. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35187. /**
  35188. * Store current camera state (fov, position, etc..)
  35189. * @returns the camera
  35190. */
  35191. storeState(): Camera;
  35192. /**
  35193. * Restores the camera state values if it has been stored. You must call storeState() first
  35194. */
  35195. protected _restoreStateValues(): boolean;
  35196. /**
  35197. * Restored camera state. You must call storeState() first.
  35198. * @returns true if restored and false otherwise
  35199. */
  35200. restoreState(): boolean;
  35201. /**
  35202. * Gets the class name of the camera.
  35203. * @returns the class name
  35204. */
  35205. getClassName(): string;
  35206. /** @hidden */
  35207. readonly _isCamera: boolean;
  35208. /**
  35209. * Gets a string representation of the camera useful for debug purpose.
  35210. * @param fullDetails Defines that a more verboe level of logging is required
  35211. * @returns the string representation
  35212. */
  35213. toString(fullDetails?: boolean): string;
  35214. /**
  35215. * Gets the current world space position of the camera.
  35216. */
  35217. get globalPosition(): Vector3;
  35218. /**
  35219. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  35220. * @returns the active meshe list
  35221. */
  35222. getActiveMeshes(): SmartArray<AbstractMesh>;
  35223. /**
  35224. * Check whether a mesh is part of the current active mesh list of the camera
  35225. * @param mesh Defines the mesh to check
  35226. * @returns true if active, false otherwise
  35227. */
  35228. isActiveMesh(mesh: Mesh): boolean;
  35229. /**
  35230. * Is this camera ready to be used/rendered
  35231. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  35232. * @return true if the camera is ready
  35233. */
  35234. isReady(completeCheck?: boolean): boolean;
  35235. /** @hidden */
  35236. _initCache(): void;
  35237. /** @hidden */
  35238. _updateCache(ignoreParentClass?: boolean): void;
  35239. /** @hidden */
  35240. _isSynchronized(): boolean;
  35241. /** @hidden */
  35242. _isSynchronizedViewMatrix(): boolean;
  35243. /** @hidden */
  35244. _isSynchronizedProjectionMatrix(): boolean;
  35245. /**
  35246. * Attach the input controls to a specific dom element to get the input from.
  35247. * @param element Defines the element the controls should be listened from
  35248. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35249. */
  35250. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35251. /**
  35252. * Detach the current controls from the specified dom element.
  35253. * @param element Defines the element to stop listening the inputs from
  35254. */
  35255. detachControl(element: HTMLElement): void;
  35256. /**
  35257. * Update the camera state according to the different inputs gathered during the frame.
  35258. */
  35259. update(): void;
  35260. /** @hidden */
  35261. _checkInputs(): void;
  35262. /** @hidden */
  35263. get rigCameras(): Camera[];
  35264. /**
  35265. * Gets the post process used by the rig cameras
  35266. */
  35267. get rigPostProcess(): Nullable<PostProcess>;
  35268. /**
  35269. * Internal, gets the first post proces.
  35270. * @returns the first post process to be run on this camera.
  35271. */
  35272. _getFirstPostProcess(): Nullable<PostProcess>;
  35273. private _cascadePostProcessesToRigCams;
  35274. /**
  35275. * Attach a post process to the camera.
  35276. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35277. * @param postProcess The post process to attach to the camera
  35278. * @param insertAt The position of the post process in case several of them are in use in the scene
  35279. * @returns the position the post process has been inserted at
  35280. */
  35281. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  35282. /**
  35283. * Detach a post process to the camera.
  35284. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35285. * @param postProcess The post process to detach from the camera
  35286. */
  35287. detachPostProcess(postProcess: PostProcess): void;
  35288. /**
  35289. * Gets the current world matrix of the camera
  35290. */
  35291. getWorldMatrix(): Matrix;
  35292. /** @hidden */
  35293. _getViewMatrix(): Matrix;
  35294. /**
  35295. * Gets the current view matrix of the camera.
  35296. * @param force forces the camera to recompute the matrix without looking at the cached state
  35297. * @returns the view matrix
  35298. */
  35299. getViewMatrix(force?: boolean): Matrix;
  35300. /**
  35301. * Freeze the projection matrix.
  35302. * It will prevent the cache check of the camera projection compute and can speed up perf
  35303. * if no parameter of the camera are meant to change
  35304. * @param projection Defines manually a projection if necessary
  35305. */
  35306. freezeProjectionMatrix(projection?: Matrix): void;
  35307. /**
  35308. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  35309. */
  35310. unfreezeProjectionMatrix(): void;
  35311. /**
  35312. * Gets the current projection matrix of the camera.
  35313. * @param force forces the camera to recompute the matrix without looking at the cached state
  35314. * @returns the projection matrix
  35315. */
  35316. getProjectionMatrix(force?: boolean): Matrix;
  35317. /**
  35318. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  35319. * @returns a Matrix
  35320. */
  35321. getTransformationMatrix(): Matrix;
  35322. private _updateFrustumPlanes;
  35323. /**
  35324. * Checks if a cullable object (mesh...) is in the camera frustum
  35325. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  35326. * @param target The object to check
  35327. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  35328. * @returns true if the object is in frustum otherwise false
  35329. */
  35330. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  35331. /**
  35332. * Checks if a cullable object (mesh...) is in the camera frustum
  35333. * Unlike isInFrustum this cheks the full bounding box
  35334. * @param target The object to check
  35335. * @returns true if the object is in frustum otherwise false
  35336. */
  35337. isCompletelyInFrustum(target: ICullable): boolean;
  35338. /**
  35339. * Gets a ray in the forward direction from the camera.
  35340. * @param length Defines the length of the ray to create
  35341. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35342. * @param origin Defines the start point of the ray which defaults to the camera position
  35343. * @returns the forward ray
  35344. */
  35345. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35346. /**
  35347. * Gets a ray in the forward direction from the camera.
  35348. * @param refRay the ray to (re)use when setting the values
  35349. * @param length Defines the length of the ray to create
  35350. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35351. * @param origin Defines the start point of the ray which defaults to the camera position
  35352. * @returns the forward ray
  35353. */
  35354. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35355. /**
  35356. * Releases resources associated with this node.
  35357. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35358. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35359. */
  35360. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35361. /** @hidden */
  35362. _isLeftCamera: boolean;
  35363. /**
  35364. * Gets the left camera of a rig setup in case of Rigged Camera
  35365. */
  35366. get isLeftCamera(): boolean;
  35367. /** @hidden */
  35368. _isRightCamera: boolean;
  35369. /**
  35370. * Gets the right camera of a rig setup in case of Rigged Camera
  35371. */
  35372. get isRightCamera(): boolean;
  35373. /**
  35374. * Gets the left camera of a rig setup in case of Rigged Camera
  35375. */
  35376. get leftCamera(): Nullable<FreeCamera>;
  35377. /**
  35378. * Gets the right camera of a rig setup in case of Rigged Camera
  35379. */
  35380. get rightCamera(): Nullable<FreeCamera>;
  35381. /**
  35382. * Gets the left camera target of a rig setup in case of Rigged Camera
  35383. * @returns the target position
  35384. */
  35385. getLeftTarget(): Nullable<Vector3>;
  35386. /**
  35387. * Gets the right camera target of a rig setup in case of Rigged Camera
  35388. * @returns the target position
  35389. */
  35390. getRightTarget(): Nullable<Vector3>;
  35391. /**
  35392. * @hidden
  35393. */
  35394. setCameraRigMode(mode: number, rigParams: any): void;
  35395. /** @hidden */
  35396. static _setStereoscopicRigMode(camera: Camera): void;
  35397. /** @hidden */
  35398. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  35399. /** @hidden */
  35400. static _setVRRigMode(camera: Camera, rigParams: any): void;
  35401. /** @hidden */
  35402. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  35403. /** @hidden */
  35404. _getVRProjectionMatrix(): Matrix;
  35405. protected _updateCameraRotationMatrix(): void;
  35406. protected _updateWebVRCameraRotationMatrix(): void;
  35407. /**
  35408. * This function MUST be overwritten by the different WebVR cameras available.
  35409. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35410. * @hidden
  35411. */
  35412. _getWebVRProjectionMatrix(): Matrix;
  35413. /**
  35414. * This function MUST be overwritten by the different WebVR cameras available.
  35415. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35416. * @hidden
  35417. */
  35418. _getWebVRViewMatrix(): Matrix;
  35419. /** @hidden */
  35420. setCameraRigParameter(name: string, value: any): void;
  35421. /**
  35422. * needs to be overridden by children so sub has required properties to be copied
  35423. * @hidden
  35424. */
  35425. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  35426. /**
  35427. * May need to be overridden by children
  35428. * @hidden
  35429. */
  35430. _updateRigCameras(): void;
  35431. /** @hidden */
  35432. _setupInputs(): void;
  35433. /**
  35434. * Serialiaze the camera setup to a json represention
  35435. * @returns the JSON representation
  35436. */
  35437. serialize(): any;
  35438. /**
  35439. * Clones the current camera.
  35440. * @param name The cloned camera name
  35441. * @returns the cloned camera
  35442. */
  35443. clone(name: string): Camera;
  35444. /**
  35445. * Gets the direction of the camera relative to a given local axis.
  35446. * @param localAxis Defines the reference axis to provide a relative direction.
  35447. * @return the direction
  35448. */
  35449. getDirection(localAxis: Vector3): Vector3;
  35450. /**
  35451. * Returns the current camera absolute rotation
  35452. */
  35453. get absoluteRotation(): Quaternion;
  35454. /**
  35455. * Gets the direction of the camera relative to a given local axis into a passed vector.
  35456. * @param localAxis Defines the reference axis to provide a relative direction.
  35457. * @param result Defines the vector to store the result in
  35458. */
  35459. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  35460. /**
  35461. * Gets a camera constructor for a given camera type
  35462. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  35463. * @param name The name of the camera the result will be able to instantiate
  35464. * @param scene The scene the result will construct the camera in
  35465. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  35466. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  35467. * @returns a factory method to construc the camera
  35468. */
  35469. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  35470. /**
  35471. * Compute the world matrix of the camera.
  35472. * @returns the camera world matrix
  35473. */
  35474. computeWorldMatrix(): Matrix;
  35475. /**
  35476. * Parse a JSON and creates the camera from the parsed information
  35477. * @param parsedCamera The JSON to parse
  35478. * @param scene The scene to instantiate the camera in
  35479. * @returns the newly constructed camera
  35480. */
  35481. static Parse(parsedCamera: any, scene: Scene): Camera;
  35482. }
  35483. }
  35484. declare module "babylonjs/Meshes/Builders/discBuilder" {
  35485. import { Nullable } from "babylonjs/types";
  35486. import { Scene } from "babylonjs/scene";
  35487. import { Vector4 } from "babylonjs/Maths/math.vector";
  35488. import { Mesh } from "babylonjs/Meshes/mesh";
  35489. /**
  35490. * Class containing static functions to help procedurally build meshes
  35491. */
  35492. export class DiscBuilder {
  35493. /**
  35494. * Creates a plane polygonal mesh. By default, this is a disc
  35495. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35496. * * 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
  35497. * * 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
  35498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35501. * @param name defines the name of the mesh
  35502. * @param options defines the options used to create the mesh
  35503. * @param scene defines the hosting scene
  35504. * @returns the plane polygonal mesh
  35505. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35506. */
  35507. static CreateDisc(name: string, options: {
  35508. radius?: number;
  35509. tessellation?: number;
  35510. arc?: number;
  35511. updatable?: boolean;
  35512. sideOrientation?: number;
  35513. frontUVs?: Vector4;
  35514. backUVs?: Vector4;
  35515. }, scene?: Nullable<Scene>): Mesh;
  35516. }
  35517. }
  35518. declare module "babylonjs/Particles/solidParticleSystem" {
  35519. import { Nullable } from "babylonjs/types";
  35520. import { Mesh } from "babylonjs/Meshes/mesh";
  35521. import { Scene, IDisposable } from "babylonjs/scene";
  35522. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  35523. import { Material } from "babylonjs/Materials/material";
  35524. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35525. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35526. /**
  35527. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35528. *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.
  35529. * The SPS is also a particle system. It provides some methods to manage the particles.
  35530. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35531. *
  35532. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35533. */
  35534. export class SolidParticleSystem implements IDisposable {
  35535. /**
  35536. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35537. * Example : var p = SPS.particles[i];
  35538. */
  35539. particles: SolidParticle[];
  35540. /**
  35541. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35542. */
  35543. nbParticles: number;
  35544. /**
  35545. * If the particles must ever face the camera (default false). Useful for planar particles.
  35546. */
  35547. billboard: boolean;
  35548. /**
  35549. * Recompute normals when adding a shape
  35550. */
  35551. recomputeNormals: boolean;
  35552. /**
  35553. * This a counter ofr your own usage. It's not set by any SPS functions.
  35554. */
  35555. counter: number;
  35556. /**
  35557. * The SPS name. This name is also given to the underlying mesh.
  35558. */
  35559. name: string;
  35560. /**
  35561. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35562. */
  35563. mesh: Mesh;
  35564. /**
  35565. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35566. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35567. */
  35568. vars: any;
  35569. /**
  35570. * This array is populated when the SPS is set as 'pickable'.
  35571. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35572. * Each element of this array is an object `{idx: int, faceId: int}`.
  35573. * `idx` is the picked particle index in the `SPS.particles` array
  35574. * `faceId` is the picked face index counted within this particle.
  35575. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35576. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35577. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35578. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35579. */
  35580. pickedParticles: {
  35581. idx: number;
  35582. faceId: number;
  35583. }[];
  35584. /**
  35585. * This array is populated when the SPS is set as 'pickable'
  35586. * Each key of this array is a submesh index.
  35587. * Each element of this array is a second array defined like this :
  35588. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35589. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35590. * `idx` is the picked particle index in the `SPS.particles` array
  35591. * `faceId` is the picked face index counted within this particle.
  35592. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35593. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35594. */
  35595. pickedBySubMesh: {
  35596. idx: number;
  35597. faceId: number;
  35598. }[][];
  35599. /**
  35600. * This array is populated when `enableDepthSort` is set to true.
  35601. * Each element of this array is an instance of the class DepthSortedParticle.
  35602. */
  35603. depthSortedParticles: DepthSortedParticle[];
  35604. /**
  35605. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35606. * @hidden
  35607. */
  35608. _bSphereOnly: boolean;
  35609. /**
  35610. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35611. * @hidden
  35612. */
  35613. _bSphereRadiusFactor: number;
  35614. private _scene;
  35615. private _positions;
  35616. private _indices;
  35617. private _normals;
  35618. private _colors;
  35619. private _uvs;
  35620. private _indices32;
  35621. private _positions32;
  35622. private _normals32;
  35623. private _fixedNormal32;
  35624. private _colors32;
  35625. private _uvs32;
  35626. private _index;
  35627. private _updatable;
  35628. private _pickable;
  35629. private _isVisibilityBoxLocked;
  35630. private _alwaysVisible;
  35631. private _depthSort;
  35632. private _expandable;
  35633. private _shapeCounter;
  35634. private _copy;
  35635. private _color;
  35636. private _computeParticleColor;
  35637. private _computeParticleTexture;
  35638. private _computeParticleRotation;
  35639. private _computeParticleVertex;
  35640. private _computeBoundingBox;
  35641. private _depthSortParticles;
  35642. private _camera;
  35643. private _mustUnrotateFixedNormals;
  35644. private _particlesIntersect;
  35645. private _needs32Bits;
  35646. private _isNotBuilt;
  35647. private _lastParticleId;
  35648. private _idxOfId;
  35649. private _multimaterialEnabled;
  35650. private _useModelMaterial;
  35651. private _indicesByMaterial;
  35652. private _materialIndexes;
  35653. private _depthSortFunction;
  35654. private _materialSortFunction;
  35655. private _materials;
  35656. private _multimaterial;
  35657. private _materialIndexesById;
  35658. private _defaultMaterial;
  35659. private _autoUpdateSubMeshes;
  35660. private _tmpVertex;
  35661. /**
  35662. * Creates a SPS (Solid Particle System) object.
  35663. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35664. * @param scene (Scene) is the scene in which the SPS is added.
  35665. * @param options defines the options of the sps e.g.
  35666. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35667. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35668. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35669. * * 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.
  35670. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35671. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35672. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35673. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35674. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35675. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35676. */
  35677. constructor(name: string, scene: Scene, options?: {
  35678. updatable?: boolean;
  35679. isPickable?: boolean;
  35680. enableDepthSort?: boolean;
  35681. particleIntersection?: boolean;
  35682. boundingSphereOnly?: boolean;
  35683. bSphereRadiusFactor?: number;
  35684. expandable?: boolean;
  35685. useModelMaterial?: boolean;
  35686. enableMultiMaterial?: boolean;
  35687. });
  35688. /**
  35689. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35690. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35691. * @returns the created mesh
  35692. */
  35693. buildMesh(): Mesh;
  35694. /**
  35695. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35696. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35697. * Thus the particles generated from `digest()` have their property `position` set yet.
  35698. * @param mesh ( Mesh ) is the mesh to be digested
  35699. * @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
  35700. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35701. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35702. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35703. * @returns the current SPS
  35704. */
  35705. digest(mesh: Mesh, options?: {
  35706. facetNb?: number;
  35707. number?: number;
  35708. delta?: number;
  35709. storage?: [];
  35710. }): SolidParticleSystem;
  35711. /**
  35712. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35713. * @hidden
  35714. */
  35715. private _unrotateFixedNormals;
  35716. /**
  35717. * Resets the temporary working copy particle
  35718. * @hidden
  35719. */
  35720. private _resetCopy;
  35721. /**
  35722. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35723. * @param p the current index in the positions array to be updated
  35724. * @param ind the current index in the indices array
  35725. * @param shape a Vector3 array, the shape geometry
  35726. * @param positions the positions array to be updated
  35727. * @param meshInd the shape indices array
  35728. * @param indices the indices array to be updated
  35729. * @param meshUV the shape uv array
  35730. * @param uvs the uv array to be updated
  35731. * @param meshCol the shape color array
  35732. * @param colors the color array to be updated
  35733. * @param meshNor the shape normals array
  35734. * @param normals the normals array to be updated
  35735. * @param idx the particle index
  35736. * @param idxInShape the particle index in its shape
  35737. * @param options the addShape() method passed options
  35738. * @model the particle model
  35739. * @hidden
  35740. */
  35741. private _meshBuilder;
  35742. /**
  35743. * Returns a shape Vector3 array from positions float array
  35744. * @param positions float array
  35745. * @returns a vector3 array
  35746. * @hidden
  35747. */
  35748. private _posToShape;
  35749. /**
  35750. * Returns a shapeUV array from a float uvs (array deep copy)
  35751. * @param uvs as a float array
  35752. * @returns a shapeUV array
  35753. * @hidden
  35754. */
  35755. private _uvsToShapeUV;
  35756. /**
  35757. * Adds a new particle object in the particles array
  35758. * @param idx particle index in particles array
  35759. * @param id particle id
  35760. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35761. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35762. * @param model particle ModelShape object
  35763. * @param shapeId model shape identifier
  35764. * @param idxInShape index of the particle in the current model
  35765. * @param bInfo model bounding info object
  35766. * @param storage target storage array, if any
  35767. * @hidden
  35768. */
  35769. private _addParticle;
  35770. /**
  35771. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35772. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35773. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35774. * @param nb (positive integer) the number of particles to be created from this model
  35775. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35776. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35777. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35778. * @returns the number of shapes in the system
  35779. */
  35780. addShape(mesh: Mesh, nb: number, options?: {
  35781. positionFunction?: any;
  35782. vertexFunction?: any;
  35783. storage?: [];
  35784. }): number;
  35785. /**
  35786. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35787. * @hidden
  35788. */
  35789. private _rebuildParticle;
  35790. /**
  35791. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35792. * @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.
  35793. * @returns the SPS.
  35794. */
  35795. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35796. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35797. * Returns an array with the removed particles.
  35798. * 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.
  35799. * The SPS can't be empty so at least one particle needs to remain in place.
  35800. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35801. * @param start index of the first particle to remove
  35802. * @param end index of the last particle to remove (included)
  35803. * @returns an array populated with the removed particles
  35804. */
  35805. removeParticles(start: number, end: number): SolidParticle[];
  35806. /**
  35807. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35808. * @param solidParticleArray an array populated with Solid Particles objects
  35809. * @returns the SPS
  35810. */
  35811. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35812. /**
  35813. * Creates a new particle and modifies the SPS mesh geometry :
  35814. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35815. * - calls _addParticle() to populate the particle array
  35816. * factorized code from addShape() and insertParticlesFromArray()
  35817. * @param idx particle index in the particles array
  35818. * @param i particle index in its shape
  35819. * @param modelShape particle ModelShape object
  35820. * @param shape shape vertex array
  35821. * @param meshInd shape indices array
  35822. * @param meshUV shape uv array
  35823. * @param meshCol shape color array
  35824. * @param meshNor shape normals array
  35825. * @param bbInfo shape bounding info
  35826. * @param storage target particle storage
  35827. * @options addShape() passed options
  35828. * @hidden
  35829. */
  35830. private _insertNewParticle;
  35831. /**
  35832. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35833. * This method calls `updateParticle()` for each particle of the SPS.
  35834. * For an animated SPS, it is usually called within the render loop.
  35835. * 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.
  35836. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35837. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35838. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35839. * @returns the SPS.
  35840. */
  35841. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35842. /**
  35843. * Disposes the SPS.
  35844. */
  35845. dispose(): void;
  35846. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35847. * idx is the particle index in the SPS
  35848. * faceId is the picked face index counted within this particle.
  35849. * Returns null if the pickInfo can't identify a picked particle.
  35850. * @param pickingInfo (PickingInfo object)
  35851. * @returns {idx: number, faceId: number} or null
  35852. */
  35853. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35854. idx: number;
  35855. faceId: number;
  35856. }>;
  35857. /**
  35858. * Returns a SolidParticle object from its identifier : particle.id
  35859. * @param id (integer) the particle Id
  35860. * @returns the searched particle or null if not found in the SPS.
  35861. */
  35862. getParticleById(id: number): Nullable<SolidParticle>;
  35863. /**
  35864. * Returns a new array populated with the particles having the passed shapeId.
  35865. * @param shapeId (integer) the shape identifier
  35866. * @returns a new solid particle array
  35867. */
  35868. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35869. /**
  35870. * Populates the passed array "ref" with the particles having the passed shapeId.
  35871. * @param shapeId the shape identifier
  35872. * @returns the SPS
  35873. * @param ref
  35874. */
  35875. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35876. /**
  35877. * Computes the required SubMeshes according the materials assigned to the particles.
  35878. * @returns the solid particle system.
  35879. * Does nothing if called before the SPS mesh is built.
  35880. */
  35881. computeSubMeshes(): SolidParticleSystem;
  35882. /**
  35883. * Sorts the solid particles by material when MultiMaterial is enabled.
  35884. * Updates the indices32 array.
  35885. * Updates the indicesByMaterial array.
  35886. * Updates the mesh indices array.
  35887. * @returns the SPS
  35888. * @hidden
  35889. */
  35890. private _sortParticlesByMaterial;
  35891. /**
  35892. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35893. * @hidden
  35894. */
  35895. private _setMaterialIndexesById;
  35896. /**
  35897. * Returns an array with unique values of Materials from the passed array
  35898. * @param array the material array to be checked and filtered
  35899. * @hidden
  35900. */
  35901. private _filterUniqueMaterialId;
  35902. /**
  35903. * Sets a new Standard Material as _defaultMaterial if not already set.
  35904. * @hidden
  35905. */
  35906. private _setDefaultMaterial;
  35907. /**
  35908. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35909. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35910. * @returns the SPS.
  35911. */
  35912. refreshVisibleSize(): SolidParticleSystem;
  35913. /**
  35914. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35915. * @param size the size (float) of the visibility box
  35916. * note : this doesn't lock the SPS mesh bounding box.
  35917. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35918. */
  35919. setVisibilityBox(size: number): void;
  35920. /**
  35921. * Gets whether the SPS as always visible or not
  35922. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35923. */
  35924. get isAlwaysVisible(): boolean;
  35925. /**
  35926. * Sets the SPS as always visible or not
  35927. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35928. */
  35929. set isAlwaysVisible(val: boolean);
  35930. /**
  35931. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35932. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35933. */
  35934. set isVisibilityBoxLocked(val: boolean);
  35935. /**
  35936. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35937. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35938. */
  35939. get isVisibilityBoxLocked(): boolean;
  35940. /**
  35941. * Tells to `setParticles()` to compute the particle rotations or not.
  35942. * Default value : true. The SPS is faster when it's set to false.
  35943. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35944. */
  35945. set computeParticleRotation(val: boolean);
  35946. /**
  35947. * Tells to `setParticles()` to compute the particle colors or not.
  35948. * Default value : true. The SPS is faster when it's set to false.
  35949. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35950. */
  35951. set computeParticleColor(val: boolean);
  35952. set computeParticleTexture(val: boolean);
  35953. /**
  35954. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35955. * Default value : false. The SPS is faster when it's set to false.
  35956. * Note : the particle custom vertex positions aren't stored values.
  35957. */
  35958. set computeParticleVertex(val: boolean);
  35959. /**
  35960. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35961. */
  35962. set computeBoundingBox(val: boolean);
  35963. /**
  35964. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35965. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35966. * Default : `true`
  35967. */
  35968. set depthSortParticles(val: boolean);
  35969. /**
  35970. * Gets if `setParticles()` computes the particle rotations or not.
  35971. * Default value : true. The SPS is faster when it's set to false.
  35972. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35973. */
  35974. get computeParticleRotation(): boolean;
  35975. /**
  35976. * Gets if `setParticles()` computes the particle colors or not.
  35977. * Default value : true. The SPS is faster when it's set to false.
  35978. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35979. */
  35980. get computeParticleColor(): boolean;
  35981. /**
  35982. * Gets if `setParticles()` computes the particle textures or not.
  35983. * Default value : true. The SPS is faster when it's set to false.
  35984. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35985. */
  35986. get computeParticleTexture(): boolean;
  35987. /**
  35988. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35989. * Default value : false. The SPS is faster when it's set to false.
  35990. * Note : the particle custom vertex positions aren't stored values.
  35991. */
  35992. get computeParticleVertex(): boolean;
  35993. /**
  35994. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35995. */
  35996. get computeBoundingBox(): boolean;
  35997. /**
  35998. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35999. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36000. * Default : `true`
  36001. */
  36002. get depthSortParticles(): boolean;
  36003. /**
  36004. * Gets if the SPS is created as expandable at construction time.
  36005. * Default : `false`
  36006. */
  36007. get expandable(): boolean;
  36008. /**
  36009. * Gets if the SPS supports the Multi Materials
  36010. */
  36011. get multimaterialEnabled(): boolean;
  36012. /**
  36013. * Gets if the SPS uses the model materials for its own multimaterial.
  36014. */
  36015. get useModelMaterial(): boolean;
  36016. /**
  36017. * The SPS used material array.
  36018. */
  36019. get materials(): Material[];
  36020. /**
  36021. * Sets the SPS MultiMaterial from the passed materials.
  36022. * Note : the passed array is internally copied and not used then by reference.
  36023. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  36024. */
  36025. setMultiMaterial(materials: Material[]): void;
  36026. /**
  36027. * The SPS computed multimaterial object
  36028. */
  36029. get multimaterial(): MultiMaterial;
  36030. set multimaterial(mm: MultiMaterial);
  36031. /**
  36032. * If the subMeshes must be updated on the next call to setParticles()
  36033. */
  36034. get autoUpdateSubMeshes(): boolean;
  36035. set autoUpdateSubMeshes(val: boolean);
  36036. /**
  36037. * This function does nothing. It may be overwritten to set all the particle first values.
  36038. * The SPS doesn't call this function, you may have to call it by your own.
  36039. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36040. */
  36041. initParticles(): void;
  36042. /**
  36043. * This function does nothing. It may be overwritten to recycle a particle.
  36044. * The SPS doesn't call this function, you may have to call it by your own.
  36045. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36046. * @param particle The particle to recycle
  36047. * @returns the recycled particle
  36048. */
  36049. recycleParticle(particle: SolidParticle): SolidParticle;
  36050. /**
  36051. * Updates a particle : this function should be overwritten by the user.
  36052. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  36053. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36054. * @example : just set a particle position or velocity and recycle conditions
  36055. * @param particle The particle to update
  36056. * @returns the updated particle
  36057. */
  36058. updateParticle(particle: SolidParticle): SolidParticle;
  36059. /**
  36060. * Updates a vertex of a particle : it can be overwritten by the user.
  36061. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  36062. * @param particle the current particle
  36063. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  36064. * @param pt the index of the current vertex in the particle shape
  36065. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  36066. * @example : just set a vertex particle position or color
  36067. * @returns the sps
  36068. */
  36069. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  36070. /**
  36071. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  36072. * This does nothing and may be overwritten by the user.
  36073. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36074. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36075. * @param update the boolean update value actually passed to setParticles()
  36076. */
  36077. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36078. /**
  36079. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36080. * This will be passed three parameters.
  36081. * This does nothing and may be overwritten by the user.
  36082. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36083. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36084. * @param update the boolean update value actually passed to setParticles()
  36085. */
  36086. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36087. }
  36088. }
  36089. declare module "babylonjs/Particles/solidParticle" {
  36090. import { Nullable } from "babylonjs/types";
  36091. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36092. import { Color4 } from "babylonjs/Maths/math.color";
  36093. import { Mesh } from "babylonjs/Meshes/mesh";
  36094. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36095. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36096. import { Plane } from "babylonjs/Maths/math.plane";
  36097. import { Material } from "babylonjs/Materials/material";
  36098. /**
  36099. * Represents one particle of a solid particle system.
  36100. */
  36101. export class SolidParticle {
  36102. /**
  36103. * particle global index
  36104. */
  36105. idx: number;
  36106. /**
  36107. * particle identifier
  36108. */
  36109. id: number;
  36110. /**
  36111. * The color of the particle
  36112. */
  36113. color: Nullable<Color4>;
  36114. /**
  36115. * The world space position of the particle.
  36116. */
  36117. position: Vector3;
  36118. /**
  36119. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36120. */
  36121. rotation: Vector3;
  36122. /**
  36123. * The world space rotation quaternion of the particle.
  36124. */
  36125. rotationQuaternion: Nullable<Quaternion>;
  36126. /**
  36127. * The scaling of the particle.
  36128. */
  36129. scaling: Vector3;
  36130. /**
  36131. * The uvs of the particle.
  36132. */
  36133. uvs: Vector4;
  36134. /**
  36135. * The current speed of the particle.
  36136. */
  36137. velocity: Vector3;
  36138. /**
  36139. * The pivot point in the particle local space.
  36140. */
  36141. pivot: Vector3;
  36142. /**
  36143. * Must the particle be translated from its pivot point in its local space ?
  36144. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36145. * Default : false
  36146. */
  36147. translateFromPivot: boolean;
  36148. /**
  36149. * Is the particle active or not ?
  36150. */
  36151. alive: boolean;
  36152. /**
  36153. * Is the particle visible or not ?
  36154. */
  36155. isVisible: boolean;
  36156. /**
  36157. * Index of this particle in the global "positions" array (Internal use)
  36158. * @hidden
  36159. */
  36160. _pos: number;
  36161. /**
  36162. * @hidden Index of this particle in the global "indices" array (Internal use)
  36163. */
  36164. _ind: number;
  36165. /**
  36166. * @hidden ModelShape of this particle (Internal use)
  36167. */
  36168. _model: ModelShape;
  36169. /**
  36170. * ModelShape id of this particle
  36171. */
  36172. shapeId: number;
  36173. /**
  36174. * Index of the particle in its shape id
  36175. */
  36176. idxInShape: number;
  36177. /**
  36178. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36179. */
  36180. _modelBoundingInfo: BoundingInfo;
  36181. /**
  36182. * @hidden Particle BoundingInfo object (Internal use)
  36183. */
  36184. _boundingInfo: BoundingInfo;
  36185. /**
  36186. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36187. */
  36188. _sps: SolidParticleSystem;
  36189. /**
  36190. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36191. */
  36192. _stillInvisible: boolean;
  36193. /**
  36194. * @hidden Last computed particle rotation matrix
  36195. */
  36196. _rotationMatrix: number[];
  36197. /**
  36198. * Parent particle Id, if any.
  36199. * Default null.
  36200. */
  36201. parentId: Nullable<number>;
  36202. /**
  36203. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36204. */
  36205. materialIndex: Nullable<number>;
  36206. /**
  36207. * Custom object or properties.
  36208. */
  36209. props: Nullable<any>;
  36210. /**
  36211. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36212. * The possible values are :
  36213. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36214. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36215. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36216. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36217. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36218. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36219. * */
  36220. cullingStrategy: number;
  36221. /**
  36222. * @hidden Internal global position in the SPS.
  36223. */
  36224. _globalPosition: Vector3;
  36225. /**
  36226. * Creates a Solid Particle object.
  36227. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36228. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36229. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36230. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36231. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36232. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36233. * @param shapeId (integer) is the model shape identifier in the SPS.
  36234. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36235. * @param sps defines the sps it is associated to
  36236. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36237. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36238. */
  36239. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36240. /**
  36241. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36242. * @param target the particle target
  36243. * @returns the current particle
  36244. */
  36245. copyToRef(target: SolidParticle): SolidParticle;
  36246. /**
  36247. * Legacy support, changed scale to scaling
  36248. */
  36249. get scale(): Vector3;
  36250. /**
  36251. * Legacy support, changed scale to scaling
  36252. */
  36253. set scale(scale: Vector3);
  36254. /**
  36255. * Legacy support, changed quaternion to rotationQuaternion
  36256. */
  36257. get quaternion(): Nullable<Quaternion>;
  36258. /**
  36259. * Legacy support, changed quaternion to rotationQuaternion
  36260. */
  36261. set quaternion(q: Nullable<Quaternion>);
  36262. /**
  36263. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36264. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36265. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36266. * @returns true if it intersects
  36267. */
  36268. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36269. /**
  36270. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36271. * A particle is in the frustum if its bounding box intersects the frustum
  36272. * @param frustumPlanes defines the frustum to test
  36273. * @returns true if the particle is in the frustum planes
  36274. */
  36275. isInFrustum(frustumPlanes: Plane[]): boolean;
  36276. /**
  36277. * get the rotation matrix of the particle
  36278. * @hidden
  36279. */
  36280. getRotationMatrix(m: Matrix): void;
  36281. }
  36282. /**
  36283. * Represents the shape of the model used by one particle of a solid particle system.
  36284. * SPS internal tool, don't use it manually.
  36285. */
  36286. export class ModelShape {
  36287. /**
  36288. * The shape id
  36289. * @hidden
  36290. */
  36291. shapeID: number;
  36292. /**
  36293. * flat array of model positions (internal use)
  36294. * @hidden
  36295. */
  36296. _shape: Vector3[];
  36297. /**
  36298. * flat array of model UVs (internal use)
  36299. * @hidden
  36300. */
  36301. _shapeUV: number[];
  36302. /**
  36303. * color array of the model
  36304. * @hidden
  36305. */
  36306. _shapeColors: number[];
  36307. /**
  36308. * indices array of the model
  36309. * @hidden
  36310. */
  36311. _indices: number[];
  36312. /**
  36313. * normals array of the model
  36314. * @hidden
  36315. */
  36316. _normals: number[];
  36317. /**
  36318. * length of the shape in the model indices array (internal use)
  36319. * @hidden
  36320. */
  36321. _indicesLength: number;
  36322. /**
  36323. * Custom position function (internal use)
  36324. * @hidden
  36325. */
  36326. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36327. /**
  36328. * Custom vertex function (internal use)
  36329. * @hidden
  36330. */
  36331. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36332. /**
  36333. * Model material (internal use)
  36334. * @hidden
  36335. */
  36336. _material: Nullable<Material>;
  36337. /**
  36338. * 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.
  36339. * SPS internal tool, don't use it manually.
  36340. * @hidden
  36341. */
  36342. 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>);
  36343. }
  36344. /**
  36345. * Represents a Depth Sorted Particle in the solid particle system.
  36346. * @hidden
  36347. */
  36348. export class DepthSortedParticle {
  36349. /**
  36350. * Particle index
  36351. */
  36352. idx: number;
  36353. /**
  36354. * Index of the particle in the "indices" array
  36355. */
  36356. ind: number;
  36357. /**
  36358. * Length of the particle shape in the "indices" array
  36359. */
  36360. indicesLength: number;
  36361. /**
  36362. * Squared distance from the particle to the camera
  36363. */
  36364. sqDistance: number;
  36365. /**
  36366. * Material index when used with MultiMaterials
  36367. */
  36368. materialIndex: number;
  36369. /**
  36370. * Creates a new sorted particle
  36371. * @param materialIndex
  36372. */
  36373. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36374. }
  36375. /**
  36376. * Represents a solid particle vertex
  36377. */
  36378. export class SolidParticleVertex {
  36379. /**
  36380. * Vertex position
  36381. */
  36382. position: Vector3;
  36383. /**
  36384. * Vertex color
  36385. */
  36386. color: Color4;
  36387. /**
  36388. * Vertex UV
  36389. */
  36390. uv: Vector2;
  36391. /**
  36392. * Creates a new solid particle vertex
  36393. */
  36394. constructor();
  36395. /** Vertex x coordinate */
  36396. get x(): number;
  36397. set x(val: number);
  36398. /** Vertex y coordinate */
  36399. get y(): number;
  36400. set y(val: number);
  36401. /** Vertex z coordinate */
  36402. get z(): number;
  36403. set z(val: number);
  36404. }
  36405. }
  36406. declare module "babylonjs/Collisions/meshCollisionData" {
  36407. import { Collider } from "babylonjs/Collisions/collider";
  36408. import { Vector3 } from "babylonjs/Maths/math.vector";
  36409. import { Nullable } from "babylonjs/types";
  36410. import { Observer } from "babylonjs/Misc/observable";
  36411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36412. /**
  36413. * @hidden
  36414. */
  36415. export class _MeshCollisionData {
  36416. _checkCollisions: boolean;
  36417. _collisionMask: number;
  36418. _collisionGroup: number;
  36419. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36420. _collider: Nullable<Collider>;
  36421. _oldPositionForCollisions: Vector3;
  36422. _diffPositionForCollisions: Vector3;
  36423. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36424. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36425. _collisionResponse: boolean;
  36426. }
  36427. }
  36428. declare module "babylonjs/Meshes/abstractMesh" {
  36429. import { Observable } from "babylonjs/Misc/observable";
  36430. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  36431. import { Camera } from "babylonjs/Cameras/camera";
  36432. import { Scene, IDisposable } from "babylonjs/scene";
  36433. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36434. import { Node } from "babylonjs/node";
  36435. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  36436. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36437. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36438. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36439. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36440. import { Material } from "babylonjs/Materials/material";
  36441. import { Light } from "babylonjs/Lights/light";
  36442. import { Skeleton } from "babylonjs/Bones/skeleton";
  36443. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  36444. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  36445. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36446. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  36447. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  36448. import { Plane } from "babylonjs/Maths/math.plane";
  36449. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36450. import { Ray } from "babylonjs/Culling/ray";
  36451. import { Collider } from "babylonjs/Collisions/collider";
  36452. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36453. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  36454. /** @hidden */
  36455. class _FacetDataStorage {
  36456. facetPositions: Vector3[];
  36457. facetNormals: Vector3[];
  36458. facetPartitioning: number[][];
  36459. facetNb: number;
  36460. partitioningSubdivisions: number;
  36461. partitioningBBoxRatio: number;
  36462. facetDataEnabled: boolean;
  36463. facetParameters: any;
  36464. bbSize: Vector3;
  36465. subDiv: {
  36466. max: number;
  36467. X: number;
  36468. Y: number;
  36469. Z: number;
  36470. };
  36471. facetDepthSort: boolean;
  36472. facetDepthSortEnabled: boolean;
  36473. depthSortedIndices: IndicesArray;
  36474. depthSortedFacets: {
  36475. ind: number;
  36476. sqDistance: number;
  36477. }[];
  36478. facetDepthSortFunction: (f1: {
  36479. ind: number;
  36480. sqDistance: number;
  36481. }, f2: {
  36482. ind: number;
  36483. sqDistance: number;
  36484. }) => number;
  36485. facetDepthSortFrom: Vector3;
  36486. facetDepthSortOrigin: Vector3;
  36487. invertedMatrix: Matrix;
  36488. }
  36489. /**
  36490. * @hidden
  36491. **/
  36492. class _InternalAbstractMeshDataInfo {
  36493. _hasVertexAlpha: boolean;
  36494. _useVertexColors: boolean;
  36495. _numBoneInfluencers: number;
  36496. _applyFog: boolean;
  36497. _receiveShadows: boolean;
  36498. _facetData: _FacetDataStorage;
  36499. _visibility: number;
  36500. _skeleton: Nullable<Skeleton>;
  36501. _layerMask: number;
  36502. _computeBonesUsingShaders: boolean;
  36503. _isActive: boolean;
  36504. _onlyForInstances: boolean;
  36505. _isActiveIntermediate: boolean;
  36506. _onlyForInstancesIntermediate: boolean;
  36507. _actAsRegularMesh: boolean;
  36508. _currentLOD: Nullable<AbstractMesh>;
  36509. }
  36510. /**
  36511. * Class used to store all common mesh properties
  36512. */
  36513. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36514. /** No occlusion */
  36515. static OCCLUSION_TYPE_NONE: number;
  36516. /** Occlusion set to optimisitic */
  36517. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36518. /** Occlusion set to strict */
  36519. static OCCLUSION_TYPE_STRICT: number;
  36520. /** Use an accurante occlusion algorithm */
  36521. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36522. /** Use a conservative occlusion algorithm */
  36523. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36524. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36525. * Test order :
  36526. * Is the bounding sphere outside the frustum ?
  36527. * If not, are the bounding box vertices outside the frustum ?
  36528. * It not, then the cullable object is in the frustum.
  36529. */
  36530. static readonly CULLINGSTRATEGY_STANDARD: number;
  36531. /** Culling strategy : Bounding Sphere Only.
  36532. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36533. * It's also less accurate than the standard because some not visible objects can still be selected.
  36534. * Test : is the bounding sphere outside the frustum ?
  36535. * If not, then the cullable object is in the frustum.
  36536. */
  36537. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36538. /** Culling strategy : Optimistic Inclusion.
  36539. * This in an inclusion test first, then the standard exclusion test.
  36540. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36541. * 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.
  36542. * Anyway, it's as accurate as the standard strategy.
  36543. * Test :
  36544. * Is the cullable object bounding sphere center in the frustum ?
  36545. * If not, apply the default culling strategy.
  36546. */
  36547. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36548. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36549. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36550. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36551. * 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.
  36552. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36553. * Test :
  36554. * Is the cullable object bounding sphere center in the frustum ?
  36555. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36556. */
  36557. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36558. /**
  36559. * No billboard
  36560. */
  36561. static get BILLBOARDMODE_NONE(): number;
  36562. /** Billboard on X axis */
  36563. static get BILLBOARDMODE_X(): number;
  36564. /** Billboard on Y axis */
  36565. static get BILLBOARDMODE_Y(): number;
  36566. /** Billboard on Z axis */
  36567. static get BILLBOARDMODE_Z(): number;
  36568. /** Billboard on all axes */
  36569. static get BILLBOARDMODE_ALL(): number;
  36570. /** Billboard on using position instead of orientation */
  36571. static get BILLBOARDMODE_USE_POSITION(): number;
  36572. /** @hidden */
  36573. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36574. /**
  36575. * The culling strategy to use to check whether the mesh must be rendered or not.
  36576. * This value can be changed at any time and will be used on the next render mesh selection.
  36577. * The possible values are :
  36578. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36579. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36580. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36581. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36582. * Please read each static variable documentation to get details about the culling process.
  36583. * */
  36584. cullingStrategy: number;
  36585. /**
  36586. * Gets the number of facets in the mesh
  36587. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36588. */
  36589. get facetNb(): number;
  36590. /**
  36591. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36592. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36593. */
  36594. get partitioningSubdivisions(): number;
  36595. set partitioningSubdivisions(nb: number);
  36596. /**
  36597. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36598. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36599. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36600. */
  36601. get partitioningBBoxRatio(): number;
  36602. set partitioningBBoxRatio(ratio: number);
  36603. /**
  36604. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36605. * Works only for updatable meshes.
  36606. * Doesn't work with multi-materials
  36607. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36608. */
  36609. get mustDepthSortFacets(): boolean;
  36610. set mustDepthSortFacets(sort: boolean);
  36611. /**
  36612. * The location (Vector3) where the facet depth sort must be computed from.
  36613. * By default, the active camera position.
  36614. * Used only when facet depth sort is enabled
  36615. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36616. */
  36617. get facetDepthSortFrom(): Vector3;
  36618. set facetDepthSortFrom(location: Vector3);
  36619. /**
  36620. * gets a boolean indicating if facetData is enabled
  36621. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36622. */
  36623. get isFacetDataEnabled(): boolean;
  36624. /** @hidden */
  36625. _updateNonUniformScalingState(value: boolean): boolean;
  36626. /**
  36627. * An event triggered when this mesh collides with another one
  36628. */
  36629. onCollideObservable: Observable<AbstractMesh>;
  36630. /** Set a function to call when this mesh collides with another one */
  36631. set onCollide(callback: () => void);
  36632. /**
  36633. * An event triggered when the collision's position changes
  36634. */
  36635. onCollisionPositionChangeObservable: Observable<Vector3>;
  36636. /** Set a function to call when the collision's position changes */
  36637. set onCollisionPositionChange(callback: () => void);
  36638. /**
  36639. * An event triggered when material is changed
  36640. */
  36641. onMaterialChangedObservable: Observable<AbstractMesh>;
  36642. /**
  36643. * Gets or sets the orientation for POV movement & rotation
  36644. */
  36645. definedFacingForward: boolean;
  36646. /** @hidden */
  36647. _occlusionQuery: Nullable<WebGLQuery>;
  36648. /** @hidden */
  36649. _renderingGroup: Nullable<RenderingGroup>;
  36650. /**
  36651. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36652. */
  36653. get visibility(): number;
  36654. /**
  36655. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36656. */
  36657. set visibility(value: number);
  36658. /** Gets or sets the alpha index used to sort transparent meshes
  36659. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36660. */
  36661. alphaIndex: number;
  36662. /**
  36663. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36664. */
  36665. isVisible: boolean;
  36666. /**
  36667. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36668. */
  36669. isPickable: boolean;
  36670. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36671. showSubMeshesBoundingBox: boolean;
  36672. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36673. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36674. */
  36675. isBlocker: boolean;
  36676. /**
  36677. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36678. */
  36679. enablePointerMoveEvents: boolean;
  36680. private _renderingGroupId;
  36681. /**
  36682. * Specifies the rendering group id for this mesh (0 by default)
  36683. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36684. */
  36685. get renderingGroupId(): number;
  36686. set renderingGroupId(value: number);
  36687. private _material;
  36688. /** Gets or sets current material */
  36689. get material(): Nullable<Material>;
  36690. set material(value: Nullable<Material>);
  36691. /**
  36692. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36693. * @see https://doc.babylonjs.com/babylon101/shadows
  36694. */
  36695. get receiveShadows(): boolean;
  36696. set receiveShadows(value: boolean);
  36697. /** Defines color to use when rendering outline */
  36698. outlineColor: Color3;
  36699. /** Define width to use when rendering outline */
  36700. outlineWidth: number;
  36701. /** Defines color to use when rendering overlay */
  36702. overlayColor: Color3;
  36703. /** Defines alpha to use when rendering overlay */
  36704. overlayAlpha: number;
  36705. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36706. get hasVertexAlpha(): boolean;
  36707. set hasVertexAlpha(value: boolean);
  36708. /** 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) */
  36709. get useVertexColors(): boolean;
  36710. set useVertexColors(value: boolean);
  36711. /**
  36712. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36713. */
  36714. get computeBonesUsingShaders(): boolean;
  36715. set computeBonesUsingShaders(value: boolean);
  36716. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36717. get numBoneInfluencers(): number;
  36718. set numBoneInfluencers(value: number);
  36719. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36720. get applyFog(): boolean;
  36721. set applyFog(value: boolean);
  36722. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36723. useOctreeForRenderingSelection: boolean;
  36724. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36725. useOctreeForPicking: boolean;
  36726. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36727. useOctreeForCollisions: boolean;
  36728. /**
  36729. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36730. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36731. */
  36732. get layerMask(): number;
  36733. set layerMask(value: number);
  36734. /**
  36735. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36736. */
  36737. alwaysSelectAsActiveMesh: boolean;
  36738. /**
  36739. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36740. */
  36741. doNotSyncBoundingInfo: boolean;
  36742. /**
  36743. * Gets or sets the current action manager
  36744. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36745. */
  36746. actionManager: Nullable<AbstractActionManager>;
  36747. private _meshCollisionData;
  36748. /**
  36749. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36750. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36751. */
  36752. ellipsoid: Vector3;
  36753. /**
  36754. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36755. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36756. */
  36757. ellipsoidOffset: Vector3;
  36758. /**
  36759. * Gets or sets a collision mask used to mask collisions (default is -1).
  36760. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36761. */
  36762. get collisionMask(): number;
  36763. set collisionMask(mask: number);
  36764. /**
  36765. * Gets or sets a collision response flag (default is true).
  36766. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36767. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36768. * to respond to the collision.
  36769. */
  36770. get collisionResponse(): boolean;
  36771. set collisionResponse(response: boolean);
  36772. /**
  36773. * Gets or sets the current collision group mask (-1 by default).
  36774. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36775. */
  36776. get collisionGroup(): number;
  36777. set collisionGroup(mask: number);
  36778. /**
  36779. * Gets or sets current surrounding meshes (null by default).
  36780. *
  36781. * By default collision detection is tested against every mesh in the scene.
  36782. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36783. * meshes will be tested for the collision.
  36784. *
  36785. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36786. */
  36787. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36788. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36789. /**
  36790. * Defines edge width used when edgesRenderer is enabled
  36791. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36792. */
  36793. edgesWidth: number;
  36794. /**
  36795. * Defines edge color used when edgesRenderer is enabled
  36796. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36797. */
  36798. edgesColor: Color4;
  36799. /** @hidden */
  36800. _edgesRenderer: Nullable<IEdgesRenderer>;
  36801. /** @hidden */
  36802. _masterMesh: Nullable<AbstractMesh>;
  36803. /** @hidden */
  36804. _boundingInfo: Nullable<BoundingInfo>;
  36805. /** @hidden */
  36806. _renderId: number;
  36807. /**
  36808. * Gets or sets the list of subMeshes
  36809. * @see https://doc.babylonjs.com/how_to/multi_materials
  36810. */
  36811. subMeshes: SubMesh[];
  36812. /** @hidden */
  36813. _intersectionsInProgress: AbstractMesh[];
  36814. /** @hidden */
  36815. _unIndexed: boolean;
  36816. /** @hidden */
  36817. _lightSources: Light[];
  36818. /** Gets the list of lights affecting that mesh */
  36819. get lightSources(): Light[];
  36820. /** @hidden */
  36821. get _positions(): Nullable<Vector3[]>;
  36822. /** @hidden */
  36823. _waitingData: {
  36824. lods: Nullable<any>;
  36825. actions: Nullable<any>;
  36826. freezeWorldMatrix: Nullable<boolean>;
  36827. };
  36828. /** @hidden */
  36829. _bonesTransformMatrices: Nullable<Float32Array>;
  36830. /** @hidden */
  36831. _transformMatrixTexture: Nullable<RawTexture>;
  36832. /**
  36833. * Gets or sets a skeleton to apply skining transformations
  36834. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36835. */
  36836. set skeleton(value: Nullable<Skeleton>);
  36837. get skeleton(): Nullable<Skeleton>;
  36838. /**
  36839. * An event triggered when the mesh is rebuilt.
  36840. */
  36841. onRebuildObservable: Observable<AbstractMesh>;
  36842. /**
  36843. * Creates a new AbstractMesh
  36844. * @param name defines the name of the mesh
  36845. * @param scene defines the hosting scene
  36846. */
  36847. constructor(name: string, scene?: Nullable<Scene>);
  36848. /**
  36849. * Returns the string "AbstractMesh"
  36850. * @returns "AbstractMesh"
  36851. */
  36852. getClassName(): string;
  36853. /**
  36854. * Gets a string representation of the current mesh
  36855. * @param fullDetails defines a boolean indicating if full details must be included
  36856. * @returns a string representation of the current mesh
  36857. */
  36858. toString(fullDetails?: boolean): string;
  36859. /**
  36860. * @hidden
  36861. */
  36862. protected _getEffectiveParent(): Nullable<Node>;
  36863. /** @hidden */
  36864. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36865. /** @hidden */
  36866. _rebuild(): void;
  36867. /** @hidden */
  36868. _resyncLightSources(): void;
  36869. /** @hidden */
  36870. _resyncLightSource(light: Light): void;
  36871. /** @hidden */
  36872. _unBindEffect(): void;
  36873. /** @hidden */
  36874. _removeLightSource(light: Light, dispose: boolean): void;
  36875. private _markSubMeshesAsDirty;
  36876. /** @hidden */
  36877. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36878. /** @hidden */
  36879. _markSubMeshesAsAttributesDirty(): void;
  36880. /** @hidden */
  36881. _markSubMeshesAsMiscDirty(): void;
  36882. /**
  36883. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36884. */
  36885. get scaling(): Vector3;
  36886. set scaling(newScaling: Vector3);
  36887. /**
  36888. * Returns true if the mesh is blocked. Implemented by child classes
  36889. */
  36890. get isBlocked(): boolean;
  36891. /**
  36892. * Returns the mesh itself by default. Implemented by child classes
  36893. * @param camera defines the camera to use to pick the right LOD level
  36894. * @returns the currentAbstractMesh
  36895. */
  36896. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36897. /**
  36898. * Returns 0 by default. Implemented by child classes
  36899. * @returns an integer
  36900. */
  36901. getTotalVertices(): number;
  36902. /**
  36903. * Returns a positive integer : the total number of indices in this mesh geometry.
  36904. * @returns the numner of indices or zero if the mesh has no geometry.
  36905. */
  36906. getTotalIndices(): number;
  36907. /**
  36908. * Returns null by default. Implemented by child classes
  36909. * @returns null
  36910. */
  36911. getIndices(): Nullable<IndicesArray>;
  36912. /**
  36913. * Returns the array of the requested vertex data kind. Implemented by child classes
  36914. * @param kind defines the vertex data kind to use
  36915. * @returns null
  36916. */
  36917. getVerticesData(kind: string): Nullable<FloatArray>;
  36918. /**
  36919. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36920. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36921. * Note that a new underlying VertexBuffer object is created each call.
  36922. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36923. * @param kind defines vertex data kind:
  36924. * * VertexBuffer.PositionKind
  36925. * * VertexBuffer.UVKind
  36926. * * VertexBuffer.UV2Kind
  36927. * * VertexBuffer.UV3Kind
  36928. * * VertexBuffer.UV4Kind
  36929. * * VertexBuffer.UV5Kind
  36930. * * VertexBuffer.UV6Kind
  36931. * * VertexBuffer.ColorKind
  36932. * * VertexBuffer.MatricesIndicesKind
  36933. * * VertexBuffer.MatricesIndicesExtraKind
  36934. * * VertexBuffer.MatricesWeightsKind
  36935. * * VertexBuffer.MatricesWeightsExtraKind
  36936. * @param data defines the data source
  36937. * @param updatable defines if the data must be flagged as updatable (or static)
  36938. * @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
  36939. * @returns the current mesh
  36940. */
  36941. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36942. /**
  36943. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36944. * If the mesh has no geometry, it is simply returned as it is.
  36945. * @param kind defines vertex data kind:
  36946. * * VertexBuffer.PositionKind
  36947. * * VertexBuffer.UVKind
  36948. * * VertexBuffer.UV2Kind
  36949. * * VertexBuffer.UV3Kind
  36950. * * VertexBuffer.UV4Kind
  36951. * * VertexBuffer.UV5Kind
  36952. * * VertexBuffer.UV6Kind
  36953. * * VertexBuffer.ColorKind
  36954. * * VertexBuffer.MatricesIndicesKind
  36955. * * VertexBuffer.MatricesIndicesExtraKind
  36956. * * VertexBuffer.MatricesWeightsKind
  36957. * * VertexBuffer.MatricesWeightsExtraKind
  36958. * @param data defines the data source
  36959. * @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
  36960. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36961. * @returns the current mesh
  36962. */
  36963. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36964. /**
  36965. * Sets the mesh indices,
  36966. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36967. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36968. * @param totalVertices Defines the total number of vertices
  36969. * @returns the current mesh
  36970. */
  36971. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36972. /**
  36973. * Gets a boolean indicating if specific vertex data is present
  36974. * @param kind defines the vertex data kind to use
  36975. * @returns true is data kind is present
  36976. */
  36977. isVerticesDataPresent(kind: string): boolean;
  36978. /**
  36979. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36980. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36981. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36982. * @returns a BoundingInfo
  36983. */
  36984. getBoundingInfo(): BoundingInfo;
  36985. /**
  36986. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36987. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36988. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36989. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36990. * @returns the current mesh
  36991. */
  36992. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36993. /**
  36994. * Overwrite the current bounding info
  36995. * @param boundingInfo defines the new bounding info
  36996. * @returns the current mesh
  36997. */
  36998. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36999. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  37000. get useBones(): boolean;
  37001. /** @hidden */
  37002. _preActivate(): void;
  37003. /** @hidden */
  37004. _preActivateForIntermediateRendering(renderId: number): void;
  37005. /** @hidden */
  37006. _activate(renderId: number, intermediateRendering: boolean): boolean;
  37007. /** @hidden */
  37008. _postActivate(): void;
  37009. /** @hidden */
  37010. _freeze(): void;
  37011. /** @hidden */
  37012. _unFreeze(): void;
  37013. /**
  37014. * Gets the current world matrix
  37015. * @returns a Matrix
  37016. */
  37017. getWorldMatrix(): Matrix;
  37018. /** @hidden */
  37019. _getWorldMatrixDeterminant(): number;
  37020. /**
  37021. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  37022. */
  37023. get isAnInstance(): boolean;
  37024. /**
  37025. * Gets a boolean indicating if this mesh has instances
  37026. */
  37027. get hasInstances(): boolean;
  37028. /**
  37029. * Gets a boolean indicating if this mesh has thin instances
  37030. */
  37031. get hasThinInstances(): boolean;
  37032. /**
  37033. * Perform relative position change from the point of view of behind the front of the mesh.
  37034. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37035. * Supports definition of mesh facing forward or backward
  37036. * @param amountRight defines the distance on the right axis
  37037. * @param amountUp defines the distance on the up axis
  37038. * @param amountForward defines the distance on the forward axis
  37039. * @returns the current mesh
  37040. */
  37041. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  37042. /**
  37043. * Calculate relative position change from the point of view of behind the front of the mesh.
  37044. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37045. * Supports definition of mesh facing forward or backward
  37046. * @param amountRight defines the distance on the right axis
  37047. * @param amountUp defines the distance on the up axis
  37048. * @param amountForward defines the distance on the forward axis
  37049. * @returns the new displacement vector
  37050. */
  37051. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  37052. /**
  37053. * Perform relative rotation change from the point of view of behind the front of the mesh.
  37054. * Supports definition of mesh facing forward or backward
  37055. * @param flipBack defines the flip
  37056. * @param twirlClockwise defines the twirl
  37057. * @param tiltRight defines the tilt
  37058. * @returns the current mesh
  37059. */
  37060. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  37061. /**
  37062. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  37063. * Supports definition of mesh facing forward or backward.
  37064. * @param flipBack defines the flip
  37065. * @param twirlClockwise defines the twirl
  37066. * @param tiltRight defines the tilt
  37067. * @returns the new rotation vector
  37068. */
  37069. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  37070. /**
  37071. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37072. * This means the mesh underlying bounding box and sphere are recomputed.
  37073. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37074. * @returns the current mesh
  37075. */
  37076. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37077. /** @hidden */
  37078. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37079. /** @hidden */
  37080. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37081. /** @hidden */
  37082. _updateBoundingInfo(): AbstractMesh;
  37083. /** @hidden */
  37084. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37085. /** @hidden */
  37086. protected _afterComputeWorldMatrix(): void;
  37087. /** @hidden */
  37088. get _effectiveMesh(): AbstractMesh;
  37089. /**
  37090. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37091. * A mesh is in the frustum if its bounding box intersects the frustum
  37092. * @param frustumPlanes defines the frustum to test
  37093. * @returns true if the mesh is in the frustum planes
  37094. */
  37095. isInFrustum(frustumPlanes: Plane[]): boolean;
  37096. /**
  37097. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37098. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37099. * @param frustumPlanes defines the frustum to test
  37100. * @returns true if the mesh is completely in the frustum planes
  37101. */
  37102. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37103. /**
  37104. * True if the mesh intersects another mesh or a SolidParticle object
  37105. * @param mesh defines a target mesh or SolidParticle to test
  37106. * @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)
  37107. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37108. * @returns true if there is an intersection
  37109. */
  37110. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37111. /**
  37112. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37113. * @param point defines the point to test
  37114. * @returns true if there is an intersection
  37115. */
  37116. intersectsPoint(point: Vector3): boolean;
  37117. /**
  37118. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37119. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37120. */
  37121. get checkCollisions(): boolean;
  37122. set checkCollisions(collisionEnabled: boolean);
  37123. /**
  37124. * Gets Collider object used to compute collisions (not physics)
  37125. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37126. */
  37127. get collider(): Nullable<Collider>;
  37128. /**
  37129. * Move the mesh using collision engine
  37130. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37131. * @param displacement defines the requested displacement vector
  37132. * @returns the current mesh
  37133. */
  37134. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37135. private _onCollisionPositionChange;
  37136. /** @hidden */
  37137. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37138. /** @hidden */
  37139. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37140. /** @hidden */
  37141. _checkCollision(collider: Collider): AbstractMesh;
  37142. /** @hidden */
  37143. _generatePointsArray(): boolean;
  37144. /**
  37145. * Checks if the passed Ray intersects with the mesh
  37146. * @param ray defines the ray to use
  37147. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37148. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37149. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37150. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37151. * @returns the picking info
  37152. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37153. */
  37154. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  37155. /**
  37156. * Clones the current mesh
  37157. * @param name defines the mesh name
  37158. * @param newParent defines the new mesh parent
  37159. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37160. * @returns the new mesh
  37161. */
  37162. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37163. /**
  37164. * Disposes all the submeshes of the current meshnp
  37165. * @returns the current mesh
  37166. */
  37167. releaseSubMeshes(): AbstractMesh;
  37168. /**
  37169. * Releases resources associated with this abstract mesh.
  37170. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37171. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37172. */
  37173. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37174. /**
  37175. * Adds the passed mesh as a child to the current mesh
  37176. * @param mesh defines the child mesh
  37177. * @returns the current mesh
  37178. */
  37179. addChild(mesh: AbstractMesh): AbstractMesh;
  37180. /**
  37181. * Removes the passed mesh from the current mesh children list
  37182. * @param mesh defines the child mesh
  37183. * @returns the current mesh
  37184. */
  37185. removeChild(mesh: AbstractMesh): AbstractMesh;
  37186. /** @hidden */
  37187. private _initFacetData;
  37188. /**
  37189. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37190. * This method can be called within the render loop.
  37191. * 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
  37192. * @returns the current mesh
  37193. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37194. */
  37195. updateFacetData(): AbstractMesh;
  37196. /**
  37197. * Returns the facetLocalNormals array.
  37198. * The normals are expressed in the mesh local spac
  37199. * @returns an array of Vector3
  37200. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37201. */
  37202. getFacetLocalNormals(): Vector3[];
  37203. /**
  37204. * Returns the facetLocalPositions array.
  37205. * The facet positions are expressed in the mesh local space
  37206. * @returns an array of Vector3
  37207. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37208. */
  37209. getFacetLocalPositions(): Vector3[];
  37210. /**
  37211. * Returns the facetLocalPartioning array
  37212. * @returns an array of array of numbers
  37213. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37214. */
  37215. getFacetLocalPartitioning(): number[][];
  37216. /**
  37217. * Returns the i-th facet position in the world system.
  37218. * This method allocates a new Vector3 per call
  37219. * @param i defines the facet index
  37220. * @returns a new Vector3
  37221. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37222. */
  37223. getFacetPosition(i: number): Vector3;
  37224. /**
  37225. * Sets the reference Vector3 with the i-th facet position in the world system
  37226. * @param i defines the facet index
  37227. * @param ref defines the target vector
  37228. * @returns the current mesh
  37229. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37230. */
  37231. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37232. /**
  37233. * Returns the i-th facet normal in the world system.
  37234. * This method allocates a new Vector3 per call
  37235. * @param i defines the facet index
  37236. * @returns a new Vector3
  37237. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37238. */
  37239. getFacetNormal(i: number): Vector3;
  37240. /**
  37241. * Sets the reference Vector3 with the i-th facet normal in the world system
  37242. * @param i defines the facet index
  37243. * @param ref defines the target vector
  37244. * @returns the current mesh
  37245. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37246. */
  37247. getFacetNormalToRef(i: number, ref: Vector3): this;
  37248. /**
  37249. * 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)
  37250. * @param x defines x coordinate
  37251. * @param y defines y coordinate
  37252. * @param z defines z coordinate
  37253. * @returns the array of facet indexes
  37254. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37255. */
  37256. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37257. /**
  37258. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37259. * @param projected sets as the (x,y,z) world projection on the facet
  37260. * @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
  37261. * @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
  37262. * @param x defines x coordinate
  37263. * @param y defines y coordinate
  37264. * @param z defines z coordinate
  37265. * @returns the face index if found (or null instead)
  37266. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37267. */
  37268. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37269. /**
  37270. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37271. * @param projected sets as the (x,y,z) local projection on the facet
  37272. * @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
  37273. * @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
  37274. * @param x defines x coordinate
  37275. * @param y defines y coordinate
  37276. * @param z defines z coordinate
  37277. * @returns the face index if found (or null instead)
  37278. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37279. */
  37280. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37281. /**
  37282. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37283. * @returns the parameters
  37284. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37285. */
  37286. getFacetDataParameters(): any;
  37287. /**
  37288. * Disables the feature FacetData and frees the related memory
  37289. * @returns the current mesh
  37290. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37291. */
  37292. disableFacetData(): AbstractMesh;
  37293. /**
  37294. * Updates the AbstractMesh indices array
  37295. * @param indices defines the data source
  37296. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37297. * @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)
  37298. * @returns the current mesh
  37299. */
  37300. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37301. /**
  37302. * Creates new normals data for the mesh
  37303. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37304. * @returns the current mesh
  37305. */
  37306. createNormals(updatable: boolean): AbstractMesh;
  37307. /**
  37308. * Align the mesh with a normal
  37309. * @param normal defines the normal to use
  37310. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37311. * @returns the current mesh
  37312. */
  37313. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37314. /** @hidden */
  37315. _checkOcclusionQuery(): boolean;
  37316. /**
  37317. * Disables the mesh edge rendering mode
  37318. * @returns the currentAbstractMesh
  37319. */
  37320. disableEdgesRendering(): AbstractMesh;
  37321. /**
  37322. * Enables the edge rendering mode on the mesh.
  37323. * This mode makes the mesh edges visible
  37324. * @param epsilon defines the maximal distance between two angles to detect a face
  37325. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37326. * @returns the currentAbstractMesh
  37327. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37328. */
  37329. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  37330. /**
  37331. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37332. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37333. */
  37334. getConnectedParticleSystems(): IParticleSystem[];
  37335. }
  37336. }
  37337. declare module "babylonjs/Actions/actionEvent" {
  37338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37339. import { Nullable } from "babylonjs/types";
  37340. import { Sprite } from "babylonjs/Sprites/sprite";
  37341. import { Scene } from "babylonjs/scene";
  37342. import { Vector2 } from "babylonjs/Maths/math.vector";
  37343. /**
  37344. * Interface used to define ActionEvent
  37345. */
  37346. export interface IActionEvent {
  37347. /** The mesh or sprite that triggered the action */
  37348. source: any;
  37349. /** The X mouse cursor position at the time of the event */
  37350. pointerX: number;
  37351. /** The Y mouse cursor position at the time of the event */
  37352. pointerY: number;
  37353. /** The mesh that is currently pointed at (can be null) */
  37354. meshUnderPointer: Nullable<AbstractMesh>;
  37355. /** the original (browser) event that triggered the ActionEvent */
  37356. sourceEvent?: any;
  37357. /** additional data for the event */
  37358. additionalData?: any;
  37359. }
  37360. /**
  37361. * ActionEvent is the event being sent when an action is triggered.
  37362. */
  37363. export class ActionEvent implements IActionEvent {
  37364. /** The mesh or sprite that triggered the action */
  37365. source: any;
  37366. /** The X mouse cursor position at the time of the event */
  37367. pointerX: number;
  37368. /** The Y mouse cursor position at the time of the event */
  37369. pointerY: number;
  37370. /** The mesh that is currently pointed at (can be null) */
  37371. meshUnderPointer: Nullable<AbstractMesh>;
  37372. /** the original (browser) event that triggered the ActionEvent */
  37373. sourceEvent?: any;
  37374. /** additional data for the event */
  37375. additionalData?: any;
  37376. /**
  37377. * Creates a new ActionEvent
  37378. * @param source The mesh or sprite that triggered the action
  37379. * @param pointerX The X mouse cursor position at the time of the event
  37380. * @param pointerY The Y mouse cursor position at the time of the event
  37381. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37382. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37383. * @param additionalData additional data for the event
  37384. */
  37385. constructor(
  37386. /** The mesh or sprite that triggered the action */
  37387. source: any,
  37388. /** The X mouse cursor position at the time of the event */
  37389. pointerX: number,
  37390. /** The Y mouse cursor position at the time of the event */
  37391. pointerY: number,
  37392. /** The mesh that is currently pointed at (can be null) */
  37393. meshUnderPointer: Nullable<AbstractMesh>,
  37394. /** the original (browser) event that triggered the ActionEvent */
  37395. sourceEvent?: any,
  37396. /** additional data for the event */
  37397. additionalData?: any);
  37398. /**
  37399. * Helper function to auto-create an ActionEvent from a source mesh.
  37400. * @param source The source mesh that triggered the event
  37401. * @param evt The original (browser) event
  37402. * @param additionalData additional data for the event
  37403. * @returns the new ActionEvent
  37404. */
  37405. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37406. /**
  37407. * Helper function to auto-create an ActionEvent from a source sprite
  37408. * @param source The source sprite that triggered the event
  37409. * @param scene Scene associated with the sprite
  37410. * @param evt The original (browser) event
  37411. * @param additionalData additional data for the event
  37412. * @returns the new ActionEvent
  37413. */
  37414. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37415. /**
  37416. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37417. * @param scene the scene where the event occurred
  37418. * @param evt The original (browser) event
  37419. * @returns the new ActionEvent
  37420. */
  37421. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37422. /**
  37423. * Helper function to auto-create an ActionEvent from a primitive
  37424. * @param prim defines the target primitive
  37425. * @param pointerPos defines the pointer position
  37426. * @param evt The original (browser) event
  37427. * @param additionalData additional data for the event
  37428. * @returns the new ActionEvent
  37429. */
  37430. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37431. }
  37432. }
  37433. declare module "babylonjs/Actions/abstractActionManager" {
  37434. import { IDisposable } from "babylonjs/scene";
  37435. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  37436. import { IAction } from "babylonjs/Actions/action";
  37437. import { Nullable } from "babylonjs/types";
  37438. /**
  37439. * Abstract class used to decouple action Manager from scene and meshes.
  37440. * Do not instantiate.
  37441. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37442. */
  37443. export abstract class AbstractActionManager implements IDisposable {
  37444. /** Gets the list of active triggers */
  37445. static Triggers: {
  37446. [key: string]: number;
  37447. };
  37448. /** Gets the cursor to use when hovering items */
  37449. hoverCursor: string;
  37450. /** Gets the list of actions */
  37451. actions: IAction[];
  37452. /**
  37453. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37454. */
  37455. isRecursive: boolean;
  37456. /**
  37457. * Releases all associated resources
  37458. */
  37459. abstract dispose(): void;
  37460. /**
  37461. * Does this action manager has pointer triggers
  37462. */
  37463. abstract get hasPointerTriggers(): boolean;
  37464. /**
  37465. * Does this action manager has pick triggers
  37466. */
  37467. abstract get hasPickTriggers(): boolean;
  37468. /**
  37469. * Process a specific trigger
  37470. * @param trigger defines the trigger to process
  37471. * @param evt defines the event details to be processed
  37472. */
  37473. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37474. /**
  37475. * Does this action manager handles actions of any of the given triggers
  37476. * @param triggers defines the triggers to be tested
  37477. * @return a boolean indicating whether one (or more) of the triggers is handled
  37478. */
  37479. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37480. /**
  37481. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37482. * speed.
  37483. * @param triggerA defines the trigger to be tested
  37484. * @param triggerB defines the trigger to be tested
  37485. * @return a boolean indicating whether one (or more) of the triggers is handled
  37486. */
  37487. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37488. /**
  37489. * Does this action manager handles actions of a given trigger
  37490. * @param trigger defines the trigger to be tested
  37491. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37492. * @return whether the trigger is handled
  37493. */
  37494. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37495. /**
  37496. * Serialize this manager to a JSON object
  37497. * @param name defines the property name to store this manager
  37498. * @returns a JSON representation of this manager
  37499. */
  37500. abstract serialize(name: string): any;
  37501. /**
  37502. * Registers an action to this action manager
  37503. * @param action defines the action to be registered
  37504. * @return the action amended (prepared) after registration
  37505. */
  37506. abstract registerAction(action: IAction): Nullable<IAction>;
  37507. /**
  37508. * Unregisters an action to this action manager
  37509. * @param action defines the action to be unregistered
  37510. * @return a boolean indicating whether the action has been unregistered
  37511. */
  37512. abstract unregisterAction(action: IAction): Boolean;
  37513. /**
  37514. * Does exist one action manager with at least one trigger
  37515. **/
  37516. static get HasTriggers(): boolean;
  37517. /**
  37518. * Does exist one action manager with at least one pick trigger
  37519. **/
  37520. static get HasPickTriggers(): boolean;
  37521. /**
  37522. * Does exist one action manager that handles actions of a given trigger
  37523. * @param trigger defines the trigger to be tested
  37524. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  37525. **/
  37526. static HasSpecificTrigger(trigger: number): boolean;
  37527. }
  37528. }
  37529. declare module "babylonjs/node" {
  37530. import { Scene } from "babylonjs/scene";
  37531. import { Nullable } from "babylonjs/types";
  37532. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  37533. import { Engine } from "babylonjs/Engines/engine";
  37534. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  37535. import { Observable } from "babylonjs/Misc/observable";
  37536. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37537. import { IInspectable } from "babylonjs/Misc/iInspectable";
  37538. import { Animatable } from "babylonjs/Animations/animatable";
  37539. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  37540. import { Animation } from "babylonjs/Animations/animation";
  37541. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37543. /**
  37544. * Defines how a node can be built from a string name.
  37545. */
  37546. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37547. /**
  37548. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37549. */
  37550. export class Node implements IBehaviorAware<Node> {
  37551. /** @hidden */
  37552. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37553. private static _NodeConstructors;
  37554. /**
  37555. * Add a new node constructor
  37556. * @param type defines the type name of the node to construct
  37557. * @param constructorFunc defines the constructor function
  37558. */
  37559. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37560. /**
  37561. * Returns a node constructor based on type name
  37562. * @param type defines the type name
  37563. * @param name defines the new node name
  37564. * @param scene defines the hosting scene
  37565. * @param options defines optional options to transmit to constructors
  37566. * @returns the new constructor or null
  37567. */
  37568. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37569. /**
  37570. * Gets or sets the name of the node
  37571. */
  37572. name: string;
  37573. /**
  37574. * Gets or sets the id of the node
  37575. */
  37576. id: string;
  37577. /**
  37578. * Gets or sets the unique id of the node
  37579. */
  37580. uniqueId: number;
  37581. /**
  37582. * Gets or sets a string used to store user defined state for the node
  37583. */
  37584. state: string;
  37585. /**
  37586. * Gets or sets an object used to store user defined information for the node
  37587. */
  37588. metadata: any;
  37589. /**
  37590. * For internal use only. Please do not use.
  37591. */
  37592. reservedDataStore: any;
  37593. /**
  37594. * List of inspectable custom properties (used by the Inspector)
  37595. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37596. */
  37597. inspectableCustomProperties: IInspectable[];
  37598. private _doNotSerialize;
  37599. /**
  37600. * Gets or sets a boolean used to define if the node must be serialized
  37601. */
  37602. get doNotSerialize(): boolean;
  37603. set doNotSerialize(value: boolean);
  37604. /** @hidden */
  37605. _isDisposed: boolean;
  37606. /**
  37607. * Gets a list of Animations associated with the node
  37608. */
  37609. animations: import("babylonjs/Animations/animation").Animation[];
  37610. protected _ranges: {
  37611. [name: string]: Nullable<AnimationRange>;
  37612. };
  37613. /**
  37614. * Callback raised when the node is ready to be used
  37615. */
  37616. onReady: Nullable<(node: Node) => void>;
  37617. private _isEnabled;
  37618. private _isParentEnabled;
  37619. private _isReady;
  37620. /** @hidden */
  37621. _currentRenderId: number;
  37622. private _parentUpdateId;
  37623. /** @hidden */
  37624. _childUpdateId: number;
  37625. /** @hidden */
  37626. _waitingParentId: Nullable<string>;
  37627. /** @hidden */
  37628. _scene: Scene;
  37629. /** @hidden */
  37630. _cache: any;
  37631. private _parentNode;
  37632. private _children;
  37633. /** @hidden */
  37634. _worldMatrix: Matrix;
  37635. /** @hidden */
  37636. _worldMatrixDeterminant: number;
  37637. /** @hidden */
  37638. _worldMatrixDeterminantIsDirty: boolean;
  37639. /** @hidden */
  37640. private _sceneRootNodesIndex;
  37641. /**
  37642. * Gets a boolean indicating if the node has been disposed
  37643. * @returns true if the node was disposed
  37644. */
  37645. isDisposed(): boolean;
  37646. /**
  37647. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37648. * @see https://doc.babylonjs.com/how_to/parenting
  37649. */
  37650. set parent(parent: Nullable<Node>);
  37651. get parent(): Nullable<Node>;
  37652. /** @hidden */
  37653. _addToSceneRootNodes(): void;
  37654. /** @hidden */
  37655. _removeFromSceneRootNodes(): void;
  37656. private _animationPropertiesOverride;
  37657. /**
  37658. * Gets or sets the animation properties override
  37659. */
  37660. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37661. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37662. /**
  37663. * Gets a string identifying the name of the class
  37664. * @returns "Node" string
  37665. */
  37666. getClassName(): string;
  37667. /** @hidden */
  37668. readonly _isNode: boolean;
  37669. /**
  37670. * An event triggered when the mesh is disposed
  37671. */
  37672. onDisposeObservable: Observable<Node>;
  37673. private _onDisposeObserver;
  37674. /**
  37675. * Sets a callback that will be raised when the node will be disposed
  37676. */
  37677. set onDispose(callback: () => void);
  37678. /**
  37679. * Creates a new Node
  37680. * @param name the name and id to be given to this node
  37681. * @param scene the scene this node will be added to
  37682. */
  37683. constructor(name: string, scene?: Nullable<Scene>);
  37684. /**
  37685. * Gets the scene of the node
  37686. * @returns a scene
  37687. */
  37688. getScene(): Scene;
  37689. /**
  37690. * Gets the engine of the node
  37691. * @returns a Engine
  37692. */
  37693. getEngine(): Engine;
  37694. private _behaviors;
  37695. /**
  37696. * Attach a behavior to the node
  37697. * @see https://doc.babylonjs.com/features/behaviour
  37698. * @param behavior defines the behavior to attach
  37699. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37700. * @returns the current Node
  37701. */
  37702. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37703. /**
  37704. * Remove an attached behavior
  37705. * @see https://doc.babylonjs.com/features/behaviour
  37706. * @param behavior defines the behavior to attach
  37707. * @returns the current Node
  37708. */
  37709. removeBehavior(behavior: Behavior<Node>): Node;
  37710. /**
  37711. * Gets the list of attached behaviors
  37712. * @see https://doc.babylonjs.com/features/behaviour
  37713. */
  37714. get behaviors(): Behavior<Node>[];
  37715. /**
  37716. * Gets an attached behavior by name
  37717. * @param name defines the name of the behavior to look for
  37718. * @see https://doc.babylonjs.com/features/behaviour
  37719. * @returns null if behavior was not found else the requested behavior
  37720. */
  37721. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37722. /**
  37723. * Returns the latest update of the World matrix
  37724. * @returns a Matrix
  37725. */
  37726. getWorldMatrix(): Matrix;
  37727. /** @hidden */
  37728. _getWorldMatrixDeterminant(): number;
  37729. /**
  37730. * Returns directly the latest state of the mesh World matrix.
  37731. * A Matrix is returned.
  37732. */
  37733. get worldMatrixFromCache(): Matrix;
  37734. /** @hidden */
  37735. _initCache(): void;
  37736. /** @hidden */
  37737. updateCache(force?: boolean): void;
  37738. /** @hidden */
  37739. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37740. /** @hidden */
  37741. _updateCache(ignoreParentClass?: boolean): void;
  37742. /** @hidden */
  37743. _isSynchronized(): boolean;
  37744. /** @hidden */
  37745. _markSyncedWithParent(): void;
  37746. /** @hidden */
  37747. isSynchronizedWithParent(): boolean;
  37748. /** @hidden */
  37749. isSynchronized(): boolean;
  37750. /**
  37751. * Is this node ready to be used/rendered
  37752. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37753. * @return true if the node is ready
  37754. */
  37755. isReady(completeCheck?: boolean): boolean;
  37756. /**
  37757. * Is this node enabled?
  37758. * 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
  37759. * @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
  37760. * @return whether this node (and its parent) is enabled
  37761. */
  37762. isEnabled(checkAncestors?: boolean): boolean;
  37763. /** @hidden */
  37764. protected _syncParentEnabledState(): void;
  37765. /**
  37766. * Set the enabled state of this node
  37767. * @param value defines the new enabled state
  37768. */
  37769. setEnabled(value: boolean): void;
  37770. /**
  37771. * Is this node a descendant of the given node?
  37772. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37773. * @param ancestor defines the parent node to inspect
  37774. * @returns a boolean indicating if this node is a descendant of the given node
  37775. */
  37776. isDescendantOf(ancestor: Node): boolean;
  37777. /** @hidden */
  37778. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37779. /**
  37780. * Will return all nodes that have this node as ascendant
  37781. * @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
  37782. * @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
  37783. * @return all children nodes of all types
  37784. */
  37785. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37786. /**
  37787. * Get all child-meshes of this node
  37788. * @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)
  37789. * @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
  37790. * @returns an array of AbstractMesh
  37791. */
  37792. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37793. /**
  37794. * Get all direct children of this node
  37795. * @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
  37796. * @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)
  37797. * @returns an array of Node
  37798. */
  37799. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37800. /** @hidden */
  37801. _setReady(state: boolean): void;
  37802. /**
  37803. * Get an animation by name
  37804. * @param name defines the name of the animation to look for
  37805. * @returns null if not found else the requested animation
  37806. */
  37807. getAnimationByName(name: string): Nullable<Animation>;
  37808. /**
  37809. * Creates an animation range for this node
  37810. * @param name defines the name of the range
  37811. * @param from defines the starting key
  37812. * @param to defines the end key
  37813. */
  37814. createAnimationRange(name: string, from: number, to: number): void;
  37815. /**
  37816. * Delete a specific animation range
  37817. * @param name defines the name of the range to delete
  37818. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37819. */
  37820. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37821. /**
  37822. * Get an animation range by name
  37823. * @param name defines the name of the animation range to look for
  37824. * @returns null if not found else the requested animation range
  37825. */
  37826. getAnimationRange(name: string): Nullable<AnimationRange>;
  37827. /**
  37828. * Gets the list of all animation ranges defined on this node
  37829. * @returns an array
  37830. */
  37831. getAnimationRanges(): Nullable<AnimationRange>[];
  37832. /**
  37833. * Will start the animation sequence
  37834. * @param name defines the range frames for animation sequence
  37835. * @param loop defines if the animation should loop (false by default)
  37836. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37837. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37838. * @returns the object created for this animation. If range does not exist, it will return null
  37839. */
  37840. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37841. /**
  37842. * Serialize animation ranges into a JSON compatible object
  37843. * @returns serialization object
  37844. */
  37845. serializeAnimationRanges(): any;
  37846. /**
  37847. * Computes the world matrix of the node
  37848. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37849. * @returns the world matrix
  37850. */
  37851. computeWorldMatrix(force?: boolean): Matrix;
  37852. /**
  37853. * Releases resources associated with this node.
  37854. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37855. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37856. */
  37857. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37858. /**
  37859. * Parse animation range data from a serialization object and store them into a given node
  37860. * @param node defines where to store the animation ranges
  37861. * @param parsedNode defines the serialization object to read data from
  37862. * @param scene defines the hosting scene
  37863. */
  37864. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37865. /**
  37866. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37867. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37868. * @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
  37869. * @returns the new bounding vectors
  37870. */
  37871. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37872. min: Vector3;
  37873. max: Vector3;
  37874. };
  37875. }
  37876. }
  37877. declare module "babylonjs/Animations/animation" {
  37878. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  37879. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  37880. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  37881. import { Nullable } from "babylonjs/types";
  37882. import { Scene } from "babylonjs/scene";
  37883. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  37884. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37885. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  37886. import { Node } from "babylonjs/node";
  37887. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  37888. import { Size } from "babylonjs/Maths/math.size";
  37889. import { Animatable } from "babylonjs/Animations/animatable";
  37890. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  37891. /**
  37892. * @hidden
  37893. */
  37894. export class _IAnimationState {
  37895. key: number;
  37896. repeatCount: number;
  37897. workValue?: any;
  37898. loopMode?: number;
  37899. offsetValue?: any;
  37900. highLimitValue?: any;
  37901. }
  37902. /**
  37903. * Class used to store any kind of animation
  37904. */
  37905. export class Animation {
  37906. /**Name of the animation */
  37907. name: string;
  37908. /**Property to animate */
  37909. targetProperty: string;
  37910. /**The frames per second of the animation */
  37911. framePerSecond: number;
  37912. /**The data type of the animation */
  37913. dataType: number;
  37914. /**The loop mode of the animation */
  37915. loopMode?: number | undefined;
  37916. /**Specifies if blending should be enabled */
  37917. enableBlending?: boolean | undefined;
  37918. /**
  37919. * Use matrix interpolation instead of using direct key value when animating matrices
  37920. */
  37921. static AllowMatricesInterpolation: boolean;
  37922. /**
  37923. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37924. */
  37925. static AllowMatrixDecomposeForInterpolation: boolean;
  37926. /** Define the Url to load snippets */
  37927. static SnippetUrl: string;
  37928. /** Snippet ID if the animation was created from the snippet server */
  37929. snippetId: string;
  37930. /**
  37931. * Stores the key frames of the animation
  37932. */
  37933. private _keys;
  37934. /**
  37935. * Stores the easing function of the animation
  37936. */
  37937. private _easingFunction;
  37938. /**
  37939. * @hidden Internal use only
  37940. */
  37941. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  37942. /**
  37943. * The set of event that will be linked to this animation
  37944. */
  37945. private _events;
  37946. /**
  37947. * Stores an array of target property paths
  37948. */
  37949. targetPropertyPath: string[];
  37950. /**
  37951. * Stores the blending speed of the animation
  37952. */
  37953. blendingSpeed: number;
  37954. /**
  37955. * Stores the animation ranges for the animation
  37956. */
  37957. private _ranges;
  37958. /**
  37959. * @hidden Internal use
  37960. */
  37961. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37962. /**
  37963. * Sets up an animation
  37964. * @param property The property to animate
  37965. * @param animationType The animation type to apply
  37966. * @param framePerSecond The frames per second of the animation
  37967. * @param easingFunction The easing function used in the animation
  37968. * @returns The created animation
  37969. */
  37970. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37971. /**
  37972. * Create and start an animation on a node
  37973. * @param name defines the name of the global animation that will be run on all nodes
  37974. * @param node defines the root node where the animation will take place
  37975. * @param targetProperty defines property to animate
  37976. * @param framePerSecond defines the number of frame per second yo use
  37977. * @param totalFrame defines the number of frames in total
  37978. * @param from defines the initial value
  37979. * @param to defines the final value
  37980. * @param loopMode defines which loop mode you want to use (off by default)
  37981. * @param easingFunction defines the easing function to use (linear by default)
  37982. * @param onAnimationEnd defines the callback to call when animation end
  37983. * @returns the animatable created for this animation
  37984. */
  37985. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37986. /**
  37987. * Create and start an animation on a node and its descendants
  37988. * @param name defines the name of the global animation that will be run on all nodes
  37989. * @param node defines the root node where the animation will take place
  37990. * @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
  37991. * @param targetProperty defines property to animate
  37992. * @param framePerSecond defines the number of frame per second to use
  37993. * @param totalFrame defines the number of frames in total
  37994. * @param from defines the initial value
  37995. * @param to defines the final value
  37996. * @param loopMode defines which loop mode you want to use (off by default)
  37997. * @param easingFunction defines the easing function to use (linear by default)
  37998. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37999. * @returns the list of animatables created for all nodes
  38000. * @example https://www.babylonjs-playground.com/#MH0VLI
  38001. */
  38002. 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[]>;
  38003. /**
  38004. * Creates a new animation, merges it with the existing animations and starts it
  38005. * @param name Name of the animation
  38006. * @param node Node which contains the scene that begins the animations
  38007. * @param targetProperty Specifies which property to animate
  38008. * @param framePerSecond The frames per second of the animation
  38009. * @param totalFrame The total number of frames
  38010. * @param from The frame at the beginning of the animation
  38011. * @param to The frame at the end of the animation
  38012. * @param loopMode Specifies the loop mode of the animation
  38013. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  38014. * @param onAnimationEnd Callback to run once the animation is complete
  38015. * @returns Nullable animation
  38016. */
  38017. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38018. /**
  38019. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38020. * @param sourceAnimation defines the Animation containing keyframes to convert
  38021. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38022. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  38023. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  38024. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  38025. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  38026. */
  38027. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  38028. /**
  38029. * Transition property of an host to the target Value
  38030. * @param property The property to transition
  38031. * @param targetValue The target Value of the property
  38032. * @param host The object where the property to animate belongs
  38033. * @param scene Scene used to run the animation
  38034. * @param frameRate Framerate (in frame/s) to use
  38035. * @param transition The transition type we want to use
  38036. * @param duration The duration of the animation, in milliseconds
  38037. * @param onAnimationEnd Callback trigger at the end of the animation
  38038. * @returns Nullable animation
  38039. */
  38040. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  38041. /**
  38042. * Return the array of runtime animations currently using this animation
  38043. */
  38044. get runtimeAnimations(): RuntimeAnimation[];
  38045. /**
  38046. * Specifies if any of the runtime animations are currently running
  38047. */
  38048. get hasRunningRuntimeAnimations(): boolean;
  38049. /**
  38050. * Initializes the animation
  38051. * @param name Name of the animation
  38052. * @param targetProperty Property to animate
  38053. * @param framePerSecond The frames per second of the animation
  38054. * @param dataType The data type of the animation
  38055. * @param loopMode The loop mode of the animation
  38056. * @param enableBlending Specifies if blending should be enabled
  38057. */
  38058. constructor(
  38059. /**Name of the animation */
  38060. name: string,
  38061. /**Property to animate */
  38062. targetProperty: string,
  38063. /**The frames per second of the animation */
  38064. framePerSecond: number,
  38065. /**The data type of the animation */
  38066. dataType: number,
  38067. /**The loop mode of the animation */
  38068. loopMode?: number | undefined,
  38069. /**Specifies if blending should be enabled */
  38070. enableBlending?: boolean | undefined);
  38071. /**
  38072. * Converts the animation to a string
  38073. * @param fullDetails support for multiple levels of logging within scene loading
  38074. * @returns String form of the animation
  38075. */
  38076. toString(fullDetails?: boolean): string;
  38077. /**
  38078. * Add an event to this animation
  38079. * @param event Event to add
  38080. */
  38081. addEvent(event: AnimationEvent): void;
  38082. /**
  38083. * Remove all events found at the given frame
  38084. * @param frame The frame to remove events from
  38085. */
  38086. removeEvents(frame: number): void;
  38087. /**
  38088. * Retrieves all the events from the animation
  38089. * @returns Events from the animation
  38090. */
  38091. getEvents(): AnimationEvent[];
  38092. /**
  38093. * Creates an animation range
  38094. * @param name Name of the animation range
  38095. * @param from Starting frame of the animation range
  38096. * @param to Ending frame of the animation
  38097. */
  38098. createRange(name: string, from: number, to: number): void;
  38099. /**
  38100. * Deletes an animation range by name
  38101. * @param name Name of the animation range to delete
  38102. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38103. */
  38104. deleteRange(name: string, deleteFrames?: boolean): void;
  38105. /**
  38106. * Gets the animation range by name, or null if not defined
  38107. * @param name Name of the animation range
  38108. * @returns Nullable animation range
  38109. */
  38110. getRange(name: string): Nullable<AnimationRange>;
  38111. /**
  38112. * Gets the key frames from the animation
  38113. * @returns The key frames of the animation
  38114. */
  38115. getKeys(): Array<IAnimationKey>;
  38116. /**
  38117. * Gets the highest frame rate of the animation
  38118. * @returns Highest frame rate of the animation
  38119. */
  38120. getHighestFrame(): number;
  38121. /**
  38122. * Gets the easing function of the animation
  38123. * @returns Easing function of the animation
  38124. */
  38125. getEasingFunction(): IEasingFunction;
  38126. /**
  38127. * Sets the easing function of the animation
  38128. * @param easingFunction A custom mathematical formula for animation
  38129. */
  38130. setEasingFunction(easingFunction: EasingFunction): void;
  38131. /**
  38132. * Interpolates a scalar linearly
  38133. * @param startValue Start value of the animation curve
  38134. * @param endValue End value of the animation curve
  38135. * @param gradient Scalar amount to interpolate
  38136. * @returns Interpolated scalar value
  38137. */
  38138. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38139. /**
  38140. * Interpolates a scalar cubically
  38141. * @param startValue Start value of the animation curve
  38142. * @param outTangent End tangent of the animation
  38143. * @param endValue End value of the animation curve
  38144. * @param inTangent Start tangent of the animation curve
  38145. * @param gradient Scalar amount to interpolate
  38146. * @returns Interpolated scalar value
  38147. */
  38148. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38149. /**
  38150. * Interpolates a quaternion using a spherical linear interpolation
  38151. * @param startValue Start value of the animation curve
  38152. * @param endValue End value of the animation curve
  38153. * @param gradient Scalar amount to interpolate
  38154. * @returns Interpolated quaternion value
  38155. */
  38156. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38157. /**
  38158. * Interpolates a quaternion cubically
  38159. * @param startValue Start value of the animation curve
  38160. * @param outTangent End tangent of the animation curve
  38161. * @param endValue End value of the animation curve
  38162. * @param inTangent Start tangent of the animation curve
  38163. * @param gradient Scalar amount to interpolate
  38164. * @returns Interpolated quaternion value
  38165. */
  38166. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38167. /**
  38168. * Interpolates a Vector3 linearl
  38169. * @param startValue Start value of the animation curve
  38170. * @param endValue End value of the animation curve
  38171. * @param gradient Scalar amount to interpolate
  38172. * @returns Interpolated scalar value
  38173. */
  38174. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38175. /**
  38176. * Interpolates a Vector3 cubically
  38177. * @param startValue Start value of the animation curve
  38178. * @param outTangent End tangent of the animation
  38179. * @param endValue End value of the animation curve
  38180. * @param inTangent Start tangent of the animation curve
  38181. * @param gradient Scalar amount to interpolate
  38182. * @returns InterpolatedVector3 value
  38183. */
  38184. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38185. /**
  38186. * Interpolates a Vector2 linearly
  38187. * @param startValue Start value of the animation curve
  38188. * @param endValue End value of the animation curve
  38189. * @param gradient Scalar amount to interpolate
  38190. * @returns Interpolated Vector2 value
  38191. */
  38192. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38193. /**
  38194. * Interpolates a Vector2 cubically
  38195. * @param startValue Start value of the animation curve
  38196. * @param outTangent End tangent of the animation
  38197. * @param endValue End value of the animation curve
  38198. * @param inTangent Start tangent of the animation curve
  38199. * @param gradient Scalar amount to interpolate
  38200. * @returns Interpolated Vector2 value
  38201. */
  38202. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38203. /**
  38204. * Interpolates a size linearly
  38205. * @param startValue Start value of the animation curve
  38206. * @param endValue End value of the animation curve
  38207. * @param gradient Scalar amount to interpolate
  38208. * @returns Interpolated Size value
  38209. */
  38210. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38211. /**
  38212. * Interpolates a Color3 linearly
  38213. * @param startValue Start value of the animation curve
  38214. * @param endValue End value of the animation curve
  38215. * @param gradient Scalar amount to interpolate
  38216. * @returns Interpolated Color3 value
  38217. */
  38218. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38219. /**
  38220. * Interpolates a Color4 linearly
  38221. * @param startValue Start value of the animation curve
  38222. * @param endValue End value of the animation curve
  38223. * @param gradient Scalar amount to interpolate
  38224. * @returns Interpolated Color3 value
  38225. */
  38226. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38227. /**
  38228. * @hidden Internal use only
  38229. */
  38230. _getKeyValue(value: any): any;
  38231. /**
  38232. * @hidden Internal use only
  38233. */
  38234. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38235. /**
  38236. * Defines the function to use to interpolate matrices
  38237. * @param startValue defines the start matrix
  38238. * @param endValue defines the end matrix
  38239. * @param gradient defines the gradient between both matrices
  38240. * @param result defines an optional target matrix where to store the interpolation
  38241. * @returns the interpolated matrix
  38242. */
  38243. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38244. /**
  38245. * Makes a copy of the animation
  38246. * @returns Cloned animation
  38247. */
  38248. clone(): Animation;
  38249. /**
  38250. * Sets the key frames of the animation
  38251. * @param values The animation key frames to set
  38252. */
  38253. setKeys(values: Array<IAnimationKey>): void;
  38254. /**
  38255. * Serializes the animation to an object
  38256. * @returns Serialized object
  38257. */
  38258. serialize(): any;
  38259. /**
  38260. * Float animation type
  38261. */
  38262. static readonly ANIMATIONTYPE_FLOAT: number;
  38263. /**
  38264. * Vector3 animation type
  38265. */
  38266. static readonly ANIMATIONTYPE_VECTOR3: number;
  38267. /**
  38268. * Quaternion animation type
  38269. */
  38270. static readonly ANIMATIONTYPE_QUATERNION: number;
  38271. /**
  38272. * Matrix animation type
  38273. */
  38274. static readonly ANIMATIONTYPE_MATRIX: number;
  38275. /**
  38276. * Color3 animation type
  38277. */
  38278. static readonly ANIMATIONTYPE_COLOR3: number;
  38279. /**
  38280. * Color3 animation type
  38281. */
  38282. static readonly ANIMATIONTYPE_COLOR4: number;
  38283. /**
  38284. * Vector2 animation type
  38285. */
  38286. static readonly ANIMATIONTYPE_VECTOR2: number;
  38287. /**
  38288. * Size animation type
  38289. */
  38290. static readonly ANIMATIONTYPE_SIZE: number;
  38291. /**
  38292. * Relative Loop Mode
  38293. */
  38294. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38295. /**
  38296. * Cycle Loop Mode
  38297. */
  38298. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38299. /**
  38300. * Constant Loop Mode
  38301. */
  38302. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38303. /** @hidden */
  38304. static _UniversalLerp(left: any, right: any, amount: number): any;
  38305. /**
  38306. * Parses an animation object and creates an animation
  38307. * @param parsedAnimation Parsed animation object
  38308. * @returns Animation object
  38309. */
  38310. static Parse(parsedAnimation: any): Animation;
  38311. /**
  38312. * Appends the serialized animations from the source animations
  38313. * @param source Source containing the animations
  38314. * @param destination Target to store the animations
  38315. */
  38316. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38317. /**
  38318. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38319. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38320. * @param url defines the url to load from
  38321. * @returns a promise that will resolve to the new animation or an array of animations
  38322. */
  38323. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38324. /**
  38325. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38326. * @param snippetId defines the snippet to load
  38327. * @returns a promise that will resolve to the new animation or a new array of animations
  38328. */
  38329. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38330. }
  38331. }
  38332. declare module "babylonjs/Animations/animatable.interface" {
  38333. import { Nullable } from "babylonjs/types";
  38334. import { Animation } from "babylonjs/Animations/animation";
  38335. /**
  38336. * Interface containing an array of animations
  38337. */
  38338. export interface IAnimatable {
  38339. /**
  38340. * Array of animations
  38341. */
  38342. animations: Nullable<Array<Animation>>;
  38343. }
  38344. }
  38345. declare module "babylonjs/Misc/decorators" {
  38346. import { Nullable } from "babylonjs/types";
  38347. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38348. import { Scene } from "babylonjs/scene";
  38349. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  38350. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38351. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38352. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38353. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38354. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38355. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38356. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38357. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38358. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38359. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38360. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38361. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38362. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38363. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38364. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38365. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38366. /**
  38367. * Decorator used to define property that can be serialized as reference to a camera
  38368. * @param sourceName defines the name of the property to decorate
  38369. */
  38370. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38371. /**
  38372. * Class used to help serialization objects
  38373. */
  38374. export class SerializationHelper {
  38375. /** @hidden */
  38376. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38377. /** @hidden */
  38378. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38379. /** @hidden */
  38380. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38381. /** @hidden */
  38382. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38383. /**
  38384. * Appends the serialized animations from the source animations
  38385. * @param source Source containing the animations
  38386. * @param destination Target to store the animations
  38387. */
  38388. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38389. /**
  38390. * Static function used to serialized a specific entity
  38391. * @param entity defines the entity to serialize
  38392. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38393. * @returns a JSON compatible object representing the serialization of the entity
  38394. */
  38395. static Serialize<T>(entity: T, serializationObject?: any): any;
  38396. /**
  38397. * Creates a new entity from a serialization data object
  38398. * @param creationFunction defines a function used to instanciated the new entity
  38399. * @param source defines the source serialization data
  38400. * @param scene defines the hosting scene
  38401. * @param rootUrl defines the root url for resources
  38402. * @returns a new entity
  38403. */
  38404. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38405. /**
  38406. * Clones an object
  38407. * @param creationFunction defines the function used to instanciate the new object
  38408. * @param source defines the source object
  38409. * @returns the cloned object
  38410. */
  38411. static Clone<T>(creationFunction: () => T, source: T): T;
  38412. /**
  38413. * Instanciates a new object based on a source one (some data will be shared between both object)
  38414. * @param creationFunction defines the function used to instanciate the new object
  38415. * @param source defines the source object
  38416. * @returns the new object
  38417. */
  38418. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38419. }
  38420. }
  38421. declare module "babylonjs/Materials/Textures/baseTexture" {
  38422. import { Observable } from "babylonjs/Misc/observable";
  38423. import { Nullable } from "babylonjs/types";
  38424. import { Scene } from "babylonjs/scene";
  38425. import { Matrix } from "babylonjs/Maths/math.vector";
  38426. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38427. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38428. import { ISize } from "babylonjs/Maths/math.size";
  38429. import "babylonjs/Misc/fileTools";
  38430. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38431. /**
  38432. * Base class of all the textures in babylon.
  38433. * It groups all the common properties the materials, post process, lights... might need
  38434. * in order to make a correct use of the texture.
  38435. */
  38436. export class BaseTexture implements IAnimatable {
  38437. /**
  38438. * Default anisotropic filtering level for the application.
  38439. * It is set to 4 as a good tradeoff between perf and quality.
  38440. */
  38441. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  38442. /**
  38443. * Gets or sets the unique id of the texture
  38444. */
  38445. uniqueId: number;
  38446. /**
  38447. * Define the name of the texture.
  38448. */
  38449. name: string;
  38450. /**
  38451. * Gets or sets an object used to store user defined information.
  38452. */
  38453. metadata: any;
  38454. /**
  38455. * For internal use only. Please do not use.
  38456. */
  38457. reservedDataStore: any;
  38458. private _hasAlpha;
  38459. /**
  38460. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  38461. */
  38462. set hasAlpha(value: boolean);
  38463. get hasAlpha(): boolean;
  38464. /**
  38465. * Defines if the alpha value should be determined via the rgb values.
  38466. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  38467. */
  38468. getAlphaFromRGB: boolean;
  38469. /**
  38470. * Intensity or strength of the texture.
  38471. * It is commonly used by materials to fine tune the intensity of the texture
  38472. */
  38473. level: number;
  38474. /**
  38475. * Define the UV chanel to use starting from 0 and defaulting to 0.
  38476. * This is part of the texture as textures usually maps to one uv set.
  38477. */
  38478. coordinatesIndex: number;
  38479. protected _coordinatesMode: number;
  38480. /**
  38481. * How a texture is mapped.
  38482. *
  38483. * | Value | Type | Description |
  38484. * | ----- | ----------------------------------- | ----------- |
  38485. * | 0 | EXPLICIT_MODE | |
  38486. * | 1 | SPHERICAL_MODE | |
  38487. * | 2 | PLANAR_MODE | |
  38488. * | 3 | CUBIC_MODE | |
  38489. * | 4 | PROJECTION_MODE | |
  38490. * | 5 | SKYBOX_MODE | |
  38491. * | 6 | INVCUBIC_MODE | |
  38492. * | 7 | EQUIRECTANGULAR_MODE | |
  38493. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  38494. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  38495. */
  38496. set coordinatesMode(value: number);
  38497. get coordinatesMode(): number;
  38498. private _wrapU;
  38499. /**
  38500. * | Value | Type | Description |
  38501. * | ----- | ------------------ | ----------- |
  38502. * | 0 | CLAMP_ADDRESSMODE | |
  38503. * | 1 | WRAP_ADDRESSMODE | |
  38504. * | 2 | MIRROR_ADDRESSMODE | |
  38505. */
  38506. get wrapU(): number;
  38507. set wrapU(value: number);
  38508. private _wrapV;
  38509. /**
  38510. * | Value | Type | Description |
  38511. * | ----- | ------------------ | ----------- |
  38512. * | 0 | CLAMP_ADDRESSMODE | |
  38513. * | 1 | WRAP_ADDRESSMODE | |
  38514. * | 2 | MIRROR_ADDRESSMODE | |
  38515. */
  38516. get wrapV(): number;
  38517. set wrapV(value: number);
  38518. /**
  38519. * | Value | Type | Description |
  38520. * | ----- | ------------------ | ----------- |
  38521. * | 0 | CLAMP_ADDRESSMODE | |
  38522. * | 1 | WRAP_ADDRESSMODE | |
  38523. * | 2 | MIRROR_ADDRESSMODE | |
  38524. */
  38525. wrapR: number;
  38526. /**
  38527. * With compliant hardware and browser (supporting anisotropic filtering)
  38528. * this defines the level of anisotropic filtering in the texture.
  38529. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  38530. */
  38531. anisotropicFilteringLevel: number;
  38532. /**
  38533. * Define if the texture is a cube texture or if false a 2d texture.
  38534. */
  38535. get isCube(): boolean;
  38536. set isCube(value: boolean);
  38537. /**
  38538. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  38539. */
  38540. get is3D(): boolean;
  38541. set is3D(value: boolean);
  38542. /**
  38543. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  38544. */
  38545. get is2DArray(): boolean;
  38546. set is2DArray(value: boolean);
  38547. private _gammaSpace;
  38548. /**
  38549. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  38550. * HDR texture are usually stored in linear space.
  38551. * This only impacts the PBR and Background materials
  38552. */
  38553. get gammaSpace(): boolean;
  38554. set gammaSpace(gamma: boolean);
  38555. /**
  38556. * Gets or sets whether or not the texture contains RGBD data.
  38557. */
  38558. get isRGBD(): boolean;
  38559. set isRGBD(value: boolean);
  38560. /**
  38561. * Is Z inverted in the texture (useful in a cube texture).
  38562. */
  38563. invertZ: boolean;
  38564. /**
  38565. * Are mip maps generated for this texture or not.
  38566. */
  38567. get noMipmap(): boolean;
  38568. /**
  38569. * @hidden
  38570. */
  38571. lodLevelInAlpha: boolean;
  38572. /**
  38573. * With prefiltered texture, defined the offset used during the prefiltering steps.
  38574. */
  38575. get lodGenerationOffset(): number;
  38576. set lodGenerationOffset(value: number);
  38577. /**
  38578. * With prefiltered texture, defined the scale used during the prefiltering steps.
  38579. */
  38580. get lodGenerationScale(): number;
  38581. set lodGenerationScale(value: number);
  38582. /**
  38583. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  38584. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  38585. * average roughness values.
  38586. */
  38587. get linearSpecularLOD(): boolean;
  38588. set linearSpecularLOD(value: boolean);
  38589. /**
  38590. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  38591. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  38592. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  38593. */
  38594. get irradianceTexture(): Nullable<BaseTexture>;
  38595. set irradianceTexture(value: Nullable<BaseTexture>);
  38596. /**
  38597. * Define if the texture is a render target.
  38598. */
  38599. isRenderTarget: boolean;
  38600. /**
  38601. * Define the unique id of the texture in the scene.
  38602. */
  38603. get uid(): string;
  38604. /** @hidden */
  38605. _prefiltered: boolean;
  38606. /**
  38607. * Return a string representation of the texture.
  38608. * @returns the texture as a string
  38609. */
  38610. toString(): string;
  38611. /**
  38612. * Get the class name of the texture.
  38613. * @returns "BaseTexture"
  38614. */
  38615. getClassName(): string;
  38616. /**
  38617. * Define the list of animation attached to the texture.
  38618. */
  38619. animations: import("babylonjs/Animations/animation").Animation[];
  38620. /**
  38621. * An event triggered when the texture is disposed.
  38622. */
  38623. onDisposeObservable: Observable<BaseTexture>;
  38624. private _onDisposeObserver;
  38625. /**
  38626. * Callback triggered when the texture has been disposed.
  38627. * Kept for back compatibility, you can use the onDisposeObservable instead.
  38628. */
  38629. set onDispose(callback: () => void);
  38630. /**
  38631. * Define the current state of the loading sequence when in delayed load mode.
  38632. */
  38633. delayLoadState: number;
  38634. protected _scene: Nullable<Scene>;
  38635. protected _engine: Nullable<ThinEngine>;
  38636. /** @hidden */
  38637. _texture: Nullable<InternalTexture>;
  38638. private _uid;
  38639. /**
  38640. * Define if the texture is preventinga material to render or not.
  38641. * If not and the texture is not ready, the engine will use a default black texture instead.
  38642. */
  38643. get isBlocking(): boolean;
  38644. /**
  38645. * Instantiates a new BaseTexture.
  38646. * Base class of all the textures in babylon.
  38647. * It groups all the common properties the materials, post process, lights... might need
  38648. * in order to make a correct use of the texture.
  38649. * @param sceneOrEngine Define the scene or engine the texture blongs to
  38650. */
  38651. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  38652. /**
  38653. * Get the scene the texture belongs to.
  38654. * @returns the scene or null if undefined
  38655. */
  38656. getScene(): Nullable<Scene>;
  38657. /** @hidden */
  38658. protected _getEngine(): Nullable<ThinEngine>;
  38659. /**
  38660. * Checks if the texture has the same transform matrix than another texture
  38661. * @param texture texture to check against
  38662. * @returns true if the transforms are the same, else false
  38663. */
  38664. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  38665. /**
  38666. * Get the texture transform matrix used to offset tile the texture for istance.
  38667. * @returns the transformation matrix
  38668. */
  38669. getTextureMatrix(): Matrix;
  38670. /**
  38671. * Get the texture reflection matrix used to rotate/transform the reflection.
  38672. * @returns the reflection matrix
  38673. */
  38674. getReflectionTextureMatrix(): Matrix;
  38675. /**
  38676. * Get the underlying lower level texture from Babylon.
  38677. * @returns the insternal texture
  38678. */
  38679. getInternalTexture(): Nullable<InternalTexture>;
  38680. /**
  38681. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  38682. * @returns true if ready or not blocking
  38683. */
  38684. isReadyOrNotBlocking(): boolean;
  38685. /**
  38686. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  38687. * @returns true if fully ready
  38688. */
  38689. isReady(): boolean;
  38690. private _cachedSize;
  38691. /**
  38692. * Get the size of the texture.
  38693. * @returns the texture size.
  38694. */
  38695. getSize(): ISize;
  38696. /**
  38697. * Get the base size of the texture.
  38698. * It can be different from the size if the texture has been resized for POT for instance
  38699. * @returns the base size
  38700. */
  38701. getBaseSize(): ISize;
  38702. /**
  38703. * Update the sampling mode of the texture.
  38704. * Default is Trilinear mode.
  38705. *
  38706. * | Value | Type | Description |
  38707. * | ----- | ------------------ | ----------- |
  38708. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  38709. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  38710. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  38711. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  38712. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  38713. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  38714. * | 7 | NEAREST_LINEAR | |
  38715. * | 8 | NEAREST_NEAREST | |
  38716. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  38717. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  38718. * | 11 | LINEAR_LINEAR | |
  38719. * | 12 | LINEAR_NEAREST | |
  38720. *
  38721. * > _mag_: magnification filter (close to the viewer)
  38722. * > _min_: minification filter (far from the viewer)
  38723. * > _mip_: filter used between mip map levels
  38724. *@param samplingMode Define the new sampling mode of the texture
  38725. */
  38726. updateSamplingMode(samplingMode: number): void;
  38727. /**
  38728. * Scales the texture if is `canRescale()`
  38729. * @param ratio the resize factor we want to use to rescale
  38730. */
  38731. scale(ratio: number): void;
  38732. /**
  38733. * Get if the texture can rescale.
  38734. */
  38735. get canRescale(): boolean;
  38736. /** @hidden */
  38737. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  38738. /** @hidden */
  38739. _rebuild(): void;
  38740. /**
  38741. * Triggers the load sequence in delayed load mode.
  38742. */
  38743. delayLoad(): void;
  38744. /**
  38745. * Clones the texture.
  38746. * @returns the cloned texture
  38747. */
  38748. clone(): Nullable<BaseTexture>;
  38749. /**
  38750. * Get the texture underlying type (INT, FLOAT...)
  38751. */
  38752. get textureType(): number;
  38753. /**
  38754. * Get the texture underlying format (RGB, RGBA...)
  38755. */
  38756. get textureFormat(): number;
  38757. /**
  38758. * Indicates that textures need to be re-calculated for all materials
  38759. */
  38760. protected _markAllSubMeshesAsTexturesDirty(): void;
  38761. /**
  38762. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  38763. * This will returns an RGBA array buffer containing either in values (0-255) or
  38764. * float values (0-1) depending of the underlying buffer type.
  38765. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  38766. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  38767. * @param buffer defines a user defined buffer to fill with data (can be null)
  38768. * @returns The Array buffer containing the pixels data.
  38769. */
  38770. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  38771. /**
  38772. * Release and destroy the underlying lower level texture aka internalTexture.
  38773. */
  38774. releaseInternalTexture(): void;
  38775. /** @hidden */
  38776. get _lodTextureHigh(): Nullable<BaseTexture>;
  38777. /** @hidden */
  38778. get _lodTextureMid(): Nullable<BaseTexture>;
  38779. /** @hidden */
  38780. get _lodTextureLow(): Nullable<BaseTexture>;
  38781. /**
  38782. * Dispose the texture and release its associated resources.
  38783. */
  38784. dispose(): void;
  38785. /**
  38786. * Serialize the texture into a JSON representation that can be parsed later on.
  38787. * @returns the JSON representation of the texture
  38788. */
  38789. serialize(): any;
  38790. /**
  38791. * Helper function to be called back once a list of texture contains only ready textures.
  38792. * @param textures Define the list of textures to wait for
  38793. * @param callback Define the callback triggered once the entire list will be ready
  38794. */
  38795. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  38796. private static _isScene;
  38797. }
  38798. }
  38799. declare module "babylonjs/Materials/effect" {
  38800. import { Observable } from "babylonjs/Misc/observable";
  38801. import { Nullable } from "babylonjs/types";
  38802. import { IDisposable } from "babylonjs/scene";
  38803. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38804. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38805. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  38806. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38807. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  38808. import { Engine } from "babylonjs/Engines/engine";
  38809. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38810. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38811. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38812. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38813. /**
  38814. * Options to be used when creating an effect.
  38815. */
  38816. export interface IEffectCreationOptions {
  38817. /**
  38818. * Atrributes that will be used in the shader.
  38819. */
  38820. attributes: string[];
  38821. /**
  38822. * Uniform varible names that will be set in the shader.
  38823. */
  38824. uniformsNames: string[];
  38825. /**
  38826. * Uniform buffer variable names that will be set in the shader.
  38827. */
  38828. uniformBuffersNames: string[];
  38829. /**
  38830. * Sampler texture variable names that will be set in the shader.
  38831. */
  38832. samplers: string[];
  38833. /**
  38834. * Define statements that will be set in the shader.
  38835. */
  38836. defines: any;
  38837. /**
  38838. * Possible fallbacks for this effect to improve performance when needed.
  38839. */
  38840. fallbacks: Nullable<IEffectFallbacks>;
  38841. /**
  38842. * Callback that will be called when the shader is compiled.
  38843. */
  38844. onCompiled: Nullable<(effect: Effect) => void>;
  38845. /**
  38846. * Callback that will be called if an error occurs during shader compilation.
  38847. */
  38848. onError: Nullable<(effect: Effect, errors: string) => void>;
  38849. /**
  38850. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38851. */
  38852. indexParameters?: any;
  38853. /**
  38854. * Max number of lights that can be used in the shader.
  38855. */
  38856. maxSimultaneousLights?: number;
  38857. /**
  38858. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38859. */
  38860. transformFeedbackVaryings?: Nullable<string[]>;
  38861. /**
  38862. * 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
  38863. */
  38864. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38865. /**
  38866. * Is this effect rendering to several color attachments ?
  38867. */
  38868. multiTarget?: boolean;
  38869. }
  38870. /**
  38871. * Effect containing vertex and fragment shader that can be executed on an object.
  38872. */
  38873. export class Effect implements IDisposable {
  38874. /**
  38875. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38876. */
  38877. static ShadersRepository: string;
  38878. /**
  38879. * Enable logging of the shader code when a compilation error occurs
  38880. */
  38881. static LogShaderCodeOnCompilationError: boolean;
  38882. /**
  38883. * Name of the effect.
  38884. */
  38885. name: any;
  38886. /**
  38887. * String container all the define statements that should be set on the shader.
  38888. */
  38889. defines: string;
  38890. /**
  38891. * Callback that will be called when the shader is compiled.
  38892. */
  38893. onCompiled: Nullable<(effect: Effect) => void>;
  38894. /**
  38895. * Callback that will be called if an error occurs during shader compilation.
  38896. */
  38897. onError: Nullable<(effect: Effect, errors: string) => void>;
  38898. /**
  38899. * Callback that will be called when effect is bound.
  38900. */
  38901. onBind: Nullable<(effect: Effect) => void>;
  38902. /**
  38903. * Unique ID of the effect.
  38904. */
  38905. uniqueId: number;
  38906. /**
  38907. * Observable that will be called when the shader is compiled.
  38908. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38909. */
  38910. onCompileObservable: Observable<Effect>;
  38911. /**
  38912. * Observable that will be called if an error occurs during shader compilation.
  38913. */
  38914. onErrorObservable: Observable<Effect>;
  38915. /** @hidden */
  38916. _onBindObservable: Nullable<Observable<Effect>>;
  38917. /**
  38918. * @hidden
  38919. * Specifies if the effect was previously ready
  38920. */
  38921. _wasPreviouslyReady: boolean;
  38922. /**
  38923. * Observable that will be called when effect is bound.
  38924. */
  38925. get onBindObservable(): Observable<Effect>;
  38926. /** @hidden */
  38927. _bonesComputationForcedToCPU: boolean;
  38928. /** @hidden */
  38929. _multiTarget: boolean;
  38930. private static _uniqueIdSeed;
  38931. private _engine;
  38932. private _uniformBuffersNames;
  38933. private _uniformBuffersNamesList;
  38934. private _uniformsNames;
  38935. private _samplerList;
  38936. private _samplers;
  38937. private _isReady;
  38938. private _compilationError;
  38939. private _allFallbacksProcessed;
  38940. private _attributesNames;
  38941. private _attributes;
  38942. private _attributeLocationByName;
  38943. private _uniforms;
  38944. /**
  38945. * Key for the effect.
  38946. * @hidden
  38947. */
  38948. _key: string;
  38949. private _indexParameters;
  38950. private _fallbacks;
  38951. private _vertexSourceCode;
  38952. private _fragmentSourceCode;
  38953. private _vertexSourceCodeOverride;
  38954. private _fragmentSourceCodeOverride;
  38955. private _transformFeedbackVaryings;
  38956. /**
  38957. * Compiled shader to webGL program.
  38958. * @hidden
  38959. */
  38960. _pipelineContext: Nullable<IPipelineContext>;
  38961. private _valueCache;
  38962. private static _baseCache;
  38963. /**
  38964. * Instantiates an effect.
  38965. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38966. * @param baseName Name of the effect.
  38967. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38968. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38969. * @param samplers List of sampler variables that will be passed to the shader.
  38970. * @param engine Engine to be used to render the effect
  38971. * @param defines Define statements to be added to the shader.
  38972. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38973. * @param onCompiled Callback that will be called when the shader is compiled.
  38974. * @param onError Callback that will be called if an error occurs during shader compilation.
  38975. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38976. */
  38977. 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);
  38978. private _useFinalCode;
  38979. /**
  38980. * Unique key for this effect
  38981. */
  38982. get key(): string;
  38983. /**
  38984. * If the effect has been compiled and prepared.
  38985. * @returns if the effect is compiled and prepared.
  38986. */
  38987. isReady(): boolean;
  38988. private _isReadyInternal;
  38989. /**
  38990. * The engine the effect was initialized with.
  38991. * @returns the engine.
  38992. */
  38993. getEngine(): Engine;
  38994. /**
  38995. * The pipeline context for this effect
  38996. * @returns the associated pipeline context
  38997. */
  38998. getPipelineContext(): Nullable<IPipelineContext>;
  38999. /**
  39000. * The set of names of attribute variables for the shader.
  39001. * @returns An array of attribute names.
  39002. */
  39003. getAttributesNames(): string[];
  39004. /**
  39005. * Returns the attribute at the given index.
  39006. * @param index The index of the attribute.
  39007. * @returns The location of the attribute.
  39008. */
  39009. getAttributeLocation(index: number): number;
  39010. /**
  39011. * Returns the attribute based on the name of the variable.
  39012. * @param name of the attribute to look up.
  39013. * @returns the attribute location.
  39014. */
  39015. getAttributeLocationByName(name: string): number;
  39016. /**
  39017. * The number of attributes.
  39018. * @returns the numnber of attributes.
  39019. */
  39020. getAttributesCount(): number;
  39021. /**
  39022. * Gets the index of a uniform variable.
  39023. * @param uniformName of the uniform to look up.
  39024. * @returns the index.
  39025. */
  39026. getUniformIndex(uniformName: string): number;
  39027. /**
  39028. * Returns the attribute based on the name of the variable.
  39029. * @param uniformName of the uniform to look up.
  39030. * @returns the location of the uniform.
  39031. */
  39032. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39033. /**
  39034. * Returns an array of sampler variable names
  39035. * @returns The array of sampler variable names.
  39036. */
  39037. getSamplers(): string[];
  39038. /**
  39039. * Returns an array of uniform variable names
  39040. * @returns The array of uniform variable names.
  39041. */
  39042. getUniformNames(): string[];
  39043. /**
  39044. * Returns an array of uniform buffer variable names
  39045. * @returns The array of uniform buffer variable names.
  39046. */
  39047. getUniformBuffersNames(): string[];
  39048. /**
  39049. * Returns the index parameters used to create the effect
  39050. * @returns The index parameters object
  39051. */
  39052. getIndexParameters(): any;
  39053. /**
  39054. * The error from the last compilation.
  39055. * @returns the error string.
  39056. */
  39057. getCompilationError(): string;
  39058. /**
  39059. * Gets a boolean indicating that all fallbacks were used during compilation
  39060. * @returns true if all fallbacks were used
  39061. */
  39062. allFallbacksProcessed(): boolean;
  39063. /**
  39064. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  39065. * @param func The callback to be used.
  39066. */
  39067. executeWhenCompiled(func: (effect: Effect) => void): void;
  39068. private _checkIsReady;
  39069. private _loadShader;
  39070. /**
  39071. * Gets the vertex shader source code of this effect
  39072. */
  39073. get vertexSourceCode(): string;
  39074. /**
  39075. * Gets the fragment shader source code of this effect
  39076. */
  39077. get fragmentSourceCode(): string;
  39078. /**
  39079. * Recompiles the webGL program
  39080. * @param vertexSourceCode The source code for the vertex shader.
  39081. * @param fragmentSourceCode The source code for the fragment shader.
  39082. * @param onCompiled Callback called when completed.
  39083. * @param onError Callback called on error.
  39084. * @hidden
  39085. */
  39086. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39087. /**
  39088. * Prepares the effect
  39089. * @hidden
  39090. */
  39091. _prepareEffect(): void;
  39092. private _getShaderCodeAndErrorLine;
  39093. private _processCompilationErrors;
  39094. /**
  39095. * Checks if the effect is supported. (Must be called after compilation)
  39096. */
  39097. get isSupported(): boolean;
  39098. /**
  39099. * Binds a texture to the engine to be used as output of the shader.
  39100. * @param channel Name of the output variable.
  39101. * @param texture Texture to bind.
  39102. * @hidden
  39103. */
  39104. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39105. /**
  39106. * Sets a texture on the engine to be used in the shader.
  39107. * @param channel Name of the sampler variable.
  39108. * @param texture Texture to set.
  39109. */
  39110. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  39111. /**
  39112. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39113. * @param channel Name of the sampler variable.
  39114. * @param texture Texture to set.
  39115. */
  39116. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39117. /**
  39118. * Sets an array of textures on the engine to be used in the shader.
  39119. * @param channel Name of the variable.
  39120. * @param textures Textures to set.
  39121. */
  39122. setTextureArray(channel: string, textures: BaseTexture[]): void;
  39123. /**
  39124. * 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)
  39125. * @param channel Name of the sampler variable.
  39126. * @param postProcess Post process to get the input texture from.
  39127. */
  39128. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39129. /**
  39130. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39131. * 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)
  39132. * @param channel Name of the sampler variable.
  39133. * @param postProcess Post process to get the output texture from.
  39134. */
  39135. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39136. /** @hidden */
  39137. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  39138. /** @hidden */
  39139. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  39140. /** @hidden */
  39141. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  39142. /** @hidden */
  39143. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  39144. /**
  39145. * Binds a buffer to a uniform.
  39146. * @param buffer Buffer to bind.
  39147. * @param name Name of the uniform variable to bind to.
  39148. */
  39149. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39150. /**
  39151. * Binds block to a uniform.
  39152. * @param blockName Name of the block to bind.
  39153. * @param index Index to bind.
  39154. */
  39155. bindUniformBlock(blockName: string, index: number): void;
  39156. /**
  39157. * Sets an interger value on a uniform variable.
  39158. * @param uniformName Name of the variable.
  39159. * @param value Value to be set.
  39160. * @returns this effect.
  39161. */
  39162. setInt(uniformName: string, value: number): Effect;
  39163. /**
  39164. * Sets an int array on a uniform variable.
  39165. * @param uniformName Name of the variable.
  39166. * @param array array to be set.
  39167. * @returns this effect.
  39168. */
  39169. setIntArray(uniformName: string, array: Int32Array): Effect;
  39170. /**
  39171. * 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)
  39172. * @param uniformName Name of the variable.
  39173. * @param array array to be set.
  39174. * @returns this effect.
  39175. */
  39176. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39177. /**
  39178. * 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)
  39179. * @param uniformName Name of the variable.
  39180. * @param array array to be set.
  39181. * @returns this effect.
  39182. */
  39183. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39184. /**
  39185. * 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)
  39186. * @param uniformName Name of the variable.
  39187. * @param array array to be set.
  39188. * @returns this effect.
  39189. */
  39190. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39191. /**
  39192. * Sets an float array on a uniform variable.
  39193. * @param uniformName Name of the variable.
  39194. * @param array array to be set.
  39195. * @returns this effect.
  39196. */
  39197. setFloatArray(uniformName: string, array: Float32Array): Effect;
  39198. /**
  39199. * 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)
  39200. * @param uniformName Name of the variable.
  39201. * @param array array to be set.
  39202. * @returns this effect.
  39203. */
  39204. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  39205. /**
  39206. * 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)
  39207. * @param uniformName Name of the variable.
  39208. * @param array array to be set.
  39209. * @returns this effect.
  39210. */
  39211. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  39212. /**
  39213. * 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)
  39214. * @param uniformName Name of the variable.
  39215. * @param array array to be set.
  39216. * @returns this effect.
  39217. */
  39218. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  39219. /**
  39220. * Sets an array on a uniform variable.
  39221. * @param uniformName Name of the variable.
  39222. * @param array array to be set.
  39223. * @returns this effect.
  39224. */
  39225. setArray(uniformName: string, array: number[]): Effect;
  39226. /**
  39227. * 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)
  39228. * @param uniformName Name of the variable.
  39229. * @param array array to be set.
  39230. * @returns this effect.
  39231. */
  39232. setArray2(uniformName: string, array: number[]): Effect;
  39233. /**
  39234. * 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)
  39235. * @param uniformName Name of the variable.
  39236. * @param array array to be set.
  39237. * @returns this effect.
  39238. */
  39239. setArray3(uniformName: string, array: number[]): Effect;
  39240. /**
  39241. * 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)
  39242. * @param uniformName Name of the variable.
  39243. * @param array array to be set.
  39244. * @returns this effect.
  39245. */
  39246. setArray4(uniformName: string, array: number[]): Effect;
  39247. /**
  39248. * Sets matrices on a uniform variable.
  39249. * @param uniformName Name of the variable.
  39250. * @param matrices matrices to be set.
  39251. * @returns this effect.
  39252. */
  39253. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39254. /**
  39255. * Sets matrix on a uniform variable.
  39256. * @param uniformName Name of the variable.
  39257. * @param matrix matrix to be set.
  39258. * @returns this effect.
  39259. */
  39260. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39261. /**
  39262. * 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)
  39263. * @param uniformName Name of the variable.
  39264. * @param matrix matrix to be set.
  39265. * @returns this effect.
  39266. */
  39267. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39268. /**
  39269. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39270. * @param uniformName Name of the variable.
  39271. * @param matrix matrix to be set.
  39272. * @returns this effect.
  39273. */
  39274. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39275. /**
  39276. * Sets a float on a uniform variable.
  39277. * @param uniformName Name of the variable.
  39278. * @param value value to be set.
  39279. * @returns this effect.
  39280. */
  39281. setFloat(uniformName: string, value: number): Effect;
  39282. /**
  39283. * Sets a boolean on a uniform variable.
  39284. * @param uniformName Name of the variable.
  39285. * @param bool value to be set.
  39286. * @returns this effect.
  39287. */
  39288. setBool(uniformName: string, bool: boolean): Effect;
  39289. /**
  39290. * Sets a Vector2 on a uniform variable.
  39291. * @param uniformName Name of the variable.
  39292. * @param vector2 vector2 to be set.
  39293. * @returns this effect.
  39294. */
  39295. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39296. /**
  39297. * Sets a float2 on a uniform variable.
  39298. * @param uniformName Name of the variable.
  39299. * @param x First float in float2.
  39300. * @param y Second float in float2.
  39301. * @returns this effect.
  39302. */
  39303. setFloat2(uniformName: string, x: number, y: number): Effect;
  39304. /**
  39305. * Sets a Vector3 on a uniform variable.
  39306. * @param uniformName Name of the variable.
  39307. * @param vector3 Value to be set.
  39308. * @returns this effect.
  39309. */
  39310. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39311. /**
  39312. * Sets a float3 on a uniform variable.
  39313. * @param uniformName Name of the variable.
  39314. * @param x First float in float3.
  39315. * @param y Second float in float3.
  39316. * @param z Third float in float3.
  39317. * @returns this effect.
  39318. */
  39319. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39320. /**
  39321. * Sets a Vector4 on a uniform variable.
  39322. * @param uniformName Name of the variable.
  39323. * @param vector4 Value to be set.
  39324. * @returns this effect.
  39325. */
  39326. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39327. /**
  39328. * Sets a float4 on a uniform variable.
  39329. * @param uniformName Name of the variable.
  39330. * @param x First float in float4.
  39331. * @param y Second float in float4.
  39332. * @param z Third float in float4.
  39333. * @param w Fourth float in float4.
  39334. * @returns this effect.
  39335. */
  39336. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39337. /**
  39338. * Sets a Color3 on a uniform variable.
  39339. * @param uniformName Name of the variable.
  39340. * @param color3 Value to be set.
  39341. * @returns this effect.
  39342. */
  39343. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39344. /**
  39345. * Sets a Color4 on a uniform variable.
  39346. * @param uniformName Name of the variable.
  39347. * @param color3 Value to be set.
  39348. * @param alpha Alpha value to be set.
  39349. * @returns this effect.
  39350. */
  39351. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39352. /**
  39353. * Sets a Color4 on a uniform variable
  39354. * @param uniformName defines the name of the variable
  39355. * @param color4 defines the value to be set
  39356. * @returns this effect.
  39357. */
  39358. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39359. /** Release all associated resources */
  39360. dispose(): void;
  39361. /**
  39362. * This function will add a new shader to the shader store
  39363. * @param name the name of the shader
  39364. * @param pixelShader optional pixel shader content
  39365. * @param vertexShader optional vertex shader content
  39366. */
  39367. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39368. /**
  39369. * Store of each shader (The can be looked up using effect.key)
  39370. */
  39371. static ShadersStore: {
  39372. [key: string]: string;
  39373. };
  39374. /**
  39375. * Store of each included file for a shader (The can be looked up using effect.key)
  39376. */
  39377. static IncludesShadersStore: {
  39378. [key: string]: string;
  39379. };
  39380. /**
  39381. * Resets the cache of effects.
  39382. */
  39383. static ResetCache(): void;
  39384. }
  39385. }
  39386. declare module "babylonjs/Engines/engineCapabilities" {
  39387. /**
  39388. * Interface used to describe the capabilities of the engine relatively to the current browser
  39389. */
  39390. export interface EngineCapabilities {
  39391. /** Maximum textures units per fragment shader */
  39392. maxTexturesImageUnits: number;
  39393. /** Maximum texture units per vertex shader */
  39394. maxVertexTextureImageUnits: number;
  39395. /** Maximum textures units in the entire pipeline */
  39396. maxCombinedTexturesImageUnits: number;
  39397. /** Maximum texture size */
  39398. maxTextureSize: number;
  39399. /** Maximum texture samples */
  39400. maxSamples?: number;
  39401. /** Maximum cube texture size */
  39402. maxCubemapTextureSize: number;
  39403. /** Maximum render texture size */
  39404. maxRenderTextureSize: number;
  39405. /** Maximum number of vertex attributes */
  39406. maxVertexAttribs: number;
  39407. /** Maximum number of varyings */
  39408. maxVaryingVectors: number;
  39409. /** Maximum number of uniforms per vertex shader */
  39410. maxVertexUniformVectors: number;
  39411. /** Maximum number of uniforms per fragment shader */
  39412. maxFragmentUniformVectors: number;
  39413. /** Defines if standard derivates (dx/dy) are supported */
  39414. standardDerivatives: boolean;
  39415. /** Defines if s3tc texture compression is supported */
  39416. s3tc?: WEBGL_compressed_texture_s3tc;
  39417. /** Defines if pvrtc texture compression is supported */
  39418. pvrtc: any;
  39419. /** Defines if etc1 texture compression is supported */
  39420. etc1: any;
  39421. /** Defines if etc2 texture compression is supported */
  39422. etc2: any;
  39423. /** Defines if astc texture compression is supported */
  39424. astc: any;
  39425. /** Defines if bptc texture compression is supported */
  39426. bptc: any;
  39427. /** Defines if float textures are supported */
  39428. textureFloat: boolean;
  39429. /** Defines if vertex array objects are supported */
  39430. vertexArrayObject: boolean;
  39431. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39432. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39433. /** Gets the maximum level of anisotropy supported */
  39434. maxAnisotropy: number;
  39435. /** Defines if instancing is supported */
  39436. instancedArrays: boolean;
  39437. /** Defines if 32 bits indices are supported */
  39438. uintIndices: boolean;
  39439. /** Defines if high precision shaders are supported */
  39440. highPrecisionShaderSupported: boolean;
  39441. /** Defines if depth reading in the fragment shader is supported */
  39442. fragmentDepthSupported: boolean;
  39443. /** Defines if float texture linear filtering is supported*/
  39444. textureFloatLinearFiltering: boolean;
  39445. /** Defines if rendering to float textures is supported */
  39446. textureFloatRender: boolean;
  39447. /** Defines if half float textures are supported*/
  39448. textureHalfFloat: boolean;
  39449. /** Defines if half float texture linear filtering is supported*/
  39450. textureHalfFloatLinearFiltering: boolean;
  39451. /** Defines if rendering to half float textures is supported */
  39452. textureHalfFloatRender: boolean;
  39453. /** Defines if textureLOD shader command is supported */
  39454. textureLOD: boolean;
  39455. /** Defines if draw buffers extension is supported */
  39456. drawBuffersExtension: boolean;
  39457. /** Defines if depth textures are supported */
  39458. depthTextureExtension: boolean;
  39459. /** Defines if float color buffer are supported */
  39460. colorBufferFloat: boolean;
  39461. /** Gets disjoint timer query extension (null if not supported) */
  39462. timerQuery?: EXT_disjoint_timer_query;
  39463. /** Defines if timestamp can be used with timer query */
  39464. canUseTimestampForTimerQuery: boolean;
  39465. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39466. multiview?: any;
  39467. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39468. oculusMultiview?: any;
  39469. /** Function used to let the system compiles shaders in background */
  39470. parallelShaderCompile?: {
  39471. COMPLETION_STATUS_KHR: number;
  39472. };
  39473. /** Max number of texture samples for MSAA */
  39474. maxMSAASamples: number;
  39475. /** Defines if the blend min max extension is supported */
  39476. blendMinMax: boolean;
  39477. }
  39478. }
  39479. declare module "babylonjs/States/depthCullingState" {
  39480. import { Nullable } from "babylonjs/types";
  39481. /**
  39482. * @hidden
  39483. **/
  39484. export class DepthCullingState {
  39485. private _isDepthTestDirty;
  39486. private _isDepthMaskDirty;
  39487. private _isDepthFuncDirty;
  39488. private _isCullFaceDirty;
  39489. private _isCullDirty;
  39490. private _isZOffsetDirty;
  39491. private _isFrontFaceDirty;
  39492. private _depthTest;
  39493. private _depthMask;
  39494. private _depthFunc;
  39495. private _cull;
  39496. private _cullFace;
  39497. private _zOffset;
  39498. private _frontFace;
  39499. /**
  39500. * Initializes the state.
  39501. */
  39502. constructor();
  39503. get isDirty(): boolean;
  39504. get zOffset(): number;
  39505. set zOffset(value: number);
  39506. get cullFace(): Nullable<number>;
  39507. set cullFace(value: Nullable<number>);
  39508. get cull(): Nullable<boolean>;
  39509. set cull(value: Nullable<boolean>);
  39510. get depthFunc(): Nullable<number>;
  39511. set depthFunc(value: Nullable<number>);
  39512. get depthMask(): boolean;
  39513. set depthMask(value: boolean);
  39514. get depthTest(): boolean;
  39515. set depthTest(value: boolean);
  39516. get frontFace(): Nullable<number>;
  39517. set frontFace(value: Nullable<number>);
  39518. reset(): void;
  39519. apply(gl: WebGLRenderingContext): void;
  39520. }
  39521. }
  39522. declare module "babylonjs/States/stencilState" {
  39523. /**
  39524. * @hidden
  39525. **/
  39526. export class StencilState {
  39527. /** 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 */
  39528. static readonly ALWAYS: number;
  39529. /** Passed to stencilOperation to specify that stencil value must be kept */
  39530. static readonly KEEP: number;
  39531. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39532. static readonly REPLACE: number;
  39533. private _isStencilTestDirty;
  39534. private _isStencilMaskDirty;
  39535. private _isStencilFuncDirty;
  39536. private _isStencilOpDirty;
  39537. private _stencilTest;
  39538. private _stencilMask;
  39539. private _stencilFunc;
  39540. private _stencilFuncRef;
  39541. private _stencilFuncMask;
  39542. private _stencilOpStencilFail;
  39543. private _stencilOpDepthFail;
  39544. private _stencilOpStencilDepthPass;
  39545. get isDirty(): boolean;
  39546. get stencilFunc(): number;
  39547. set stencilFunc(value: number);
  39548. get stencilFuncRef(): number;
  39549. set stencilFuncRef(value: number);
  39550. get stencilFuncMask(): number;
  39551. set stencilFuncMask(value: number);
  39552. get stencilOpStencilFail(): number;
  39553. set stencilOpStencilFail(value: number);
  39554. get stencilOpDepthFail(): number;
  39555. set stencilOpDepthFail(value: number);
  39556. get stencilOpStencilDepthPass(): number;
  39557. set stencilOpStencilDepthPass(value: number);
  39558. get stencilMask(): number;
  39559. set stencilMask(value: number);
  39560. get stencilTest(): boolean;
  39561. set stencilTest(value: boolean);
  39562. constructor();
  39563. reset(): void;
  39564. apply(gl: WebGLRenderingContext): void;
  39565. }
  39566. }
  39567. declare module "babylonjs/States/alphaCullingState" {
  39568. /**
  39569. * @hidden
  39570. **/
  39571. export class AlphaState {
  39572. private _isAlphaBlendDirty;
  39573. private _isBlendFunctionParametersDirty;
  39574. private _isBlendEquationParametersDirty;
  39575. private _isBlendConstantsDirty;
  39576. private _alphaBlend;
  39577. private _blendFunctionParameters;
  39578. private _blendEquationParameters;
  39579. private _blendConstants;
  39580. /**
  39581. * Initializes the state.
  39582. */
  39583. constructor();
  39584. get isDirty(): boolean;
  39585. get alphaBlend(): boolean;
  39586. set alphaBlend(value: boolean);
  39587. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39588. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39589. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39590. reset(): void;
  39591. apply(gl: WebGLRenderingContext): void;
  39592. }
  39593. }
  39594. declare module "babylonjs/Engines/WebGL/webGLShaderProcessors" {
  39595. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39596. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  39597. /** @hidden */
  39598. export class WebGLShaderProcessor implements IShaderProcessor {
  39599. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  39600. }
  39601. }
  39602. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  39603. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39604. /** @hidden */
  39605. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39606. attributeProcessor(attribute: string): string;
  39607. varyingProcessor(varying: string, isFragment: boolean): string;
  39608. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  39609. }
  39610. }
  39611. declare module "babylonjs/Engines/instancingAttributeInfo" {
  39612. /**
  39613. * Interface for attribute information associated with buffer instanciation
  39614. */
  39615. export interface InstancingAttributeInfo {
  39616. /**
  39617. * Name of the GLSL attribute
  39618. * if attribute index is not specified, this is used to retrieve the index from the effect
  39619. */
  39620. attributeName: string;
  39621. /**
  39622. * Index/offset of the attribute in the vertex shader
  39623. * if not specified, this will be computes from the name.
  39624. */
  39625. index?: number;
  39626. /**
  39627. * size of the attribute, 1, 2, 3 or 4
  39628. */
  39629. attributeSize: number;
  39630. /**
  39631. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39632. */
  39633. offset: number;
  39634. /**
  39635. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39636. * default to 1
  39637. */
  39638. divisor?: number;
  39639. /**
  39640. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39641. * default is FLOAT
  39642. */
  39643. attributeType?: number;
  39644. /**
  39645. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39646. */
  39647. normalized?: boolean;
  39648. }
  39649. }
  39650. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  39651. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39652. import { Nullable } from "babylonjs/types";
  39653. module "babylonjs/Engines/thinEngine" {
  39654. interface ThinEngine {
  39655. /**
  39656. * Update a video texture
  39657. * @param texture defines the texture to update
  39658. * @param video defines the video element to use
  39659. * @param invertY defines if data must be stored with Y axis inverted
  39660. */
  39661. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39662. }
  39663. }
  39664. }
  39665. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  39666. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39667. import { Nullable } from "babylonjs/types";
  39668. module "babylonjs/Engines/thinEngine" {
  39669. interface ThinEngine {
  39670. /**
  39671. * Creates a dynamic texture
  39672. * @param width defines the width of the texture
  39673. * @param height defines the height of the texture
  39674. * @param generateMipMaps defines if the engine should generate the mip levels
  39675. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39676. * @returns the dynamic texture inside an InternalTexture
  39677. */
  39678. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39679. /**
  39680. * Update the content of a dynamic texture
  39681. * @param texture defines the texture to update
  39682. * @param canvas defines the canvas containing the source
  39683. * @param invertY defines if data must be stored with Y axis inverted
  39684. * @param premulAlpha defines if alpha is stored as premultiplied
  39685. * @param format defines the format of the data
  39686. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39687. */
  39688. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39689. }
  39690. }
  39691. }
  39692. declare module "babylonjs/Materials/Textures/videoTexture" {
  39693. import { Observable } from "babylonjs/Misc/observable";
  39694. import { Nullable } from "babylonjs/types";
  39695. import { Scene } from "babylonjs/scene";
  39696. import { Texture } from "babylonjs/Materials/Textures/texture";
  39697. import "babylonjs/Engines/Extensions/engine.videoTexture";
  39698. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  39699. /**
  39700. * Settings for finer control over video usage
  39701. */
  39702. export interface VideoTextureSettings {
  39703. /**
  39704. * Applies `autoplay` to video, if specified
  39705. */
  39706. autoPlay?: boolean;
  39707. /**
  39708. * Applies `muted` to video, if specified
  39709. */
  39710. muted?: boolean;
  39711. /**
  39712. * Applies `loop` to video, if specified
  39713. */
  39714. loop?: boolean;
  39715. /**
  39716. * Automatically updates internal texture from video at every frame in the render loop
  39717. */
  39718. autoUpdateTexture: boolean;
  39719. /**
  39720. * Image src displayed during the video loading or until the user interacts with the video.
  39721. */
  39722. poster?: string;
  39723. }
  39724. /**
  39725. * If you want to display a video in your scene, this is the special texture for that.
  39726. * This special texture works similar to other textures, with the exception of a few parameters.
  39727. * @see https://doc.babylonjs.com/how_to/video_texture
  39728. */
  39729. export class VideoTexture extends Texture {
  39730. /**
  39731. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  39732. */
  39733. readonly autoUpdateTexture: boolean;
  39734. /**
  39735. * The video instance used by the texture internally
  39736. */
  39737. readonly video: HTMLVideoElement;
  39738. private _onUserActionRequestedObservable;
  39739. /**
  39740. * Event triggerd when a dom action is required by the user to play the video.
  39741. * This happens due to recent changes in browser policies preventing video to auto start.
  39742. */
  39743. get onUserActionRequestedObservable(): Observable<Texture>;
  39744. private _generateMipMaps;
  39745. private _stillImageCaptured;
  39746. private _displayingPosterTexture;
  39747. private _settings;
  39748. private _createInternalTextureOnEvent;
  39749. private _frameId;
  39750. private _currentSrc;
  39751. /**
  39752. * Creates a video texture.
  39753. * If you want to display a video in your scene, this is the special texture for that.
  39754. * This special texture works similar to other textures, with the exception of a few parameters.
  39755. * @see https://doc.babylonjs.com/how_to/video_texture
  39756. * @param name optional name, will detect from video source, if not defined
  39757. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  39758. * @param scene is obviously the current scene.
  39759. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  39760. * @param invertY is false by default but can be used to invert video on Y axis
  39761. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  39762. * @param settings allows finer control over video usage
  39763. */
  39764. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  39765. private _getName;
  39766. private _getVideo;
  39767. private _createInternalTexture;
  39768. private reset;
  39769. /**
  39770. * @hidden Internal method to initiate `update`.
  39771. */
  39772. _rebuild(): void;
  39773. /**
  39774. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  39775. */
  39776. update(): void;
  39777. /**
  39778. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  39779. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  39780. */
  39781. updateTexture(isVisible: boolean): void;
  39782. protected _updateInternalTexture: () => void;
  39783. /**
  39784. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  39785. * @param url New url.
  39786. */
  39787. updateURL(url: string): void;
  39788. /**
  39789. * Clones the texture.
  39790. * @returns the cloned texture
  39791. */
  39792. clone(): VideoTexture;
  39793. /**
  39794. * Dispose the texture and release its associated resources.
  39795. */
  39796. dispose(): void;
  39797. /**
  39798. * Creates a video texture straight from a stream.
  39799. * @param scene Define the scene the texture should be created in
  39800. * @param stream Define the stream the texture should be created from
  39801. * @returns The created video texture as a promise
  39802. */
  39803. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  39804. /**
  39805. * Creates a video texture straight from your WebCam video feed.
  39806. * @param scene Define the scene the texture should be created in
  39807. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39808. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39809. * @returns The created video texture as a promise
  39810. */
  39811. static CreateFromWebCamAsync(scene: Scene, constraints: {
  39812. minWidth: number;
  39813. maxWidth: number;
  39814. minHeight: number;
  39815. maxHeight: number;
  39816. deviceId: string;
  39817. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  39818. /**
  39819. * Creates a video texture straight from your WebCam video feed.
  39820. * @param scene Define the scene the texture should be created in
  39821. * @param onReady Define a callback to triggered once the texture will be ready
  39822. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39823. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39824. */
  39825. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  39826. minWidth: number;
  39827. maxWidth: number;
  39828. minHeight: number;
  39829. maxHeight: number;
  39830. deviceId: string;
  39831. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  39832. }
  39833. }
  39834. declare module "babylonjs/Engines/thinEngine" {
  39835. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  39836. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  39837. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39838. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39839. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  39840. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  39841. import { Observable } from "babylonjs/Misc/observable";
  39842. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  39843. import { StencilState } from "babylonjs/States/stencilState";
  39844. import { AlphaState } from "babylonjs/States/alphaCullingState";
  39845. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39846. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  39847. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  39848. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39849. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  39850. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  39851. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  39852. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  39853. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39854. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39855. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  39856. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  39857. import { WebRequest } from "babylonjs/Misc/webRequest";
  39858. import { LoadFileError } from "babylonjs/Misc/fileTools";
  39859. /**
  39860. * Defines the interface used by objects working like Scene
  39861. * @hidden
  39862. */
  39863. export interface ISceneLike {
  39864. _addPendingData(data: any): void;
  39865. _removePendingData(data: any): void;
  39866. offlineProvider: IOfflineProvider;
  39867. }
  39868. /**
  39869. * Information about the current host
  39870. */
  39871. export interface HostInformation {
  39872. /**
  39873. * Defines if the current host is a mobile
  39874. */
  39875. isMobile: boolean;
  39876. }
  39877. /** Interface defining initialization parameters for Engine class */
  39878. export interface EngineOptions extends WebGLContextAttributes {
  39879. /**
  39880. * Defines if the engine should no exceed a specified device ratio
  39881. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39882. */
  39883. limitDeviceRatio?: number;
  39884. /**
  39885. * Defines if webvr should be enabled automatically
  39886. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39887. */
  39888. autoEnableWebVR?: boolean;
  39889. /**
  39890. * Defines if webgl2 should be turned off even if supported
  39891. * @see https://doc.babylonjs.com/features/webgl2
  39892. */
  39893. disableWebGL2Support?: boolean;
  39894. /**
  39895. * Defines if webaudio should be initialized as well
  39896. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39897. */
  39898. audioEngine?: boolean;
  39899. /**
  39900. * Defines if animations should run using a deterministic lock step
  39901. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39902. */
  39903. deterministicLockstep?: boolean;
  39904. /** Defines the maximum steps to use with deterministic lock step mode */
  39905. lockstepMaxSteps?: number;
  39906. /** Defines the seconds between each deterministic lock step */
  39907. timeStep?: number;
  39908. /**
  39909. * Defines that engine should ignore context lost events
  39910. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39911. */
  39912. doNotHandleContextLost?: boolean;
  39913. /**
  39914. * Defines that engine should ignore modifying touch action attribute and style
  39915. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39916. */
  39917. doNotHandleTouchAction?: boolean;
  39918. /**
  39919. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39920. */
  39921. useHighPrecisionFloats?: boolean;
  39922. /**
  39923. * Make the canvas XR Compatible for XR sessions
  39924. */
  39925. xrCompatible?: boolean;
  39926. /**
  39927. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39928. */
  39929. useHighPrecisionMatrix?: boolean;
  39930. /**
  39931. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39932. */
  39933. failIfMajorPerformanceCaveat?: boolean;
  39934. }
  39935. /**
  39936. * The base engine class (root of all engines)
  39937. */
  39938. export class ThinEngine {
  39939. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39940. static ExceptionList: ({
  39941. key: string;
  39942. capture: string;
  39943. captureConstraint: number;
  39944. targets: string[];
  39945. } | {
  39946. key: string;
  39947. capture: null;
  39948. captureConstraint: null;
  39949. targets: string[];
  39950. })[];
  39951. /** @hidden */
  39952. static _TextureLoaders: IInternalTextureLoader[];
  39953. /**
  39954. * Returns the current npm package of the sdk
  39955. */
  39956. static get NpmPackage(): string;
  39957. /**
  39958. * Returns the current version of the framework
  39959. */
  39960. static get Version(): string;
  39961. /**
  39962. * Returns a string describing the current engine
  39963. */
  39964. get description(): string;
  39965. /**
  39966. * Gets or sets the epsilon value used by collision engine
  39967. */
  39968. static CollisionsEpsilon: number;
  39969. /**
  39970. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39971. */
  39972. static get ShadersRepository(): string;
  39973. static set ShadersRepository(value: string);
  39974. /** @hidden */
  39975. _shaderProcessor: IShaderProcessor;
  39976. /**
  39977. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39978. */
  39979. forcePOTTextures: boolean;
  39980. /**
  39981. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39982. */
  39983. isFullscreen: boolean;
  39984. /**
  39985. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39986. */
  39987. cullBackFaces: boolean;
  39988. /**
  39989. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39990. */
  39991. renderEvenInBackground: boolean;
  39992. /**
  39993. * Gets or sets a boolean indicating that cache can be kept between frames
  39994. */
  39995. preventCacheWipeBetweenFrames: boolean;
  39996. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39997. validateShaderPrograms: boolean;
  39998. /**
  39999. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40000. * This can provide greater z depth for distant objects.
  40001. */
  40002. useReverseDepthBuffer: boolean;
  40003. /**
  40004. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40005. */
  40006. disableUniformBuffers: boolean;
  40007. /** @hidden */
  40008. _uniformBuffers: UniformBuffer[];
  40009. /**
  40010. * Gets a boolean indicating that the engine supports uniform buffers
  40011. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40012. */
  40013. get supportsUniformBuffers(): boolean;
  40014. /** @hidden */
  40015. _gl: WebGLRenderingContext;
  40016. /** @hidden */
  40017. _webGLVersion: number;
  40018. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40019. protected _windowIsBackground: boolean;
  40020. protected _creationOptions: EngineOptions;
  40021. protected _highPrecisionShadersAllowed: boolean;
  40022. /** @hidden */
  40023. get _shouldUseHighPrecisionShader(): boolean;
  40024. /**
  40025. * Gets a boolean indicating that only power of 2 textures are supported
  40026. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40027. */
  40028. get needPOTTextures(): boolean;
  40029. /** @hidden */
  40030. _badOS: boolean;
  40031. /** @hidden */
  40032. _badDesktopOS: boolean;
  40033. private _hardwareScalingLevel;
  40034. /** @hidden */
  40035. _caps: EngineCapabilities;
  40036. private _isStencilEnable;
  40037. private _glVersion;
  40038. private _glRenderer;
  40039. private _glVendor;
  40040. /** @hidden */
  40041. _videoTextureSupported: boolean;
  40042. protected _renderingQueueLaunched: boolean;
  40043. protected _activeRenderLoops: (() => void)[];
  40044. /**
  40045. * Observable signaled when a context lost event is raised
  40046. */
  40047. onContextLostObservable: Observable<ThinEngine>;
  40048. /**
  40049. * Observable signaled when a context restored event is raised
  40050. */
  40051. onContextRestoredObservable: Observable<ThinEngine>;
  40052. private _onContextLost;
  40053. private _onContextRestored;
  40054. protected _contextWasLost: boolean;
  40055. /** @hidden */
  40056. _doNotHandleContextLost: boolean;
  40057. /**
  40058. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40059. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40060. */
  40061. get doNotHandleContextLost(): boolean;
  40062. set doNotHandleContextLost(value: boolean);
  40063. /**
  40064. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40065. */
  40066. disableVertexArrayObjects: boolean;
  40067. /** @hidden */
  40068. protected _colorWrite: boolean;
  40069. /** @hidden */
  40070. protected _colorWriteChanged: boolean;
  40071. /** @hidden */
  40072. protected _depthCullingState: DepthCullingState;
  40073. /** @hidden */
  40074. protected _stencilState: StencilState;
  40075. /** @hidden */
  40076. _alphaState: AlphaState;
  40077. /** @hidden */
  40078. _alphaMode: number;
  40079. /** @hidden */
  40080. _alphaEquation: number;
  40081. /** @hidden */
  40082. _internalTexturesCache: InternalTexture[];
  40083. /** @hidden */
  40084. protected _activeChannel: number;
  40085. private _currentTextureChannel;
  40086. /** @hidden */
  40087. protected _boundTexturesCache: {
  40088. [key: string]: Nullable<InternalTexture>;
  40089. };
  40090. /** @hidden */
  40091. protected _currentEffect: Nullable<Effect>;
  40092. /** @hidden */
  40093. protected _currentProgram: Nullable<WebGLProgram>;
  40094. private _compiledEffects;
  40095. private _vertexAttribArraysEnabled;
  40096. /** @hidden */
  40097. protected _cachedViewport: Nullable<IViewportLike>;
  40098. private _cachedVertexArrayObject;
  40099. /** @hidden */
  40100. protected _cachedVertexBuffers: any;
  40101. /** @hidden */
  40102. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40103. /** @hidden */
  40104. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40105. /** @hidden */
  40106. _currentRenderTarget: Nullable<InternalTexture>;
  40107. private _uintIndicesCurrentlySet;
  40108. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40109. /** @hidden */
  40110. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40111. /** @hidden */
  40112. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40113. private _currentBufferPointers;
  40114. private _currentInstanceLocations;
  40115. private _currentInstanceBuffers;
  40116. private _textureUnits;
  40117. /** @hidden */
  40118. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40119. /** @hidden */
  40120. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40121. /** @hidden */
  40122. _boundRenderFunction: any;
  40123. private _vaoRecordInProgress;
  40124. private _mustWipeVertexAttributes;
  40125. private _emptyTexture;
  40126. private _emptyCubeTexture;
  40127. private _emptyTexture3D;
  40128. private _emptyTexture2DArray;
  40129. /** @hidden */
  40130. _frameHandler: number;
  40131. private _nextFreeTextureSlots;
  40132. private _maxSimultaneousTextures;
  40133. private _activeRequests;
  40134. /** @hidden */
  40135. _transformTextureUrl: Nullable<(url: string) => string>;
  40136. /**
  40137. * Gets information about the current host
  40138. */
  40139. hostInformation: HostInformation;
  40140. protected get _supportsHardwareTextureRescaling(): boolean;
  40141. private _framebufferDimensionsObject;
  40142. /**
  40143. * sets the object from which width and height will be taken from when getting render width and height
  40144. * Will fallback to the gl object
  40145. * @param dimensions the framebuffer width and height that will be used.
  40146. */
  40147. set framebufferDimensionsObject(dimensions: Nullable<{
  40148. framebufferWidth: number;
  40149. framebufferHeight: number;
  40150. }>);
  40151. /**
  40152. * Gets the current viewport
  40153. */
  40154. get currentViewport(): Nullable<IViewportLike>;
  40155. /**
  40156. * Gets the default empty texture
  40157. */
  40158. get emptyTexture(): InternalTexture;
  40159. /**
  40160. * Gets the default empty 3D texture
  40161. */
  40162. get emptyTexture3D(): InternalTexture;
  40163. /**
  40164. * Gets the default empty 2D array texture
  40165. */
  40166. get emptyTexture2DArray(): InternalTexture;
  40167. /**
  40168. * Gets the default empty cube texture
  40169. */
  40170. get emptyCubeTexture(): InternalTexture;
  40171. /**
  40172. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40173. */
  40174. readonly premultipliedAlpha: boolean;
  40175. /**
  40176. * Observable event triggered before each texture is initialized
  40177. */
  40178. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  40179. /**
  40180. * Creates a new engine
  40181. * @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
  40182. * @param antialias defines enable antialiasing (default: false)
  40183. * @param options defines further options to be sent to the getContext() function
  40184. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40185. */
  40186. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40187. private _rebuildInternalTextures;
  40188. private _rebuildEffects;
  40189. /**
  40190. * Gets a boolean indicating if all created effects are ready
  40191. * @returns true if all effects are ready
  40192. */
  40193. areAllEffectsReady(): boolean;
  40194. protected _rebuildBuffers(): void;
  40195. protected _initGLContext(): void;
  40196. /**
  40197. * Gets version of the current webGL context
  40198. */
  40199. get webGLVersion(): number;
  40200. /**
  40201. * Gets a string identifying the name of the class
  40202. * @returns "Engine" string
  40203. */
  40204. getClassName(): string;
  40205. /**
  40206. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40207. */
  40208. get isStencilEnable(): boolean;
  40209. /** @hidden */
  40210. _prepareWorkingCanvas(): void;
  40211. /**
  40212. * Reset the texture cache to empty state
  40213. */
  40214. resetTextureCache(): void;
  40215. /**
  40216. * Gets an object containing information about the current webGL context
  40217. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40218. */
  40219. getGlInfo(): {
  40220. vendor: string;
  40221. renderer: string;
  40222. version: string;
  40223. };
  40224. /**
  40225. * Defines the hardware scaling level.
  40226. * By default the hardware scaling level is computed from the window device ratio.
  40227. * 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.
  40228. * @param level defines the level to use
  40229. */
  40230. setHardwareScalingLevel(level: number): void;
  40231. /**
  40232. * Gets the current hardware scaling level.
  40233. * By default the hardware scaling level is computed from the window device ratio.
  40234. * 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.
  40235. * @returns a number indicating the current hardware scaling level
  40236. */
  40237. getHardwareScalingLevel(): number;
  40238. /**
  40239. * Gets the list of loaded textures
  40240. * @returns an array containing all loaded textures
  40241. */
  40242. getLoadedTexturesCache(): InternalTexture[];
  40243. /**
  40244. * Gets the object containing all engine capabilities
  40245. * @returns the EngineCapabilities object
  40246. */
  40247. getCaps(): EngineCapabilities;
  40248. /**
  40249. * stop executing a render loop function and remove it from the execution array
  40250. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40251. */
  40252. stopRenderLoop(renderFunction?: () => void): void;
  40253. /** @hidden */
  40254. _renderLoop(): void;
  40255. /**
  40256. * Gets the HTML canvas attached with the current webGL context
  40257. * @returns a HTML canvas
  40258. */
  40259. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40260. /**
  40261. * Gets host window
  40262. * @returns the host window object
  40263. */
  40264. getHostWindow(): Nullable<Window>;
  40265. /**
  40266. * Gets the current render width
  40267. * @param useScreen defines if screen size must be used (or the current render target if any)
  40268. * @returns a number defining the current render width
  40269. */
  40270. getRenderWidth(useScreen?: boolean): number;
  40271. /**
  40272. * Gets the current render height
  40273. * @param useScreen defines if screen size must be used (or the current render target if any)
  40274. * @returns a number defining the current render height
  40275. */
  40276. getRenderHeight(useScreen?: boolean): number;
  40277. /**
  40278. * Can be used to override the current requestAnimationFrame requester.
  40279. * @hidden
  40280. */
  40281. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40282. /**
  40283. * Register and execute a render loop. The engine can have more than one render function
  40284. * @param renderFunction defines the function to continuously execute
  40285. */
  40286. runRenderLoop(renderFunction: () => void): void;
  40287. /**
  40288. * Clear the current render buffer or the current render target (if any is set up)
  40289. * @param color defines the color to use
  40290. * @param backBuffer defines if the back buffer must be cleared
  40291. * @param depth defines if the depth buffer must be cleared
  40292. * @param stencil defines if the stencil buffer must be cleared
  40293. */
  40294. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40295. private _viewportCached;
  40296. /** @hidden */
  40297. _viewport(x: number, y: number, width: number, height: number): void;
  40298. /**
  40299. * Set the WebGL's viewport
  40300. * @param viewport defines the viewport element to be used
  40301. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40302. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40303. */
  40304. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40305. /**
  40306. * Begin a new frame
  40307. */
  40308. beginFrame(): void;
  40309. /**
  40310. * Enf the current frame
  40311. */
  40312. endFrame(): void;
  40313. /**
  40314. * Resize the view according to the canvas' size
  40315. */
  40316. resize(): void;
  40317. /**
  40318. * Force a specific size of the canvas
  40319. * @param width defines the new canvas' width
  40320. * @param height defines the new canvas' height
  40321. * @returns true if the size was changed
  40322. */
  40323. setSize(width: number, height: number): boolean;
  40324. /**
  40325. * Binds the frame buffer to the specified texture.
  40326. * @param texture The texture to render to or null for the default canvas
  40327. * @param faceIndex The face of the texture to render to in case of cube texture
  40328. * @param requiredWidth The width of the target to render to
  40329. * @param requiredHeight The height of the target to render to
  40330. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40331. * @param lodLevel defines the lod level to bind to the frame buffer
  40332. * @param layer defines the 2d array index to bind to frame buffer to
  40333. */
  40334. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40335. /** @hidden */
  40336. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40337. /**
  40338. * Unbind the current render target texture from the webGL context
  40339. * @param texture defines the render target texture to unbind
  40340. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40341. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40342. */
  40343. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40344. /**
  40345. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40346. */
  40347. flushFramebuffer(): void;
  40348. /**
  40349. * Unbind the current render target and bind the default framebuffer
  40350. */
  40351. restoreDefaultFramebuffer(): void;
  40352. /** @hidden */
  40353. protected _resetVertexBufferBinding(): void;
  40354. /**
  40355. * Creates a vertex buffer
  40356. * @param data the data for the vertex buffer
  40357. * @returns the new WebGL static buffer
  40358. */
  40359. createVertexBuffer(data: DataArray): DataBuffer;
  40360. private _createVertexBuffer;
  40361. /**
  40362. * Creates a dynamic vertex buffer
  40363. * @param data the data for the dynamic vertex buffer
  40364. * @returns the new WebGL dynamic buffer
  40365. */
  40366. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40367. protected _resetIndexBufferBinding(): void;
  40368. /**
  40369. * Creates a new index buffer
  40370. * @param indices defines the content of the index buffer
  40371. * @param updatable defines if the index buffer must be updatable
  40372. * @returns a new webGL buffer
  40373. */
  40374. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40375. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40376. /**
  40377. * Bind a webGL buffer to the webGL context
  40378. * @param buffer defines the buffer to bind
  40379. */
  40380. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40381. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40382. private bindBuffer;
  40383. /**
  40384. * update the bound buffer with the given data
  40385. * @param data defines the data to update
  40386. */
  40387. updateArrayBuffer(data: Float32Array): void;
  40388. private _vertexAttribPointer;
  40389. /** @hidden */
  40390. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40391. private _bindVertexBuffersAttributes;
  40392. /**
  40393. * Records a vertex array object
  40394. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40395. * @param vertexBuffers defines the list of vertex buffers to store
  40396. * @param indexBuffer defines the index buffer to store
  40397. * @param effect defines the effect to store
  40398. * @returns the new vertex array object
  40399. */
  40400. recordVertexArrayObject(vertexBuffers: {
  40401. [key: string]: VertexBuffer;
  40402. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40403. /**
  40404. * Bind a specific vertex array object
  40405. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40406. * @param vertexArrayObject defines the vertex array object to bind
  40407. * @param indexBuffer defines the index buffer to bind
  40408. */
  40409. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40410. /**
  40411. * Bind webGl buffers directly to the webGL context
  40412. * @param vertexBuffer defines the vertex buffer to bind
  40413. * @param indexBuffer defines the index buffer to bind
  40414. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40415. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40416. * @param effect defines the effect associated with the vertex buffer
  40417. */
  40418. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40419. private _unbindVertexArrayObject;
  40420. /**
  40421. * Bind a list of vertex buffers to the webGL context
  40422. * @param vertexBuffers defines the list of vertex buffers to bind
  40423. * @param indexBuffer defines the index buffer to bind
  40424. * @param effect defines the effect associated with the vertex buffers
  40425. */
  40426. bindBuffers(vertexBuffers: {
  40427. [key: string]: Nullable<VertexBuffer>;
  40428. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  40429. /**
  40430. * Unbind all instance attributes
  40431. */
  40432. unbindInstanceAttributes(): void;
  40433. /**
  40434. * Release and free the memory of a vertex array object
  40435. * @param vao defines the vertex array object to delete
  40436. */
  40437. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40438. /** @hidden */
  40439. _releaseBuffer(buffer: DataBuffer): boolean;
  40440. protected _deleteBuffer(buffer: DataBuffer): void;
  40441. /**
  40442. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40443. * @param instancesBuffer defines the webGL buffer to update and bind
  40444. * @param data defines the data to store in the buffer
  40445. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40446. */
  40447. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40448. /**
  40449. * Bind the content of a webGL buffer used with instantiation
  40450. * @param instancesBuffer defines the webGL buffer to bind
  40451. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40452. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40453. */
  40454. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40455. /**
  40456. * Disable the instance attribute corresponding to the name in parameter
  40457. * @param name defines the name of the attribute to disable
  40458. */
  40459. disableInstanceAttributeByName(name: string): void;
  40460. /**
  40461. * Disable the instance attribute corresponding to the location in parameter
  40462. * @param attributeLocation defines the attribute location of the attribute to disable
  40463. */
  40464. disableInstanceAttribute(attributeLocation: number): void;
  40465. /**
  40466. * Disable the attribute corresponding to the location in parameter
  40467. * @param attributeLocation defines the attribute location of the attribute to disable
  40468. */
  40469. disableAttributeByIndex(attributeLocation: number): void;
  40470. /**
  40471. * Send a draw order
  40472. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40473. * @param indexStart defines the starting index
  40474. * @param indexCount defines the number of index to draw
  40475. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40476. */
  40477. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40478. /**
  40479. * Draw a list of points
  40480. * @param verticesStart defines the index of first vertex to draw
  40481. * @param verticesCount defines the count of vertices to draw
  40482. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40483. */
  40484. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40485. /**
  40486. * Draw a list of unindexed primitives
  40487. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40488. * @param verticesStart defines the index of first vertex to draw
  40489. * @param verticesCount defines the count of vertices to draw
  40490. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40491. */
  40492. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40493. /**
  40494. * Draw a list of indexed primitives
  40495. * @param fillMode defines the primitive to use
  40496. * @param indexStart defines the starting index
  40497. * @param indexCount defines the number of index to draw
  40498. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40499. */
  40500. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40501. /**
  40502. * Draw a list of unindexed primitives
  40503. * @param fillMode defines the primitive to use
  40504. * @param verticesStart defines the index of first vertex to draw
  40505. * @param verticesCount defines the count of vertices to draw
  40506. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40507. */
  40508. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40509. private _drawMode;
  40510. /** @hidden */
  40511. protected _reportDrawCall(): void;
  40512. /** @hidden */
  40513. _releaseEffect(effect: Effect): void;
  40514. /** @hidden */
  40515. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40516. /**
  40517. * Create a new effect (used to store vertex/fragment shaders)
  40518. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40519. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40520. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40521. * @param samplers defines an array of string used to represent textures
  40522. * @param defines defines the string containing the defines to use to compile the shaders
  40523. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40524. * @param onCompiled defines a function to call when the effect creation is successful
  40525. * @param onError defines a function to call when the effect creation has failed
  40526. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40527. * @returns the new Effect
  40528. */
  40529. 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;
  40530. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40531. private _compileShader;
  40532. private _compileRawShader;
  40533. /** @hidden */
  40534. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40535. /**
  40536. * Directly creates a webGL program
  40537. * @param pipelineContext defines the pipeline context to attach to
  40538. * @param vertexCode defines the vertex shader code to use
  40539. * @param fragmentCode defines the fragment shader code to use
  40540. * @param context defines the webGL context to use (if not set, the current one will be used)
  40541. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40542. * @returns the new webGL program
  40543. */
  40544. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40545. /**
  40546. * Creates a webGL program
  40547. * @param pipelineContext defines the pipeline context to attach to
  40548. * @param vertexCode defines the vertex shader code to use
  40549. * @param fragmentCode defines the fragment shader code to use
  40550. * @param defines defines the string containing the defines to use to compile the shaders
  40551. * @param context defines the webGL context to use (if not set, the current one will be used)
  40552. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40553. * @returns the new webGL program
  40554. */
  40555. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40556. /**
  40557. * Creates a new pipeline context
  40558. * @returns the new pipeline
  40559. */
  40560. createPipelineContext(): IPipelineContext;
  40561. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40562. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40563. /** @hidden */
  40564. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  40565. /** @hidden */
  40566. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40567. /** @hidden */
  40568. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40569. /**
  40570. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40571. * @param pipelineContext defines the pipeline context to use
  40572. * @param uniformsNames defines the list of uniform names
  40573. * @returns an array of webGL uniform locations
  40574. */
  40575. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40576. /**
  40577. * Gets the lsit of active attributes for a given webGL program
  40578. * @param pipelineContext defines the pipeline context to use
  40579. * @param attributesNames defines the list of attribute names to get
  40580. * @returns an array of indices indicating the offset of each attribute
  40581. */
  40582. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40583. /**
  40584. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40585. * @param effect defines the effect to activate
  40586. */
  40587. enableEffect(effect: Nullable<Effect>): void;
  40588. /**
  40589. * Set the value of an uniform to a number (int)
  40590. * @param uniform defines the webGL uniform location where to store the value
  40591. * @param value defines the int number to store
  40592. * @returns true if the value was set
  40593. */
  40594. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40595. /**
  40596. * Set the value of an uniform to an array of int32
  40597. * @param uniform defines the webGL uniform location where to store the value
  40598. * @param array defines the array of int32 to store
  40599. * @returns true if the value was set
  40600. */
  40601. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40602. /**
  40603. * Set the value of an uniform to an array of int32 (stored as vec2)
  40604. * @param uniform defines the webGL uniform location where to store the value
  40605. * @param array defines the array of int32 to store
  40606. * @returns true if the value was set
  40607. */
  40608. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40609. /**
  40610. * Set the value of an uniform to an array of int32 (stored as vec3)
  40611. * @param uniform defines the webGL uniform location where to store the value
  40612. * @param array defines the array of int32 to store
  40613. * @returns true if the value was set
  40614. */
  40615. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40616. /**
  40617. * Set the value of an uniform to an array of int32 (stored as vec4)
  40618. * @param uniform defines the webGL uniform location where to store the value
  40619. * @param array defines the array of int32 to store
  40620. * @returns true if the value was set
  40621. */
  40622. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40623. /**
  40624. * Set the value of an uniform to an array of number
  40625. * @param uniform defines the webGL uniform location where to store the value
  40626. * @param array defines the array of number to store
  40627. * @returns true if the value was set
  40628. */
  40629. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40630. /**
  40631. * Set the value of an uniform to an array of number (stored as vec2)
  40632. * @param uniform defines the webGL uniform location where to store the value
  40633. * @param array defines the array of number to store
  40634. * @returns true if the value was set
  40635. */
  40636. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40637. /**
  40638. * Set the value of an uniform to an array of number (stored as vec3)
  40639. * @param uniform defines the webGL uniform location where to store the value
  40640. * @param array defines the array of number to store
  40641. * @returns true if the value was set
  40642. */
  40643. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40644. /**
  40645. * Set the value of an uniform to an array of number (stored as vec4)
  40646. * @param uniform defines the webGL uniform location where to store the value
  40647. * @param array defines the array of number to store
  40648. * @returns true if the value was set
  40649. */
  40650. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40651. /**
  40652. * Set the value of an uniform to an array of float32 (stored as matrices)
  40653. * @param uniform defines the webGL uniform location where to store the value
  40654. * @param matrices defines the array of float32 to store
  40655. * @returns true if the value was set
  40656. */
  40657. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40658. /**
  40659. * Set the value of an uniform to a matrix (3x3)
  40660. * @param uniform defines the webGL uniform location where to store the value
  40661. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40662. * @returns true if the value was set
  40663. */
  40664. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40665. /**
  40666. * Set the value of an uniform to a matrix (2x2)
  40667. * @param uniform defines the webGL uniform location where to store the value
  40668. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40669. * @returns true if the value was set
  40670. */
  40671. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40672. /**
  40673. * Set the value of an uniform to a number (float)
  40674. * @param uniform defines the webGL uniform location where to store the value
  40675. * @param value defines the float number to store
  40676. * @returns true if the value was transfered
  40677. */
  40678. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40679. /**
  40680. * Set the value of an uniform to a vec2
  40681. * @param uniform defines the webGL uniform location where to store the value
  40682. * @param x defines the 1st component of the value
  40683. * @param y defines the 2nd component of the value
  40684. * @returns true if the value was set
  40685. */
  40686. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40687. /**
  40688. * Set the value of an uniform to a vec3
  40689. * @param uniform defines the webGL uniform location where to store the value
  40690. * @param x defines the 1st component of the value
  40691. * @param y defines the 2nd component of the value
  40692. * @param z defines the 3rd component of the value
  40693. * @returns true if the value was set
  40694. */
  40695. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40696. /**
  40697. * Set the value of an uniform to a vec4
  40698. * @param uniform defines the webGL uniform location where to store the value
  40699. * @param x defines the 1st component of the value
  40700. * @param y defines the 2nd component of the value
  40701. * @param z defines the 3rd component of the value
  40702. * @param w defines the 4th component of the value
  40703. * @returns true if the value was set
  40704. */
  40705. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40706. /**
  40707. * Apply all cached states (depth, culling, stencil and alpha)
  40708. */
  40709. applyStates(): void;
  40710. /**
  40711. * Enable or disable color writing
  40712. * @param enable defines the state to set
  40713. */
  40714. setColorWrite(enable: boolean): void;
  40715. /**
  40716. * Gets a boolean indicating if color writing is enabled
  40717. * @returns the current color writing state
  40718. */
  40719. getColorWrite(): boolean;
  40720. /**
  40721. * Gets the depth culling state manager
  40722. */
  40723. get depthCullingState(): DepthCullingState;
  40724. /**
  40725. * Gets the alpha state manager
  40726. */
  40727. get alphaState(): AlphaState;
  40728. /**
  40729. * Gets the stencil state manager
  40730. */
  40731. get stencilState(): StencilState;
  40732. /**
  40733. * Clears the list of texture accessible through engine.
  40734. * This can help preventing texture load conflict due to name collision.
  40735. */
  40736. clearInternalTexturesCache(): void;
  40737. /**
  40738. * Force the entire cache to be cleared
  40739. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  40740. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  40741. */
  40742. wipeCaches(bruteForce?: boolean): void;
  40743. /** @hidden */
  40744. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  40745. min: number;
  40746. mag: number;
  40747. };
  40748. /** @hidden */
  40749. _createTexture(): WebGLTexture;
  40750. /**
  40751. * Usually called from Texture.ts.
  40752. * Passed information to create a WebGLTexture
  40753. * @param url defines a value which contains one of the following:
  40754. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  40755. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  40756. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  40757. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  40758. * @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)
  40759. * @param scene needed for loading to the correct scene
  40760. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  40761. * @param onLoad optional callback to be called upon successful completion
  40762. * @param onError optional callback to be called upon failure
  40763. * @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
  40764. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  40765. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  40766. * @param forcedExtension defines the extension to use to pick the right loader
  40767. * @param mimeType defines an optional mime type
  40768. * @param loaderOptions options to be passed to the loader
  40769. * @returns a InternalTexture for assignment back into BABYLON.Texture
  40770. */
  40771. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  40772. /**
  40773. * Loads an image as an HTMLImageElement.
  40774. * @param input url string, ArrayBuffer, or Blob to load
  40775. * @param onLoad callback called when the image successfully loads
  40776. * @param onError callback called when the image fails to load
  40777. * @param offlineProvider offline provider for caching
  40778. * @param mimeType optional mime type
  40779. * @returns the HTMLImageElement of the loaded image
  40780. * @hidden
  40781. */
  40782. 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>;
  40783. /**
  40784. * @hidden
  40785. */
  40786. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  40787. private _unpackFlipYCached;
  40788. /**
  40789. * In case you are sharing the context with other applications, it might
  40790. * be interested to not cache the unpack flip y state to ensure a consistent
  40791. * value would be set.
  40792. */
  40793. enableUnpackFlipYCached: boolean;
  40794. /** @hidden */
  40795. _unpackFlipY(value: boolean): void;
  40796. /** @hidden */
  40797. _getUnpackAlignement(): number;
  40798. private _getTextureTarget;
  40799. /**
  40800. * Update the sampling mode of a given texture
  40801. * @param samplingMode defines the required sampling mode
  40802. * @param texture defines the texture to update
  40803. * @param generateMipMaps defines whether to generate mipmaps for the texture
  40804. */
  40805. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  40806. /**
  40807. * Update the sampling mode of a given texture
  40808. * @param texture defines the texture to update
  40809. * @param wrapU defines the texture wrap mode of the u coordinates
  40810. * @param wrapV defines the texture wrap mode of the v coordinates
  40811. * @param wrapR defines the texture wrap mode of the r coordinates
  40812. */
  40813. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  40814. /** @hidden */
  40815. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  40816. width: number;
  40817. height: number;
  40818. layers?: number;
  40819. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  40820. /** @hidden */
  40821. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40822. /** @hidden */
  40823. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  40824. /**
  40825. * Update a portion of an internal texture
  40826. * @param texture defines the texture to update
  40827. * @param imageData defines the data to store into the texture
  40828. * @param xOffset defines the x coordinates of the update rectangle
  40829. * @param yOffset defines the y coordinates of the update rectangle
  40830. * @param width defines the width of the update rectangle
  40831. * @param height defines the height of the update rectangle
  40832. * @param faceIndex defines the face index if texture is a cube (0 by default)
  40833. * @param lod defines the lod level to update (0 by default)
  40834. */
  40835. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  40836. /** @hidden */
  40837. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40838. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  40839. private _prepareWebGLTexture;
  40840. /** @hidden */
  40841. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  40842. private _getDepthStencilBuffer;
  40843. /** @hidden */
  40844. _releaseFramebufferObjects(texture: InternalTexture): void;
  40845. /** @hidden */
  40846. _releaseTexture(texture: InternalTexture): void;
  40847. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  40848. protected _setProgram(program: WebGLProgram): void;
  40849. protected _boundUniforms: {
  40850. [key: number]: WebGLUniformLocation;
  40851. };
  40852. /**
  40853. * Binds an effect to the webGL context
  40854. * @param effect defines the effect to bind
  40855. */
  40856. bindSamplers(effect: Effect): void;
  40857. private _activateCurrentTexture;
  40858. /** @hidden */
  40859. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  40860. /** @hidden */
  40861. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  40862. /**
  40863. * Unbind all textures from the webGL context
  40864. */
  40865. unbindAllTextures(): void;
  40866. /**
  40867. * Sets a texture to the according uniform.
  40868. * @param channel The texture channel
  40869. * @param uniform The uniform to set
  40870. * @param texture The texture to apply
  40871. */
  40872. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  40873. private _bindSamplerUniformToChannel;
  40874. private _getTextureWrapMode;
  40875. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  40876. /**
  40877. * Sets an array of texture to the webGL context
  40878. * @param channel defines the channel where the texture array must be set
  40879. * @param uniform defines the associated uniform location
  40880. * @param textures defines the array of textures to bind
  40881. */
  40882. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  40883. /** @hidden */
  40884. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  40885. private _setTextureParameterFloat;
  40886. private _setTextureParameterInteger;
  40887. /**
  40888. * Unbind all vertex attributes from the webGL context
  40889. */
  40890. unbindAllAttributes(): void;
  40891. /**
  40892. * 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
  40893. */
  40894. releaseEffects(): void;
  40895. /**
  40896. * Dispose and release all associated resources
  40897. */
  40898. dispose(): void;
  40899. /**
  40900. * Attach a new callback raised when context lost event is fired
  40901. * @param callback defines the callback to call
  40902. */
  40903. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40904. /**
  40905. * Attach a new callback raised when context restored event is fired
  40906. * @param callback defines the callback to call
  40907. */
  40908. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40909. /**
  40910. * Get the current error code of the webGL context
  40911. * @returns the error code
  40912. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40913. */
  40914. getError(): number;
  40915. private _canRenderToFloatFramebuffer;
  40916. private _canRenderToHalfFloatFramebuffer;
  40917. private _canRenderToFramebuffer;
  40918. /** @hidden */
  40919. _getWebGLTextureType(type: number): number;
  40920. /** @hidden */
  40921. _getInternalFormat(format: number): number;
  40922. /** @hidden */
  40923. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  40924. /** @hidden */
  40925. _getRGBAMultiSampleBufferFormat(type: number): number;
  40926. /** @hidden */
  40927. _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;
  40928. /**
  40929. * Loads a file from a url
  40930. * @param url url to load
  40931. * @param onSuccess callback called when the file successfully loads
  40932. * @param onProgress callback called while file is loading (if the server supports this mode)
  40933. * @param offlineProvider defines the offline provider for caching
  40934. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  40935. * @param onError callback called when the file fails to load
  40936. * @returns a file request object
  40937. * @hidden
  40938. */
  40939. 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;
  40940. /**
  40941. * Reads pixels from the current frame buffer. Please note that this function can be slow
  40942. * @param x defines the x coordinate of the rectangle where pixels must be read
  40943. * @param y defines the y coordinate of the rectangle where pixels must be read
  40944. * @param width defines the width of the rectangle where pixels must be read
  40945. * @param height defines the height of the rectangle where pixels must be read
  40946. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  40947. * @returns a Uint8Array containing RGBA colors
  40948. */
  40949. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  40950. private static _IsSupported;
  40951. private static _HasMajorPerformanceCaveat;
  40952. /**
  40953. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40954. */
  40955. static get IsSupported(): boolean;
  40956. /**
  40957. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40958. * @returns true if the engine can be created
  40959. * @ignorenaming
  40960. */
  40961. static isSupported(): boolean;
  40962. /**
  40963. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  40964. */
  40965. static get HasMajorPerformanceCaveat(): boolean;
  40966. /**
  40967. * Find the next highest power of two.
  40968. * @param x Number to start search from.
  40969. * @return Next highest power of two.
  40970. */
  40971. static CeilingPOT(x: number): number;
  40972. /**
  40973. * Find the next lowest power of two.
  40974. * @param x Number to start search from.
  40975. * @return Next lowest power of two.
  40976. */
  40977. static FloorPOT(x: number): number;
  40978. /**
  40979. * Find the nearest power of two.
  40980. * @param x Number to start search from.
  40981. * @return Next nearest power of two.
  40982. */
  40983. static NearestPOT(x: number): number;
  40984. /**
  40985. * Get the closest exponent of two
  40986. * @param value defines the value to approximate
  40987. * @param max defines the maximum value to return
  40988. * @param mode defines how to define the closest value
  40989. * @returns closest exponent of two of the given value
  40990. */
  40991. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  40992. /**
  40993. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  40994. * @param func - the function to be called
  40995. * @param requester - the object that will request the next frame. Falls back to window.
  40996. * @returns frame number
  40997. */
  40998. static QueueNewFrame(func: () => void, requester?: any): number;
  40999. /**
  41000. * Gets host document
  41001. * @returns the host document object
  41002. */
  41003. getHostDocument(): Nullable<Document>;
  41004. }
  41005. }
  41006. declare module "babylonjs/Materials/Textures/internalTexture" {
  41007. import { Observable } from "babylonjs/Misc/observable";
  41008. import { Nullable, int } from "babylonjs/types";
  41009. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  41010. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41011. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  41012. /**
  41013. * Defines the source of the internal texture
  41014. */
  41015. export enum InternalTextureSource {
  41016. /**
  41017. * The source of the texture data is unknown
  41018. */
  41019. Unknown = 0,
  41020. /**
  41021. * Texture data comes from an URL
  41022. */
  41023. Url = 1,
  41024. /**
  41025. * Texture data is only used for temporary storage
  41026. */
  41027. Temp = 2,
  41028. /**
  41029. * Texture data comes from raw data (ArrayBuffer)
  41030. */
  41031. Raw = 3,
  41032. /**
  41033. * Texture content is dynamic (video or dynamic texture)
  41034. */
  41035. Dynamic = 4,
  41036. /**
  41037. * Texture content is generated by rendering to it
  41038. */
  41039. RenderTarget = 5,
  41040. /**
  41041. * Texture content is part of a multi render target process
  41042. */
  41043. MultiRenderTarget = 6,
  41044. /**
  41045. * Texture data comes from a cube data file
  41046. */
  41047. Cube = 7,
  41048. /**
  41049. * Texture data comes from a raw cube data
  41050. */
  41051. CubeRaw = 8,
  41052. /**
  41053. * Texture data come from a prefiltered cube data file
  41054. */
  41055. CubePrefiltered = 9,
  41056. /**
  41057. * Texture content is raw 3D data
  41058. */
  41059. Raw3D = 10,
  41060. /**
  41061. * Texture content is raw 2D array data
  41062. */
  41063. Raw2DArray = 11,
  41064. /**
  41065. * Texture content is a depth texture
  41066. */
  41067. Depth = 12,
  41068. /**
  41069. * Texture data comes from a raw cube data encoded with RGBD
  41070. */
  41071. CubeRawRGBD = 13
  41072. }
  41073. /**
  41074. * Class used to store data associated with WebGL texture data for the engine
  41075. * This class should not be used directly
  41076. */
  41077. export class InternalTexture {
  41078. /** @hidden */
  41079. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41080. /**
  41081. * Defines if the texture is ready
  41082. */
  41083. isReady: boolean;
  41084. /**
  41085. * Defines if the texture is a cube texture
  41086. */
  41087. isCube: boolean;
  41088. /**
  41089. * Defines if the texture contains 3D data
  41090. */
  41091. is3D: boolean;
  41092. /**
  41093. * Defines if the texture contains 2D array data
  41094. */
  41095. is2DArray: boolean;
  41096. /**
  41097. * Defines if the texture contains multiview data
  41098. */
  41099. isMultiview: boolean;
  41100. /**
  41101. * Gets the URL used to load this texture
  41102. */
  41103. url: string;
  41104. /**
  41105. * Gets the sampling mode of the texture
  41106. */
  41107. samplingMode: number;
  41108. /**
  41109. * Gets a boolean indicating if the texture needs mipmaps generation
  41110. */
  41111. generateMipMaps: boolean;
  41112. /**
  41113. * Gets the number of samples used by the texture (WebGL2+ only)
  41114. */
  41115. samples: number;
  41116. /**
  41117. * Gets the type of the texture (int, float...)
  41118. */
  41119. type: number;
  41120. /**
  41121. * Gets the format of the texture (RGB, RGBA...)
  41122. */
  41123. format: number;
  41124. /**
  41125. * Observable called when the texture is loaded
  41126. */
  41127. onLoadedObservable: Observable<InternalTexture>;
  41128. /**
  41129. * Gets the width of the texture
  41130. */
  41131. width: number;
  41132. /**
  41133. * Gets the height of the texture
  41134. */
  41135. height: number;
  41136. /**
  41137. * Gets the depth of the texture
  41138. */
  41139. depth: number;
  41140. /**
  41141. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41142. */
  41143. baseWidth: number;
  41144. /**
  41145. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41146. */
  41147. baseHeight: number;
  41148. /**
  41149. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41150. */
  41151. baseDepth: number;
  41152. /**
  41153. * Gets a boolean indicating if the texture is inverted on Y axis
  41154. */
  41155. invertY: boolean;
  41156. /** @hidden */
  41157. _invertVScale: boolean;
  41158. /** @hidden */
  41159. _associatedChannel: number;
  41160. /** @hidden */
  41161. _source: InternalTextureSource;
  41162. /** @hidden */
  41163. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41164. /** @hidden */
  41165. _bufferView: Nullable<ArrayBufferView>;
  41166. /** @hidden */
  41167. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41168. /** @hidden */
  41169. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41170. /** @hidden */
  41171. _size: number;
  41172. /** @hidden */
  41173. _extension: string;
  41174. /** @hidden */
  41175. _files: Nullable<string[]>;
  41176. /** @hidden */
  41177. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41178. /** @hidden */
  41179. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41180. /** @hidden */
  41181. _framebuffer: Nullable<WebGLFramebuffer>;
  41182. /** @hidden */
  41183. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41184. /** @hidden */
  41185. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41186. /** @hidden */
  41187. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41188. /** @hidden */
  41189. _attachments: Nullable<number[]>;
  41190. /** @hidden */
  41191. _textureArray: Nullable<InternalTexture[]>;
  41192. /** @hidden */
  41193. _cachedCoordinatesMode: Nullable<number>;
  41194. /** @hidden */
  41195. _cachedWrapU: Nullable<number>;
  41196. /** @hidden */
  41197. _cachedWrapV: Nullable<number>;
  41198. /** @hidden */
  41199. _cachedWrapR: Nullable<number>;
  41200. /** @hidden */
  41201. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41202. /** @hidden */
  41203. _isDisabled: boolean;
  41204. /** @hidden */
  41205. _compression: Nullable<string>;
  41206. /** @hidden */
  41207. _generateStencilBuffer: boolean;
  41208. /** @hidden */
  41209. _generateDepthBuffer: boolean;
  41210. /** @hidden */
  41211. _comparisonFunction: number;
  41212. /** @hidden */
  41213. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41214. /** @hidden */
  41215. _lodGenerationScale: number;
  41216. /** @hidden */
  41217. _lodGenerationOffset: number;
  41218. /** @hidden */
  41219. _depthStencilTexture: Nullable<InternalTexture>;
  41220. /** @hidden */
  41221. _colorTextureArray: Nullable<WebGLTexture>;
  41222. /** @hidden */
  41223. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41224. /** @hidden */
  41225. _lodTextureHigh: Nullable<BaseTexture>;
  41226. /** @hidden */
  41227. _lodTextureMid: Nullable<BaseTexture>;
  41228. /** @hidden */
  41229. _lodTextureLow: Nullable<BaseTexture>;
  41230. /** @hidden */
  41231. _isRGBD: boolean;
  41232. /** @hidden */
  41233. _linearSpecularLOD: boolean;
  41234. /** @hidden */
  41235. _irradianceTexture: Nullable<BaseTexture>;
  41236. /** @hidden */
  41237. _webGLTexture: Nullable<WebGLTexture>;
  41238. /** @hidden */
  41239. _references: number;
  41240. /** @hidden */
  41241. _gammaSpace: Nullable<boolean>;
  41242. private _engine;
  41243. /**
  41244. * Gets the Engine the texture belongs to.
  41245. * @returns The babylon engine
  41246. */
  41247. getEngine(): ThinEngine;
  41248. /**
  41249. * Gets the data source type of the texture
  41250. */
  41251. get source(): InternalTextureSource;
  41252. /**
  41253. * Creates a new InternalTexture
  41254. * @param engine defines the engine to use
  41255. * @param source defines the type of data that will be used
  41256. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41257. */
  41258. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41259. /**
  41260. * Increments the number of references (ie. the number of Texture that point to it)
  41261. */
  41262. incrementReferences(): void;
  41263. /**
  41264. * Change the size of the texture (not the size of the content)
  41265. * @param width defines the new width
  41266. * @param height defines the new height
  41267. * @param depth defines the new depth (1 by default)
  41268. */
  41269. updateSize(width: int, height: int, depth?: int): void;
  41270. /** @hidden */
  41271. _rebuild(): void;
  41272. /** @hidden */
  41273. _swapAndDie(target: InternalTexture): void;
  41274. /**
  41275. * Dispose the current allocated resources
  41276. */
  41277. dispose(): void;
  41278. }
  41279. }
  41280. declare module "babylonjs/Audio/analyser" {
  41281. import { Scene } from "babylonjs/scene";
  41282. /**
  41283. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41284. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41285. */
  41286. export class Analyser {
  41287. /**
  41288. * Gets or sets the smoothing
  41289. * @ignorenaming
  41290. */
  41291. SMOOTHING: number;
  41292. /**
  41293. * Gets or sets the FFT table size
  41294. * @ignorenaming
  41295. */
  41296. FFT_SIZE: number;
  41297. /**
  41298. * Gets or sets the bar graph amplitude
  41299. * @ignorenaming
  41300. */
  41301. BARGRAPHAMPLITUDE: number;
  41302. /**
  41303. * Gets or sets the position of the debug canvas
  41304. * @ignorenaming
  41305. */
  41306. DEBUGCANVASPOS: {
  41307. x: number;
  41308. y: number;
  41309. };
  41310. /**
  41311. * Gets or sets the debug canvas size
  41312. * @ignorenaming
  41313. */
  41314. DEBUGCANVASSIZE: {
  41315. width: number;
  41316. height: number;
  41317. };
  41318. private _byteFreqs;
  41319. private _byteTime;
  41320. private _floatFreqs;
  41321. private _webAudioAnalyser;
  41322. private _debugCanvas;
  41323. private _debugCanvasContext;
  41324. private _scene;
  41325. private _registerFunc;
  41326. private _audioEngine;
  41327. /**
  41328. * Creates a new analyser
  41329. * @param scene defines hosting scene
  41330. */
  41331. constructor(scene: Scene);
  41332. /**
  41333. * Get the number of data values you will have to play with for the visualization
  41334. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41335. * @returns a number
  41336. */
  41337. getFrequencyBinCount(): number;
  41338. /**
  41339. * Gets the current frequency data as a byte array
  41340. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41341. * @returns a Uint8Array
  41342. */
  41343. getByteFrequencyData(): Uint8Array;
  41344. /**
  41345. * Gets the current waveform as a byte array
  41346. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41347. * @returns a Uint8Array
  41348. */
  41349. getByteTimeDomainData(): Uint8Array;
  41350. /**
  41351. * Gets the current frequency data as a float array
  41352. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41353. * @returns a Float32Array
  41354. */
  41355. getFloatFrequencyData(): Float32Array;
  41356. /**
  41357. * Renders the debug canvas
  41358. */
  41359. drawDebugCanvas(): void;
  41360. /**
  41361. * Stops rendering the debug canvas and removes it
  41362. */
  41363. stopDebugCanvas(): void;
  41364. /**
  41365. * Connects two audio nodes
  41366. * @param inputAudioNode defines first node to connect
  41367. * @param outputAudioNode defines second node to connect
  41368. */
  41369. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41370. /**
  41371. * Releases all associated resources
  41372. */
  41373. dispose(): void;
  41374. }
  41375. }
  41376. declare module "babylonjs/Audio/audioEngine" {
  41377. import { IDisposable } from "babylonjs/scene";
  41378. import { Analyser } from "babylonjs/Audio/analyser";
  41379. import { Nullable } from "babylonjs/types";
  41380. import { Observable } from "babylonjs/Misc/observable";
  41381. /**
  41382. * This represents an audio engine and it is responsible
  41383. * to play, synchronize and analyse sounds throughout the application.
  41384. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41385. */
  41386. export interface IAudioEngine extends IDisposable {
  41387. /**
  41388. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41389. */
  41390. readonly canUseWebAudio: boolean;
  41391. /**
  41392. * Gets the current AudioContext if available.
  41393. */
  41394. readonly audioContext: Nullable<AudioContext>;
  41395. /**
  41396. * The master gain node defines the global audio volume of your audio engine.
  41397. */
  41398. readonly masterGain: GainNode;
  41399. /**
  41400. * Gets whether or not mp3 are supported by your browser.
  41401. */
  41402. readonly isMP3supported: boolean;
  41403. /**
  41404. * Gets whether or not ogg are supported by your browser.
  41405. */
  41406. readonly isOGGsupported: boolean;
  41407. /**
  41408. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41409. * @ignoreNaming
  41410. */
  41411. WarnedWebAudioUnsupported: boolean;
  41412. /**
  41413. * Defines if the audio engine relies on a custom unlocked button.
  41414. * In this case, the embedded button will not be displayed.
  41415. */
  41416. useCustomUnlockedButton: boolean;
  41417. /**
  41418. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  41419. */
  41420. readonly unlocked: boolean;
  41421. /**
  41422. * Event raised when audio has been unlocked on the browser.
  41423. */
  41424. onAudioUnlockedObservable: Observable<AudioEngine>;
  41425. /**
  41426. * Event raised when audio has been locked on the browser.
  41427. */
  41428. onAudioLockedObservable: Observable<AudioEngine>;
  41429. /**
  41430. * Flags the audio engine in Locked state.
  41431. * This happens due to new browser policies preventing audio to autoplay.
  41432. */
  41433. lock(): void;
  41434. /**
  41435. * Unlocks the audio engine once a user action has been done on the dom.
  41436. * This is helpful to resume play once browser policies have been satisfied.
  41437. */
  41438. unlock(): void;
  41439. /**
  41440. * Gets the global volume sets on the master gain.
  41441. * @returns the global volume if set or -1 otherwise
  41442. */
  41443. getGlobalVolume(): number;
  41444. /**
  41445. * Sets the global volume of your experience (sets on the master gain).
  41446. * @param newVolume Defines the new global volume of the application
  41447. */
  41448. setGlobalVolume(newVolume: number): void;
  41449. /**
  41450. * Connect the audio engine to an audio analyser allowing some amazing
  41451. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41452. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41453. * @param analyser The analyser to connect to the engine
  41454. */
  41455. connectToAnalyser(analyser: Analyser): void;
  41456. }
  41457. /**
  41458. * This represents the default audio engine used in babylon.
  41459. * It is responsible to play, synchronize and analyse sounds throughout the application.
  41460. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41461. */
  41462. export class AudioEngine implements IAudioEngine {
  41463. private _audioContext;
  41464. private _audioContextInitialized;
  41465. private _muteButton;
  41466. private _hostElement;
  41467. /**
  41468. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41469. */
  41470. canUseWebAudio: boolean;
  41471. /**
  41472. * The master gain node defines the global audio volume of your audio engine.
  41473. */
  41474. masterGain: GainNode;
  41475. /**
  41476. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41477. * @ignoreNaming
  41478. */
  41479. WarnedWebAudioUnsupported: boolean;
  41480. /**
  41481. * Gets whether or not mp3 are supported by your browser.
  41482. */
  41483. isMP3supported: boolean;
  41484. /**
  41485. * Gets whether or not ogg are supported by your browser.
  41486. */
  41487. isOGGsupported: boolean;
  41488. /**
  41489. * Gets whether audio has been unlocked on the device.
  41490. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  41491. * a user interaction has happened.
  41492. */
  41493. unlocked: boolean;
  41494. /**
  41495. * Defines if the audio engine relies on a custom unlocked button.
  41496. * In this case, the embedded button will not be displayed.
  41497. */
  41498. useCustomUnlockedButton: boolean;
  41499. /**
  41500. * Event raised when audio has been unlocked on the browser.
  41501. */
  41502. onAudioUnlockedObservable: Observable<AudioEngine>;
  41503. /**
  41504. * Event raised when audio has been locked on the browser.
  41505. */
  41506. onAudioLockedObservable: Observable<AudioEngine>;
  41507. /**
  41508. * Gets the current AudioContext if available.
  41509. */
  41510. get audioContext(): Nullable<AudioContext>;
  41511. private _connectedAnalyser;
  41512. /**
  41513. * Instantiates a new audio engine.
  41514. *
  41515. * There should be only one per page as some browsers restrict the number
  41516. * of audio contexts you can create.
  41517. * @param hostElement defines the host element where to display the mute icon if necessary
  41518. */
  41519. constructor(hostElement?: Nullable<HTMLElement>);
  41520. /**
  41521. * Flags the audio engine in Locked state.
  41522. * This happens due to new browser policies preventing audio to autoplay.
  41523. */
  41524. lock(): void;
  41525. /**
  41526. * Unlocks the audio engine once a user action has been done on the dom.
  41527. * This is helpful to resume play once browser policies have been satisfied.
  41528. */
  41529. unlock(): void;
  41530. private _resumeAudioContext;
  41531. private _initializeAudioContext;
  41532. private _tryToRun;
  41533. private _triggerRunningState;
  41534. private _triggerSuspendedState;
  41535. private _displayMuteButton;
  41536. private _moveButtonToTopLeft;
  41537. private _onResize;
  41538. private _hideMuteButton;
  41539. /**
  41540. * Destroy and release the resources associated with the audio ccontext.
  41541. */
  41542. dispose(): void;
  41543. /**
  41544. * Gets the global volume sets on the master gain.
  41545. * @returns the global volume if set or -1 otherwise
  41546. */
  41547. getGlobalVolume(): number;
  41548. /**
  41549. * Sets the global volume of your experience (sets on the master gain).
  41550. * @param newVolume Defines the new global volume of the application
  41551. */
  41552. setGlobalVolume(newVolume: number): void;
  41553. /**
  41554. * Connect the audio engine to an audio analyser allowing some amazing
  41555. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41556. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41557. * @param analyser The analyser to connect to the engine
  41558. */
  41559. connectToAnalyser(analyser: Analyser): void;
  41560. }
  41561. }
  41562. declare module "babylonjs/Loading/loadingScreen" {
  41563. /**
  41564. * Interface used to present a loading screen while loading a scene
  41565. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41566. */
  41567. export interface ILoadingScreen {
  41568. /**
  41569. * Function called to display the loading screen
  41570. */
  41571. displayLoadingUI: () => void;
  41572. /**
  41573. * Function called to hide the loading screen
  41574. */
  41575. hideLoadingUI: () => void;
  41576. /**
  41577. * Gets or sets the color to use for the background
  41578. */
  41579. loadingUIBackgroundColor: string;
  41580. /**
  41581. * Gets or sets the text to display while loading
  41582. */
  41583. loadingUIText: string;
  41584. }
  41585. /**
  41586. * Class used for the default loading screen
  41587. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41588. */
  41589. export class DefaultLoadingScreen implements ILoadingScreen {
  41590. private _renderingCanvas;
  41591. private _loadingText;
  41592. private _loadingDivBackgroundColor;
  41593. private _loadingDiv;
  41594. private _loadingTextDiv;
  41595. /** Gets or sets the logo url to use for the default loading screen */
  41596. static DefaultLogoUrl: string;
  41597. /** Gets or sets the spinner url to use for the default loading screen */
  41598. static DefaultSpinnerUrl: string;
  41599. /**
  41600. * Creates a new default loading screen
  41601. * @param _renderingCanvas defines the canvas used to render the scene
  41602. * @param _loadingText defines the default text to display
  41603. * @param _loadingDivBackgroundColor defines the default background color
  41604. */
  41605. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41606. /**
  41607. * Function called to display the loading screen
  41608. */
  41609. displayLoadingUI(): void;
  41610. /**
  41611. * Function called to hide the loading screen
  41612. */
  41613. hideLoadingUI(): void;
  41614. /**
  41615. * Gets or sets the text to display while loading
  41616. */
  41617. set loadingUIText(text: string);
  41618. get loadingUIText(): string;
  41619. /**
  41620. * Gets or sets the color to use for the background
  41621. */
  41622. get loadingUIBackgroundColor(): string;
  41623. set loadingUIBackgroundColor(color: string);
  41624. private _resizeLoadingUI;
  41625. }
  41626. }
  41627. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  41628. /**
  41629. * Interface for any object that can request an animation frame
  41630. */
  41631. export interface ICustomAnimationFrameRequester {
  41632. /**
  41633. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41634. */
  41635. renderFunction?: Function;
  41636. /**
  41637. * Called to request the next frame to render to
  41638. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41639. */
  41640. requestAnimationFrame: Function;
  41641. /**
  41642. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41643. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41644. */
  41645. requestID?: number;
  41646. }
  41647. }
  41648. declare module "babylonjs/Misc/performanceMonitor" {
  41649. /**
  41650. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41651. */
  41652. export class PerformanceMonitor {
  41653. private _enabled;
  41654. private _rollingFrameTime;
  41655. private _lastFrameTimeMs;
  41656. /**
  41657. * constructor
  41658. * @param frameSampleSize The number of samples required to saturate the sliding window
  41659. */
  41660. constructor(frameSampleSize?: number);
  41661. /**
  41662. * Samples current frame
  41663. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41664. */
  41665. sampleFrame(timeMs?: number): void;
  41666. /**
  41667. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41668. */
  41669. get averageFrameTime(): number;
  41670. /**
  41671. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41672. */
  41673. get averageFrameTimeVariance(): number;
  41674. /**
  41675. * Returns the frame time of the most recent frame
  41676. */
  41677. get instantaneousFrameTime(): number;
  41678. /**
  41679. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41680. */
  41681. get averageFPS(): number;
  41682. /**
  41683. * Returns the average framerate in frames per second using the most recent frame time
  41684. */
  41685. get instantaneousFPS(): number;
  41686. /**
  41687. * Returns true if enough samples have been taken to completely fill the sliding window
  41688. */
  41689. get isSaturated(): boolean;
  41690. /**
  41691. * Enables contributions to the sliding window sample set
  41692. */
  41693. enable(): void;
  41694. /**
  41695. * Disables contributions to the sliding window sample set
  41696. * Samples will not be interpolated over the disabled period
  41697. */
  41698. disable(): void;
  41699. /**
  41700. * Returns true if sampling is enabled
  41701. */
  41702. get isEnabled(): boolean;
  41703. /**
  41704. * Resets performance monitor
  41705. */
  41706. reset(): void;
  41707. }
  41708. /**
  41709. * RollingAverage
  41710. *
  41711. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41712. */
  41713. export class RollingAverage {
  41714. /**
  41715. * Current average
  41716. */
  41717. average: number;
  41718. /**
  41719. * Current variance
  41720. */
  41721. variance: number;
  41722. protected _samples: Array<number>;
  41723. protected _sampleCount: number;
  41724. protected _pos: number;
  41725. protected _m2: number;
  41726. /**
  41727. * constructor
  41728. * @param length The number of samples required to saturate the sliding window
  41729. */
  41730. constructor(length: number);
  41731. /**
  41732. * Adds a sample to the sample set
  41733. * @param v The sample value
  41734. */
  41735. add(v: number): void;
  41736. /**
  41737. * Returns previously added values or null if outside of history or outside the sliding window domain
  41738. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41739. * @return Value previously recorded with add() or null if outside of range
  41740. */
  41741. history(i: number): number;
  41742. /**
  41743. * Returns true if enough samples have been taken to completely fill the sliding window
  41744. * @return true if sample-set saturated
  41745. */
  41746. isSaturated(): boolean;
  41747. /**
  41748. * Resets the rolling average (equivalent to 0 samples taken so far)
  41749. */
  41750. reset(): void;
  41751. /**
  41752. * Wraps a value around the sample range boundaries
  41753. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41754. * @return Wrapped position in sample range
  41755. */
  41756. protected _wrapPosition(i: number): number;
  41757. }
  41758. }
  41759. declare module "babylonjs/Misc/perfCounter" {
  41760. /**
  41761. * This class is used to track a performance counter which is number based.
  41762. * The user has access to many properties which give statistics of different nature.
  41763. *
  41764. * The implementer can track two kinds of Performance Counter: time and count.
  41765. * 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.
  41766. * 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.
  41767. */
  41768. export class PerfCounter {
  41769. /**
  41770. * Gets or sets a global boolean to turn on and off all the counters
  41771. */
  41772. static Enabled: boolean;
  41773. /**
  41774. * Returns the smallest value ever
  41775. */
  41776. get min(): number;
  41777. /**
  41778. * Returns the biggest value ever
  41779. */
  41780. get max(): number;
  41781. /**
  41782. * Returns the average value since the performance counter is running
  41783. */
  41784. get average(): number;
  41785. /**
  41786. * Returns the average value of the last second the counter was monitored
  41787. */
  41788. get lastSecAverage(): number;
  41789. /**
  41790. * Returns the current value
  41791. */
  41792. get current(): number;
  41793. /**
  41794. * Gets the accumulated total
  41795. */
  41796. get total(): number;
  41797. /**
  41798. * Gets the total value count
  41799. */
  41800. get count(): number;
  41801. /**
  41802. * Creates a new counter
  41803. */
  41804. constructor();
  41805. /**
  41806. * Call this method to start monitoring a new frame.
  41807. * 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.
  41808. */
  41809. fetchNewFrame(): void;
  41810. /**
  41811. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41812. * @param newCount the count value to add to the monitored count
  41813. * @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.
  41814. */
  41815. addCount(newCount: number, fetchResult: boolean): void;
  41816. /**
  41817. * Start monitoring this performance counter
  41818. */
  41819. beginMonitoring(): void;
  41820. /**
  41821. * Compute the time lapsed since the previous beginMonitoring() call.
  41822. * @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
  41823. */
  41824. endMonitoring(newFrame?: boolean): void;
  41825. private _fetchResult;
  41826. private _startMonitoringTime;
  41827. private _min;
  41828. private _max;
  41829. private _average;
  41830. private _current;
  41831. private _totalValueCount;
  41832. private _totalAccumulated;
  41833. private _lastSecAverage;
  41834. private _lastSecAccumulated;
  41835. private _lastSecTime;
  41836. private _lastSecValueCount;
  41837. }
  41838. }
  41839. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  41840. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41841. import { Nullable } from "babylonjs/types";
  41842. module "babylonjs/Engines/thinEngine" {
  41843. interface ThinEngine {
  41844. /** @hidden */
  41845. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  41846. }
  41847. }
  41848. }
  41849. declare module "babylonjs/Engines/engine" {
  41850. import { Observable } from "babylonjs/Misc/observable";
  41851. import { Nullable } from "babylonjs/types";
  41852. import { Scene } from "babylonjs/scene";
  41853. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41854. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  41855. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  41856. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  41857. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  41858. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  41859. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  41860. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  41861. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  41862. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41863. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  41864. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  41865. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  41866. import "babylonjs/Engines/Extensions/engine.alpha";
  41867. import "babylonjs/Engines/Extensions/engine.readTexture";
  41868. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  41869. import { Material } from "babylonjs/Materials/material";
  41870. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41871. /**
  41872. * Defines the interface used by display changed events
  41873. */
  41874. export interface IDisplayChangedEventArgs {
  41875. /** Gets the vrDisplay object (if any) */
  41876. vrDisplay: Nullable<any>;
  41877. /** Gets a boolean indicating if webVR is supported */
  41878. vrSupported: boolean;
  41879. }
  41880. /**
  41881. * Defines the interface used by objects containing a viewport (like a camera)
  41882. */
  41883. interface IViewportOwnerLike {
  41884. /**
  41885. * Gets or sets the viewport
  41886. */
  41887. viewport: IViewportLike;
  41888. }
  41889. /**
  41890. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  41891. */
  41892. export class Engine extends ThinEngine {
  41893. /** Defines that alpha blending is disabled */
  41894. static readonly ALPHA_DISABLE: number;
  41895. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  41896. static readonly ALPHA_ADD: number;
  41897. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  41898. static readonly ALPHA_COMBINE: number;
  41899. /** Defines that alpha blending to DEST - SRC * DEST */
  41900. static readonly ALPHA_SUBTRACT: number;
  41901. /** Defines that alpha blending to SRC * DEST */
  41902. static readonly ALPHA_MULTIPLY: number;
  41903. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  41904. static readonly ALPHA_MAXIMIZED: number;
  41905. /** Defines that alpha blending to SRC + DEST */
  41906. static readonly ALPHA_ONEONE: number;
  41907. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  41908. static readonly ALPHA_PREMULTIPLIED: number;
  41909. /**
  41910. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  41911. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  41912. */
  41913. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  41914. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  41915. static readonly ALPHA_INTERPOLATE: number;
  41916. /**
  41917. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  41918. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  41919. */
  41920. static readonly ALPHA_SCREENMODE: number;
  41921. /** Defines that the ressource is not delayed*/
  41922. static readonly DELAYLOADSTATE_NONE: number;
  41923. /** Defines that the ressource was successfully delay loaded */
  41924. static readonly DELAYLOADSTATE_LOADED: number;
  41925. /** Defines that the ressource is currently delay loading */
  41926. static readonly DELAYLOADSTATE_LOADING: number;
  41927. /** Defines that the ressource is delayed and has not started loading */
  41928. static readonly DELAYLOADSTATE_NOTLOADED: number;
  41929. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  41930. static readonly NEVER: number;
  41931. /** 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 */
  41932. static readonly ALWAYS: number;
  41933. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  41934. static readonly LESS: number;
  41935. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  41936. static readonly EQUAL: number;
  41937. /** 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 */
  41938. static readonly LEQUAL: number;
  41939. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  41940. static readonly GREATER: number;
  41941. /** 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 */
  41942. static readonly GEQUAL: number;
  41943. /** 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 */
  41944. static readonly NOTEQUAL: number;
  41945. /** Passed to stencilOperation to specify that stencil value must be kept */
  41946. static readonly KEEP: number;
  41947. /** Passed to stencilOperation to specify that stencil value must be replaced */
  41948. static readonly REPLACE: number;
  41949. /** Passed to stencilOperation to specify that stencil value must be incremented */
  41950. static readonly INCR: number;
  41951. /** Passed to stencilOperation to specify that stencil value must be decremented */
  41952. static readonly DECR: number;
  41953. /** Passed to stencilOperation to specify that stencil value must be inverted */
  41954. static readonly INVERT: number;
  41955. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  41956. static readonly INCR_WRAP: number;
  41957. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  41958. static readonly DECR_WRAP: number;
  41959. /** Texture is not repeating outside of 0..1 UVs */
  41960. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  41961. /** Texture is repeating outside of 0..1 UVs */
  41962. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  41963. /** Texture is repeating and mirrored */
  41964. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  41965. /** ALPHA */
  41966. static readonly TEXTUREFORMAT_ALPHA: number;
  41967. /** LUMINANCE */
  41968. static readonly TEXTUREFORMAT_LUMINANCE: number;
  41969. /** LUMINANCE_ALPHA */
  41970. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  41971. /** RGB */
  41972. static readonly TEXTUREFORMAT_RGB: number;
  41973. /** RGBA */
  41974. static readonly TEXTUREFORMAT_RGBA: number;
  41975. /** RED */
  41976. static readonly TEXTUREFORMAT_RED: number;
  41977. /** RED (2nd reference) */
  41978. static readonly TEXTUREFORMAT_R: number;
  41979. /** RG */
  41980. static readonly TEXTUREFORMAT_RG: number;
  41981. /** RED_INTEGER */
  41982. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  41983. /** RED_INTEGER (2nd reference) */
  41984. static readonly TEXTUREFORMAT_R_INTEGER: number;
  41985. /** RG_INTEGER */
  41986. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  41987. /** RGB_INTEGER */
  41988. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  41989. /** RGBA_INTEGER */
  41990. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  41991. /** UNSIGNED_BYTE */
  41992. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  41993. /** UNSIGNED_BYTE (2nd reference) */
  41994. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  41995. /** FLOAT */
  41996. static readonly TEXTURETYPE_FLOAT: number;
  41997. /** HALF_FLOAT */
  41998. static readonly TEXTURETYPE_HALF_FLOAT: number;
  41999. /** BYTE */
  42000. static readonly TEXTURETYPE_BYTE: number;
  42001. /** SHORT */
  42002. static readonly TEXTURETYPE_SHORT: number;
  42003. /** UNSIGNED_SHORT */
  42004. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42005. /** INT */
  42006. static readonly TEXTURETYPE_INT: number;
  42007. /** UNSIGNED_INT */
  42008. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42009. /** UNSIGNED_SHORT_4_4_4_4 */
  42010. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42011. /** UNSIGNED_SHORT_5_5_5_1 */
  42012. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42013. /** UNSIGNED_SHORT_5_6_5 */
  42014. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42015. /** UNSIGNED_INT_2_10_10_10_REV */
  42016. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42017. /** UNSIGNED_INT_24_8 */
  42018. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42019. /** UNSIGNED_INT_10F_11F_11F_REV */
  42020. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42021. /** UNSIGNED_INT_5_9_9_9_REV */
  42022. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42023. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42024. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42025. /** nearest is mag = nearest and min = nearest and mip = linear */
  42026. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42027. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42028. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42029. /** Trilinear is mag = linear and min = linear and mip = linear */
  42030. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42031. /** nearest is mag = nearest and min = nearest and mip = linear */
  42032. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42033. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42034. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42035. /** Trilinear is mag = linear and min = linear and mip = linear */
  42036. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42037. /** mag = nearest and min = nearest and mip = nearest */
  42038. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42039. /** mag = nearest and min = linear and mip = nearest */
  42040. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42041. /** mag = nearest and min = linear and mip = linear */
  42042. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42043. /** mag = nearest and min = linear and mip = none */
  42044. static readonly TEXTURE_NEAREST_LINEAR: number;
  42045. /** mag = nearest and min = nearest and mip = none */
  42046. static readonly TEXTURE_NEAREST_NEAREST: number;
  42047. /** mag = linear and min = nearest and mip = nearest */
  42048. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42049. /** mag = linear and min = nearest and mip = linear */
  42050. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42051. /** mag = linear and min = linear and mip = none */
  42052. static readonly TEXTURE_LINEAR_LINEAR: number;
  42053. /** mag = linear and min = nearest and mip = none */
  42054. static readonly TEXTURE_LINEAR_NEAREST: number;
  42055. /** Explicit coordinates mode */
  42056. static readonly TEXTURE_EXPLICIT_MODE: number;
  42057. /** Spherical coordinates mode */
  42058. static readonly TEXTURE_SPHERICAL_MODE: number;
  42059. /** Planar coordinates mode */
  42060. static readonly TEXTURE_PLANAR_MODE: number;
  42061. /** Cubic coordinates mode */
  42062. static readonly TEXTURE_CUBIC_MODE: number;
  42063. /** Projection coordinates mode */
  42064. static readonly TEXTURE_PROJECTION_MODE: number;
  42065. /** Skybox coordinates mode */
  42066. static readonly TEXTURE_SKYBOX_MODE: number;
  42067. /** Inverse Cubic coordinates mode */
  42068. static readonly TEXTURE_INVCUBIC_MODE: number;
  42069. /** Equirectangular coordinates mode */
  42070. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42071. /** Equirectangular Fixed coordinates mode */
  42072. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42073. /** Equirectangular Fixed Mirrored coordinates mode */
  42074. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42075. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42076. static readonly SCALEMODE_FLOOR: number;
  42077. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42078. static readonly SCALEMODE_NEAREST: number;
  42079. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42080. static readonly SCALEMODE_CEILING: number;
  42081. /**
  42082. * Returns the current npm package of the sdk
  42083. */
  42084. static get NpmPackage(): string;
  42085. /**
  42086. * Returns the current version of the framework
  42087. */
  42088. static get Version(): string;
  42089. /** Gets the list of created engines */
  42090. static get Instances(): Engine[];
  42091. /**
  42092. * Gets the latest created engine
  42093. */
  42094. static get LastCreatedEngine(): Nullable<Engine>;
  42095. /**
  42096. * Gets the latest created scene
  42097. */
  42098. static get LastCreatedScene(): Nullable<Scene>;
  42099. /**
  42100. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42101. * @param flag defines which part of the materials must be marked as dirty
  42102. * @param predicate defines a predicate used to filter which materials should be affected
  42103. */
  42104. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42105. /**
  42106. * Method called to create the default loading screen.
  42107. * This can be overriden in your own app.
  42108. * @param canvas The rendering canvas element
  42109. * @returns The loading screen
  42110. */
  42111. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42112. /**
  42113. * Method called to create the default rescale post process on each engine.
  42114. */
  42115. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42116. /**
  42117. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42118. **/
  42119. enableOfflineSupport: boolean;
  42120. /**
  42121. * 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)
  42122. **/
  42123. disableManifestCheck: boolean;
  42124. /**
  42125. * Gets the list of created scenes
  42126. */
  42127. scenes: Scene[];
  42128. /**
  42129. * Event raised when a new scene is created
  42130. */
  42131. onNewSceneAddedObservable: Observable<Scene>;
  42132. /**
  42133. * Gets the list of created postprocesses
  42134. */
  42135. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42136. /**
  42137. * Gets a boolean indicating if the pointer is currently locked
  42138. */
  42139. isPointerLock: boolean;
  42140. /**
  42141. * Observable event triggered each time the rendering canvas is resized
  42142. */
  42143. onResizeObservable: Observable<Engine>;
  42144. /**
  42145. * Observable event triggered each time the canvas loses focus
  42146. */
  42147. onCanvasBlurObservable: Observable<Engine>;
  42148. /**
  42149. * Observable event triggered each time the canvas gains focus
  42150. */
  42151. onCanvasFocusObservable: Observable<Engine>;
  42152. /**
  42153. * Observable event triggered each time the canvas receives pointerout event
  42154. */
  42155. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42156. /**
  42157. * Observable raised when the engine begins a new frame
  42158. */
  42159. onBeginFrameObservable: Observable<Engine>;
  42160. /**
  42161. * If set, will be used to request the next animation frame for the render loop
  42162. */
  42163. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42164. /**
  42165. * Observable raised when the engine ends the current frame
  42166. */
  42167. onEndFrameObservable: Observable<Engine>;
  42168. /**
  42169. * Observable raised when the engine is about to compile a shader
  42170. */
  42171. onBeforeShaderCompilationObservable: Observable<Engine>;
  42172. /**
  42173. * Observable raised when the engine has jsut compiled a shader
  42174. */
  42175. onAfterShaderCompilationObservable: Observable<Engine>;
  42176. /**
  42177. * Gets the audio engine
  42178. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42179. * @ignorenaming
  42180. */
  42181. static audioEngine: IAudioEngine;
  42182. /**
  42183. * Default AudioEngine factory responsible of creating the Audio Engine.
  42184. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42185. */
  42186. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42187. /**
  42188. * Default offline support factory responsible of creating a tool used to store data locally.
  42189. * By default, this will create a Database object if the workload has been embedded.
  42190. */
  42191. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42192. private _loadingScreen;
  42193. private _pointerLockRequested;
  42194. private _rescalePostProcess;
  42195. private _deterministicLockstep;
  42196. private _lockstepMaxSteps;
  42197. private _timeStep;
  42198. protected get _supportsHardwareTextureRescaling(): boolean;
  42199. private _fps;
  42200. private _deltaTime;
  42201. /** @hidden */
  42202. _drawCalls: PerfCounter;
  42203. /** 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 */
  42204. canvasTabIndex: number;
  42205. /**
  42206. * Turn this value on if you want to pause FPS computation when in background
  42207. */
  42208. disablePerformanceMonitorInBackground: boolean;
  42209. private _performanceMonitor;
  42210. /**
  42211. * Gets the performance monitor attached to this engine
  42212. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42213. */
  42214. get performanceMonitor(): PerformanceMonitor;
  42215. private _onFocus;
  42216. private _onBlur;
  42217. private _onCanvasPointerOut;
  42218. private _onCanvasBlur;
  42219. private _onCanvasFocus;
  42220. private _onFullscreenChange;
  42221. private _onPointerLockChange;
  42222. /**
  42223. * Gets the HTML element used to attach event listeners
  42224. * @returns a HTML element
  42225. */
  42226. getInputElement(): Nullable<HTMLElement>;
  42227. /**
  42228. * Creates a new engine
  42229. * @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
  42230. * @param antialias defines enable antialiasing (default: false)
  42231. * @param options defines further options to be sent to the getContext() function
  42232. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42233. */
  42234. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42235. /**
  42236. * Gets current aspect ratio
  42237. * @param viewportOwner defines the camera to use to get the aspect ratio
  42238. * @param useScreen defines if screen size must be used (or the current render target if any)
  42239. * @returns a number defining the aspect ratio
  42240. */
  42241. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42242. /**
  42243. * Gets current screen aspect ratio
  42244. * @returns a number defining the aspect ratio
  42245. */
  42246. getScreenAspectRatio(): number;
  42247. /**
  42248. * Gets the client rect of the HTML canvas attached with the current webGL context
  42249. * @returns a client rectanglee
  42250. */
  42251. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42252. /**
  42253. * Gets the client rect of the HTML element used for events
  42254. * @returns a client rectanglee
  42255. */
  42256. getInputElementClientRect(): Nullable<ClientRect>;
  42257. /**
  42258. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42259. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42260. * @returns true if engine is in deterministic lock step mode
  42261. */
  42262. isDeterministicLockStep(): boolean;
  42263. /**
  42264. * Gets the max steps when engine is running in deterministic lock step
  42265. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42266. * @returns the max steps
  42267. */
  42268. getLockstepMaxSteps(): number;
  42269. /**
  42270. * Returns the time in ms between steps when using deterministic lock step.
  42271. * @returns time step in (ms)
  42272. */
  42273. getTimeStep(): number;
  42274. /**
  42275. * Force the mipmap generation for the given render target texture
  42276. * @param texture defines the render target texture to use
  42277. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42278. */
  42279. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42280. /** States */
  42281. /**
  42282. * Set various states to the webGL context
  42283. * @param culling defines backface culling state
  42284. * @param zOffset defines the value to apply to zOffset (0 by default)
  42285. * @param force defines if states must be applied even if cache is up to date
  42286. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42287. */
  42288. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42289. /**
  42290. * Set the z offset to apply to current rendering
  42291. * @param value defines the offset to apply
  42292. */
  42293. setZOffset(value: number): void;
  42294. /**
  42295. * Gets the current value of the zOffset
  42296. * @returns the current zOffset state
  42297. */
  42298. getZOffset(): number;
  42299. /**
  42300. * Enable or disable depth buffering
  42301. * @param enable defines the state to set
  42302. */
  42303. setDepthBuffer(enable: boolean): void;
  42304. /**
  42305. * Gets a boolean indicating if depth writing is enabled
  42306. * @returns the current depth writing state
  42307. */
  42308. getDepthWrite(): boolean;
  42309. /**
  42310. * Enable or disable depth writing
  42311. * @param enable defines the state to set
  42312. */
  42313. setDepthWrite(enable: boolean): void;
  42314. /**
  42315. * Gets a boolean indicating if stencil buffer is enabled
  42316. * @returns the current stencil buffer state
  42317. */
  42318. getStencilBuffer(): boolean;
  42319. /**
  42320. * Enable or disable the stencil buffer
  42321. * @param enable defines if the stencil buffer must be enabled or disabled
  42322. */
  42323. setStencilBuffer(enable: boolean): void;
  42324. /**
  42325. * Gets the current stencil mask
  42326. * @returns a number defining the new stencil mask to use
  42327. */
  42328. getStencilMask(): number;
  42329. /**
  42330. * Sets the current stencil mask
  42331. * @param mask defines the new stencil mask to use
  42332. */
  42333. setStencilMask(mask: number): void;
  42334. /**
  42335. * Gets the current stencil function
  42336. * @returns a number defining the stencil function to use
  42337. */
  42338. getStencilFunction(): number;
  42339. /**
  42340. * Gets the current stencil reference value
  42341. * @returns a number defining the stencil reference value to use
  42342. */
  42343. getStencilFunctionReference(): number;
  42344. /**
  42345. * Gets the current stencil mask
  42346. * @returns a number defining the stencil mask to use
  42347. */
  42348. getStencilFunctionMask(): number;
  42349. /**
  42350. * Sets the current stencil function
  42351. * @param stencilFunc defines the new stencil function to use
  42352. */
  42353. setStencilFunction(stencilFunc: number): void;
  42354. /**
  42355. * Sets the current stencil reference
  42356. * @param reference defines the new stencil reference to use
  42357. */
  42358. setStencilFunctionReference(reference: number): void;
  42359. /**
  42360. * Sets the current stencil mask
  42361. * @param mask defines the new stencil mask to use
  42362. */
  42363. setStencilFunctionMask(mask: number): void;
  42364. /**
  42365. * Gets the current stencil operation when stencil fails
  42366. * @returns a number defining stencil operation to use when stencil fails
  42367. */
  42368. getStencilOperationFail(): number;
  42369. /**
  42370. * Gets the current stencil operation when depth fails
  42371. * @returns a number defining stencil operation to use when depth fails
  42372. */
  42373. getStencilOperationDepthFail(): number;
  42374. /**
  42375. * Gets the current stencil operation when stencil passes
  42376. * @returns a number defining stencil operation to use when stencil passes
  42377. */
  42378. getStencilOperationPass(): number;
  42379. /**
  42380. * Sets the stencil operation to use when stencil fails
  42381. * @param operation defines the stencil operation to use when stencil fails
  42382. */
  42383. setStencilOperationFail(operation: number): void;
  42384. /**
  42385. * Sets the stencil operation to use when depth fails
  42386. * @param operation defines the stencil operation to use when depth fails
  42387. */
  42388. setStencilOperationDepthFail(operation: number): void;
  42389. /**
  42390. * Sets the stencil operation to use when stencil passes
  42391. * @param operation defines the stencil operation to use when stencil passes
  42392. */
  42393. setStencilOperationPass(operation: number): void;
  42394. /**
  42395. * Sets a boolean indicating if the dithering state is enabled or disabled
  42396. * @param value defines the dithering state
  42397. */
  42398. setDitheringState(value: boolean): void;
  42399. /**
  42400. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42401. * @param value defines the rasterizer state
  42402. */
  42403. setRasterizerState(value: boolean): void;
  42404. /**
  42405. * Gets the current depth function
  42406. * @returns a number defining the depth function
  42407. */
  42408. getDepthFunction(): Nullable<number>;
  42409. /**
  42410. * Sets the current depth function
  42411. * @param depthFunc defines the function to use
  42412. */
  42413. setDepthFunction(depthFunc: number): void;
  42414. /**
  42415. * Sets the current depth function to GREATER
  42416. */
  42417. setDepthFunctionToGreater(): void;
  42418. /**
  42419. * Sets the current depth function to GEQUAL
  42420. */
  42421. setDepthFunctionToGreaterOrEqual(): void;
  42422. /**
  42423. * Sets the current depth function to LESS
  42424. */
  42425. setDepthFunctionToLess(): void;
  42426. /**
  42427. * Sets the current depth function to LEQUAL
  42428. */
  42429. setDepthFunctionToLessOrEqual(): void;
  42430. private _cachedStencilBuffer;
  42431. private _cachedStencilFunction;
  42432. private _cachedStencilMask;
  42433. private _cachedStencilOperationPass;
  42434. private _cachedStencilOperationFail;
  42435. private _cachedStencilOperationDepthFail;
  42436. private _cachedStencilReference;
  42437. /**
  42438. * Caches the the state of the stencil buffer
  42439. */
  42440. cacheStencilState(): void;
  42441. /**
  42442. * Restores the state of the stencil buffer
  42443. */
  42444. restoreStencilState(): void;
  42445. /**
  42446. * Directly set the WebGL Viewport
  42447. * @param x defines the x coordinate of the viewport (in screen space)
  42448. * @param y defines the y coordinate of the viewport (in screen space)
  42449. * @param width defines the width of the viewport (in screen space)
  42450. * @param height defines the height of the viewport (in screen space)
  42451. * @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
  42452. */
  42453. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42454. /**
  42455. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42456. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42457. * @param y defines the y-coordinate of the corner of the clear rectangle
  42458. * @param width defines the width of the clear rectangle
  42459. * @param height defines the height of the clear rectangle
  42460. * @param clearColor defines the clear color
  42461. */
  42462. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42463. /**
  42464. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42465. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42466. * @param y defines the y-coordinate of the corner of the clear rectangle
  42467. * @param width defines the width of the clear rectangle
  42468. * @param height defines the height of the clear rectangle
  42469. */
  42470. enableScissor(x: number, y: number, width: number, height: number): void;
  42471. /**
  42472. * Disable previously set scissor test rectangle
  42473. */
  42474. disableScissor(): void;
  42475. protected _reportDrawCall(): void;
  42476. /**
  42477. * Initializes a webVR display and starts listening to display change events
  42478. * The onVRDisplayChangedObservable will be notified upon these changes
  42479. * @returns The onVRDisplayChangedObservable
  42480. */
  42481. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42482. /** @hidden */
  42483. _prepareVRComponent(): void;
  42484. /** @hidden */
  42485. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42486. /** @hidden */
  42487. _submitVRFrame(): void;
  42488. /**
  42489. * Call this function to leave webVR mode
  42490. * Will do nothing if webVR is not supported or if there is no webVR device
  42491. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42492. */
  42493. disableVR(): void;
  42494. /**
  42495. * Gets a boolean indicating that the system is in VR mode and is presenting
  42496. * @returns true if VR mode is engaged
  42497. */
  42498. isVRPresenting(): boolean;
  42499. /** @hidden */
  42500. _requestVRFrame(): void;
  42501. /** @hidden */
  42502. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42503. /**
  42504. * Gets the source code of the vertex shader associated with a specific webGL program
  42505. * @param program defines the program to use
  42506. * @returns a string containing the source code of the vertex shader associated with the program
  42507. */
  42508. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42509. /**
  42510. * Gets the source code of the fragment shader associated with a specific webGL program
  42511. * @param program defines the program to use
  42512. * @returns a string containing the source code of the fragment shader associated with the program
  42513. */
  42514. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42515. /**
  42516. * Sets a depth stencil texture from a render target to the according uniform.
  42517. * @param channel The texture channel
  42518. * @param uniform The uniform to set
  42519. * @param texture The render target texture containing the depth stencil texture to apply
  42520. */
  42521. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  42522. /**
  42523. * Sets a texture to the webGL context from a postprocess
  42524. * @param channel defines the channel to use
  42525. * @param postProcess defines the source postprocess
  42526. */
  42527. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  42528. /**
  42529. * Binds the output of the passed in post process to the texture channel specified
  42530. * @param channel The channel the texture should be bound to
  42531. * @param postProcess The post process which's output should be bound
  42532. */
  42533. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  42534. protected _rebuildBuffers(): void;
  42535. /** @hidden */
  42536. _renderFrame(): void;
  42537. _renderLoop(): void;
  42538. /** @hidden */
  42539. _renderViews(): boolean;
  42540. /**
  42541. * Toggle full screen mode
  42542. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42543. */
  42544. switchFullscreen(requestPointerLock: boolean): void;
  42545. /**
  42546. * Enters full screen mode
  42547. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42548. */
  42549. enterFullscreen(requestPointerLock: boolean): void;
  42550. /**
  42551. * Exits full screen mode
  42552. */
  42553. exitFullscreen(): void;
  42554. /**
  42555. * Enters Pointerlock mode
  42556. */
  42557. enterPointerlock(): void;
  42558. /**
  42559. * Exits Pointerlock mode
  42560. */
  42561. exitPointerlock(): void;
  42562. /**
  42563. * Begin a new frame
  42564. */
  42565. beginFrame(): void;
  42566. /**
  42567. * Enf the current frame
  42568. */
  42569. endFrame(): void;
  42570. resize(): void;
  42571. /**
  42572. * Force a specific size of the canvas
  42573. * @param width defines the new canvas' width
  42574. * @param height defines the new canvas' height
  42575. * @returns true if the size was changed
  42576. */
  42577. setSize(width: number, height: number): boolean;
  42578. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42579. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42580. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42581. _releaseTexture(texture: InternalTexture): void;
  42582. /**
  42583. * @hidden
  42584. * Rescales a texture
  42585. * @param source input texutre
  42586. * @param destination destination texture
  42587. * @param scene scene to use to render the resize
  42588. * @param internalFormat format to use when resizing
  42589. * @param onComplete callback to be called when resize has completed
  42590. */
  42591. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42592. /**
  42593. * Gets the current framerate
  42594. * @returns a number representing the framerate
  42595. */
  42596. getFps(): number;
  42597. /**
  42598. * Gets the time spent between current and previous frame
  42599. * @returns a number representing the delta time in ms
  42600. */
  42601. getDeltaTime(): number;
  42602. private _measureFps;
  42603. /** @hidden */
  42604. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42605. /**
  42606. * Updates the sample count of a render target texture
  42607. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42608. * @param texture defines the texture to update
  42609. * @param samples defines the sample count to set
  42610. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42611. */
  42612. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42613. /**
  42614. * Updates a depth texture Comparison Mode and Function.
  42615. * If the comparison Function is equal to 0, the mode will be set to none.
  42616. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42617. * @param texture The texture to set the comparison function for
  42618. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42619. */
  42620. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42621. /**
  42622. * Creates a webGL buffer to use with instanciation
  42623. * @param capacity defines the size of the buffer
  42624. * @returns the webGL buffer
  42625. */
  42626. createInstancesBuffer(capacity: number): DataBuffer;
  42627. /**
  42628. * Delete a webGL buffer used with instanciation
  42629. * @param buffer defines the webGL buffer to delete
  42630. */
  42631. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42632. private _clientWaitAsync;
  42633. /** @hidden */
  42634. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  42635. dispose(): void;
  42636. private _disableTouchAction;
  42637. /**
  42638. * Display the loading screen
  42639. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42640. */
  42641. displayLoadingUI(): void;
  42642. /**
  42643. * Hide the loading screen
  42644. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42645. */
  42646. hideLoadingUI(): void;
  42647. /**
  42648. * Gets the current loading screen object
  42649. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42650. */
  42651. get loadingScreen(): ILoadingScreen;
  42652. /**
  42653. * Sets the current loading screen object
  42654. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42655. */
  42656. set loadingScreen(loadingScreen: ILoadingScreen);
  42657. /**
  42658. * Sets the current loading screen text
  42659. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42660. */
  42661. set loadingUIText(text: string);
  42662. /**
  42663. * Sets the current loading screen background color
  42664. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42665. */
  42666. set loadingUIBackgroundColor(color: string);
  42667. /** Pointerlock and fullscreen */
  42668. /**
  42669. * Ask the browser to promote the current element to pointerlock mode
  42670. * @param element defines the DOM element to promote
  42671. */
  42672. static _RequestPointerlock(element: HTMLElement): void;
  42673. /**
  42674. * Asks the browser to exit pointerlock mode
  42675. */
  42676. static _ExitPointerlock(): void;
  42677. /**
  42678. * Ask the browser to promote the current element to fullscreen rendering mode
  42679. * @param element defines the DOM element to promote
  42680. */
  42681. static _RequestFullscreen(element: HTMLElement): void;
  42682. /**
  42683. * Asks the browser to exit fullscreen mode
  42684. */
  42685. static _ExitFullscreen(): void;
  42686. }
  42687. }
  42688. declare module "babylonjs/Engines/engineStore" {
  42689. import { Nullable } from "babylonjs/types";
  42690. import { Engine } from "babylonjs/Engines/engine";
  42691. import { Scene } from "babylonjs/scene";
  42692. /**
  42693. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42694. * during the life time of the application.
  42695. */
  42696. export class EngineStore {
  42697. /** Gets the list of created engines */
  42698. static Instances: import("babylonjs/Engines/engine").Engine[];
  42699. /** @hidden */
  42700. static _LastCreatedScene: Nullable<Scene>;
  42701. /**
  42702. * Gets the latest created engine
  42703. */
  42704. static get LastCreatedEngine(): Nullable<Engine>;
  42705. /**
  42706. * Gets the latest created scene
  42707. */
  42708. static get LastCreatedScene(): Nullable<Scene>;
  42709. /**
  42710. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42711. * @ignorenaming
  42712. */
  42713. static UseFallbackTexture: boolean;
  42714. /**
  42715. * Texture content used if a texture cannot loaded
  42716. * @ignorenaming
  42717. */
  42718. static FallbackTexture: string;
  42719. }
  42720. }
  42721. declare module "babylonjs/Misc/promise" {
  42722. /**
  42723. * Helper class that provides a small promise polyfill
  42724. */
  42725. export class PromisePolyfill {
  42726. /**
  42727. * Static function used to check if the polyfill is required
  42728. * If this is the case then the function will inject the polyfill to window.Promise
  42729. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  42730. */
  42731. static Apply(force?: boolean): void;
  42732. }
  42733. }
  42734. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  42735. /**
  42736. * Interface for screenshot methods with describe argument called `size` as object with options
  42737. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  42738. */
  42739. export interface IScreenshotSize {
  42740. /**
  42741. * number in pixels for canvas height
  42742. */
  42743. height?: number;
  42744. /**
  42745. * multiplier allowing render at a higher or lower resolution
  42746. * If value is defined then height and width will be ignored and taken from camera
  42747. */
  42748. precision?: number;
  42749. /**
  42750. * number in pixels for canvas width
  42751. */
  42752. width?: number;
  42753. }
  42754. }
  42755. declare module "babylonjs/Misc/tools" {
  42756. import { Nullable, float } from "babylonjs/types";
  42757. import { DomManagement } from "babylonjs/Misc/domManagement";
  42758. import { WebRequest } from "babylonjs/Misc/webRequest";
  42759. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  42760. import { ReadFileError } from "babylonjs/Misc/fileTools";
  42761. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42762. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  42763. import { Camera } from "babylonjs/Cameras/camera";
  42764. import { Engine } from "babylonjs/Engines/engine";
  42765. interface IColor4Like {
  42766. r: float;
  42767. g: float;
  42768. b: float;
  42769. a: float;
  42770. }
  42771. /**
  42772. * Class containing a set of static utilities functions
  42773. */
  42774. export class Tools {
  42775. /**
  42776. * Gets or sets the base URL to use to load assets
  42777. */
  42778. static get BaseUrl(): string;
  42779. static set BaseUrl(value: string);
  42780. /**
  42781. * Enable/Disable Custom HTTP Request Headers globally.
  42782. * default = false
  42783. * @see CustomRequestHeaders
  42784. */
  42785. static UseCustomRequestHeaders: boolean;
  42786. /**
  42787. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  42788. * i.e. when loading files, where the server/service expects an Authorization header
  42789. */
  42790. static CustomRequestHeaders: {
  42791. [key: string]: string;
  42792. };
  42793. /**
  42794. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  42795. */
  42796. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  42797. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  42798. /**
  42799. * Default behaviour for cors in the application.
  42800. * It can be a string if the expected behavior is identical in the entire app.
  42801. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  42802. */
  42803. static get CorsBehavior(): string | ((url: string | string[]) => string);
  42804. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  42805. /**
  42806. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42807. * @ignorenaming
  42808. */
  42809. static get UseFallbackTexture(): boolean;
  42810. static set UseFallbackTexture(value: boolean);
  42811. /**
  42812. * Use this object to register external classes like custom textures or material
  42813. * to allow the laoders to instantiate them
  42814. */
  42815. static get RegisteredExternalClasses(): {
  42816. [key: string]: Object;
  42817. };
  42818. static set RegisteredExternalClasses(classes: {
  42819. [key: string]: Object;
  42820. });
  42821. /**
  42822. * Texture content used if a texture cannot loaded
  42823. * @ignorenaming
  42824. */
  42825. static get fallbackTexture(): string;
  42826. static set fallbackTexture(value: string);
  42827. /**
  42828. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  42829. * @param u defines the coordinate on X axis
  42830. * @param v defines the coordinate on Y axis
  42831. * @param width defines the width of the source data
  42832. * @param height defines the height of the source data
  42833. * @param pixels defines the source byte array
  42834. * @param color defines the output color
  42835. */
  42836. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  42837. /**
  42838. * Interpolates between a and b via alpha
  42839. * @param a The lower value (returned when alpha = 0)
  42840. * @param b The upper value (returned when alpha = 1)
  42841. * @param alpha The interpolation-factor
  42842. * @return The mixed value
  42843. */
  42844. static Mix(a: number, b: number, alpha: number): number;
  42845. /**
  42846. * Tries to instantiate a new object from a given class name
  42847. * @param className defines the class name to instantiate
  42848. * @returns the new object or null if the system was not able to do the instantiation
  42849. */
  42850. static Instantiate(className: string): any;
  42851. /**
  42852. * Provides a slice function that will work even on IE
  42853. * @param data defines the array to slice
  42854. * @param start defines the start of the data (optional)
  42855. * @param end defines the end of the data (optional)
  42856. * @returns the new sliced array
  42857. */
  42858. static Slice<T>(data: T, start?: number, end?: number): T;
  42859. /**
  42860. * Provides a slice function that will work even on IE
  42861. * The difference between this and Slice is that this will force-convert to array
  42862. * @param data defines the array to slice
  42863. * @param start defines the start of the data (optional)
  42864. * @param end defines the end of the data (optional)
  42865. * @returns the new sliced array
  42866. */
  42867. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  42868. /**
  42869. * Polyfill for setImmediate
  42870. * @param action defines the action to execute after the current execution block
  42871. */
  42872. static SetImmediate(action: () => void): void;
  42873. /**
  42874. * Function indicating if a number is an exponent of 2
  42875. * @param value defines the value to test
  42876. * @returns true if the value is an exponent of 2
  42877. */
  42878. static IsExponentOfTwo(value: number): boolean;
  42879. private static _tmpFloatArray;
  42880. /**
  42881. * Returns the nearest 32-bit single precision float representation of a Number
  42882. * @param value A Number. If the parameter is of a different type, it will get converted
  42883. * to a number or to NaN if it cannot be converted
  42884. * @returns number
  42885. */
  42886. static FloatRound(value: number): number;
  42887. /**
  42888. * Extracts the filename from a path
  42889. * @param path defines the path to use
  42890. * @returns the filename
  42891. */
  42892. static GetFilename(path: string): string;
  42893. /**
  42894. * Extracts the "folder" part of a path (everything before the filename).
  42895. * @param uri The URI to extract the info from
  42896. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  42897. * @returns The "folder" part of the path
  42898. */
  42899. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  42900. /**
  42901. * Extracts text content from a DOM element hierarchy
  42902. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  42903. */
  42904. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  42905. /**
  42906. * Convert an angle in radians to degrees
  42907. * @param angle defines the angle to convert
  42908. * @returns the angle in degrees
  42909. */
  42910. static ToDegrees(angle: number): number;
  42911. /**
  42912. * Convert an angle in degrees to radians
  42913. * @param angle defines the angle to convert
  42914. * @returns the angle in radians
  42915. */
  42916. static ToRadians(angle: number): number;
  42917. /**
  42918. * Returns an array if obj is not an array
  42919. * @param obj defines the object to evaluate as an array
  42920. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  42921. * @returns either obj directly if obj is an array or a new array containing obj
  42922. */
  42923. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  42924. /**
  42925. * Gets the pointer prefix to use
  42926. * @param engine defines the engine we are finding the prefix for
  42927. * @returns "pointer" if touch is enabled. Else returns "mouse"
  42928. */
  42929. static GetPointerPrefix(engine: Engine): string;
  42930. /**
  42931. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  42932. * @param url define the url we are trying
  42933. * @param element define the dom element where to configure the cors policy
  42934. */
  42935. static SetCorsBehavior(url: string | string[], element: {
  42936. crossOrigin: string | null;
  42937. }): void;
  42938. /**
  42939. * Removes unwanted characters from an url
  42940. * @param url defines the url to clean
  42941. * @returns the cleaned url
  42942. */
  42943. static CleanUrl(url: string): string;
  42944. /**
  42945. * Gets or sets a function used to pre-process url before using them to load assets
  42946. */
  42947. static get PreprocessUrl(): (url: string) => string;
  42948. static set PreprocessUrl(processor: (url: string) => string);
  42949. /**
  42950. * Loads an image as an HTMLImageElement.
  42951. * @param input url string, ArrayBuffer, or Blob to load
  42952. * @param onLoad callback called when the image successfully loads
  42953. * @param onError callback called when the image fails to load
  42954. * @param offlineProvider offline provider for caching
  42955. * @param mimeType optional mime type
  42956. * @returns the HTMLImageElement of the loaded image
  42957. */
  42958. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  42959. /**
  42960. * Loads a file from a url
  42961. * @param url url string, ArrayBuffer, or Blob to load
  42962. * @param onSuccess callback called when the file successfully loads
  42963. * @param onProgress callback called while file is loading (if the server supports this mode)
  42964. * @param offlineProvider defines the offline provider for caching
  42965. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42966. * @param onError callback called when the file fails to load
  42967. * @returns a file request object
  42968. */
  42969. 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;
  42970. /**
  42971. * Loads a file from a url
  42972. * @param url the file url to load
  42973. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42974. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  42975. */
  42976. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  42977. /**
  42978. * Load a script (identified by an url). When the url returns, the
  42979. * content of this file is added into a new script element, attached to the DOM (body element)
  42980. * @param scriptUrl defines the url of the script to laod
  42981. * @param onSuccess defines the callback called when the script is loaded
  42982. * @param onError defines the callback to call if an error occurs
  42983. * @param scriptId defines the id of the script element
  42984. */
  42985. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  42986. /**
  42987. * Load an asynchronous script (identified by an url). When the url returns, the
  42988. * content of this file is added into a new script element, attached to the DOM (body element)
  42989. * @param scriptUrl defines the url of the script to laod
  42990. * @param scriptId defines the id of the script element
  42991. * @returns a promise request object
  42992. */
  42993. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  42994. /**
  42995. * Loads a file from a blob
  42996. * @param fileToLoad defines the blob to use
  42997. * @param callback defines the callback to call when data is loaded
  42998. * @param progressCallback defines the callback to call during loading process
  42999. * @returns a file request object
  43000. */
  43001. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43002. /**
  43003. * Reads a file from a File object
  43004. * @param file defines the file to load
  43005. * @param onSuccess defines the callback to call when data is loaded
  43006. * @param onProgress defines the callback to call during loading process
  43007. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43008. * @param onError defines the callback to call when an error occurs
  43009. * @returns a file request object
  43010. */
  43011. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43012. /**
  43013. * Creates a data url from a given string content
  43014. * @param content defines the content to convert
  43015. * @returns the new data url link
  43016. */
  43017. static FileAsURL(content: string): string;
  43018. /**
  43019. * Format the given number to a specific decimal format
  43020. * @param value defines the number to format
  43021. * @param decimals defines the number of decimals to use
  43022. * @returns the formatted string
  43023. */
  43024. static Format(value: number, decimals?: number): string;
  43025. /**
  43026. * Tries to copy an object by duplicating every property
  43027. * @param source defines the source object
  43028. * @param destination defines the target object
  43029. * @param doNotCopyList defines a list of properties to avoid
  43030. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43031. */
  43032. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43033. /**
  43034. * Gets a boolean indicating if the given object has no own property
  43035. * @param obj defines the object to test
  43036. * @returns true if object has no own property
  43037. */
  43038. static IsEmpty(obj: any): boolean;
  43039. /**
  43040. * Function used to register events at window level
  43041. * @param windowElement defines the Window object to use
  43042. * @param events defines the events to register
  43043. */
  43044. static RegisterTopRootEvents(windowElement: Window, events: {
  43045. name: string;
  43046. handler: Nullable<(e: FocusEvent) => any>;
  43047. }[]): void;
  43048. /**
  43049. * Function used to unregister events from window level
  43050. * @param windowElement defines the Window object to use
  43051. * @param events defines the events to unregister
  43052. */
  43053. static UnregisterTopRootEvents(windowElement: Window, events: {
  43054. name: string;
  43055. handler: Nullable<(e: FocusEvent) => any>;
  43056. }[]): void;
  43057. /**
  43058. * @ignore
  43059. */
  43060. static _ScreenshotCanvas: HTMLCanvasElement;
  43061. /**
  43062. * Dumps the current bound framebuffer
  43063. * @param width defines the rendering width
  43064. * @param height defines the rendering height
  43065. * @param engine defines the hosting engine
  43066. * @param successCallback defines the callback triggered once the data are available
  43067. * @param mimeType defines the mime type of the result
  43068. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43069. */
  43070. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43071. /**
  43072. * Converts the canvas data to blob.
  43073. * This acts as a polyfill for browsers not supporting the to blob function.
  43074. * @param canvas Defines the canvas to extract the data from
  43075. * @param successCallback Defines the callback triggered once the data are available
  43076. * @param mimeType Defines the mime type of the result
  43077. */
  43078. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43079. /**
  43080. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43081. * @param successCallback defines the callback triggered once the data are available
  43082. * @param mimeType defines the mime type of the result
  43083. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43084. */
  43085. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43086. /**
  43087. * Downloads a blob in the browser
  43088. * @param blob defines the blob to download
  43089. * @param fileName defines the name of the downloaded file
  43090. */
  43091. static Download(blob: Blob, fileName: string): void;
  43092. /**
  43093. * Captures a screenshot of the current rendering
  43094. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43095. * @param engine defines the rendering engine
  43096. * @param camera defines the source camera
  43097. * @param size This parameter can be set to a single number or to an object with the
  43098. * following (optional) properties: precision, width, height. If a single number is passed,
  43099. * it will be used for both width and height. If an object is passed, the screenshot size
  43100. * will be derived from the parameters. The precision property is a multiplier allowing
  43101. * rendering at a higher or lower resolution
  43102. * @param successCallback defines the callback receives a single parameter which contains the
  43103. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43104. * src parameter of an <img> to display it
  43105. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43106. * Check your browser for supported MIME types
  43107. */
  43108. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43109. /**
  43110. * Captures a screenshot of the current rendering
  43111. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43112. * @param engine defines the rendering engine
  43113. * @param camera defines the source camera
  43114. * @param size This parameter can be set to a single number or to an object with the
  43115. * following (optional) properties: precision, width, height. If a single number is passed,
  43116. * it will be used for both width and height. If an object is passed, the screenshot size
  43117. * will be derived from the parameters. The precision property is a multiplier allowing
  43118. * rendering at a higher or lower resolution
  43119. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43120. * Check your browser for supported MIME types
  43121. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43122. * to the src parameter of an <img> to display it
  43123. */
  43124. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43125. /**
  43126. * Generates an image screenshot from the specified camera.
  43127. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43128. * @param engine The engine to use for rendering
  43129. * @param camera The camera to use for rendering
  43130. * @param size This parameter can be set to a single number or to an object with the
  43131. * following (optional) properties: precision, width, height. If a single number is passed,
  43132. * it will be used for both width and height. If an object is passed, the screenshot size
  43133. * will be derived from the parameters. The precision property is a multiplier allowing
  43134. * rendering at a higher or lower resolution
  43135. * @param successCallback The callback receives a single parameter which contains the
  43136. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43137. * src parameter of an <img> to display it
  43138. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43139. * Check your browser for supported MIME types
  43140. * @param samples Texture samples (default: 1)
  43141. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43142. * @param fileName A name for for the downloaded file.
  43143. */
  43144. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43145. /**
  43146. * Generates an image screenshot from the specified camera.
  43147. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43148. * @param engine The engine to use for rendering
  43149. * @param camera The camera to use for rendering
  43150. * @param size This parameter can be set to a single number or to an object with the
  43151. * following (optional) properties: precision, width, height. If a single number is passed,
  43152. * it will be used for both width and height. If an object is passed, the screenshot size
  43153. * will be derived from the parameters. The precision property is a multiplier allowing
  43154. * rendering at a higher or lower resolution
  43155. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43156. * Check your browser for supported MIME types
  43157. * @param samples Texture samples (default: 1)
  43158. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43159. * @param fileName A name for for the downloaded file.
  43160. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43161. * to the src parameter of an <img> to display it
  43162. */
  43163. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43164. /**
  43165. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43166. * Be aware Math.random() could cause collisions, but:
  43167. * "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"
  43168. * @returns a pseudo random id
  43169. */
  43170. static RandomId(): string;
  43171. /**
  43172. * Test if the given uri is a base64 string
  43173. * @param uri The uri to test
  43174. * @return True if the uri is a base64 string or false otherwise
  43175. */
  43176. static IsBase64(uri: string): boolean;
  43177. /**
  43178. * Decode the given base64 uri.
  43179. * @param uri The uri to decode
  43180. * @return The decoded base64 data.
  43181. */
  43182. static DecodeBase64(uri: string): ArrayBuffer;
  43183. /**
  43184. * Gets the absolute url.
  43185. * @param url the input url
  43186. * @return the absolute url
  43187. */
  43188. static GetAbsoluteUrl(url: string): string;
  43189. /**
  43190. * No log
  43191. */
  43192. static readonly NoneLogLevel: number;
  43193. /**
  43194. * Only message logs
  43195. */
  43196. static readonly MessageLogLevel: number;
  43197. /**
  43198. * Only warning logs
  43199. */
  43200. static readonly WarningLogLevel: number;
  43201. /**
  43202. * Only error logs
  43203. */
  43204. static readonly ErrorLogLevel: number;
  43205. /**
  43206. * All logs
  43207. */
  43208. static readonly AllLogLevel: number;
  43209. /**
  43210. * Gets a value indicating the number of loading errors
  43211. * @ignorenaming
  43212. */
  43213. static get errorsCount(): number;
  43214. /**
  43215. * Callback called when a new log is added
  43216. */
  43217. static OnNewCacheEntry: (entry: string) => void;
  43218. /**
  43219. * Log a message to the console
  43220. * @param message defines the message to log
  43221. */
  43222. static Log(message: string): void;
  43223. /**
  43224. * Write a warning message to the console
  43225. * @param message defines the message to log
  43226. */
  43227. static Warn(message: string): void;
  43228. /**
  43229. * Write an error message to the console
  43230. * @param message defines the message to log
  43231. */
  43232. static Error(message: string): void;
  43233. /**
  43234. * Gets current log cache (list of logs)
  43235. */
  43236. static get LogCache(): string;
  43237. /**
  43238. * Clears the log cache
  43239. */
  43240. static ClearLogCache(): void;
  43241. /**
  43242. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43243. */
  43244. static set LogLevels(level: number);
  43245. /**
  43246. * Checks if the window object exists
  43247. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43248. */
  43249. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43250. /**
  43251. * No performance log
  43252. */
  43253. static readonly PerformanceNoneLogLevel: number;
  43254. /**
  43255. * Use user marks to log performance
  43256. */
  43257. static readonly PerformanceUserMarkLogLevel: number;
  43258. /**
  43259. * Log performance to the console
  43260. */
  43261. static readonly PerformanceConsoleLogLevel: number;
  43262. private static _performance;
  43263. /**
  43264. * Sets the current performance log level
  43265. */
  43266. static set PerformanceLogLevel(level: number);
  43267. private static _StartPerformanceCounterDisabled;
  43268. private static _EndPerformanceCounterDisabled;
  43269. private static _StartUserMark;
  43270. private static _EndUserMark;
  43271. private static _StartPerformanceConsole;
  43272. private static _EndPerformanceConsole;
  43273. /**
  43274. * Starts a performance counter
  43275. */
  43276. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43277. /**
  43278. * Ends a specific performance coutner
  43279. */
  43280. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43281. /**
  43282. * Gets either window.performance.now() if supported or Date.now() else
  43283. */
  43284. static get Now(): number;
  43285. /**
  43286. * This method will return the name of the class used to create the instance of the given object.
  43287. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43288. * @param object the object to get the class name from
  43289. * @param isType defines if the object is actually a type
  43290. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43291. */
  43292. static GetClassName(object: any, isType?: boolean): string;
  43293. /**
  43294. * Gets the first element of an array satisfying a given predicate
  43295. * @param array defines the array to browse
  43296. * @param predicate defines the predicate to use
  43297. * @returns null if not found or the element
  43298. */
  43299. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43300. /**
  43301. * This method will return the name of the full name of the class, including its owning module (if any).
  43302. * 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).
  43303. * @param object the object to get the class name from
  43304. * @param isType defines if the object is actually a type
  43305. * @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.
  43306. * @ignorenaming
  43307. */
  43308. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43309. /**
  43310. * Returns a promise that resolves after the given amount of time.
  43311. * @param delay Number of milliseconds to delay
  43312. * @returns Promise that resolves after the given amount of time
  43313. */
  43314. static DelayAsync(delay: number): Promise<void>;
  43315. /**
  43316. * Utility function to detect if the current user agent is Safari
  43317. * @returns whether or not the current user agent is safari
  43318. */
  43319. static IsSafari(): boolean;
  43320. }
  43321. /**
  43322. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43323. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43324. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43325. * @param name The name of the class, case should be preserved
  43326. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43327. */
  43328. export function className(name: string, module?: string): (target: Object) => void;
  43329. /**
  43330. * An implementation of a loop for asynchronous functions.
  43331. */
  43332. export class AsyncLoop {
  43333. /**
  43334. * Defines the number of iterations for the loop
  43335. */
  43336. iterations: number;
  43337. /**
  43338. * Defines the current index of the loop.
  43339. */
  43340. index: number;
  43341. private _done;
  43342. private _fn;
  43343. private _successCallback;
  43344. /**
  43345. * Constructor.
  43346. * @param iterations the number of iterations.
  43347. * @param func the function to run each iteration
  43348. * @param successCallback the callback that will be called upon succesful execution
  43349. * @param offset starting offset.
  43350. */
  43351. constructor(
  43352. /**
  43353. * Defines the number of iterations for the loop
  43354. */
  43355. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43356. /**
  43357. * Execute the next iteration. Must be called after the last iteration was finished.
  43358. */
  43359. executeNext(): void;
  43360. /**
  43361. * Break the loop and run the success callback.
  43362. */
  43363. breakLoop(): void;
  43364. /**
  43365. * Create and run an async loop.
  43366. * @param iterations the number of iterations.
  43367. * @param fn the function to run each iteration
  43368. * @param successCallback the callback that will be called upon succesful execution
  43369. * @param offset starting offset.
  43370. * @returns the created async loop object
  43371. */
  43372. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43373. /**
  43374. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43375. * @param iterations total number of iterations
  43376. * @param syncedIterations number of synchronous iterations in each async iteration.
  43377. * @param fn the function to call each iteration.
  43378. * @param callback a success call back that will be called when iterating stops.
  43379. * @param breakFunction a break condition (optional)
  43380. * @param timeout timeout settings for the setTimeout function. default - 0.
  43381. * @returns the created async loop object
  43382. */
  43383. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43384. }
  43385. }
  43386. declare module "babylonjs/Misc/stringDictionary" {
  43387. import { Nullable } from "babylonjs/types";
  43388. /**
  43389. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43390. * The underlying implementation relies on an associative array to ensure the best performances.
  43391. * The value can be anything including 'null' but except 'undefined'
  43392. */
  43393. export class StringDictionary<T> {
  43394. /**
  43395. * This will clear this dictionary and copy the content from the 'source' one.
  43396. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43397. * @param source the dictionary to take the content from and copy to this dictionary
  43398. */
  43399. copyFrom(source: StringDictionary<T>): void;
  43400. /**
  43401. * Get a value based from its key
  43402. * @param key the given key to get the matching value from
  43403. * @return the value if found, otherwise undefined is returned
  43404. */
  43405. get(key: string): T | undefined;
  43406. /**
  43407. * Get a value from its key or add it if it doesn't exist.
  43408. * This method will ensure you that a given key/data will be present in the dictionary.
  43409. * @param key the given key to get the matching value from
  43410. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43411. * The factory will only be invoked if there's no data for the given key.
  43412. * @return the value corresponding to the key.
  43413. */
  43414. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43415. /**
  43416. * Get a value from its key if present in the dictionary otherwise add it
  43417. * @param key the key to get the value from
  43418. * @param val if there's no such key/value pair in the dictionary add it with this value
  43419. * @return the value corresponding to the key
  43420. */
  43421. getOrAdd(key: string, val: T): T;
  43422. /**
  43423. * Check if there's a given key in the dictionary
  43424. * @param key the key to check for
  43425. * @return true if the key is present, false otherwise
  43426. */
  43427. contains(key: string): boolean;
  43428. /**
  43429. * Add a new key and its corresponding value
  43430. * @param key the key to add
  43431. * @param value the value corresponding to the key
  43432. * @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
  43433. */
  43434. add(key: string, value: T): boolean;
  43435. /**
  43436. * Update a specific value associated to a key
  43437. * @param key defines the key to use
  43438. * @param value defines the value to store
  43439. * @returns true if the value was updated (or false if the key was not found)
  43440. */
  43441. set(key: string, value: T): boolean;
  43442. /**
  43443. * Get the element of the given key and remove it from the dictionary
  43444. * @param key defines the key to search
  43445. * @returns the value associated with the key or null if not found
  43446. */
  43447. getAndRemove(key: string): Nullable<T>;
  43448. /**
  43449. * Remove a key/value from the dictionary.
  43450. * @param key the key to remove
  43451. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43452. */
  43453. remove(key: string): boolean;
  43454. /**
  43455. * Clear the whole content of the dictionary
  43456. */
  43457. clear(): void;
  43458. /**
  43459. * Gets the current count
  43460. */
  43461. get count(): number;
  43462. /**
  43463. * Execute a callback on each key/val of the dictionary.
  43464. * Note that you can remove any element in this dictionary in the callback implementation
  43465. * @param callback the callback to execute on a given key/value pair
  43466. */
  43467. forEach(callback: (key: string, val: T) => void): void;
  43468. /**
  43469. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43470. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43471. * Note that you can remove any element in this dictionary in the callback implementation
  43472. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43473. * @returns the first item
  43474. */
  43475. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43476. private _count;
  43477. private _data;
  43478. }
  43479. }
  43480. declare module "babylonjs/Collisions/collisionCoordinator" {
  43481. import { Nullable } from "babylonjs/types";
  43482. import { Scene } from "babylonjs/scene";
  43483. import { Vector3 } from "babylonjs/Maths/math.vector";
  43484. import { Collider } from "babylonjs/Collisions/collider";
  43485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43486. /** @hidden */
  43487. export interface ICollisionCoordinator {
  43488. createCollider(): Collider;
  43489. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43490. init(scene: Scene): void;
  43491. }
  43492. /** @hidden */
  43493. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43494. private _scene;
  43495. private _scaledPosition;
  43496. private _scaledVelocity;
  43497. private _finalPosition;
  43498. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43499. createCollider(): Collider;
  43500. init(scene: Scene): void;
  43501. private _collideWithWorld;
  43502. }
  43503. }
  43504. declare module "babylonjs/Inputs/scene.inputManager" {
  43505. import { Nullable } from "babylonjs/types";
  43506. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43507. import { Vector2 } from "babylonjs/Maths/math.vector";
  43508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43509. import { Scene } from "babylonjs/scene";
  43510. /**
  43511. * Class used to manage all inputs for the scene.
  43512. */
  43513. export class InputManager {
  43514. /** The distance in pixel that you have to move to prevent some events */
  43515. static DragMovementThreshold: number;
  43516. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43517. static LongPressDelay: number;
  43518. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43519. static DoubleClickDelay: number;
  43520. /** If you need to check double click without raising a single click at first click, enable this flag */
  43521. static ExclusiveDoubleClickMode: boolean;
  43522. /** 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. */
  43523. private _alreadyAttached;
  43524. private _alreadyAttachedTo;
  43525. private _wheelEventName;
  43526. private _onPointerMove;
  43527. private _onPointerDown;
  43528. private _onPointerUp;
  43529. private _initClickEvent;
  43530. private _initActionManager;
  43531. private _delayedSimpleClick;
  43532. private _delayedSimpleClickTimeout;
  43533. private _previousDelayedSimpleClickTimeout;
  43534. private _meshPickProceed;
  43535. private _previousButtonPressed;
  43536. private _currentPickResult;
  43537. private _previousPickResult;
  43538. private _totalPointersPressed;
  43539. private _doubleClickOccured;
  43540. private _pointerOverMesh;
  43541. private _pickedDownMesh;
  43542. private _pickedUpMesh;
  43543. private _pointerX;
  43544. private _pointerY;
  43545. private _unTranslatedPointerX;
  43546. private _unTranslatedPointerY;
  43547. private _startingPointerPosition;
  43548. private _previousStartingPointerPosition;
  43549. private _startingPointerTime;
  43550. private _previousStartingPointerTime;
  43551. private _pointerCaptures;
  43552. private _meshUnderPointerId;
  43553. private _onKeyDown;
  43554. private _onKeyUp;
  43555. private _keyboardIsAttached;
  43556. private _onCanvasFocusObserver;
  43557. private _onCanvasBlurObserver;
  43558. private _scene;
  43559. /**
  43560. * Creates a new InputManager
  43561. * @param scene defines the hosting scene
  43562. */
  43563. constructor(scene: Scene);
  43564. /**
  43565. * Gets the mesh that is currently under the pointer
  43566. */
  43567. get meshUnderPointer(): Nullable<AbstractMesh>;
  43568. /**
  43569. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43570. * @param pointerId the pointer id to use
  43571. * @returns The mesh under this pointer id or null if not found
  43572. */
  43573. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43574. /**
  43575. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43576. */
  43577. get unTranslatedPointer(): Vector2;
  43578. /**
  43579. * Gets or sets the current on-screen X position of the pointer
  43580. */
  43581. get pointerX(): number;
  43582. set pointerX(value: number);
  43583. /**
  43584. * Gets or sets the current on-screen Y position of the pointer
  43585. */
  43586. get pointerY(): number;
  43587. set pointerY(value: number);
  43588. private _updatePointerPosition;
  43589. private _processPointerMove;
  43590. private _setRayOnPointerInfo;
  43591. private _checkPrePointerObservable;
  43592. /**
  43593. * Use this method to simulate a pointer move on a mesh
  43594. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43595. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43596. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43597. */
  43598. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43599. /**
  43600. * Use this method to simulate a pointer down on a mesh
  43601. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43602. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43603. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43604. */
  43605. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43606. private _processPointerDown;
  43607. /** @hidden */
  43608. _isPointerSwiping(): boolean;
  43609. /**
  43610. * Use this method to simulate a pointer up on a mesh
  43611. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43612. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43613. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43614. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43615. */
  43616. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43617. private _processPointerUp;
  43618. /**
  43619. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43620. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43621. * @returns true if the pointer was captured
  43622. */
  43623. isPointerCaptured(pointerId?: number): boolean;
  43624. /**
  43625. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43626. * @param attachUp defines if you want to attach events to pointerup
  43627. * @param attachDown defines if you want to attach events to pointerdown
  43628. * @param attachMove defines if you want to attach events to pointermove
  43629. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43630. */
  43631. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43632. /**
  43633. * Detaches all event handlers
  43634. */
  43635. detachControl(): void;
  43636. /**
  43637. * Force the value of meshUnderPointer
  43638. * @param mesh defines the mesh to use
  43639. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43640. */
  43641. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43642. /**
  43643. * Gets the mesh under the pointer
  43644. * @returns a Mesh or null if no mesh is under the pointer
  43645. */
  43646. getPointerOverMesh(): Nullable<AbstractMesh>;
  43647. }
  43648. }
  43649. declare module "babylonjs/Animations/animationGroup" {
  43650. import { Animatable } from "babylonjs/Animations/animatable";
  43651. import { Animation } from "babylonjs/Animations/animation";
  43652. import { Scene, IDisposable } from "babylonjs/scene";
  43653. import { Observable } from "babylonjs/Misc/observable";
  43654. import { Nullable } from "babylonjs/types";
  43655. import "babylonjs/Animations/animatable";
  43656. /**
  43657. * This class defines the direct association between an animation and a target
  43658. */
  43659. export class TargetedAnimation {
  43660. /**
  43661. * Animation to perform
  43662. */
  43663. animation: Animation;
  43664. /**
  43665. * Target to animate
  43666. */
  43667. target: any;
  43668. /**
  43669. * Returns the string "TargetedAnimation"
  43670. * @returns "TargetedAnimation"
  43671. */
  43672. getClassName(): string;
  43673. /**
  43674. * Serialize the object
  43675. * @returns the JSON object representing the current entity
  43676. */
  43677. serialize(): any;
  43678. }
  43679. /**
  43680. * Use this class to create coordinated animations on multiple targets
  43681. */
  43682. export class AnimationGroup implements IDisposable {
  43683. /** The name of the animation group */
  43684. name: string;
  43685. private _scene;
  43686. private _targetedAnimations;
  43687. private _animatables;
  43688. private _from;
  43689. private _to;
  43690. private _isStarted;
  43691. private _isPaused;
  43692. private _speedRatio;
  43693. private _loopAnimation;
  43694. private _isAdditive;
  43695. /**
  43696. * Gets or sets the unique id of the node
  43697. */
  43698. uniqueId: number;
  43699. /**
  43700. * This observable will notify when one animation have ended
  43701. */
  43702. onAnimationEndObservable: Observable<TargetedAnimation>;
  43703. /**
  43704. * Observer raised when one animation loops
  43705. */
  43706. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43707. /**
  43708. * Observer raised when all animations have looped
  43709. */
  43710. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43711. /**
  43712. * This observable will notify when all animations have ended.
  43713. */
  43714. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43715. /**
  43716. * This observable will notify when all animations have paused.
  43717. */
  43718. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43719. /**
  43720. * This observable will notify when all animations are playing.
  43721. */
  43722. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  43723. /**
  43724. * Gets the first frame
  43725. */
  43726. get from(): number;
  43727. /**
  43728. * Gets the last frame
  43729. */
  43730. get to(): number;
  43731. /**
  43732. * Define if the animations are started
  43733. */
  43734. get isStarted(): boolean;
  43735. /**
  43736. * Gets a value indicating that the current group is playing
  43737. */
  43738. get isPlaying(): boolean;
  43739. /**
  43740. * Gets or sets the speed ratio to use for all animations
  43741. */
  43742. get speedRatio(): number;
  43743. /**
  43744. * Gets or sets the speed ratio to use for all animations
  43745. */
  43746. set speedRatio(value: number);
  43747. /**
  43748. * Gets or sets if all animations should loop or not
  43749. */
  43750. get loopAnimation(): boolean;
  43751. set loopAnimation(value: boolean);
  43752. /**
  43753. * Gets or sets if all animations should be evaluated additively
  43754. */
  43755. get isAdditive(): boolean;
  43756. set isAdditive(value: boolean);
  43757. /**
  43758. * Gets the targeted animations for this animation group
  43759. */
  43760. get targetedAnimations(): Array<TargetedAnimation>;
  43761. /**
  43762. * returning the list of animatables controlled by this animation group.
  43763. */
  43764. get animatables(): Array<Animatable>;
  43765. /**
  43766. * Gets the list of target animations
  43767. */
  43768. get children(): TargetedAnimation[];
  43769. /**
  43770. * Instantiates a new Animation Group.
  43771. * This helps managing several animations at once.
  43772. * @see https://doc.babylonjs.com/how_to/group
  43773. * @param name Defines the name of the group
  43774. * @param scene Defines the scene the group belongs to
  43775. */
  43776. constructor(
  43777. /** The name of the animation group */
  43778. name: string, scene?: Nullable<Scene>);
  43779. /**
  43780. * Add an animation (with its target) in the group
  43781. * @param animation defines the animation we want to add
  43782. * @param target defines the target of the animation
  43783. * @returns the TargetedAnimation object
  43784. */
  43785. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  43786. /**
  43787. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  43788. * It can add constant keys at begin or end
  43789. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  43790. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  43791. * @returns the animation group
  43792. */
  43793. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  43794. private _animationLoopCount;
  43795. private _animationLoopFlags;
  43796. private _processLoop;
  43797. /**
  43798. * Start all animations on given targets
  43799. * @param loop defines if animations must loop
  43800. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  43801. * @param from defines the from key (optional)
  43802. * @param to defines the to key (optional)
  43803. * @param isAdditive defines the additive state for the resulting animatables (optional)
  43804. * @returns the current animation group
  43805. */
  43806. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  43807. /**
  43808. * Pause all animations
  43809. * @returns the animation group
  43810. */
  43811. pause(): AnimationGroup;
  43812. /**
  43813. * Play all animations to initial state
  43814. * This function will start() the animations if they were not started or will restart() them if they were paused
  43815. * @param loop defines if animations must loop
  43816. * @returns the animation group
  43817. */
  43818. play(loop?: boolean): AnimationGroup;
  43819. /**
  43820. * Reset all animations to initial state
  43821. * @returns the animation group
  43822. */
  43823. reset(): AnimationGroup;
  43824. /**
  43825. * Restart animations from key 0
  43826. * @returns the animation group
  43827. */
  43828. restart(): AnimationGroup;
  43829. /**
  43830. * Stop all animations
  43831. * @returns the animation group
  43832. */
  43833. stop(): AnimationGroup;
  43834. /**
  43835. * Set animation weight for all animatables
  43836. * @param weight defines the weight to use
  43837. * @return the animationGroup
  43838. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43839. */
  43840. setWeightForAllAnimatables(weight: number): AnimationGroup;
  43841. /**
  43842. * Synchronize and normalize all animatables with a source animatable
  43843. * @param root defines the root animatable to synchronize with
  43844. * @return the animationGroup
  43845. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43846. */
  43847. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  43848. /**
  43849. * Goes to a specific frame in this animation group
  43850. * @param frame the frame number to go to
  43851. * @return the animationGroup
  43852. */
  43853. goToFrame(frame: number): AnimationGroup;
  43854. /**
  43855. * Dispose all associated resources
  43856. */
  43857. dispose(): void;
  43858. private _checkAnimationGroupEnded;
  43859. /**
  43860. * Clone the current animation group and returns a copy
  43861. * @param newName defines the name of the new group
  43862. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  43863. * @returns the new aniamtion group
  43864. */
  43865. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  43866. /**
  43867. * Serializes the animationGroup to an object
  43868. * @returns Serialized object
  43869. */
  43870. serialize(): any;
  43871. /**
  43872. * Returns a new AnimationGroup object parsed from the source provided.
  43873. * @param parsedAnimationGroup defines the source
  43874. * @param scene defines the scene that will receive the animationGroup
  43875. * @returns a new AnimationGroup
  43876. */
  43877. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  43878. /**
  43879. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  43880. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  43881. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  43882. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  43883. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  43884. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  43885. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  43886. */
  43887. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  43888. /**
  43889. * Returns the string "AnimationGroup"
  43890. * @returns "AnimationGroup"
  43891. */
  43892. getClassName(): string;
  43893. /**
  43894. * Creates a detailled string about the object
  43895. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  43896. * @returns a string representing the object
  43897. */
  43898. toString(fullDetails?: boolean): string;
  43899. }
  43900. }
  43901. declare module "babylonjs/scene" {
  43902. import { Nullable } from "babylonjs/types";
  43903. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  43904. import { Observable } from "babylonjs/Misc/observable";
  43905. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43906. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  43907. import { Geometry } from "babylonjs/Meshes/geometry";
  43908. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43909. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43911. import { Mesh } from "babylonjs/Meshes/mesh";
  43912. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43913. import { Bone } from "babylonjs/Bones/bone";
  43914. import { Skeleton } from "babylonjs/Bones/skeleton";
  43915. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  43916. import { Camera } from "babylonjs/Cameras/camera";
  43917. import { AbstractScene } from "babylonjs/abstractScene";
  43918. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43919. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43920. import { Material } from "babylonjs/Materials/material";
  43921. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43922. import { Effect } from "babylonjs/Materials/effect";
  43923. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  43924. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  43925. import { Light } from "babylonjs/Lights/light";
  43926. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43927. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  43928. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  43929. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  43930. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  43931. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  43932. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  43933. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, PreActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  43934. import { Engine } from "babylonjs/Engines/engine";
  43935. import { Node } from "babylonjs/node";
  43936. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  43937. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  43938. import { WebRequest } from "babylonjs/Misc/webRequest";
  43939. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  43940. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  43941. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43942. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  43943. import { Plane } from "babylonjs/Maths/math.plane";
  43944. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  43945. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  43946. import { Ray } from "babylonjs/Culling/ray";
  43947. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  43948. import { Animation } from "babylonjs/Animations/animation";
  43949. import { Animatable } from "babylonjs/Animations/animatable";
  43950. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43951. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  43952. import { Collider } from "babylonjs/Collisions/collider";
  43953. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43954. /**
  43955. * Define an interface for all classes that will hold resources
  43956. */
  43957. export interface IDisposable {
  43958. /**
  43959. * Releases all held resources
  43960. */
  43961. dispose(): void;
  43962. }
  43963. /** Interface defining initialization parameters for Scene class */
  43964. export interface SceneOptions {
  43965. /**
  43966. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  43967. * It will improve performance when the number of geometries becomes important.
  43968. */
  43969. useGeometryUniqueIdsMap?: boolean;
  43970. /**
  43971. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  43972. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  43973. */
  43974. useMaterialMeshMap?: boolean;
  43975. /**
  43976. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  43977. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  43978. */
  43979. useClonedMeshMap?: boolean;
  43980. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  43981. virtual?: boolean;
  43982. }
  43983. /**
  43984. * Represents a scene to be rendered by the engine.
  43985. * @see https://doc.babylonjs.com/features/scene
  43986. */
  43987. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  43988. /** The fog is deactivated */
  43989. static readonly FOGMODE_NONE: number;
  43990. /** The fog density is following an exponential function */
  43991. static readonly FOGMODE_EXP: number;
  43992. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  43993. static readonly FOGMODE_EXP2: number;
  43994. /** The fog density is following a linear function. */
  43995. static readonly FOGMODE_LINEAR: number;
  43996. /**
  43997. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  43998. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43999. */
  44000. static MinDeltaTime: number;
  44001. /**
  44002. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  44003. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44004. */
  44005. static MaxDeltaTime: number;
  44006. /**
  44007. * Factory used to create the default material.
  44008. * @param name The name of the material to create
  44009. * @param scene The scene to create the material for
  44010. * @returns The default material
  44011. */
  44012. static DefaultMaterialFactory(scene: Scene): Material;
  44013. /**
  44014. * Factory used to create the a collision coordinator.
  44015. * @returns The collision coordinator
  44016. */
  44017. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  44018. /** @hidden */
  44019. _inputManager: InputManager;
  44020. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  44021. cameraToUseForPointers: Nullable<Camera>;
  44022. /** @hidden */
  44023. readonly _isScene: boolean;
  44024. /** @hidden */
  44025. _blockEntityCollection: boolean;
  44026. /**
  44027. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  44028. */
  44029. autoClear: boolean;
  44030. /**
  44031. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  44032. */
  44033. autoClearDepthAndStencil: boolean;
  44034. /**
  44035. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  44036. */
  44037. clearColor: Color4;
  44038. /**
  44039. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  44040. */
  44041. ambientColor: Color3;
  44042. /**
  44043. * This is use to store the default BRDF lookup for PBR materials in your scene.
  44044. * It should only be one of the following (if not the default embedded one):
  44045. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44046. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  44047. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44048. * The material properties need to be setup according to the type of texture in use.
  44049. */
  44050. environmentBRDFTexture: BaseTexture;
  44051. /**
  44052. * Texture used in all pbr material as the reflection texture.
  44053. * As in the majority of the scene they are the same (exception for multi room and so on),
  44054. * this is easier to reference from here than from all the materials.
  44055. */
  44056. get environmentTexture(): Nullable<BaseTexture>;
  44057. /**
  44058. * Texture used in all pbr material as the reflection texture.
  44059. * As in the majority of the scene they are the same (exception for multi room and so on),
  44060. * this is easier to set here than in all the materials.
  44061. */
  44062. set environmentTexture(value: Nullable<BaseTexture>);
  44063. /** @hidden */
  44064. protected _environmentIntensity: number;
  44065. /**
  44066. * Intensity of the environment in all pbr material.
  44067. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44068. * As in the majority of the scene they are the same (exception for multi room and so on),
  44069. * this is easier to reference from here than from all the materials.
  44070. */
  44071. get environmentIntensity(): number;
  44072. /**
  44073. * Intensity of the environment in all pbr material.
  44074. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44075. * As in the majority of the scene they are the same (exception for multi room and so on),
  44076. * this is easier to set here than in all the materials.
  44077. */
  44078. set environmentIntensity(value: number);
  44079. /** @hidden */
  44080. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44081. /**
  44082. * Default image processing configuration used either in the rendering
  44083. * Forward main pass or through the imageProcessingPostProcess if present.
  44084. * As in the majority of the scene they are the same (exception for multi camera),
  44085. * this is easier to reference from here than from all the materials and post process.
  44086. *
  44087. * No setter as we it is a shared configuration, you can set the values instead.
  44088. */
  44089. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44090. private _forceWireframe;
  44091. /**
  44092. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  44093. */
  44094. set forceWireframe(value: boolean);
  44095. get forceWireframe(): boolean;
  44096. private _skipFrustumClipping;
  44097. /**
  44098. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  44099. */
  44100. set skipFrustumClipping(value: boolean);
  44101. get skipFrustumClipping(): boolean;
  44102. private _forcePointsCloud;
  44103. /**
  44104. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  44105. */
  44106. set forcePointsCloud(value: boolean);
  44107. get forcePointsCloud(): boolean;
  44108. /**
  44109. * Gets or sets the active clipplane 1
  44110. */
  44111. clipPlane: Nullable<Plane>;
  44112. /**
  44113. * Gets or sets the active clipplane 2
  44114. */
  44115. clipPlane2: Nullable<Plane>;
  44116. /**
  44117. * Gets or sets the active clipplane 3
  44118. */
  44119. clipPlane3: Nullable<Plane>;
  44120. /**
  44121. * Gets or sets the active clipplane 4
  44122. */
  44123. clipPlane4: Nullable<Plane>;
  44124. /**
  44125. * Gets or sets the active clipplane 5
  44126. */
  44127. clipPlane5: Nullable<Plane>;
  44128. /**
  44129. * Gets or sets the active clipplane 6
  44130. */
  44131. clipPlane6: Nullable<Plane>;
  44132. /**
  44133. * Gets or sets a boolean indicating if animations are enabled
  44134. */
  44135. animationsEnabled: boolean;
  44136. private _animationPropertiesOverride;
  44137. /**
  44138. * Gets or sets the animation properties override
  44139. */
  44140. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  44141. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  44142. /**
  44143. * Gets or sets a boolean indicating if a constant deltatime has to be used
  44144. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  44145. */
  44146. useConstantAnimationDeltaTime: boolean;
  44147. /**
  44148. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  44149. * Please note that it requires to run a ray cast through the scene on every frame
  44150. */
  44151. constantlyUpdateMeshUnderPointer: boolean;
  44152. /**
  44153. * Defines the HTML cursor to use when hovering over interactive elements
  44154. */
  44155. hoverCursor: string;
  44156. /**
  44157. * Defines the HTML default cursor to use (empty by default)
  44158. */
  44159. defaultCursor: string;
  44160. /**
  44161. * Defines whether cursors are handled by the scene.
  44162. */
  44163. doNotHandleCursors: boolean;
  44164. /**
  44165. * This is used to call preventDefault() on pointer down
  44166. * in order to block unwanted artifacts like system double clicks
  44167. */
  44168. preventDefaultOnPointerDown: boolean;
  44169. /**
  44170. * This is used to call preventDefault() on pointer up
  44171. * in order to block unwanted artifacts like system double clicks
  44172. */
  44173. preventDefaultOnPointerUp: boolean;
  44174. /**
  44175. * Gets or sets user defined metadata
  44176. */
  44177. metadata: any;
  44178. /**
  44179. * For internal use only. Please do not use.
  44180. */
  44181. reservedDataStore: any;
  44182. /**
  44183. * Gets the name of the plugin used to load this scene (null by default)
  44184. */
  44185. loadingPluginName: string;
  44186. /**
  44187. * Use this array to add regular expressions used to disable offline support for specific urls
  44188. */
  44189. disableOfflineSupportExceptionRules: RegExp[];
  44190. /**
  44191. * An event triggered when the scene is disposed.
  44192. */
  44193. onDisposeObservable: Observable<Scene>;
  44194. private _onDisposeObserver;
  44195. /** Sets a function to be executed when this scene is disposed. */
  44196. set onDispose(callback: () => void);
  44197. /**
  44198. * An event triggered before rendering the scene (right after animations and physics)
  44199. */
  44200. onBeforeRenderObservable: Observable<Scene>;
  44201. private _onBeforeRenderObserver;
  44202. /** Sets a function to be executed before rendering this scene */
  44203. set beforeRender(callback: Nullable<() => void>);
  44204. /**
  44205. * An event triggered after rendering the scene
  44206. */
  44207. onAfterRenderObservable: Observable<Scene>;
  44208. /**
  44209. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  44210. */
  44211. onAfterRenderCameraObservable: Observable<Camera>;
  44212. private _onAfterRenderObserver;
  44213. /** Sets a function to be executed after rendering this scene */
  44214. set afterRender(callback: Nullable<() => void>);
  44215. /**
  44216. * An event triggered before animating the scene
  44217. */
  44218. onBeforeAnimationsObservable: Observable<Scene>;
  44219. /**
  44220. * An event triggered after animations processing
  44221. */
  44222. onAfterAnimationsObservable: Observable<Scene>;
  44223. /**
  44224. * An event triggered before draw calls are ready to be sent
  44225. */
  44226. onBeforeDrawPhaseObservable: Observable<Scene>;
  44227. /**
  44228. * An event triggered after draw calls have been sent
  44229. */
  44230. onAfterDrawPhaseObservable: Observable<Scene>;
  44231. /**
  44232. * An event triggered when the scene is ready
  44233. */
  44234. onReadyObservable: Observable<Scene>;
  44235. /**
  44236. * An event triggered before rendering a camera
  44237. */
  44238. onBeforeCameraRenderObservable: Observable<Camera>;
  44239. private _onBeforeCameraRenderObserver;
  44240. /** Sets a function to be executed before rendering a camera*/
  44241. set beforeCameraRender(callback: () => void);
  44242. /**
  44243. * An event triggered after rendering a camera
  44244. */
  44245. onAfterCameraRenderObservable: Observable<Camera>;
  44246. private _onAfterCameraRenderObserver;
  44247. /** Sets a function to be executed after rendering a camera*/
  44248. set afterCameraRender(callback: () => void);
  44249. /**
  44250. * An event triggered when active meshes evaluation is about to start
  44251. */
  44252. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  44253. /**
  44254. * An event triggered when active meshes evaluation is done
  44255. */
  44256. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  44257. /**
  44258. * An event triggered when particles rendering is about to start
  44259. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44260. */
  44261. onBeforeParticlesRenderingObservable: Observable<Scene>;
  44262. /**
  44263. * An event triggered when particles rendering is done
  44264. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44265. */
  44266. onAfterParticlesRenderingObservable: Observable<Scene>;
  44267. /**
  44268. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  44269. */
  44270. onDataLoadedObservable: Observable<Scene>;
  44271. /**
  44272. * An event triggered when a camera is created
  44273. */
  44274. onNewCameraAddedObservable: Observable<Camera>;
  44275. /**
  44276. * An event triggered when a camera is removed
  44277. */
  44278. onCameraRemovedObservable: Observable<Camera>;
  44279. /**
  44280. * An event triggered when a light is created
  44281. */
  44282. onNewLightAddedObservable: Observable<Light>;
  44283. /**
  44284. * An event triggered when a light is removed
  44285. */
  44286. onLightRemovedObservable: Observable<Light>;
  44287. /**
  44288. * An event triggered when a geometry is created
  44289. */
  44290. onNewGeometryAddedObservable: Observable<Geometry>;
  44291. /**
  44292. * An event triggered when a geometry is removed
  44293. */
  44294. onGeometryRemovedObservable: Observable<Geometry>;
  44295. /**
  44296. * An event triggered when a transform node is created
  44297. */
  44298. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  44299. /**
  44300. * An event triggered when a transform node is removed
  44301. */
  44302. onTransformNodeRemovedObservable: Observable<TransformNode>;
  44303. /**
  44304. * An event triggered when a mesh is created
  44305. */
  44306. onNewMeshAddedObservable: Observable<AbstractMesh>;
  44307. /**
  44308. * An event triggered when a mesh is removed
  44309. */
  44310. onMeshRemovedObservable: Observable<AbstractMesh>;
  44311. /**
  44312. * An event triggered when a skeleton is created
  44313. */
  44314. onNewSkeletonAddedObservable: Observable<Skeleton>;
  44315. /**
  44316. * An event triggered when a skeleton is removed
  44317. */
  44318. onSkeletonRemovedObservable: Observable<Skeleton>;
  44319. /**
  44320. * An event triggered when a material is created
  44321. */
  44322. onNewMaterialAddedObservable: Observable<Material>;
  44323. /**
  44324. * An event triggered when a material is removed
  44325. */
  44326. onMaterialRemovedObservable: Observable<Material>;
  44327. /**
  44328. * An event triggered when a texture is created
  44329. */
  44330. onNewTextureAddedObservable: Observable<BaseTexture>;
  44331. /**
  44332. * An event triggered when a texture is removed
  44333. */
  44334. onTextureRemovedObservable: Observable<BaseTexture>;
  44335. /**
  44336. * An event triggered when render targets are about to be rendered
  44337. * Can happen multiple times per frame.
  44338. */
  44339. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  44340. /**
  44341. * An event triggered when render targets were rendered.
  44342. * Can happen multiple times per frame.
  44343. */
  44344. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  44345. /**
  44346. * An event triggered before calculating deterministic simulation step
  44347. */
  44348. onBeforeStepObservable: Observable<Scene>;
  44349. /**
  44350. * An event triggered after calculating deterministic simulation step
  44351. */
  44352. onAfterStepObservable: Observable<Scene>;
  44353. /**
  44354. * An event triggered when the activeCamera property is updated
  44355. */
  44356. onActiveCameraChanged: Observable<Scene>;
  44357. /**
  44358. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  44359. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44360. * 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)
  44361. */
  44362. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44363. /**
  44364. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  44365. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44366. * 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)
  44367. */
  44368. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44369. /**
  44370. * This Observable will when a mesh has been imported into the scene.
  44371. */
  44372. onMeshImportedObservable: Observable<AbstractMesh>;
  44373. /**
  44374. * This Observable will when an animation file has been imported into the scene.
  44375. */
  44376. onAnimationFileImportedObservable: Observable<Scene>;
  44377. /**
  44378. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  44379. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  44380. */
  44381. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  44382. /** @hidden */
  44383. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  44384. /**
  44385. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  44386. */
  44387. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  44388. /**
  44389. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  44390. */
  44391. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  44392. /**
  44393. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  44394. */
  44395. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  44396. /** Callback called when a pointer move is detected */
  44397. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44398. /** Callback called when a pointer down is detected */
  44399. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44400. /** Callback called when a pointer up is detected */
  44401. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  44402. /** Callback called when a pointer pick is detected */
  44403. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  44404. /**
  44405. * 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).
  44406. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  44407. */
  44408. onPrePointerObservable: Observable<PointerInfoPre>;
  44409. /**
  44410. * Observable event triggered each time an input event is received from the rendering canvas
  44411. */
  44412. onPointerObservable: Observable<PointerInfo>;
  44413. /**
  44414. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  44415. */
  44416. get unTranslatedPointer(): Vector2;
  44417. /**
  44418. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  44419. */
  44420. static get DragMovementThreshold(): number;
  44421. static set DragMovementThreshold(value: number);
  44422. /**
  44423. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  44424. */
  44425. static get LongPressDelay(): number;
  44426. static set LongPressDelay(value: number);
  44427. /**
  44428. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  44429. */
  44430. static get DoubleClickDelay(): number;
  44431. static set DoubleClickDelay(value: number);
  44432. /** If you need to check double click without raising a single click at first click, enable this flag */
  44433. static get ExclusiveDoubleClickMode(): boolean;
  44434. static set ExclusiveDoubleClickMode(value: boolean);
  44435. /** @hidden */
  44436. _mirroredCameraPosition: Nullable<Vector3>;
  44437. /**
  44438. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  44439. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  44440. */
  44441. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  44442. /**
  44443. * Observable event triggered each time an keyboard event is received from the hosting window
  44444. */
  44445. onKeyboardObservable: Observable<KeyboardInfo>;
  44446. private _useRightHandedSystem;
  44447. /**
  44448. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  44449. */
  44450. set useRightHandedSystem(value: boolean);
  44451. get useRightHandedSystem(): boolean;
  44452. private _timeAccumulator;
  44453. private _currentStepId;
  44454. private _currentInternalStep;
  44455. /**
  44456. * Sets the step Id used by deterministic lock step
  44457. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44458. * @param newStepId defines the step Id
  44459. */
  44460. setStepId(newStepId: number): void;
  44461. /**
  44462. * Gets the step Id used by deterministic lock step
  44463. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44464. * @returns the step Id
  44465. */
  44466. getStepId(): number;
  44467. /**
  44468. * Gets the internal step used by deterministic lock step
  44469. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44470. * @returns the internal step
  44471. */
  44472. getInternalStep(): number;
  44473. private _fogEnabled;
  44474. /**
  44475. * Gets or sets a boolean indicating if fog is enabled on this scene
  44476. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44477. * (Default is true)
  44478. */
  44479. set fogEnabled(value: boolean);
  44480. get fogEnabled(): boolean;
  44481. private _fogMode;
  44482. /**
  44483. * Gets or sets the fog mode to use
  44484. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44485. * | mode | value |
  44486. * | --- | --- |
  44487. * | FOGMODE_NONE | 0 |
  44488. * | FOGMODE_EXP | 1 |
  44489. * | FOGMODE_EXP2 | 2 |
  44490. * | FOGMODE_LINEAR | 3 |
  44491. */
  44492. set fogMode(value: number);
  44493. get fogMode(): number;
  44494. /**
  44495. * Gets or sets the fog color to use
  44496. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44497. * (Default is Color3(0.2, 0.2, 0.3))
  44498. */
  44499. fogColor: Color3;
  44500. /**
  44501. * Gets or sets the fog density to use
  44502. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44503. * (Default is 0.1)
  44504. */
  44505. fogDensity: number;
  44506. /**
  44507. * Gets or sets the fog start distance to use
  44508. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44509. * (Default is 0)
  44510. */
  44511. fogStart: number;
  44512. /**
  44513. * Gets or sets the fog end distance to use
  44514. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44515. * (Default is 1000)
  44516. */
  44517. fogEnd: number;
  44518. /**
  44519. * Flag indicating that the frame buffer binding is handled by another component
  44520. */
  44521. prePass: boolean;
  44522. private _shadowsEnabled;
  44523. /**
  44524. * Gets or sets a boolean indicating if shadows are enabled on this scene
  44525. */
  44526. set shadowsEnabled(value: boolean);
  44527. get shadowsEnabled(): boolean;
  44528. private _lightsEnabled;
  44529. /**
  44530. * Gets or sets a boolean indicating if lights are enabled on this scene
  44531. */
  44532. set lightsEnabled(value: boolean);
  44533. get lightsEnabled(): boolean;
  44534. /** All of the active cameras added to this scene. */
  44535. activeCameras: Camera[];
  44536. /** @hidden */
  44537. _activeCamera: Nullable<Camera>;
  44538. /** Gets or sets the current active camera */
  44539. get activeCamera(): Nullable<Camera>;
  44540. set activeCamera(value: Nullable<Camera>);
  44541. private _defaultMaterial;
  44542. /** The default material used on meshes when no material is affected */
  44543. get defaultMaterial(): Material;
  44544. /** The default material used on meshes when no material is affected */
  44545. set defaultMaterial(value: Material);
  44546. private _texturesEnabled;
  44547. /**
  44548. * Gets or sets a boolean indicating if textures are enabled on this scene
  44549. */
  44550. set texturesEnabled(value: boolean);
  44551. get texturesEnabled(): boolean;
  44552. /**
  44553. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  44554. */
  44555. physicsEnabled: boolean;
  44556. /**
  44557. * Gets or sets a boolean indicating if particles are enabled on this scene
  44558. */
  44559. particlesEnabled: boolean;
  44560. /**
  44561. * Gets or sets a boolean indicating if sprites are enabled on this scene
  44562. */
  44563. spritesEnabled: boolean;
  44564. private _skeletonsEnabled;
  44565. /**
  44566. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  44567. */
  44568. set skeletonsEnabled(value: boolean);
  44569. get skeletonsEnabled(): boolean;
  44570. /**
  44571. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  44572. */
  44573. lensFlaresEnabled: boolean;
  44574. /**
  44575. * Gets or sets a boolean indicating if collisions are enabled on this scene
  44576. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44577. */
  44578. collisionsEnabled: boolean;
  44579. private _collisionCoordinator;
  44580. /** @hidden */
  44581. get collisionCoordinator(): ICollisionCoordinator;
  44582. /**
  44583. * Defines the gravity applied to this scene (used only for collisions)
  44584. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44585. */
  44586. gravity: Vector3;
  44587. /**
  44588. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  44589. */
  44590. postProcessesEnabled: boolean;
  44591. /**
  44592. * Gets the current postprocess manager
  44593. */
  44594. postProcessManager: PostProcessManager;
  44595. /**
  44596. * Gets or sets a boolean indicating if render targets are enabled on this scene
  44597. */
  44598. renderTargetsEnabled: boolean;
  44599. /**
  44600. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  44601. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  44602. */
  44603. dumpNextRenderTargets: boolean;
  44604. /**
  44605. * The list of user defined render targets added to the scene
  44606. */
  44607. customRenderTargets: RenderTargetTexture[];
  44608. /**
  44609. * Defines if texture loading must be delayed
  44610. * If true, textures will only be loaded when they need to be rendered
  44611. */
  44612. useDelayedTextureLoading: boolean;
  44613. /**
  44614. * Gets the list of meshes imported to the scene through SceneLoader
  44615. */
  44616. importedMeshesFiles: String[];
  44617. /**
  44618. * Gets or sets a boolean indicating if probes are enabled on this scene
  44619. */
  44620. probesEnabled: boolean;
  44621. /**
  44622. * Gets or sets the current offline provider to use to store scene data
  44623. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  44624. */
  44625. offlineProvider: IOfflineProvider;
  44626. /**
  44627. * Gets or sets the action manager associated with the scene
  44628. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  44629. */
  44630. actionManager: AbstractActionManager;
  44631. private _meshesForIntersections;
  44632. /**
  44633. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  44634. */
  44635. proceduralTexturesEnabled: boolean;
  44636. private _engine;
  44637. private _totalVertices;
  44638. /** @hidden */
  44639. _activeIndices: PerfCounter;
  44640. /** @hidden */
  44641. _activeParticles: PerfCounter;
  44642. /** @hidden */
  44643. _activeBones: PerfCounter;
  44644. private _animationRatio;
  44645. /** @hidden */
  44646. _animationTimeLast: number;
  44647. /** @hidden */
  44648. _animationTime: number;
  44649. /**
  44650. * Gets or sets a general scale for animation speed
  44651. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  44652. */
  44653. animationTimeScale: number;
  44654. /** @hidden */
  44655. _cachedMaterial: Nullable<Material>;
  44656. /** @hidden */
  44657. _cachedEffect: Nullable<Effect>;
  44658. /** @hidden */
  44659. _cachedVisibility: Nullable<number>;
  44660. private _renderId;
  44661. private _frameId;
  44662. private _executeWhenReadyTimeoutId;
  44663. private _intermediateRendering;
  44664. private _viewUpdateFlag;
  44665. private _projectionUpdateFlag;
  44666. /** @hidden */
  44667. _toBeDisposed: Nullable<IDisposable>[];
  44668. private _activeRequests;
  44669. /** @hidden */
  44670. _pendingData: any[];
  44671. private _isDisposed;
  44672. /**
  44673. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  44674. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  44675. */
  44676. dispatchAllSubMeshesOfActiveMeshes: boolean;
  44677. private _activeMeshes;
  44678. private _processedMaterials;
  44679. private _renderTargets;
  44680. /** @hidden */
  44681. _activeParticleSystems: SmartArray<IParticleSystem>;
  44682. private _activeSkeletons;
  44683. private _softwareSkinnedMeshes;
  44684. private _renderingManager;
  44685. /** @hidden */
  44686. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  44687. private _transformMatrix;
  44688. private _sceneUbo;
  44689. /** @hidden */
  44690. _viewMatrix: Matrix;
  44691. private _projectionMatrix;
  44692. /** @hidden */
  44693. _forcedViewPosition: Nullable<Vector3>;
  44694. /** @hidden */
  44695. _frustumPlanes: Plane[];
  44696. /**
  44697. * Gets the list of frustum planes (built from the active camera)
  44698. */
  44699. get frustumPlanes(): Plane[];
  44700. /**
  44701. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  44702. * This is useful if there are more lights that the maximum simulteanous authorized
  44703. */
  44704. requireLightSorting: boolean;
  44705. /** @hidden */
  44706. readonly useMaterialMeshMap: boolean;
  44707. /** @hidden */
  44708. readonly useClonedMeshMap: boolean;
  44709. private _externalData;
  44710. private _uid;
  44711. /**
  44712. * @hidden
  44713. * Backing store of defined scene components.
  44714. */
  44715. _components: ISceneComponent[];
  44716. /**
  44717. * @hidden
  44718. * Backing store of defined scene components.
  44719. */
  44720. _serializableComponents: ISceneSerializableComponent[];
  44721. /**
  44722. * List of components to register on the next registration step.
  44723. */
  44724. private _transientComponents;
  44725. /**
  44726. * Registers the transient components if needed.
  44727. */
  44728. private _registerTransientComponents;
  44729. /**
  44730. * @hidden
  44731. * Add a component to the scene.
  44732. * Note that the ccomponent could be registered on th next frame if this is called after
  44733. * the register component stage.
  44734. * @param component Defines the component to add to the scene
  44735. */
  44736. _addComponent(component: ISceneComponent): void;
  44737. /**
  44738. * @hidden
  44739. * Gets a component from the scene.
  44740. * @param name defines the name of the component to retrieve
  44741. * @returns the component or null if not present
  44742. */
  44743. _getComponent(name: string): Nullable<ISceneComponent>;
  44744. /**
  44745. * @hidden
  44746. * Defines the actions happening before camera updates.
  44747. */
  44748. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  44749. /**
  44750. * @hidden
  44751. * Defines the actions happening before clear the canvas.
  44752. */
  44753. _beforeClearStage: Stage<SimpleStageAction>;
  44754. /**
  44755. * @hidden
  44756. * Defines the actions when collecting render targets for the frame.
  44757. */
  44758. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44759. /**
  44760. * @hidden
  44761. * Defines the actions happening for one camera in the frame.
  44762. */
  44763. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44764. /**
  44765. * @hidden
  44766. * Defines the actions happening during the per mesh ready checks.
  44767. */
  44768. _isReadyForMeshStage: Stage<MeshStageAction>;
  44769. /**
  44770. * @hidden
  44771. * Defines the actions happening before evaluate active mesh checks.
  44772. */
  44773. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  44774. /**
  44775. * @hidden
  44776. * Defines the actions happening during the evaluate sub mesh checks.
  44777. */
  44778. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  44779. /**
  44780. * @hidden
  44781. * Defines the actions happening during the active mesh stage.
  44782. */
  44783. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  44784. /**
  44785. * @hidden
  44786. * Defines the actions happening during the per camera render target step.
  44787. */
  44788. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  44789. /**
  44790. * @hidden
  44791. * Defines the actions happening just before the active camera is drawing.
  44792. */
  44793. _beforeCameraDrawStage: Stage<CameraStageAction>;
  44794. /**
  44795. * @hidden
  44796. * Defines the actions happening just before a render target is drawing.
  44797. */
  44798. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  44799. /**
  44800. * @hidden
  44801. * Defines the actions happening just before a rendering group is drawing.
  44802. */
  44803. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  44804. /**
  44805. * @hidden
  44806. * Defines the actions happening just before a mesh is drawing.
  44807. */
  44808. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  44809. /**
  44810. * @hidden
  44811. * Defines the actions happening just after a mesh has been drawn.
  44812. */
  44813. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  44814. /**
  44815. * @hidden
  44816. * Defines the actions happening just after a rendering group has been drawn.
  44817. */
  44818. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  44819. /**
  44820. * @hidden
  44821. * Defines the actions happening just after the active camera has been drawn.
  44822. */
  44823. _afterCameraDrawStage: Stage<CameraStageAction>;
  44824. /**
  44825. * @hidden
  44826. * Defines the actions happening just after a render target has been drawn.
  44827. */
  44828. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  44829. /**
  44830. * @hidden
  44831. * Defines the actions happening just after rendering all cameras and computing intersections.
  44832. */
  44833. _afterRenderStage: Stage<SimpleStageAction>;
  44834. /**
  44835. * @hidden
  44836. * Defines the actions happening when a pointer move event happens.
  44837. */
  44838. _pointerMoveStage: Stage<PointerMoveStageAction>;
  44839. /**
  44840. * @hidden
  44841. * Defines the actions happening when a pointer down event happens.
  44842. */
  44843. _pointerDownStage: Stage<PointerUpDownStageAction>;
  44844. /**
  44845. * @hidden
  44846. * Defines the actions happening when a pointer up event happens.
  44847. */
  44848. _pointerUpStage: Stage<PointerUpDownStageAction>;
  44849. /**
  44850. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  44851. */
  44852. private geometriesByUniqueId;
  44853. /**
  44854. * Creates a new Scene
  44855. * @param engine defines the engine to use to render this scene
  44856. * @param options defines the scene options
  44857. */
  44858. constructor(engine: Engine, options?: SceneOptions);
  44859. /**
  44860. * Gets a string identifying the name of the class
  44861. * @returns "Scene" string
  44862. */
  44863. getClassName(): string;
  44864. private _defaultMeshCandidates;
  44865. /**
  44866. * @hidden
  44867. */
  44868. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44869. private _defaultSubMeshCandidates;
  44870. /**
  44871. * @hidden
  44872. */
  44873. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44874. /**
  44875. * Sets the default candidate providers for the scene.
  44876. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  44877. * and getCollidingSubMeshCandidates to their default function
  44878. */
  44879. setDefaultCandidateProviders(): void;
  44880. /**
  44881. * Gets the mesh that is currently under the pointer
  44882. */
  44883. get meshUnderPointer(): Nullable<AbstractMesh>;
  44884. /**
  44885. * Gets or sets the current on-screen X position of the pointer
  44886. */
  44887. get pointerX(): number;
  44888. set pointerX(value: number);
  44889. /**
  44890. * Gets or sets the current on-screen Y position of the pointer
  44891. */
  44892. get pointerY(): number;
  44893. set pointerY(value: number);
  44894. /**
  44895. * Gets the cached material (ie. the latest rendered one)
  44896. * @returns the cached material
  44897. */
  44898. getCachedMaterial(): Nullable<Material>;
  44899. /**
  44900. * Gets the cached effect (ie. the latest rendered one)
  44901. * @returns the cached effect
  44902. */
  44903. getCachedEffect(): Nullable<Effect>;
  44904. /**
  44905. * Gets the cached visibility state (ie. the latest rendered one)
  44906. * @returns the cached visibility state
  44907. */
  44908. getCachedVisibility(): Nullable<number>;
  44909. /**
  44910. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  44911. * @param material defines the current material
  44912. * @param effect defines the current effect
  44913. * @param visibility defines the current visibility state
  44914. * @returns true if one parameter is not cached
  44915. */
  44916. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  44917. /**
  44918. * Gets the engine associated with the scene
  44919. * @returns an Engine
  44920. */
  44921. getEngine(): Engine;
  44922. /**
  44923. * Gets the total number of vertices rendered per frame
  44924. * @returns the total number of vertices rendered per frame
  44925. */
  44926. getTotalVertices(): number;
  44927. /**
  44928. * Gets the performance counter for total vertices
  44929. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44930. */
  44931. get totalVerticesPerfCounter(): PerfCounter;
  44932. /**
  44933. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  44934. * @returns the total number of active indices rendered per frame
  44935. */
  44936. getActiveIndices(): number;
  44937. /**
  44938. * Gets the performance counter for active indices
  44939. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44940. */
  44941. get totalActiveIndicesPerfCounter(): PerfCounter;
  44942. /**
  44943. * Gets the total number of active particles rendered per frame
  44944. * @returns the total number of active particles rendered per frame
  44945. */
  44946. getActiveParticles(): number;
  44947. /**
  44948. * Gets the performance counter for active particles
  44949. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44950. */
  44951. get activeParticlesPerfCounter(): PerfCounter;
  44952. /**
  44953. * Gets the total number of active bones rendered per frame
  44954. * @returns the total number of active bones rendered per frame
  44955. */
  44956. getActiveBones(): number;
  44957. /**
  44958. * Gets the performance counter for active bones
  44959. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44960. */
  44961. get activeBonesPerfCounter(): PerfCounter;
  44962. /**
  44963. * Gets the array of active meshes
  44964. * @returns an array of AbstractMesh
  44965. */
  44966. getActiveMeshes(): SmartArray<AbstractMesh>;
  44967. /**
  44968. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  44969. * @returns a number
  44970. */
  44971. getAnimationRatio(): number;
  44972. /**
  44973. * Gets an unique Id for the current render phase
  44974. * @returns a number
  44975. */
  44976. getRenderId(): number;
  44977. /**
  44978. * Gets an unique Id for the current frame
  44979. * @returns a number
  44980. */
  44981. getFrameId(): number;
  44982. /** Call this function if you want to manually increment the render Id*/
  44983. incrementRenderId(): void;
  44984. private _createUbo;
  44985. /**
  44986. * Use this method to simulate a pointer move on a mesh
  44987. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44988. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44989. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44990. * @returns the current scene
  44991. */
  44992. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  44993. /**
  44994. * Use this method to simulate a pointer down on a mesh
  44995. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44996. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44997. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44998. * @returns the current scene
  44999. */
  45000. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  45001. /**
  45002. * Use this method to simulate a pointer up on a mesh
  45003. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45004. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45005. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45006. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  45007. * @returns the current scene
  45008. */
  45009. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  45010. /**
  45011. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  45012. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  45013. * @returns true if the pointer was captured
  45014. */
  45015. isPointerCaptured(pointerId?: number): boolean;
  45016. /**
  45017. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  45018. * @param attachUp defines if you want to attach events to pointerup
  45019. * @param attachDown defines if you want to attach events to pointerdown
  45020. * @param attachMove defines if you want to attach events to pointermove
  45021. */
  45022. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  45023. /** Detaches all event handlers*/
  45024. detachControl(): void;
  45025. /**
  45026. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  45027. * Delay loaded resources are not taking in account
  45028. * @return true if all required resources are ready
  45029. */
  45030. isReady(): boolean;
  45031. /** Resets all cached information relative to material (including effect and visibility) */
  45032. resetCachedMaterial(): void;
  45033. /**
  45034. * Registers a function to be called before every frame render
  45035. * @param func defines the function to register
  45036. */
  45037. registerBeforeRender(func: () => void): void;
  45038. /**
  45039. * Unregisters a function called before every frame render
  45040. * @param func defines the function to unregister
  45041. */
  45042. unregisterBeforeRender(func: () => void): void;
  45043. /**
  45044. * Registers a function to be called after every frame render
  45045. * @param func defines the function to register
  45046. */
  45047. registerAfterRender(func: () => void): void;
  45048. /**
  45049. * Unregisters a function called after every frame render
  45050. * @param func defines the function to unregister
  45051. */
  45052. unregisterAfterRender(func: () => void): void;
  45053. private _executeOnceBeforeRender;
  45054. /**
  45055. * The provided function will run before render once and will be disposed afterwards.
  45056. * A timeout delay can be provided so that the function will be executed in N ms.
  45057. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  45058. * @param func The function to be executed.
  45059. * @param timeout optional delay in ms
  45060. */
  45061. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  45062. /** @hidden */
  45063. _addPendingData(data: any): void;
  45064. /** @hidden */
  45065. _removePendingData(data: any): void;
  45066. /**
  45067. * Returns the number of items waiting to be loaded
  45068. * @returns the number of items waiting to be loaded
  45069. */
  45070. getWaitingItemsCount(): number;
  45071. /**
  45072. * Returns a boolean indicating if the scene is still loading data
  45073. */
  45074. get isLoading(): boolean;
  45075. /**
  45076. * Registers a function to be executed when the scene is ready
  45077. * @param {Function} func - the function to be executed
  45078. */
  45079. executeWhenReady(func: () => void): void;
  45080. /**
  45081. * Returns a promise that resolves when the scene is ready
  45082. * @returns A promise that resolves when the scene is ready
  45083. */
  45084. whenReadyAsync(): Promise<void>;
  45085. /** @hidden */
  45086. _checkIsReady(): void;
  45087. /**
  45088. * Gets all animatable attached to the scene
  45089. */
  45090. get animatables(): Animatable[];
  45091. /**
  45092. * Resets the last animation time frame.
  45093. * Useful to override when animations start running when loading a scene for the first time.
  45094. */
  45095. resetLastAnimationTimeFrame(): void;
  45096. /**
  45097. * Gets the current view matrix
  45098. * @returns a Matrix
  45099. */
  45100. getViewMatrix(): Matrix;
  45101. /**
  45102. * Gets the current projection matrix
  45103. * @returns a Matrix
  45104. */
  45105. getProjectionMatrix(): Matrix;
  45106. /**
  45107. * Gets the current transform matrix
  45108. * @returns a Matrix made of View * Projection
  45109. */
  45110. getTransformMatrix(): Matrix;
  45111. /**
  45112. * Sets the current transform matrix
  45113. * @param viewL defines the View matrix to use
  45114. * @param projectionL defines the Projection matrix to use
  45115. * @param viewR defines the right View matrix to use (if provided)
  45116. * @param projectionR defines the right Projection matrix to use (if provided)
  45117. */
  45118. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  45119. /**
  45120. * Gets the uniform buffer used to store scene data
  45121. * @returns a UniformBuffer
  45122. */
  45123. getSceneUniformBuffer(): UniformBuffer;
  45124. /**
  45125. * Gets an unique (relatively to the current scene) Id
  45126. * @returns an unique number for the scene
  45127. */
  45128. getUniqueId(): number;
  45129. /**
  45130. * Add a mesh to the list of scene's meshes
  45131. * @param newMesh defines the mesh to add
  45132. * @param recursive if all child meshes should also be added to the scene
  45133. */
  45134. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  45135. /**
  45136. * Remove a mesh for the list of scene's meshes
  45137. * @param toRemove defines the mesh to remove
  45138. * @param recursive if all child meshes should also be removed from the scene
  45139. * @returns the index where the mesh was in the mesh list
  45140. */
  45141. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  45142. /**
  45143. * Add a transform node to the list of scene's transform nodes
  45144. * @param newTransformNode defines the transform node to add
  45145. */
  45146. addTransformNode(newTransformNode: TransformNode): void;
  45147. /**
  45148. * Remove a transform node for the list of scene's transform nodes
  45149. * @param toRemove defines the transform node to remove
  45150. * @returns the index where the transform node was in the transform node list
  45151. */
  45152. removeTransformNode(toRemove: TransformNode): number;
  45153. /**
  45154. * Remove a skeleton for the list of scene's skeletons
  45155. * @param toRemove defines the skeleton to remove
  45156. * @returns the index where the skeleton was in the skeleton list
  45157. */
  45158. removeSkeleton(toRemove: Skeleton): number;
  45159. /**
  45160. * Remove a morph target for the list of scene's morph targets
  45161. * @param toRemove defines the morph target to remove
  45162. * @returns the index where the morph target was in the morph target list
  45163. */
  45164. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  45165. /**
  45166. * Remove a light for the list of scene's lights
  45167. * @param toRemove defines the light to remove
  45168. * @returns the index where the light was in the light list
  45169. */
  45170. removeLight(toRemove: Light): number;
  45171. /**
  45172. * Remove a camera for the list of scene's cameras
  45173. * @param toRemove defines the camera to remove
  45174. * @returns the index where the camera was in the camera list
  45175. */
  45176. removeCamera(toRemove: Camera): number;
  45177. /**
  45178. * Remove a particle system for the list of scene's particle systems
  45179. * @param toRemove defines the particle system to remove
  45180. * @returns the index where the particle system was in the particle system list
  45181. */
  45182. removeParticleSystem(toRemove: IParticleSystem): number;
  45183. /**
  45184. * Remove a animation for the list of scene's animations
  45185. * @param toRemove defines the animation to remove
  45186. * @returns the index where the animation was in the animation list
  45187. */
  45188. removeAnimation(toRemove: Animation): number;
  45189. /**
  45190. * Will stop the animation of the given target
  45191. * @param target - the target
  45192. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  45193. * @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)
  45194. */
  45195. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  45196. /**
  45197. * Removes the given animation group from this scene.
  45198. * @param toRemove The animation group to remove
  45199. * @returns The index of the removed animation group
  45200. */
  45201. removeAnimationGroup(toRemove: AnimationGroup): number;
  45202. /**
  45203. * Removes the given multi-material from this scene.
  45204. * @param toRemove The multi-material to remove
  45205. * @returns The index of the removed multi-material
  45206. */
  45207. removeMultiMaterial(toRemove: MultiMaterial): number;
  45208. /**
  45209. * Removes the given material from this scene.
  45210. * @param toRemove The material to remove
  45211. * @returns The index of the removed material
  45212. */
  45213. removeMaterial(toRemove: Material): number;
  45214. /**
  45215. * Removes the given action manager from this scene.
  45216. * @param toRemove The action manager to remove
  45217. * @returns The index of the removed action manager
  45218. */
  45219. removeActionManager(toRemove: AbstractActionManager): number;
  45220. /**
  45221. * Removes the given texture from this scene.
  45222. * @param toRemove The texture to remove
  45223. * @returns The index of the removed texture
  45224. */
  45225. removeTexture(toRemove: BaseTexture): number;
  45226. /**
  45227. * Adds the given light to this scene
  45228. * @param newLight The light to add
  45229. */
  45230. addLight(newLight: Light): void;
  45231. /**
  45232. * Sorts the list list based on light priorities
  45233. */
  45234. sortLightsByPriority(): void;
  45235. /**
  45236. * Adds the given camera to this scene
  45237. * @param newCamera The camera to add
  45238. */
  45239. addCamera(newCamera: Camera): void;
  45240. /**
  45241. * Adds the given skeleton to this scene
  45242. * @param newSkeleton The skeleton to add
  45243. */
  45244. addSkeleton(newSkeleton: Skeleton): void;
  45245. /**
  45246. * Adds the given particle system to this scene
  45247. * @param newParticleSystem The particle system to add
  45248. */
  45249. addParticleSystem(newParticleSystem: IParticleSystem): void;
  45250. /**
  45251. * Adds the given animation to this scene
  45252. * @param newAnimation The animation to add
  45253. */
  45254. addAnimation(newAnimation: Animation): void;
  45255. /**
  45256. * Adds the given animation group to this scene.
  45257. * @param newAnimationGroup The animation group to add
  45258. */
  45259. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  45260. /**
  45261. * Adds the given multi-material to this scene
  45262. * @param newMultiMaterial The multi-material to add
  45263. */
  45264. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  45265. /**
  45266. * Adds the given material to this scene
  45267. * @param newMaterial The material to add
  45268. */
  45269. addMaterial(newMaterial: Material): void;
  45270. /**
  45271. * Adds the given morph target to this scene
  45272. * @param newMorphTargetManager The morph target to add
  45273. */
  45274. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  45275. /**
  45276. * Adds the given geometry to this scene
  45277. * @param newGeometry The geometry to add
  45278. */
  45279. addGeometry(newGeometry: Geometry): void;
  45280. /**
  45281. * Adds the given action manager to this scene
  45282. * @param newActionManager The action manager to add
  45283. */
  45284. addActionManager(newActionManager: AbstractActionManager): void;
  45285. /**
  45286. * Adds the given texture to this scene.
  45287. * @param newTexture The texture to add
  45288. */
  45289. addTexture(newTexture: BaseTexture): void;
  45290. /**
  45291. * Switch active camera
  45292. * @param newCamera defines the new active camera
  45293. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  45294. */
  45295. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  45296. /**
  45297. * sets the active camera of the scene using its ID
  45298. * @param id defines the camera's ID
  45299. * @return the new active camera or null if none found.
  45300. */
  45301. setActiveCameraByID(id: string): Nullable<Camera>;
  45302. /**
  45303. * sets the active camera of the scene using its name
  45304. * @param name defines the camera's name
  45305. * @returns the new active camera or null if none found.
  45306. */
  45307. setActiveCameraByName(name: string): Nullable<Camera>;
  45308. /**
  45309. * get an animation group using its name
  45310. * @param name defines the material's name
  45311. * @return the animation group or null if none found.
  45312. */
  45313. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  45314. /**
  45315. * Get a material using its unique id
  45316. * @param uniqueId defines the material's unique id
  45317. * @return the material or null if none found.
  45318. */
  45319. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  45320. /**
  45321. * get a material using its id
  45322. * @param id defines the material's ID
  45323. * @return the material or null if none found.
  45324. */
  45325. getMaterialByID(id: string): Nullable<Material>;
  45326. /**
  45327. * Gets a the last added material using a given id
  45328. * @param id defines the material's ID
  45329. * @return the last material with the given id or null if none found.
  45330. */
  45331. getLastMaterialByID(id: string): Nullable<Material>;
  45332. /**
  45333. * Gets a material using its name
  45334. * @param name defines the material's name
  45335. * @return the material or null if none found.
  45336. */
  45337. getMaterialByName(name: string): Nullable<Material>;
  45338. /**
  45339. * Get a texture using its unique id
  45340. * @param uniqueId defines the texture's unique id
  45341. * @return the texture or null if none found.
  45342. */
  45343. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  45344. /**
  45345. * Gets a camera using its id
  45346. * @param id defines the id to look for
  45347. * @returns the camera or null if not found
  45348. */
  45349. getCameraByID(id: string): Nullable<Camera>;
  45350. /**
  45351. * Gets a camera using its unique id
  45352. * @param uniqueId defines the unique id to look for
  45353. * @returns the camera or null if not found
  45354. */
  45355. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  45356. /**
  45357. * Gets a camera using its name
  45358. * @param name defines the camera's name
  45359. * @return the camera or null if none found.
  45360. */
  45361. getCameraByName(name: string): Nullable<Camera>;
  45362. /**
  45363. * Gets a bone using its id
  45364. * @param id defines the bone's id
  45365. * @return the bone or null if not found
  45366. */
  45367. getBoneByID(id: string): Nullable<Bone>;
  45368. /**
  45369. * Gets a bone using its id
  45370. * @param name defines the bone's name
  45371. * @return the bone or null if not found
  45372. */
  45373. getBoneByName(name: string): Nullable<Bone>;
  45374. /**
  45375. * Gets a light node using its name
  45376. * @param name defines the the light's name
  45377. * @return the light or null if none found.
  45378. */
  45379. getLightByName(name: string): Nullable<Light>;
  45380. /**
  45381. * Gets a light node using its id
  45382. * @param id defines the light's id
  45383. * @return the light or null if none found.
  45384. */
  45385. getLightByID(id: string): Nullable<Light>;
  45386. /**
  45387. * Gets a light node using its scene-generated unique ID
  45388. * @param uniqueId defines the light's unique id
  45389. * @return the light or null if none found.
  45390. */
  45391. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  45392. /**
  45393. * Gets a particle system by id
  45394. * @param id defines the particle system id
  45395. * @return the corresponding system or null if none found
  45396. */
  45397. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  45398. /**
  45399. * Gets a geometry using its ID
  45400. * @param id defines the geometry's id
  45401. * @return the geometry or null if none found.
  45402. */
  45403. getGeometryByID(id: string): Nullable<Geometry>;
  45404. private _getGeometryByUniqueID;
  45405. /**
  45406. * Add a new geometry to this scene
  45407. * @param geometry defines the geometry to be added to the scene.
  45408. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  45409. * @return a boolean defining if the geometry was added or not
  45410. */
  45411. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  45412. /**
  45413. * Removes an existing geometry
  45414. * @param geometry defines the geometry to be removed from the scene
  45415. * @return a boolean defining if the geometry was removed or not
  45416. */
  45417. removeGeometry(geometry: Geometry): boolean;
  45418. /**
  45419. * Gets the list of geometries attached to the scene
  45420. * @returns an array of Geometry
  45421. */
  45422. getGeometries(): Geometry[];
  45423. /**
  45424. * Gets the first added mesh found of a given ID
  45425. * @param id defines the id to search for
  45426. * @return the mesh found or null if not found at all
  45427. */
  45428. getMeshByID(id: string): Nullable<AbstractMesh>;
  45429. /**
  45430. * Gets a list of meshes using their id
  45431. * @param id defines the id to search for
  45432. * @returns a list of meshes
  45433. */
  45434. getMeshesByID(id: string): Array<AbstractMesh>;
  45435. /**
  45436. * Gets the first added transform node found of a given ID
  45437. * @param id defines the id to search for
  45438. * @return the found transform node or null if not found at all.
  45439. */
  45440. getTransformNodeByID(id: string): Nullable<TransformNode>;
  45441. /**
  45442. * Gets a transform node with its auto-generated unique id
  45443. * @param uniqueId efines the unique id to search for
  45444. * @return the found transform node or null if not found at all.
  45445. */
  45446. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  45447. /**
  45448. * Gets a list of transform nodes using their id
  45449. * @param id defines the id to search for
  45450. * @returns a list of transform nodes
  45451. */
  45452. getTransformNodesByID(id: string): Array<TransformNode>;
  45453. /**
  45454. * Gets a mesh with its auto-generated unique id
  45455. * @param uniqueId defines the unique id to search for
  45456. * @return the found mesh or null if not found at all.
  45457. */
  45458. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  45459. /**
  45460. * Gets a the last added mesh using a given id
  45461. * @param id defines the id to search for
  45462. * @return the found mesh or null if not found at all.
  45463. */
  45464. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  45465. /**
  45466. * Gets a the last added node (Mesh, Camera, Light) using a given id
  45467. * @param id defines the id to search for
  45468. * @return the found node or null if not found at all
  45469. */
  45470. getLastEntryByID(id: string): Nullable<Node>;
  45471. /**
  45472. * Gets a node (Mesh, Camera, Light) using a given id
  45473. * @param id defines the id to search for
  45474. * @return the found node or null if not found at all
  45475. */
  45476. getNodeByID(id: string): Nullable<Node>;
  45477. /**
  45478. * Gets a node (Mesh, Camera, Light) using a given name
  45479. * @param name defines the name to search for
  45480. * @return the found node or null if not found at all.
  45481. */
  45482. getNodeByName(name: string): Nullable<Node>;
  45483. /**
  45484. * Gets a mesh using a given name
  45485. * @param name defines the name to search for
  45486. * @return the found mesh or null if not found at all.
  45487. */
  45488. getMeshByName(name: string): Nullable<AbstractMesh>;
  45489. /**
  45490. * Gets a transform node using a given name
  45491. * @param name defines the name to search for
  45492. * @return the found transform node or null if not found at all.
  45493. */
  45494. getTransformNodeByName(name: string): Nullable<TransformNode>;
  45495. /**
  45496. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  45497. * @param id defines the id to search for
  45498. * @return the found skeleton or null if not found at all.
  45499. */
  45500. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  45501. /**
  45502. * Gets a skeleton using a given auto generated unique id
  45503. * @param uniqueId defines the unique id to search for
  45504. * @return the found skeleton or null if not found at all.
  45505. */
  45506. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  45507. /**
  45508. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  45509. * @param id defines the id to search for
  45510. * @return the found skeleton or null if not found at all.
  45511. */
  45512. getSkeletonById(id: string): Nullable<Skeleton>;
  45513. /**
  45514. * Gets a skeleton using a given name
  45515. * @param name defines the name to search for
  45516. * @return the found skeleton or null if not found at all.
  45517. */
  45518. getSkeletonByName(name: string): Nullable<Skeleton>;
  45519. /**
  45520. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  45521. * @param id defines the id to search for
  45522. * @return the found morph target manager or null if not found at all.
  45523. */
  45524. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  45525. /**
  45526. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  45527. * @param id defines the id to search for
  45528. * @return the found morph target or null if not found at all.
  45529. */
  45530. getMorphTargetById(id: string): Nullable<MorphTarget>;
  45531. /**
  45532. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  45533. * @param name defines the name to search for
  45534. * @return the found morph target or null if not found at all.
  45535. */
  45536. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  45537. /**
  45538. * Gets a post process using a given name (if many are found, this function will pick the first one)
  45539. * @param name defines the name to search for
  45540. * @return the found post process or null if not found at all.
  45541. */
  45542. getPostProcessByName(name: string): Nullable<PostProcess>;
  45543. /**
  45544. * Gets a boolean indicating if the given mesh is active
  45545. * @param mesh defines the mesh to look for
  45546. * @returns true if the mesh is in the active list
  45547. */
  45548. isActiveMesh(mesh: AbstractMesh): boolean;
  45549. /**
  45550. * Return a unique id as a string which can serve as an identifier for the scene
  45551. */
  45552. get uid(): string;
  45553. /**
  45554. * Add an externaly attached data from its key.
  45555. * This method call will fail and return false, if such key already exists.
  45556. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  45557. * @param key the unique key that identifies the data
  45558. * @param data the data object to associate to the key for this Engine instance
  45559. * @return true if no such key were already present and the data was added successfully, false otherwise
  45560. */
  45561. addExternalData<T>(key: string, data: T): boolean;
  45562. /**
  45563. * Get an externaly attached data from its key
  45564. * @param key the unique key that identifies the data
  45565. * @return the associated data, if present (can be null), or undefined if not present
  45566. */
  45567. getExternalData<T>(key: string): Nullable<T>;
  45568. /**
  45569. * Get an externaly attached data from its key, create it using a factory if it's not already present
  45570. * @param key the unique key that identifies the data
  45571. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  45572. * @return the associated data, can be null if the factory returned null.
  45573. */
  45574. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  45575. /**
  45576. * Remove an externaly attached data from the Engine instance
  45577. * @param key the unique key that identifies the data
  45578. * @return true if the data was successfully removed, false if it doesn't exist
  45579. */
  45580. removeExternalData(key: string): boolean;
  45581. private _evaluateSubMesh;
  45582. /**
  45583. * Clear the processed materials smart array preventing retention point in material dispose.
  45584. */
  45585. freeProcessedMaterials(): void;
  45586. private _preventFreeActiveMeshesAndRenderingGroups;
  45587. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  45588. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  45589. * when disposing several meshes in a row or a hierarchy of meshes.
  45590. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  45591. */
  45592. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  45593. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  45594. /**
  45595. * Clear the active meshes smart array preventing retention point in mesh dispose.
  45596. */
  45597. freeActiveMeshes(): void;
  45598. /**
  45599. * Clear the info related to rendering groups preventing retention points during dispose.
  45600. */
  45601. freeRenderingGroups(): void;
  45602. /** @hidden */
  45603. _isInIntermediateRendering(): boolean;
  45604. /**
  45605. * Lambda returning the list of potentially active meshes.
  45606. */
  45607. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  45608. /**
  45609. * Lambda returning the list of potentially active sub meshes.
  45610. */
  45611. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  45612. /**
  45613. * Lambda returning the list of potentially intersecting sub meshes.
  45614. */
  45615. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  45616. /**
  45617. * Lambda returning the list of potentially colliding sub meshes.
  45618. */
  45619. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  45620. private _activeMeshesFrozen;
  45621. private _skipEvaluateActiveMeshesCompletely;
  45622. /**
  45623. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  45624. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  45625. * @param onSuccess optional success callback
  45626. * @param onError optional error callback
  45627. * @returns the current scene
  45628. */
  45629. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  45630. /**
  45631. * Use this function to restart evaluating active meshes on every frame
  45632. * @returns the current scene
  45633. */
  45634. unfreezeActiveMeshes(): Scene;
  45635. private _evaluateActiveMeshes;
  45636. private _activeMesh;
  45637. /**
  45638. * Update the transform matrix to update from the current active camera
  45639. * @param force defines a boolean used to force the update even if cache is up to date
  45640. */
  45641. updateTransformMatrix(force?: boolean): void;
  45642. private _bindFrameBuffer;
  45643. /** @hidden */
  45644. _allowPostProcessClearColor: boolean;
  45645. /** @hidden */
  45646. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  45647. private _processSubCameras;
  45648. private _checkIntersections;
  45649. /** @hidden */
  45650. _advancePhysicsEngineStep(step: number): void;
  45651. /**
  45652. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  45653. */
  45654. getDeterministicFrameTime: () => number;
  45655. /** @hidden */
  45656. _animate(): void;
  45657. /** Execute all animations (for a frame) */
  45658. animate(): void;
  45659. /**
  45660. * Render the scene
  45661. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  45662. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  45663. */
  45664. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  45665. /**
  45666. * Freeze all materials
  45667. * A frozen material will not be updatable but should be faster to render
  45668. */
  45669. freezeMaterials(): void;
  45670. /**
  45671. * Unfreeze all materials
  45672. * A frozen material will not be updatable but should be faster to render
  45673. */
  45674. unfreezeMaterials(): void;
  45675. /**
  45676. * Releases all held ressources
  45677. */
  45678. dispose(): void;
  45679. /**
  45680. * Gets if the scene is already disposed
  45681. */
  45682. get isDisposed(): boolean;
  45683. /**
  45684. * Call this function to reduce memory footprint of the scene.
  45685. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  45686. */
  45687. clearCachedVertexData(): void;
  45688. /**
  45689. * This function will remove the local cached buffer data from texture.
  45690. * It will save memory but will prevent the texture from being rebuilt
  45691. */
  45692. cleanCachedTextureBuffer(): void;
  45693. /**
  45694. * Get the world extend vectors with an optional filter
  45695. *
  45696. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  45697. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  45698. */
  45699. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  45700. min: Vector3;
  45701. max: Vector3;
  45702. };
  45703. /**
  45704. * Creates a ray that can be used to pick in the scene
  45705. * @param x defines the x coordinate of the origin (on-screen)
  45706. * @param y defines the y coordinate of the origin (on-screen)
  45707. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45708. * @param camera defines the camera to use for the picking
  45709. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45710. * @returns a Ray
  45711. */
  45712. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  45713. /**
  45714. * Creates a ray that can be used to pick in the scene
  45715. * @param x defines the x coordinate of the origin (on-screen)
  45716. * @param y defines the y coordinate of the origin (on-screen)
  45717. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45718. * @param result defines the ray where to store the picking ray
  45719. * @param camera defines the camera to use for the picking
  45720. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45721. * @returns the current scene
  45722. */
  45723. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  45724. /**
  45725. * Creates a ray that can be used to pick in the scene
  45726. * @param x defines the x coordinate of the origin (on-screen)
  45727. * @param y defines the y coordinate of the origin (on-screen)
  45728. * @param camera defines the camera to use for the picking
  45729. * @returns a Ray
  45730. */
  45731. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  45732. /**
  45733. * Creates a ray that can be used to pick in the scene
  45734. * @param x defines the x coordinate of the origin (on-screen)
  45735. * @param y defines the y coordinate of the origin (on-screen)
  45736. * @param result defines the ray where to store the picking ray
  45737. * @param camera defines the camera to use for the picking
  45738. * @returns the current scene
  45739. */
  45740. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  45741. /** Launch a ray to try to pick a mesh in the scene
  45742. * @param x position on screen
  45743. * @param y position on screen
  45744. * @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
  45745. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45746. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45747. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45748. * @returns a PickingInfo
  45749. */
  45750. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45751. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  45752. * @param x position on screen
  45753. * @param y position on screen
  45754. * @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
  45755. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45756. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45757. * @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)
  45758. */
  45759. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  45760. /** Use the given ray to pick a mesh in the scene
  45761. * @param ray The ray to use to pick meshes
  45762. * @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
  45763. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45764. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45765. * @returns a PickingInfo
  45766. */
  45767. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45768. /**
  45769. * Launch a ray to try to pick a mesh in the scene
  45770. * @param x X position on screen
  45771. * @param y Y position on screen
  45772. * @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
  45773. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45774. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45775. * @returns an array of PickingInfo
  45776. */
  45777. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45778. /**
  45779. * Launch a ray to try to pick a mesh in the scene
  45780. * @param ray Ray to use
  45781. * @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
  45782. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45783. * @returns an array of PickingInfo
  45784. */
  45785. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45786. /**
  45787. * Force the value of meshUnderPointer
  45788. * @param mesh defines the mesh to use
  45789. * @param pointerId optional pointer id when using more than one pointer
  45790. */
  45791. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  45792. /**
  45793. * Gets the mesh under the pointer
  45794. * @returns a Mesh or null if no mesh is under the pointer
  45795. */
  45796. getPointerOverMesh(): Nullable<AbstractMesh>;
  45797. /** @hidden */
  45798. _rebuildGeometries(): void;
  45799. /** @hidden */
  45800. _rebuildTextures(): void;
  45801. private _getByTags;
  45802. /**
  45803. * Get a list of meshes by tags
  45804. * @param tagsQuery defines the tags query to use
  45805. * @param forEach defines a predicate used to filter results
  45806. * @returns an array of Mesh
  45807. */
  45808. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  45809. /**
  45810. * Get a list of cameras by tags
  45811. * @param tagsQuery defines the tags query to use
  45812. * @param forEach defines a predicate used to filter results
  45813. * @returns an array of Camera
  45814. */
  45815. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  45816. /**
  45817. * Get a list of lights by tags
  45818. * @param tagsQuery defines the tags query to use
  45819. * @param forEach defines a predicate used to filter results
  45820. * @returns an array of Light
  45821. */
  45822. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  45823. /**
  45824. * Get a list of materials by tags
  45825. * @param tagsQuery defines the tags query to use
  45826. * @param forEach defines a predicate used to filter results
  45827. * @returns an array of Material
  45828. */
  45829. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  45830. /**
  45831. * Get a list of transform nodes by tags
  45832. * @param tagsQuery defines the tags query to use
  45833. * @param forEach defines a predicate used to filter results
  45834. * @returns an array of TransformNode
  45835. */
  45836. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  45837. /**
  45838. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  45839. * This allowed control for front to back rendering or reversly depending of the special needs.
  45840. *
  45841. * @param renderingGroupId The rendering group id corresponding to its index
  45842. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  45843. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  45844. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  45845. */
  45846. 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;
  45847. /**
  45848. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  45849. *
  45850. * @param renderingGroupId The rendering group id corresponding to its index
  45851. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  45852. * @param depth Automatically clears depth between groups if true and autoClear is true.
  45853. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  45854. */
  45855. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  45856. /**
  45857. * Gets the current auto clear configuration for one rendering group of the rendering
  45858. * manager.
  45859. * @param index the rendering group index to get the information for
  45860. * @returns The auto clear setup for the requested rendering group
  45861. */
  45862. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  45863. private _blockMaterialDirtyMechanism;
  45864. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  45865. get blockMaterialDirtyMechanism(): boolean;
  45866. set blockMaterialDirtyMechanism(value: boolean);
  45867. /**
  45868. * Will flag all materials as dirty to trigger new shader compilation
  45869. * @param flag defines the flag used to specify which material part must be marked as dirty
  45870. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  45871. */
  45872. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  45873. /** @hidden */
  45874. _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;
  45875. /** @hidden */
  45876. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  45877. /** @hidden */
  45878. _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;
  45879. /** @hidden */
  45880. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  45881. /** @hidden */
  45882. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  45883. /** @hidden */
  45884. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  45885. }
  45886. }
  45887. declare module "babylonjs/assetContainer" {
  45888. import { AbstractScene } from "babylonjs/abstractScene";
  45889. import { Scene } from "babylonjs/scene";
  45890. import { Mesh } from "babylonjs/Meshes/mesh";
  45891. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45892. import { Skeleton } from "babylonjs/Bones/skeleton";
  45893. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45894. import { Animatable } from "babylonjs/Animations/animatable";
  45895. import { Nullable } from "babylonjs/types";
  45896. import { Node } from "babylonjs/node";
  45897. /**
  45898. * Set of assets to keep when moving a scene into an asset container.
  45899. */
  45900. export class KeepAssets extends AbstractScene {
  45901. }
  45902. /**
  45903. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  45904. */
  45905. export class InstantiatedEntries {
  45906. /**
  45907. * List of new root nodes (eg. nodes with no parent)
  45908. */
  45909. rootNodes: TransformNode[];
  45910. /**
  45911. * List of new skeletons
  45912. */
  45913. skeletons: Skeleton[];
  45914. /**
  45915. * List of new animation groups
  45916. */
  45917. animationGroups: AnimationGroup[];
  45918. }
  45919. /**
  45920. * Container with a set of assets that can be added or removed from a scene.
  45921. */
  45922. export class AssetContainer extends AbstractScene {
  45923. private _wasAddedToScene;
  45924. /**
  45925. * The scene the AssetContainer belongs to.
  45926. */
  45927. scene: Scene;
  45928. /**
  45929. * Instantiates an AssetContainer.
  45930. * @param scene The scene the AssetContainer belongs to.
  45931. */
  45932. constructor(scene: Scene);
  45933. /**
  45934. * Instantiate or clone all meshes and add the new ones to the scene.
  45935. * Skeletons and animation groups will all be cloned
  45936. * @param nameFunction defines an optional function used to get new names for clones
  45937. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  45938. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  45939. */
  45940. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  45941. /**
  45942. * Adds all the assets from the container to the scene.
  45943. */
  45944. addAllToScene(): void;
  45945. /**
  45946. * Removes all the assets in the container from the scene
  45947. */
  45948. removeAllFromScene(): void;
  45949. /**
  45950. * Disposes all the assets in the container
  45951. */
  45952. dispose(): void;
  45953. private _moveAssets;
  45954. /**
  45955. * Removes all the assets contained in the scene and adds them to the container.
  45956. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  45957. */
  45958. moveAllFromScene(keepAssets?: KeepAssets): void;
  45959. /**
  45960. * 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.
  45961. * @returns the root mesh
  45962. */
  45963. createRootMesh(): Mesh;
  45964. /**
  45965. * Merge animations (direct and animation groups) from this asset container into a scene
  45966. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45967. * @param animatables set of animatables to retarget to a node from the scene
  45968. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  45969. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  45970. */
  45971. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  45972. }
  45973. }
  45974. declare module "babylonjs/abstractScene" {
  45975. import { Scene } from "babylonjs/scene";
  45976. import { Nullable } from "babylonjs/types";
  45977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45978. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45979. import { Geometry } from "babylonjs/Meshes/geometry";
  45980. import { Skeleton } from "babylonjs/Bones/skeleton";
  45981. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  45982. import { AssetContainer } from "babylonjs/assetContainer";
  45983. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45984. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45985. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45986. import { Material } from "babylonjs/Materials/material";
  45987. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  45988. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  45989. import { Camera } from "babylonjs/Cameras/camera";
  45990. import { Light } from "babylonjs/Lights/light";
  45991. import { Node } from "babylonjs/node";
  45992. import { Animation } from "babylonjs/Animations/animation";
  45993. /**
  45994. * Defines how the parser contract is defined.
  45995. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  45996. */
  45997. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  45998. /**
  45999. * Defines how the individual parser contract is defined.
  46000. * These parser can parse an individual asset
  46001. */
  46002. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  46003. /**
  46004. * Base class of the scene acting as a container for the different elements composing a scene.
  46005. * This class is dynamically extended by the different components of the scene increasing
  46006. * flexibility and reducing coupling
  46007. */
  46008. export abstract class AbstractScene {
  46009. /**
  46010. * Stores the list of available parsers in the application.
  46011. */
  46012. private static _BabylonFileParsers;
  46013. /**
  46014. * Stores the list of available individual parsers in the application.
  46015. */
  46016. private static _IndividualBabylonFileParsers;
  46017. /**
  46018. * Adds a parser in the list of available ones
  46019. * @param name Defines the name of the parser
  46020. * @param parser Defines the parser to add
  46021. */
  46022. static AddParser(name: string, parser: BabylonFileParser): void;
  46023. /**
  46024. * Gets a general parser from the list of avaialble ones
  46025. * @param name Defines the name of the parser
  46026. * @returns the requested parser or null
  46027. */
  46028. static GetParser(name: string): Nullable<BabylonFileParser>;
  46029. /**
  46030. * Adds n individual parser in the list of available ones
  46031. * @param name Defines the name of the parser
  46032. * @param parser Defines the parser to add
  46033. */
  46034. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  46035. /**
  46036. * Gets an individual parser from the list of avaialble ones
  46037. * @param name Defines the name of the parser
  46038. * @returns the requested parser or null
  46039. */
  46040. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  46041. /**
  46042. * Parser json data and populate both a scene and its associated container object
  46043. * @param jsonData Defines the data to parse
  46044. * @param scene Defines the scene to parse the data for
  46045. * @param container Defines the container attached to the parsing sequence
  46046. * @param rootUrl Defines the root url of the data
  46047. */
  46048. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  46049. /**
  46050. * Gets the list of root nodes (ie. nodes with no parent)
  46051. */
  46052. rootNodes: Node[];
  46053. /** All of the cameras added to this scene
  46054. * @see https://doc.babylonjs.com/babylon101/cameras
  46055. */
  46056. cameras: Camera[];
  46057. /**
  46058. * All of the lights added to this scene
  46059. * @see https://doc.babylonjs.com/babylon101/lights
  46060. */
  46061. lights: Light[];
  46062. /**
  46063. * All of the (abstract) meshes added to this scene
  46064. */
  46065. meshes: AbstractMesh[];
  46066. /**
  46067. * The list of skeletons added to the scene
  46068. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  46069. */
  46070. skeletons: Skeleton[];
  46071. /**
  46072. * All of the particle systems added to this scene
  46073. * @see https://doc.babylonjs.com/babylon101/particles
  46074. */
  46075. particleSystems: IParticleSystem[];
  46076. /**
  46077. * Gets a list of Animations associated with the scene
  46078. */
  46079. animations: Animation[];
  46080. /**
  46081. * All of the animation groups added to this scene
  46082. * @see https://doc.babylonjs.com/how_to/group
  46083. */
  46084. animationGroups: AnimationGroup[];
  46085. /**
  46086. * All of the multi-materials added to this scene
  46087. * @see https://doc.babylonjs.com/how_to/multi_materials
  46088. */
  46089. multiMaterials: MultiMaterial[];
  46090. /**
  46091. * All of the materials added to this scene
  46092. * In the context of a Scene, it is not supposed to be modified manually.
  46093. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  46094. * Note also that the order of the Material within the array is not significant and might change.
  46095. * @see https://doc.babylonjs.com/babylon101/materials
  46096. */
  46097. materials: Material[];
  46098. /**
  46099. * The list of morph target managers added to the scene
  46100. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  46101. */
  46102. morphTargetManagers: MorphTargetManager[];
  46103. /**
  46104. * The list of geometries used in the scene.
  46105. */
  46106. geometries: Geometry[];
  46107. /**
  46108. * All of the tranform nodes added to this scene
  46109. * In the context of a Scene, it is not supposed to be modified manually.
  46110. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  46111. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  46112. * @see https://doc.babylonjs.com/how_to/transformnode
  46113. */
  46114. transformNodes: TransformNode[];
  46115. /**
  46116. * ActionManagers available on the scene.
  46117. */
  46118. actionManagers: AbstractActionManager[];
  46119. /**
  46120. * Textures to keep.
  46121. */
  46122. textures: BaseTexture[];
  46123. /** @hidden */
  46124. protected _environmentTexture: Nullable<BaseTexture>;
  46125. /**
  46126. * Texture used in all pbr material as the reflection texture.
  46127. * As in the majority of the scene they are the same (exception for multi room and so on),
  46128. * this is easier to reference from here than from all the materials.
  46129. */
  46130. get environmentTexture(): Nullable<BaseTexture>;
  46131. set environmentTexture(value: Nullable<BaseTexture>);
  46132. /**
  46133. * The list of postprocesses added to the scene
  46134. */
  46135. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  46136. /**
  46137. * @returns all meshes, lights, cameras, transformNodes and bones
  46138. */
  46139. getNodes(): Array<Node>;
  46140. }
  46141. }
  46142. declare module "babylonjs/Audio/sound" {
  46143. import { Observable } from "babylonjs/Misc/observable";
  46144. import { Vector3 } from "babylonjs/Maths/math.vector";
  46145. import { Nullable } from "babylonjs/types";
  46146. import { Scene } from "babylonjs/scene";
  46147. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46148. /**
  46149. * Interface used to define options for Sound class
  46150. */
  46151. export interface ISoundOptions {
  46152. /**
  46153. * Does the sound autoplay once loaded.
  46154. */
  46155. autoplay?: boolean;
  46156. /**
  46157. * Does the sound loop after it finishes playing once.
  46158. */
  46159. loop?: boolean;
  46160. /**
  46161. * Sound's volume
  46162. */
  46163. volume?: number;
  46164. /**
  46165. * Is it a spatial sound?
  46166. */
  46167. spatialSound?: boolean;
  46168. /**
  46169. * Maximum distance to hear that sound
  46170. */
  46171. maxDistance?: number;
  46172. /**
  46173. * Uses user defined attenuation function
  46174. */
  46175. useCustomAttenuation?: boolean;
  46176. /**
  46177. * Define the roll off factor of spatial sounds.
  46178. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46179. */
  46180. rolloffFactor?: number;
  46181. /**
  46182. * Define the reference distance the sound should be heard perfectly.
  46183. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46184. */
  46185. refDistance?: number;
  46186. /**
  46187. * Define the distance attenuation model the sound will follow.
  46188. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46189. */
  46190. distanceModel?: string;
  46191. /**
  46192. * Defines the playback speed (1 by default)
  46193. */
  46194. playbackRate?: number;
  46195. /**
  46196. * Defines if the sound is from a streaming source
  46197. */
  46198. streaming?: boolean;
  46199. /**
  46200. * Defines an optional length (in seconds) inside the sound file
  46201. */
  46202. length?: number;
  46203. /**
  46204. * Defines an optional offset (in seconds) inside the sound file
  46205. */
  46206. offset?: number;
  46207. /**
  46208. * If true, URLs will not be required to state the audio file codec to use.
  46209. */
  46210. skipCodecCheck?: boolean;
  46211. }
  46212. /**
  46213. * Defines a sound that can be played in the application.
  46214. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  46215. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46216. */
  46217. export class Sound {
  46218. /**
  46219. * The name of the sound in the scene.
  46220. */
  46221. name: string;
  46222. /**
  46223. * Does the sound autoplay once loaded.
  46224. */
  46225. autoplay: boolean;
  46226. /**
  46227. * Does the sound loop after it finishes playing once.
  46228. */
  46229. loop: boolean;
  46230. /**
  46231. * Does the sound use a custom attenuation curve to simulate the falloff
  46232. * happening when the source gets further away from the camera.
  46233. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46234. */
  46235. useCustomAttenuation: boolean;
  46236. /**
  46237. * The sound track id this sound belongs to.
  46238. */
  46239. soundTrackId: number;
  46240. /**
  46241. * Is this sound currently played.
  46242. */
  46243. isPlaying: boolean;
  46244. /**
  46245. * Is this sound currently paused.
  46246. */
  46247. isPaused: boolean;
  46248. /**
  46249. * Does this sound enables spatial sound.
  46250. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46251. */
  46252. spatialSound: boolean;
  46253. /**
  46254. * Define the reference distance the sound should be heard perfectly.
  46255. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46256. */
  46257. refDistance: number;
  46258. /**
  46259. * Define the roll off factor of spatial sounds.
  46260. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46261. */
  46262. rolloffFactor: number;
  46263. /**
  46264. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  46265. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46266. */
  46267. maxDistance: number;
  46268. /**
  46269. * Define the distance attenuation model the sound will follow.
  46270. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46271. */
  46272. distanceModel: string;
  46273. /**
  46274. * @hidden
  46275. * Back Compat
  46276. **/
  46277. onended: () => any;
  46278. /**
  46279. * Gets or sets an object used to store user defined information for the sound.
  46280. */
  46281. metadata: any;
  46282. /**
  46283. * Observable event when the current playing sound finishes.
  46284. */
  46285. onEndedObservable: Observable<Sound>;
  46286. private _panningModel;
  46287. private _playbackRate;
  46288. private _streaming;
  46289. private _startTime;
  46290. private _startOffset;
  46291. private _position;
  46292. /** @hidden */
  46293. _positionInEmitterSpace: boolean;
  46294. private _localDirection;
  46295. private _volume;
  46296. private _isReadyToPlay;
  46297. private _isDirectional;
  46298. private _readyToPlayCallback;
  46299. private _audioBuffer;
  46300. private _soundSource;
  46301. private _streamingSource;
  46302. private _soundPanner;
  46303. private _soundGain;
  46304. private _inputAudioNode;
  46305. private _outputAudioNode;
  46306. private _coneInnerAngle;
  46307. private _coneOuterAngle;
  46308. private _coneOuterGain;
  46309. private _scene;
  46310. private _connectedTransformNode;
  46311. private _customAttenuationFunction;
  46312. private _registerFunc;
  46313. private _isOutputConnected;
  46314. private _htmlAudioElement;
  46315. private _urlType;
  46316. private _length?;
  46317. private _offset?;
  46318. /** @hidden */
  46319. static _SceneComponentInitialization: (scene: Scene) => void;
  46320. /**
  46321. * Create a sound and attach it to a scene
  46322. * @param name Name of your sound
  46323. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  46324. * @param scene defines the scene the sound belongs to
  46325. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  46326. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  46327. */
  46328. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  46329. /**
  46330. * Release the sound and its associated resources
  46331. */
  46332. dispose(): void;
  46333. /**
  46334. * Gets if the sounds is ready to be played or not.
  46335. * @returns true if ready, otherwise false
  46336. */
  46337. isReady(): boolean;
  46338. private _soundLoaded;
  46339. /**
  46340. * Sets the data of the sound from an audiobuffer
  46341. * @param audioBuffer The audioBuffer containing the data
  46342. */
  46343. setAudioBuffer(audioBuffer: AudioBuffer): void;
  46344. /**
  46345. * Updates the current sounds options such as maxdistance, loop...
  46346. * @param options A JSON object containing values named as the object properties
  46347. */
  46348. updateOptions(options: ISoundOptions): void;
  46349. private _createSpatialParameters;
  46350. private _updateSpatialParameters;
  46351. /**
  46352. * Switch the panning model to HRTF:
  46353. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46354. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46355. */
  46356. switchPanningModelToHRTF(): void;
  46357. /**
  46358. * Switch the panning model to Equal Power:
  46359. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46360. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46361. */
  46362. switchPanningModelToEqualPower(): void;
  46363. private _switchPanningModel;
  46364. /**
  46365. * Connect this sound to a sound track audio node like gain...
  46366. * @param soundTrackAudioNode the sound track audio node to connect to
  46367. */
  46368. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  46369. /**
  46370. * Transform this sound into a directional source
  46371. * @param coneInnerAngle Size of the inner cone in degree
  46372. * @param coneOuterAngle Size of the outer cone in degree
  46373. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  46374. */
  46375. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  46376. /**
  46377. * Gets or sets the inner angle for the directional cone.
  46378. */
  46379. get directionalConeInnerAngle(): number;
  46380. /**
  46381. * Gets or sets the inner angle for the directional cone.
  46382. */
  46383. set directionalConeInnerAngle(value: number);
  46384. /**
  46385. * Gets or sets the outer angle for the directional cone.
  46386. */
  46387. get directionalConeOuterAngle(): number;
  46388. /**
  46389. * Gets or sets the outer angle for the directional cone.
  46390. */
  46391. set directionalConeOuterAngle(value: number);
  46392. /**
  46393. * Sets the position of the emitter if spatial sound is enabled
  46394. * @param newPosition Defines the new posisiton
  46395. */
  46396. setPosition(newPosition: Vector3): void;
  46397. /**
  46398. * Sets the local direction of the emitter if spatial sound is enabled
  46399. * @param newLocalDirection Defines the new local direction
  46400. */
  46401. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  46402. private _updateDirection;
  46403. /** @hidden */
  46404. updateDistanceFromListener(): void;
  46405. /**
  46406. * Sets a new custom attenuation function for the sound.
  46407. * @param callback Defines the function used for the attenuation
  46408. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46409. */
  46410. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  46411. /**
  46412. * Play the sound
  46413. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  46414. * @param offset (optional) Start the sound at a specific time in seconds
  46415. * @param length (optional) Sound duration (in seconds)
  46416. */
  46417. play(time?: number, offset?: number, length?: number): void;
  46418. private _onended;
  46419. /**
  46420. * Stop the sound
  46421. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  46422. */
  46423. stop(time?: number): void;
  46424. /**
  46425. * Put the sound in pause
  46426. */
  46427. pause(): void;
  46428. /**
  46429. * Sets a dedicated volume for this sounds
  46430. * @param newVolume Define the new volume of the sound
  46431. * @param time Define time for gradual change to new volume
  46432. */
  46433. setVolume(newVolume: number, time?: number): void;
  46434. /**
  46435. * Set the sound play back rate
  46436. * @param newPlaybackRate Define the playback rate the sound should be played at
  46437. */
  46438. setPlaybackRate(newPlaybackRate: number): void;
  46439. /**
  46440. * Gets the volume of the sound.
  46441. * @returns the volume of the sound
  46442. */
  46443. getVolume(): number;
  46444. /**
  46445. * Attach the sound to a dedicated mesh
  46446. * @param transformNode The transform node to connect the sound with
  46447. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46448. */
  46449. attachToMesh(transformNode: TransformNode): void;
  46450. /**
  46451. * Detach the sound from the previously attached mesh
  46452. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46453. */
  46454. detachFromMesh(): void;
  46455. private _onRegisterAfterWorldMatrixUpdate;
  46456. /**
  46457. * Clone the current sound in the scene.
  46458. * @returns the new sound clone
  46459. */
  46460. clone(): Nullable<Sound>;
  46461. /**
  46462. * Gets the current underlying audio buffer containing the data
  46463. * @returns the audio buffer
  46464. */
  46465. getAudioBuffer(): Nullable<AudioBuffer>;
  46466. /**
  46467. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  46468. * @returns the source node
  46469. */
  46470. getSoundSource(): Nullable<AudioBufferSourceNode>;
  46471. /**
  46472. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  46473. * @returns the gain node
  46474. */
  46475. getSoundGain(): Nullable<GainNode>;
  46476. /**
  46477. * Serializes the Sound in a JSON representation
  46478. * @returns the JSON representation of the sound
  46479. */
  46480. serialize(): any;
  46481. /**
  46482. * Parse a JSON representation of a sound to innstantiate in a given scene
  46483. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  46484. * @param scene Define the scene the new parsed sound should be created in
  46485. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  46486. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  46487. * @returns the newly parsed sound
  46488. */
  46489. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  46490. }
  46491. }
  46492. declare module "babylonjs/Actions/directAudioActions" {
  46493. import { Action } from "babylonjs/Actions/action";
  46494. import { Condition } from "babylonjs/Actions/condition";
  46495. import { Sound } from "babylonjs/Audio/sound";
  46496. /**
  46497. * This defines an action helpful to play a defined sound on a triggered action.
  46498. */
  46499. export class PlaySoundAction extends Action {
  46500. private _sound;
  46501. /**
  46502. * Instantiate the action
  46503. * @param triggerOptions defines the trigger options
  46504. * @param sound defines the sound to play
  46505. * @param condition defines the trigger related conditions
  46506. */
  46507. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46508. /** @hidden */
  46509. _prepare(): void;
  46510. /**
  46511. * Execute the action and play the sound.
  46512. */
  46513. execute(): void;
  46514. /**
  46515. * Serializes the actions and its related information.
  46516. * @param parent defines the object to serialize in
  46517. * @returns the serialized object
  46518. */
  46519. serialize(parent: any): any;
  46520. }
  46521. /**
  46522. * This defines an action helpful to stop a defined sound on a triggered action.
  46523. */
  46524. export class StopSoundAction extends Action {
  46525. private _sound;
  46526. /**
  46527. * Instantiate the action
  46528. * @param triggerOptions defines the trigger options
  46529. * @param sound defines the sound to stop
  46530. * @param condition defines the trigger related conditions
  46531. */
  46532. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46533. /** @hidden */
  46534. _prepare(): void;
  46535. /**
  46536. * Execute the action and stop the sound.
  46537. */
  46538. execute(): void;
  46539. /**
  46540. * Serializes the actions and its related information.
  46541. * @param parent defines the object to serialize in
  46542. * @returns the serialized object
  46543. */
  46544. serialize(parent: any): any;
  46545. }
  46546. }
  46547. declare module "babylonjs/Actions/interpolateValueAction" {
  46548. import { Action } from "babylonjs/Actions/action";
  46549. import { Condition } from "babylonjs/Actions/condition";
  46550. import { Observable } from "babylonjs/Misc/observable";
  46551. /**
  46552. * This defines an action responsible to change the value of a property
  46553. * by interpolating between its current value and the newly set one once triggered.
  46554. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46555. */
  46556. export class InterpolateValueAction extends Action {
  46557. /**
  46558. * Defines the path of the property where the value should be interpolated
  46559. */
  46560. propertyPath: string;
  46561. /**
  46562. * Defines the target value at the end of the interpolation.
  46563. */
  46564. value: any;
  46565. /**
  46566. * Defines the time it will take for the property to interpolate to the value.
  46567. */
  46568. duration: number;
  46569. /**
  46570. * Defines if the other scene animations should be stopped when the action has been triggered
  46571. */
  46572. stopOtherAnimations?: boolean;
  46573. /**
  46574. * Defines a callback raised once the interpolation animation has been done.
  46575. */
  46576. onInterpolationDone?: () => void;
  46577. /**
  46578. * Observable triggered once the interpolation animation has been done.
  46579. */
  46580. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  46581. private _target;
  46582. private _effectiveTarget;
  46583. private _property;
  46584. /**
  46585. * Instantiate the action
  46586. * @param triggerOptions defines the trigger options
  46587. * @param target defines the object containing the value to interpolate
  46588. * @param propertyPath defines the path to the property in the target object
  46589. * @param value defines the target value at the end of the interpolation
  46590. * @param duration deines the time it will take for the property to interpolate to the value.
  46591. * @param condition defines the trigger related conditions
  46592. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  46593. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  46594. */
  46595. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  46596. /** @hidden */
  46597. _prepare(): void;
  46598. /**
  46599. * Execute the action starts the value interpolation.
  46600. */
  46601. execute(): void;
  46602. /**
  46603. * Serializes the actions and its related information.
  46604. * @param parent defines the object to serialize in
  46605. * @returns the serialized object
  46606. */
  46607. serialize(parent: any): any;
  46608. }
  46609. }
  46610. declare module "babylonjs/Actions/index" {
  46611. export * from "babylonjs/Actions/abstractActionManager";
  46612. export * from "babylonjs/Actions/action";
  46613. export * from "babylonjs/Actions/actionEvent";
  46614. export * from "babylonjs/Actions/actionManager";
  46615. export * from "babylonjs/Actions/condition";
  46616. export * from "babylonjs/Actions/directActions";
  46617. export * from "babylonjs/Actions/directAudioActions";
  46618. export * from "babylonjs/Actions/interpolateValueAction";
  46619. }
  46620. declare module "babylonjs/Animations/index" {
  46621. export * from "babylonjs/Animations/animatable";
  46622. export * from "babylonjs/Animations/animation";
  46623. export * from "babylonjs/Animations/animationGroup";
  46624. export * from "babylonjs/Animations/animationPropertiesOverride";
  46625. export * from "babylonjs/Animations/easing";
  46626. export * from "babylonjs/Animations/runtimeAnimation";
  46627. export * from "babylonjs/Animations/animationEvent";
  46628. export * from "babylonjs/Animations/animationGroup";
  46629. export * from "babylonjs/Animations/animationKey";
  46630. export * from "babylonjs/Animations/animationRange";
  46631. export * from "babylonjs/Animations/animatable.interface";
  46632. }
  46633. declare module "babylonjs/Audio/soundTrack" {
  46634. import { Sound } from "babylonjs/Audio/sound";
  46635. import { Analyser } from "babylonjs/Audio/analyser";
  46636. import { Scene } from "babylonjs/scene";
  46637. /**
  46638. * Options allowed during the creation of a sound track.
  46639. */
  46640. export interface ISoundTrackOptions {
  46641. /**
  46642. * The volume the sound track should take during creation
  46643. */
  46644. volume?: number;
  46645. /**
  46646. * Define if the sound track is the main sound track of the scene
  46647. */
  46648. mainTrack?: boolean;
  46649. }
  46650. /**
  46651. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  46652. * It will be also used in a future release to apply effects on a specific track.
  46653. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46654. */
  46655. export class SoundTrack {
  46656. /**
  46657. * The unique identifier of the sound track in the scene.
  46658. */
  46659. id: number;
  46660. /**
  46661. * The list of sounds included in the sound track.
  46662. */
  46663. soundCollection: Array<Sound>;
  46664. private _outputAudioNode;
  46665. private _scene;
  46666. private _connectedAnalyser;
  46667. private _options;
  46668. private _isInitialized;
  46669. /**
  46670. * Creates a new sound track.
  46671. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46672. * @param scene Define the scene the sound track belongs to
  46673. * @param options
  46674. */
  46675. constructor(scene: Scene, options?: ISoundTrackOptions);
  46676. private _initializeSoundTrackAudioGraph;
  46677. /**
  46678. * Release the sound track and its associated resources
  46679. */
  46680. dispose(): void;
  46681. /**
  46682. * Adds a sound to this sound track
  46683. * @param sound define the cound to add
  46684. * @ignoreNaming
  46685. */
  46686. AddSound(sound: Sound): void;
  46687. /**
  46688. * Removes a sound to this sound track
  46689. * @param sound define the cound to remove
  46690. * @ignoreNaming
  46691. */
  46692. RemoveSound(sound: Sound): void;
  46693. /**
  46694. * Set a global volume for the full sound track.
  46695. * @param newVolume Define the new volume of the sound track
  46696. */
  46697. setVolume(newVolume: number): void;
  46698. /**
  46699. * Switch the panning model to HRTF:
  46700. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46701. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46702. */
  46703. switchPanningModelToHRTF(): void;
  46704. /**
  46705. * Switch the panning model to Equal Power:
  46706. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46707. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46708. */
  46709. switchPanningModelToEqualPower(): void;
  46710. /**
  46711. * Connect the sound track to an audio analyser allowing some amazing
  46712. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  46713. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  46714. * @param analyser The analyser to connect to the engine
  46715. */
  46716. connectToAnalyser(analyser: Analyser): void;
  46717. }
  46718. }
  46719. declare module "babylonjs/Audio/audioSceneComponent" {
  46720. import { Sound } from "babylonjs/Audio/sound";
  46721. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  46722. import { Nullable } from "babylonjs/types";
  46723. import { Vector3 } from "babylonjs/Maths/math.vector";
  46724. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46725. import { Scene } from "babylonjs/scene";
  46726. import { AbstractScene } from "babylonjs/abstractScene";
  46727. import "babylonjs/Audio/audioEngine";
  46728. module "babylonjs/abstractScene" {
  46729. interface AbstractScene {
  46730. /**
  46731. * The list of sounds used in the scene.
  46732. */
  46733. sounds: Nullable<Array<Sound>>;
  46734. }
  46735. }
  46736. module "babylonjs/scene" {
  46737. interface Scene {
  46738. /**
  46739. * @hidden
  46740. * Backing field
  46741. */
  46742. _mainSoundTrack: SoundTrack;
  46743. /**
  46744. * The main sound track played by the scene.
  46745. * It cotains your primary collection of sounds.
  46746. */
  46747. mainSoundTrack: SoundTrack;
  46748. /**
  46749. * The list of sound tracks added to the scene
  46750. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46751. */
  46752. soundTracks: Nullable<Array<SoundTrack>>;
  46753. /**
  46754. * Gets a sound using a given name
  46755. * @param name defines the name to search for
  46756. * @return the found sound or null if not found at all.
  46757. */
  46758. getSoundByName(name: string): Nullable<Sound>;
  46759. /**
  46760. * Gets or sets if audio support is enabled
  46761. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46762. */
  46763. audioEnabled: boolean;
  46764. /**
  46765. * Gets or sets if audio will be output to headphones
  46766. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46767. */
  46768. headphone: boolean;
  46769. /**
  46770. * Gets or sets custom audio listener position provider
  46771. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46772. */
  46773. audioListenerPositionProvider: Nullable<() => Vector3>;
  46774. /**
  46775. * Gets or sets a refresh rate when using 3D audio positioning
  46776. */
  46777. audioPositioningRefreshRate: number;
  46778. }
  46779. }
  46780. /**
  46781. * Defines the sound scene component responsible to manage any sounds
  46782. * in a given scene.
  46783. */
  46784. export class AudioSceneComponent implements ISceneSerializableComponent {
  46785. private static _CameraDirectionLH;
  46786. private static _CameraDirectionRH;
  46787. /**
  46788. * The component name helpfull to identify the component in the list of scene components.
  46789. */
  46790. readonly name: string;
  46791. /**
  46792. * The scene the component belongs to.
  46793. */
  46794. scene: Scene;
  46795. private _audioEnabled;
  46796. /**
  46797. * Gets whether audio is enabled or not.
  46798. * Please use related enable/disable method to switch state.
  46799. */
  46800. get audioEnabled(): boolean;
  46801. private _headphone;
  46802. /**
  46803. * Gets whether audio is outputing to headphone or not.
  46804. * Please use the according Switch methods to change output.
  46805. */
  46806. get headphone(): boolean;
  46807. /**
  46808. * Gets or sets a refresh rate when using 3D audio positioning
  46809. */
  46810. audioPositioningRefreshRate: number;
  46811. private _audioListenerPositionProvider;
  46812. /**
  46813. * Gets the current audio listener position provider
  46814. */
  46815. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  46816. /**
  46817. * Sets a custom listener position for all sounds in the scene
  46818. * By default, this is the position of the first active camera
  46819. */
  46820. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  46821. /**
  46822. * Creates a new instance of the component for the given scene
  46823. * @param scene Defines the scene to register the component in
  46824. */
  46825. constructor(scene: Scene);
  46826. /**
  46827. * Registers the component in a given scene
  46828. */
  46829. register(): void;
  46830. /**
  46831. * Rebuilds the elements related to this component in case of
  46832. * context lost for instance.
  46833. */
  46834. rebuild(): void;
  46835. /**
  46836. * Serializes the component data to the specified json object
  46837. * @param serializationObject The object to serialize to
  46838. */
  46839. serialize(serializationObject: any): void;
  46840. /**
  46841. * Adds all the elements from the container to the scene
  46842. * @param container the container holding the elements
  46843. */
  46844. addFromContainer(container: AbstractScene): void;
  46845. /**
  46846. * Removes all the elements in the container from the scene
  46847. * @param container contains the elements to remove
  46848. * @param dispose if the removed element should be disposed (default: false)
  46849. */
  46850. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46851. /**
  46852. * Disposes the component and the associated ressources.
  46853. */
  46854. dispose(): void;
  46855. /**
  46856. * Disables audio in the associated scene.
  46857. */
  46858. disableAudio(): void;
  46859. /**
  46860. * Enables audio in the associated scene.
  46861. */
  46862. enableAudio(): void;
  46863. /**
  46864. * Switch audio to headphone output.
  46865. */
  46866. switchAudioModeForHeadphones(): void;
  46867. /**
  46868. * Switch audio to normal speakers.
  46869. */
  46870. switchAudioModeForNormalSpeakers(): void;
  46871. private _cachedCameraDirection;
  46872. private _cachedCameraPosition;
  46873. private _lastCheck;
  46874. private _afterRender;
  46875. }
  46876. }
  46877. declare module "babylonjs/Audio/weightedsound" {
  46878. import { Sound } from "babylonjs/Audio/sound";
  46879. /**
  46880. * Wraps one or more Sound objects and selects one with random weight for playback.
  46881. */
  46882. export class WeightedSound {
  46883. /** When true a Sound will be selected and played when the current playing Sound completes. */
  46884. loop: boolean;
  46885. private _coneInnerAngle;
  46886. private _coneOuterAngle;
  46887. private _volume;
  46888. /** A Sound is currently playing. */
  46889. isPlaying: boolean;
  46890. /** A Sound is currently paused. */
  46891. isPaused: boolean;
  46892. private _sounds;
  46893. private _weights;
  46894. private _currentIndex?;
  46895. /**
  46896. * Creates a new WeightedSound from the list of sounds given.
  46897. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  46898. * @param sounds Array of Sounds that will be selected from.
  46899. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  46900. */
  46901. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  46902. /**
  46903. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  46904. */
  46905. get directionalConeInnerAngle(): number;
  46906. /**
  46907. * The size of cone in degress for a directional sound in which there will be no attenuation.
  46908. */
  46909. set directionalConeInnerAngle(value: number);
  46910. /**
  46911. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  46912. * Listener angles between innerAngle and outerAngle will falloff linearly.
  46913. */
  46914. get directionalConeOuterAngle(): number;
  46915. /**
  46916. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  46917. * Listener angles between innerAngle and outerAngle will falloff linearly.
  46918. */
  46919. set directionalConeOuterAngle(value: number);
  46920. /**
  46921. * Playback volume.
  46922. */
  46923. get volume(): number;
  46924. /**
  46925. * Playback volume.
  46926. */
  46927. set volume(value: number);
  46928. private _onended;
  46929. /**
  46930. * Suspend playback
  46931. */
  46932. pause(): void;
  46933. /**
  46934. * Stop playback
  46935. */
  46936. stop(): void;
  46937. /**
  46938. * Start playback.
  46939. * @param startOffset Position the clip head at a specific time in seconds.
  46940. */
  46941. play(startOffset?: number): void;
  46942. }
  46943. }
  46944. declare module "babylonjs/Audio/index" {
  46945. export * from "babylonjs/Audio/analyser";
  46946. export * from "babylonjs/Audio/audioEngine";
  46947. export * from "babylonjs/Audio/audioSceneComponent";
  46948. export * from "babylonjs/Audio/sound";
  46949. export * from "babylonjs/Audio/soundTrack";
  46950. export * from "babylonjs/Audio/weightedsound";
  46951. }
  46952. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  46953. import { Behavior } from "babylonjs/Behaviors/behavior";
  46954. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46955. import { BackEase } from "babylonjs/Animations/easing";
  46956. /**
  46957. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  46958. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46959. */
  46960. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  46961. /**
  46962. * Gets the name of the behavior.
  46963. */
  46964. get name(): string;
  46965. /**
  46966. * The easing function used by animations
  46967. */
  46968. static EasingFunction: BackEase;
  46969. /**
  46970. * The easing mode used by animations
  46971. */
  46972. static EasingMode: number;
  46973. /**
  46974. * The duration of the animation, in milliseconds
  46975. */
  46976. transitionDuration: number;
  46977. /**
  46978. * Length of the distance animated by the transition when lower radius is reached
  46979. */
  46980. lowerRadiusTransitionRange: number;
  46981. /**
  46982. * Length of the distance animated by the transition when upper radius is reached
  46983. */
  46984. upperRadiusTransitionRange: number;
  46985. private _autoTransitionRange;
  46986. /**
  46987. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  46988. */
  46989. get autoTransitionRange(): boolean;
  46990. /**
  46991. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  46992. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  46993. */
  46994. set autoTransitionRange(value: boolean);
  46995. private _attachedCamera;
  46996. private _onAfterCheckInputsObserver;
  46997. private _onMeshTargetChangedObserver;
  46998. /**
  46999. * Initializes the behavior.
  47000. */
  47001. init(): void;
  47002. /**
  47003. * Attaches the behavior to its arc rotate camera.
  47004. * @param camera Defines the camera to attach the behavior to
  47005. */
  47006. attach(camera: ArcRotateCamera): void;
  47007. /**
  47008. * Detaches the behavior from its current arc rotate camera.
  47009. */
  47010. detach(): void;
  47011. private _radiusIsAnimating;
  47012. private _radiusBounceTransition;
  47013. private _animatables;
  47014. private _cachedWheelPrecision;
  47015. /**
  47016. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  47017. * @param radiusLimit The limit to check against.
  47018. * @return Bool to indicate if at limit.
  47019. */
  47020. private _isRadiusAtLimit;
  47021. /**
  47022. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  47023. * @param radiusDelta The delta by which to animate to. Can be negative.
  47024. */
  47025. private _applyBoundRadiusAnimation;
  47026. /**
  47027. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  47028. */
  47029. protected _clearAnimationLocks(): void;
  47030. /**
  47031. * Stops and removes all animations that have been applied to the camera
  47032. */
  47033. stopAllAnimations(): void;
  47034. }
  47035. }
  47036. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  47037. import { Behavior } from "babylonjs/Behaviors/behavior";
  47038. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47039. import { ExponentialEase } from "babylonjs/Animations/easing";
  47040. import { Nullable } from "babylonjs/types";
  47041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47042. import { Vector3 } from "babylonjs/Maths/math.vector";
  47043. /**
  47044. * 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.
  47045. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47046. */
  47047. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  47048. /**
  47049. * Gets the name of the behavior.
  47050. */
  47051. get name(): string;
  47052. private _mode;
  47053. private _radiusScale;
  47054. private _positionScale;
  47055. private _defaultElevation;
  47056. private _elevationReturnTime;
  47057. private _elevationReturnWaitTime;
  47058. private _zoomStopsAnimation;
  47059. private _framingTime;
  47060. /**
  47061. * The easing function used by animations
  47062. */
  47063. static EasingFunction: ExponentialEase;
  47064. /**
  47065. * The easing mode used by animations
  47066. */
  47067. static EasingMode: number;
  47068. /**
  47069. * Sets the current mode used by the behavior
  47070. */
  47071. set mode(mode: number);
  47072. /**
  47073. * Gets current mode used by the behavior.
  47074. */
  47075. get mode(): number;
  47076. /**
  47077. * Sets the scale applied to the radius (1 by default)
  47078. */
  47079. set radiusScale(radius: number);
  47080. /**
  47081. * Gets the scale applied to the radius
  47082. */
  47083. get radiusScale(): number;
  47084. /**
  47085. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47086. */
  47087. set positionScale(scale: number);
  47088. /**
  47089. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47090. */
  47091. get positionScale(): number;
  47092. /**
  47093. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47094. * behaviour is triggered, in radians.
  47095. */
  47096. set defaultElevation(elevation: number);
  47097. /**
  47098. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47099. * behaviour is triggered, in radians.
  47100. */
  47101. get defaultElevation(): number;
  47102. /**
  47103. * Sets the time (in milliseconds) taken to return to the default beta position.
  47104. * Negative value indicates camera should not return to default.
  47105. */
  47106. set elevationReturnTime(speed: number);
  47107. /**
  47108. * Gets the time (in milliseconds) taken to return to the default beta position.
  47109. * Negative value indicates camera should not return to default.
  47110. */
  47111. get elevationReturnTime(): number;
  47112. /**
  47113. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47114. */
  47115. set elevationReturnWaitTime(time: number);
  47116. /**
  47117. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47118. */
  47119. get elevationReturnWaitTime(): number;
  47120. /**
  47121. * Sets the flag that indicates if user zooming should stop animation.
  47122. */
  47123. set zoomStopsAnimation(flag: boolean);
  47124. /**
  47125. * Gets the flag that indicates if user zooming should stop animation.
  47126. */
  47127. get zoomStopsAnimation(): boolean;
  47128. /**
  47129. * Sets the transition time when framing the mesh, in milliseconds
  47130. */
  47131. set framingTime(time: number);
  47132. /**
  47133. * Gets the transition time when framing the mesh, in milliseconds
  47134. */
  47135. get framingTime(): number;
  47136. /**
  47137. * Define if the behavior should automatically change the configured
  47138. * camera limits and sensibilities.
  47139. */
  47140. autoCorrectCameraLimitsAndSensibility: boolean;
  47141. private _onPrePointerObservableObserver;
  47142. private _onAfterCheckInputsObserver;
  47143. private _onMeshTargetChangedObserver;
  47144. private _attachedCamera;
  47145. private _isPointerDown;
  47146. private _lastInteractionTime;
  47147. /**
  47148. * Initializes the behavior.
  47149. */
  47150. init(): void;
  47151. /**
  47152. * Attaches the behavior to its arc rotate camera.
  47153. * @param camera Defines the camera to attach the behavior to
  47154. */
  47155. attach(camera: ArcRotateCamera): void;
  47156. /**
  47157. * Detaches the behavior from its current arc rotate camera.
  47158. */
  47159. detach(): void;
  47160. private _animatables;
  47161. private _betaIsAnimating;
  47162. private _betaTransition;
  47163. private _radiusTransition;
  47164. private _vectorTransition;
  47165. /**
  47166. * Targets the given mesh and updates zoom level accordingly.
  47167. * @param mesh The mesh to target.
  47168. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47169. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47170. */
  47171. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47172. /**
  47173. * Targets the given mesh with its children and updates zoom level accordingly.
  47174. * @param mesh The mesh to target.
  47175. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47176. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47177. */
  47178. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47179. /**
  47180. * Targets the given meshes with their children and updates zoom level accordingly.
  47181. * @param meshes The mesh to target.
  47182. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47183. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47184. */
  47185. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47186. /**
  47187. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  47188. * @param minimumWorld Determines the smaller position of the bounding box extend
  47189. * @param maximumWorld Determines the bigger position of the bounding box extend
  47190. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47191. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47192. */
  47193. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47194. /**
  47195. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  47196. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  47197. * frustum width.
  47198. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  47199. * to fully enclose the mesh in the viewing frustum.
  47200. */
  47201. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  47202. /**
  47203. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  47204. * is automatically returned to its default position (expected to be above ground plane).
  47205. */
  47206. private _maintainCameraAboveGround;
  47207. /**
  47208. * Returns the frustum slope based on the canvas ratio and camera FOV
  47209. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  47210. */
  47211. private _getFrustumSlope;
  47212. /**
  47213. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  47214. */
  47215. private _clearAnimationLocks;
  47216. /**
  47217. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47218. */
  47219. private _applyUserInteraction;
  47220. /**
  47221. * Stops and removes all animations that have been applied to the camera
  47222. */
  47223. stopAllAnimations(): void;
  47224. /**
  47225. * Gets a value indicating if the user is moving the camera
  47226. */
  47227. get isUserIsMoving(): boolean;
  47228. /**
  47229. * The camera can move all the way towards the mesh.
  47230. */
  47231. static IgnoreBoundsSizeMode: number;
  47232. /**
  47233. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  47234. */
  47235. static FitFrustumSidesMode: number;
  47236. }
  47237. }
  47238. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  47239. import { Nullable } from "babylonjs/types";
  47240. import { Camera } from "babylonjs/Cameras/camera";
  47241. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47242. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47243. /**
  47244. * Base class for Camera Pointer Inputs.
  47245. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  47246. * for example usage.
  47247. */
  47248. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  47249. /**
  47250. * Defines the camera the input is attached to.
  47251. */
  47252. abstract camera: Camera;
  47253. /**
  47254. * Whether keyboard modifier keys are pressed at time of last mouse event.
  47255. */
  47256. protected _altKey: boolean;
  47257. protected _ctrlKey: boolean;
  47258. protected _metaKey: boolean;
  47259. protected _shiftKey: boolean;
  47260. /**
  47261. * Which mouse buttons were pressed at time of last mouse event.
  47262. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  47263. */
  47264. protected _buttonsPressed: number;
  47265. /**
  47266. * Defines the buttons associated with the input to handle camera move.
  47267. */
  47268. buttons: number[];
  47269. /**
  47270. * Attach the input controls to a specific dom element to get the input from.
  47271. * @param element Defines the element the controls should be listened from
  47272. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47273. */
  47274. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47275. /**
  47276. * Detach the current controls from the specified dom element.
  47277. * @param element Defines the element to stop listening the inputs from
  47278. */
  47279. detachControl(element: Nullable<HTMLElement>): void;
  47280. /**
  47281. * Gets the class name of the current input.
  47282. * @returns the class name
  47283. */
  47284. getClassName(): string;
  47285. /**
  47286. * Get the friendly name associated with the input class.
  47287. * @returns the input friendly name
  47288. */
  47289. getSimpleName(): string;
  47290. /**
  47291. * Called on pointer POINTERDOUBLETAP event.
  47292. * Override this method to provide functionality on POINTERDOUBLETAP event.
  47293. */
  47294. protected onDoubleTap(type: string): void;
  47295. /**
  47296. * Called on pointer POINTERMOVE event if only a single touch is active.
  47297. * Override this method to provide functionality.
  47298. */
  47299. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47300. /**
  47301. * Called on pointer POINTERMOVE event if multiple touches are active.
  47302. * Override this method to provide functionality.
  47303. */
  47304. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47305. /**
  47306. * Called on JS contextmenu event.
  47307. * Override this method to provide functionality.
  47308. */
  47309. protected onContextMenu(evt: PointerEvent): void;
  47310. /**
  47311. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47312. * press.
  47313. * Override this method to provide functionality.
  47314. */
  47315. protected onButtonDown(evt: PointerEvent): void;
  47316. /**
  47317. * Called each time a new POINTERUP event occurs. Ie, for each button
  47318. * release.
  47319. * Override this method to provide functionality.
  47320. */
  47321. protected onButtonUp(evt: PointerEvent): void;
  47322. /**
  47323. * Called when window becomes inactive.
  47324. * Override this method to provide functionality.
  47325. */
  47326. protected onLostFocus(): void;
  47327. private _pointerInput;
  47328. private _observer;
  47329. private _onLostFocus;
  47330. private pointA;
  47331. private pointB;
  47332. }
  47333. }
  47334. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  47335. import { Nullable } from "babylonjs/types";
  47336. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47337. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  47338. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47339. /**
  47340. * Manage the pointers inputs to control an arc rotate camera.
  47341. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47342. */
  47343. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  47344. /**
  47345. * Defines the camera the input is attached to.
  47346. */
  47347. camera: ArcRotateCamera;
  47348. /**
  47349. * Gets the class name of the current input.
  47350. * @returns the class name
  47351. */
  47352. getClassName(): string;
  47353. /**
  47354. * Defines the buttons associated with the input to handle camera move.
  47355. */
  47356. buttons: number[];
  47357. /**
  47358. * Defines the pointer angular sensibility along the X axis or how fast is
  47359. * the camera rotating.
  47360. */
  47361. angularSensibilityX: number;
  47362. /**
  47363. * Defines the pointer angular sensibility along the Y axis or how fast is
  47364. * the camera rotating.
  47365. */
  47366. angularSensibilityY: number;
  47367. /**
  47368. * Defines the pointer pinch precision or how fast is the camera zooming.
  47369. */
  47370. pinchPrecision: number;
  47371. /**
  47372. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47373. * from 0.
  47374. * It defines the percentage of current camera.radius to use as delta when
  47375. * pinch zoom is used.
  47376. */
  47377. pinchDeltaPercentage: number;
  47378. /**
  47379. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47380. * that any object in the plane at the camera's target point will scale
  47381. * perfectly with finger motion.
  47382. * Overrides pinchDeltaPercentage and pinchPrecision.
  47383. */
  47384. useNaturalPinchZoom: boolean;
  47385. /**
  47386. * Defines the pointer panning sensibility or how fast is the camera moving.
  47387. */
  47388. panningSensibility: number;
  47389. /**
  47390. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  47391. */
  47392. multiTouchPanning: boolean;
  47393. /**
  47394. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  47395. * zoom (pinch) through multitouch.
  47396. */
  47397. multiTouchPanAndZoom: boolean;
  47398. /**
  47399. * Revers pinch action direction.
  47400. */
  47401. pinchInwards: boolean;
  47402. private _isPanClick;
  47403. private _twoFingerActivityCount;
  47404. private _isPinching;
  47405. /**
  47406. * Called on pointer POINTERMOVE event if only a single touch is active.
  47407. */
  47408. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47409. /**
  47410. * Called on pointer POINTERDOUBLETAP event.
  47411. */
  47412. protected onDoubleTap(type: string): void;
  47413. /**
  47414. * Called on pointer POINTERMOVE event if multiple touches are active.
  47415. */
  47416. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47417. /**
  47418. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47419. * press.
  47420. */
  47421. protected onButtonDown(evt: PointerEvent): void;
  47422. /**
  47423. * Called each time a new POINTERUP event occurs. Ie, for each button
  47424. * release.
  47425. */
  47426. protected onButtonUp(evt: PointerEvent): void;
  47427. /**
  47428. * Called when window becomes inactive.
  47429. */
  47430. protected onLostFocus(): void;
  47431. }
  47432. }
  47433. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  47434. import { Nullable } from "babylonjs/types";
  47435. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47436. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47437. /**
  47438. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  47439. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47440. */
  47441. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  47442. /**
  47443. * Defines the camera the input is attached to.
  47444. */
  47445. camera: ArcRotateCamera;
  47446. /**
  47447. * Defines the list of key codes associated with the up action (increase alpha)
  47448. */
  47449. keysUp: number[];
  47450. /**
  47451. * Defines the list of key codes associated with the down action (decrease alpha)
  47452. */
  47453. keysDown: number[];
  47454. /**
  47455. * Defines the list of key codes associated with the left action (increase beta)
  47456. */
  47457. keysLeft: number[];
  47458. /**
  47459. * Defines the list of key codes associated with the right action (decrease beta)
  47460. */
  47461. keysRight: number[];
  47462. /**
  47463. * Defines the list of key codes associated with the reset action.
  47464. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  47465. */
  47466. keysReset: number[];
  47467. /**
  47468. * Defines the panning sensibility of the inputs.
  47469. * (How fast is the camera panning)
  47470. */
  47471. panningSensibility: number;
  47472. /**
  47473. * Defines the zooming sensibility of the inputs.
  47474. * (How fast is the camera zooming)
  47475. */
  47476. zoomingSensibility: number;
  47477. /**
  47478. * Defines whether maintaining the alt key down switch the movement mode from
  47479. * orientation to zoom.
  47480. */
  47481. useAltToZoom: boolean;
  47482. /**
  47483. * Rotation speed of the camera
  47484. */
  47485. angularSpeed: number;
  47486. private _keys;
  47487. private _ctrlPressed;
  47488. private _altPressed;
  47489. private _onCanvasBlurObserver;
  47490. private _onKeyboardObserver;
  47491. private _engine;
  47492. private _scene;
  47493. /**
  47494. * Attach the input controls to a specific dom element to get the input from.
  47495. * @param element Defines the element the controls should be listened from
  47496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47497. */
  47498. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47499. /**
  47500. * Detach the current controls from the specified dom element.
  47501. * @param element Defines the element to stop listening the inputs from
  47502. */
  47503. detachControl(element: Nullable<HTMLElement>): void;
  47504. /**
  47505. * Update the current camera state depending on the inputs that have been used this frame.
  47506. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47507. */
  47508. checkInputs(): void;
  47509. /**
  47510. * Gets the class name of the current intput.
  47511. * @returns the class name
  47512. */
  47513. getClassName(): string;
  47514. /**
  47515. * Get the friendly name associated with the input class.
  47516. * @returns the input friendly name
  47517. */
  47518. getSimpleName(): string;
  47519. }
  47520. }
  47521. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  47522. import { Nullable } from "babylonjs/types";
  47523. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47524. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47525. /**
  47526. * Manage the mouse wheel inputs to control an arc rotate camera.
  47527. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47528. */
  47529. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  47530. /**
  47531. * Defines the camera the input is attached to.
  47532. */
  47533. camera: ArcRotateCamera;
  47534. /**
  47535. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47536. */
  47537. wheelPrecision: number;
  47538. /**
  47539. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47540. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47541. */
  47542. wheelDeltaPercentage: number;
  47543. private _wheel;
  47544. private _observer;
  47545. private computeDeltaFromMouseWheelLegacyEvent;
  47546. /**
  47547. * Attach the input controls to a specific dom element to get the input from.
  47548. * @param element Defines the element the controls should be listened from
  47549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47550. */
  47551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47552. /**
  47553. * Detach the current controls from the specified dom element.
  47554. * @param element Defines the element to stop listening the inputs from
  47555. */
  47556. detachControl(element: Nullable<HTMLElement>): void;
  47557. /**
  47558. * Gets the class name of the current intput.
  47559. * @returns the class name
  47560. */
  47561. getClassName(): string;
  47562. /**
  47563. * Get the friendly name associated with the input class.
  47564. * @returns the input friendly name
  47565. */
  47566. getSimpleName(): string;
  47567. }
  47568. }
  47569. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47570. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47571. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  47572. /**
  47573. * Default Inputs manager for the ArcRotateCamera.
  47574. * It groups all the default supported inputs for ease of use.
  47575. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47576. */
  47577. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  47578. /**
  47579. * Instantiates a new ArcRotateCameraInputsManager.
  47580. * @param camera Defines the camera the inputs belong to
  47581. */
  47582. constructor(camera: ArcRotateCamera);
  47583. /**
  47584. * Add mouse wheel input support to the input manager.
  47585. * @returns the current input manager
  47586. */
  47587. addMouseWheel(): ArcRotateCameraInputsManager;
  47588. /**
  47589. * Add pointers input support to the input manager.
  47590. * @returns the current input manager
  47591. */
  47592. addPointers(): ArcRotateCameraInputsManager;
  47593. /**
  47594. * Add keyboard input support to the input manager.
  47595. * @returns the current input manager
  47596. */
  47597. addKeyboard(): ArcRotateCameraInputsManager;
  47598. }
  47599. }
  47600. declare module "babylonjs/Cameras/arcRotateCamera" {
  47601. import { Observable } from "babylonjs/Misc/observable";
  47602. import { Nullable } from "babylonjs/types";
  47603. import { Scene } from "babylonjs/scene";
  47604. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47606. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  47607. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  47608. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  47609. import { Camera } from "babylonjs/Cameras/camera";
  47610. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  47611. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47612. import { Collider } from "babylonjs/Collisions/collider";
  47613. /**
  47614. * This represents an orbital type of camera.
  47615. *
  47616. * 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.
  47617. * 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.
  47618. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  47619. */
  47620. export class ArcRotateCamera extends TargetCamera {
  47621. /**
  47622. * Defines the rotation angle of the camera along the longitudinal axis.
  47623. */
  47624. alpha: number;
  47625. /**
  47626. * Defines the rotation angle of the camera along the latitudinal axis.
  47627. */
  47628. beta: number;
  47629. /**
  47630. * Defines the radius of the camera from it s target point.
  47631. */
  47632. radius: number;
  47633. protected _target: Vector3;
  47634. protected _targetHost: Nullable<AbstractMesh>;
  47635. /**
  47636. * Defines the target point of the camera.
  47637. * The camera looks towards it form the radius distance.
  47638. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  47639. */
  47640. get target(): Vector3;
  47641. set target(value: Vector3);
  47642. /**
  47643. * Define the current local position of the camera in the scene
  47644. */
  47645. get position(): Vector3;
  47646. set position(newPosition: Vector3);
  47647. protected _upToYMatrix: Matrix;
  47648. protected _YToUpMatrix: Matrix;
  47649. /**
  47650. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  47651. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  47652. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  47653. */
  47654. set upVector(vec: Vector3);
  47655. get upVector(): Vector3;
  47656. /**
  47657. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  47658. */
  47659. setMatUp(): void;
  47660. /**
  47661. * Current inertia value on the longitudinal axis.
  47662. * The bigger this number the longer it will take for the camera to stop.
  47663. */
  47664. inertialAlphaOffset: number;
  47665. /**
  47666. * Current inertia value on the latitudinal axis.
  47667. * The bigger this number the longer it will take for the camera to stop.
  47668. */
  47669. inertialBetaOffset: number;
  47670. /**
  47671. * Current inertia value on the radius axis.
  47672. * The bigger this number the longer it will take for the camera to stop.
  47673. */
  47674. inertialRadiusOffset: number;
  47675. /**
  47676. * Minimum allowed angle on the longitudinal axis.
  47677. * This can help limiting how the Camera is able to move in the scene.
  47678. */
  47679. lowerAlphaLimit: Nullable<number>;
  47680. /**
  47681. * Maximum allowed angle on the longitudinal axis.
  47682. * This can help limiting how the Camera is able to move in the scene.
  47683. */
  47684. upperAlphaLimit: Nullable<number>;
  47685. /**
  47686. * Minimum allowed angle on the latitudinal axis.
  47687. * This can help limiting how the Camera is able to move in the scene.
  47688. */
  47689. lowerBetaLimit: number;
  47690. /**
  47691. * Maximum allowed angle on the latitudinal axis.
  47692. * This can help limiting how the Camera is able to move in the scene.
  47693. */
  47694. upperBetaLimit: number;
  47695. /**
  47696. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  47697. * This can help limiting how the Camera is able to move in the scene.
  47698. */
  47699. lowerRadiusLimit: Nullable<number>;
  47700. /**
  47701. * Maximum allowed distance of the camera to the target (The camera can not get further).
  47702. * This can help limiting how the Camera is able to move in the scene.
  47703. */
  47704. upperRadiusLimit: Nullable<number>;
  47705. /**
  47706. * Defines the current inertia value used during panning of the camera along the X axis.
  47707. */
  47708. inertialPanningX: number;
  47709. /**
  47710. * Defines the current inertia value used during panning of the camera along the Y axis.
  47711. */
  47712. inertialPanningY: number;
  47713. /**
  47714. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  47715. * Basically if your fingers moves away from more than this distance you will be considered
  47716. * in pinch mode.
  47717. */
  47718. pinchToPanMaxDistance: number;
  47719. /**
  47720. * Defines the maximum distance the camera can pan.
  47721. * This could help keeping the cammera always in your scene.
  47722. */
  47723. panningDistanceLimit: Nullable<number>;
  47724. /**
  47725. * Defines the target of the camera before paning.
  47726. */
  47727. panningOriginTarget: Vector3;
  47728. /**
  47729. * Defines the value of the inertia used during panning.
  47730. * 0 would mean stop inertia and one would mean no decelleration at all.
  47731. */
  47732. panningInertia: number;
  47733. /**
  47734. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  47735. */
  47736. get angularSensibilityX(): number;
  47737. set angularSensibilityX(value: number);
  47738. /**
  47739. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  47740. */
  47741. get angularSensibilityY(): number;
  47742. set angularSensibilityY(value: number);
  47743. /**
  47744. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  47745. */
  47746. get pinchPrecision(): number;
  47747. set pinchPrecision(value: number);
  47748. /**
  47749. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  47750. * It will be used instead of pinchDeltaPrecision if different from 0.
  47751. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  47752. */
  47753. get pinchDeltaPercentage(): number;
  47754. set pinchDeltaPercentage(value: number);
  47755. /**
  47756. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  47757. * and pinch delta percentage.
  47758. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47759. * that any object in the plane at the camera's target point will scale
  47760. * perfectly with finger motion.
  47761. */
  47762. get useNaturalPinchZoom(): boolean;
  47763. set useNaturalPinchZoom(value: boolean);
  47764. /**
  47765. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  47766. */
  47767. get panningSensibility(): number;
  47768. set panningSensibility(value: number);
  47769. /**
  47770. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  47771. */
  47772. get keysUp(): number[];
  47773. set keysUp(value: number[]);
  47774. /**
  47775. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  47776. */
  47777. get keysDown(): number[];
  47778. set keysDown(value: number[]);
  47779. /**
  47780. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  47781. */
  47782. get keysLeft(): number[];
  47783. set keysLeft(value: number[]);
  47784. /**
  47785. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  47786. */
  47787. get keysRight(): number[];
  47788. set keysRight(value: number[]);
  47789. /**
  47790. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47791. */
  47792. get wheelPrecision(): number;
  47793. set wheelPrecision(value: number);
  47794. /**
  47795. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  47796. * It will be used instead of pinchDeltaPrecision if different from 0.
  47797. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  47798. */
  47799. get wheelDeltaPercentage(): number;
  47800. set wheelDeltaPercentage(value: number);
  47801. /**
  47802. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  47803. */
  47804. zoomOnFactor: number;
  47805. /**
  47806. * Defines a screen offset for the camera position.
  47807. */
  47808. targetScreenOffset: Vector2;
  47809. /**
  47810. * Allows the camera to be completely reversed.
  47811. * If false the camera can not arrive upside down.
  47812. */
  47813. allowUpsideDown: boolean;
  47814. /**
  47815. * Define if double tap/click is used to restore the previously saved state of the camera.
  47816. */
  47817. useInputToRestoreState: boolean;
  47818. /** @hidden */
  47819. _viewMatrix: Matrix;
  47820. /** @hidden */
  47821. _useCtrlForPanning: boolean;
  47822. /** @hidden */
  47823. _panningMouseButton: number;
  47824. /**
  47825. * Defines the input associated to the camera.
  47826. */
  47827. inputs: ArcRotateCameraInputsManager;
  47828. /** @hidden */
  47829. _reset: () => void;
  47830. /**
  47831. * Defines the allowed panning axis.
  47832. */
  47833. panningAxis: Vector3;
  47834. protected _localDirection: Vector3;
  47835. protected _transformedDirection: Vector3;
  47836. private _bouncingBehavior;
  47837. /**
  47838. * Gets the bouncing behavior of the camera if it has been enabled.
  47839. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47840. */
  47841. get bouncingBehavior(): Nullable<BouncingBehavior>;
  47842. /**
  47843. * Defines if the bouncing behavior of the camera is enabled on the camera.
  47844. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47845. */
  47846. get useBouncingBehavior(): boolean;
  47847. set useBouncingBehavior(value: boolean);
  47848. private _framingBehavior;
  47849. /**
  47850. * Gets the framing behavior of the camera if it has been enabled.
  47851. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47852. */
  47853. get framingBehavior(): Nullable<FramingBehavior>;
  47854. /**
  47855. * Defines if the framing behavior of the camera is enabled on the camera.
  47856. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47857. */
  47858. get useFramingBehavior(): boolean;
  47859. set useFramingBehavior(value: boolean);
  47860. private _autoRotationBehavior;
  47861. /**
  47862. * Gets the auto rotation behavior of the camera if it has been enabled.
  47863. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47864. */
  47865. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  47866. /**
  47867. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  47868. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47869. */
  47870. get useAutoRotationBehavior(): boolean;
  47871. set useAutoRotationBehavior(value: boolean);
  47872. /**
  47873. * Observable triggered when the mesh target has been changed on the camera.
  47874. */
  47875. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  47876. /**
  47877. * Event raised when the camera is colliding with a mesh.
  47878. */
  47879. onCollide: (collidedMesh: AbstractMesh) => void;
  47880. /**
  47881. * Defines whether the camera should check collision with the objects oh the scene.
  47882. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  47883. */
  47884. checkCollisions: boolean;
  47885. /**
  47886. * Defines the collision radius of the camera.
  47887. * This simulates a sphere around the camera.
  47888. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47889. */
  47890. collisionRadius: Vector3;
  47891. protected _collider: Collider;
  47892. protected _previousPosition: Vector3;
  47893. protected _collisionVelocity: Vector3;
  47894. protected _newPosition: Vector3;
  47895. protected _previousAlpha: number;
  47896. protected _previousBeta: number;
  47897. protected _previousRadius: number;
  47898. protected _collisionTriggered: boolean;
  47899. protected _targetBoundingCenter: Nullable<Vector3>;
  47900. private _computationVector;
  47901. /**
  47902. * Instantiates a new ArcRotateCamera in a given scene
  47903. * @param name Defines the name of the camera
  47904. * @param alpha Defines the camera rotation along the logitudinal axis
  47905. * @param beta Defines the camera rotation along the latitudinal axis
  47906. * @param radius Defines the camera distance from its target
  47907. * @param target Defines the camera target
  47908. * @param scene Defines the scene the camera belongs to
  47909. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  47910. */
  47911. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47912. /** @hidden */
  47913. _initCache(): void;
  47914. /** @hidden */
  47915. _updateCache(ignoreParentClass?: boolean): void;
  47916. protected _getTargetPosition(): Vector3;
  47917. private _storedAlpha;
  47918. private _storedBeta;
  47919. private _storedRadius;
  47920. private _storedTarget;
  47921. private _storedTargetScreenOffset;
  47922. /**
  47923. * Stores the current state of the camera (alpha, beta, radius and target)
  47924. * @returns the camera itself
  47925. */
  47926. storeState(): Camera;
  47927. /**
  47928. * @hidden
  47929. * Restored camera state. You must call storeState() first
  47930. */
  47931. _restoreStateValues(): boolean;
  47932. /** @hidden */
  47933. _isSynchronizedViewMatrix(): boolean;
  47934. /**
  47935. * Attached controls to the current camera.
  47936. * @param element Defines the element the controls should be listened from
  47937. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47938. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  47939. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  47940. */
  47941. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  47942. /**
  47943. * Detach the current controls from the camera.
  47944. * The camera will stop reacting to inputs.
  47945. * @param element Defines the element to stop listening the inputs from
  47946. */
  47947. detachControl(element: HTMLElement): void;
  47948. /** @hidden */
  47949. _checkInputs(): void;
  47950. protected _checkLimits(): void;
  47951. /**
  47952. * Rebuilds angles (alpha, beta) and radius from the give position and target
  47953. */
  47954. rebuildAnglesAndRadius(): void;
  47955. /**
  47956. * Use a position to define the current camera related information like alpha, beta and radius
  47957. * @param position Defines the position to set the camera at
  47958. */
  47959. setPosition(position: Vector3): void;
  47960. /**
  47961. * Defines the target the camera should look at.
  47962. * This will automatically adapt alpha beta and radius to fit within the new target.
  47963. * @param target Defines the new target as a Vector or a mesh
  47964. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  47965. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  47966. */
  47967. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  47968. /** @hidden */
  47969. _getViewMatrix(): Matrix;
  47970. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  47971. /**
  47972. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  47973. * @param meshes Defines the mesh to zoom on
  47974. * @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)
  47975. */
  47976. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  47977. /**
  47978. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  47979. * The target will be changed but the radius
  47980. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  47981. * @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)
  47982. */
  47983. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  47984. min: Vector3;
  47985. max: Vector3;
  47986. distance: number;
  47987. }, doNotUpdateMaxZ?: boolean): void;
  47988. /**
  47989. * @override
  47990. * Override Camera.createRigCamera
  47991. */
  47992. createRigCamera(name: string, cameraIndex: number): Camera;
  47993. /**
  47994. * @hidden
  47995. * @override
  47996. * Override Camera._updateRigCameras
  47997. */
  47998. _updateRigCameras(): void;
  47999. /**
  48000. * Destroy the camera and release the current resources hold by it.
  48001. */
  48002. dispose(): void;
  48003. /**
  48004. * Gets the current object class name.
  48005. * @return the class name
  48006. */
  48007. getClassName(): string;
  48008. }
  48009. }
  48010. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  48011. import { Behavior } from "babylonjs/Behaviors/behavior";
  48012. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48013. /**
  48014. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  48015. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48016. */
  48017. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  48018. /**
  48019. * Gets the name of the behavior.
  48020. */
  48021. get name(): string;
  48022. private _zoomStopsAnimation;
  48023. private _idleRotationSpeed;
  48024. private _idleRotationWaitTime;
  48025. private _idleRotationSpinupTime;
  48026. /**
  48027. * Sets the flag that indicates if user zooming should stop animation.
  48028. */
  48029. set zoomStopsAnimation(flag: boolean);
  48030. /**
  48031. * Gets the flag that indicates if user zooming should stop animation.
  48032. */
  48033. get zoomStopsAnimation(): boolean;
  48034. /**
  48035. * Sets the default speed at which the camera rotates around the model.
  48036. */
  48037. set idleRotationSpeed(speed: number);
  48038. /**
  48039. * Gets the default speed at which the camera rotates around the model.
  48040. */
  48041. get idleRotationSpeed(): number;
  48042. /**
  48043. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  48044. */
  48045. set idleRotationWaitTime(time: number);
  48046. /**
  48047. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  48048. */
  48049. get idleRotationWaitTime(): number;
  48050. /**
  48051. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48052. */
  48053. set idleRotationSpinupTime(time: number);
  48054. /**
  48055. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48056. */
  48057. get idleRotationSpinupTime(): number;
  48058. /**
  48059. * Gets a value indicating if the camera is currently rotating because of this behavior
  48060. */
  48061. get rotationInProgress(): boolean;
  48062. private _onPrePointerObservableObserver;
  48063. private _onAfterCheckInputsObserver;
  48064. private _attachedCamera;
  48065. private _isPointerDown;
  48066. private _lastFrameTime;
  48067. private _lastInteractionTime;
  48068. private _cameraRotationSpeed;
  48069. /**
  48070. * Initializes the behavior.
  48071. */
  48072. init(): void;
  48073. /**
  48074. * Attaches the behavior to its arc rotate camera.
  48075. * @param camera Defines the camera to attach the behavior to
  48076. */
  48077. attach(camera: ArcRotateCamera): void;
  48078. /**
  48079. * Detaches the behavior from its current arc rotate camera.
  48080. */
  48081. detach(): void;
  48082. /**
  48083. * Returns true if user is scrolling.
  48084. * @return true if user is scrolling.
  48085. */
  48086. private _userIsZooming;
  48087. private _lastFrameRadius;
  48088. private _shouldAnimationStopForInteraction;
  48089. /**
  48090. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  48091. */
  48092. private _applyUserInteraction;
  48093. private _userIsMoving;
  48094. }
  48095. }
  48096. declare module "babylonjs/Behaviors/Cameras/index" {
  48097. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48098. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48099. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  48100. }
  48101. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  48102. import { Mesh } from "babylonjs/Meshes/mesh";
  48103. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48104. import { Behavior } from "babylonjs/Behaviors/behavior";
  48105. /**
  48106. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  48107. */
  48108. export class AttachToBoxBehavior implements Behavior<Mesh> {
  48109. private ui;
  48110. /**
  48111. * The name of the behavior
  48112. */
  48113. name: string;
  48114. /**
  48115. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  48116. */
  48117. distanceAwayFromFace: number;
  48118. /**
  48119. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  48120. */
  48121. distanceAwayFromBottomOfFace: number;
  48122. private _faceVectors;
  48123. private _target;
  48124. private _scene;
  48125. private _onRenderObserver;
  48126. private _tmpMatrix;
  48127. private _tmpVector;
  48128. /**
  48129. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  48130. * @param ui The transform node that should be attched to the mesh
  48131. */
  48132. constructor(ui: TransformNode);
  48133. /**
  48134. * Initializes the behavior
  48135. */
  48136. init(): void;
  48137. private _closestFace;
  48138. private _zeroVector;
  48139. private _lookAtTmpMatrix;
  48140. private _lookAtToRef;
  48141. /**
  48142. * Attaches the AttachToBoxBehavior to the passed in mesh
  48143. * @param target The mesh that the specified node will be attached to
  48144. */
  48145. attach(target: Mesh): void;
  48146. /**
  48147. * Detaches the behavior from the mesh
  48148. */
  48149. detach(): void;
  48150. }
  48151. }
  48152. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  48153. import { Behavior } from "babylonjs/Behaviors/behavior";
  48154. import { Mesh } from "babylonjs/Meshes/mesh";
  48155. /**
  48156. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  48157. */
  48158. export class FadeInOutBehavior implements Behavior<Mesh> {
  48159. /**
  48160. * Time in milliseconds to delay before fading in (Default: 0)
  48161. */
  48162. delay: number;
  48163. /**
  48164. * Time in milliseconds for the mesh to fade in (Default: 300)
  48165. */
  48166. fadeInTime: number;
  48167. private _millisecondsPerFrame;
  48168. private _hovered;
  48169. private _hoverValue;
  48170. private _ownerNode;
  48171. /**
  48172. * Instatiates the FadeInOutBehavior
  48173. */
  48174. constructor();
  48175. /**
  48176. * The name of the behavior
  48177. */
  48178. get name(): string;
  48179. /**
  48180. * Initializes the behavior
  48181. */
  48182. init(): void;
  48183. /**
  48184. * Attaches the fade behavior on the passed in mesh
  48185. * @param ownerNode The mesh that will be faded in/out once attached
  48186. */
  48187. attach(ownerNode: Mesh): void;
  48188. /**
  48189. * Detaches the behavior from the mesh
  48190. */
  48191. detach(): void;
  48192. /**
  48193. * Triggers the mesh to begin fading in or out
  48194. * @param value if the object should fade in or out (true to fade in)
  48195. */
  48196. fadeIn(value: boolean): void;
  48197. private _update;
  48198. private _setAllVisibility;
  48199. }
  48200. }
  48201. declare module "babylonjs/Misc/pivotTools" {
  48202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48203. /**
  48204. * Class containing a set of static utilities functions for managing Pivots
  48205. * @hidden
  48206. */
  48207. export class PivotTools {
  48208. private static _PivotCached;
  48209. private static _OldPivotPoint;
  48210. private static _PivotTranslation;
  48211. private static _PivotTmpVector;
  48212. private static _PivotPostMultiplyPivotMatrix;
  48213. /** @hidden */
  48214. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  48215. /** @hidden */
  48216. static _RestorePivotPoint(mesh: AbstractMesh): void;
  48217. }
  48218. }
  48219. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  48220. import { Scene } from "babylonjs/scene";
  48221. import { Vector4 } from "babylonjs/Maths/math.vector";
  48222. import { Mesh } from "babylonjs/Meshes/mesh";
  48223. import { Nullable } from "babylonjs/types";
  48224. import { Plane } from "babylonjs/Maths/math.plane";
  48225. /**
  48226. * Class containing static functions to help procedurally build meshes
  48227. */
  48228. export class PlaneBuilder {
  48229. /**
  48230. * Creates a plane mesh
  48231. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  48232. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  48233. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  48234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48235. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48237. * @param name defines the name of the mesh
  48238. * @param options defines the options used to create the mesh
  48239. * @param scene defines the hosting scene
  48240. * @returns the plane mesh
  48241. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  48242. */
  48243. static CreatePlane(name: string, options: {
  48244. size?: number;
  48245. width?: number;
  48246. height?: number;
  48247. sideOrientation?: number;
  48248. frontUVs?: Vector4;
  48249. backUVs?: Vector4;
  48250. updatable?: boolean;
  48251. sourcePlane?: Plane;
  48252. }, scene?: Nullable<Scene>): Mesh;
  48253. }
  48254. }
  48255. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  48256. import { Behavior } from "babylonjs/Behaviors/behavior";
  48257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48258. import { Observable } from "babylonjs/Misc/observable";
  48259. import { Vector3 } from "babylonjs/Maths/math.vector";
  48260. import { Ray } from "babylonjs/Culling/ray";
  48261. import "babylonjs/Meshes/Builders/planeBuilder";
  48262. /**
  48263. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  48264. */
  48265. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  48266. private static _AnyMouseID;
  48267. /**
  48268. * Abstract mesh the behavior is set on
  48269. */
  48270. attachedNode: AbstractMesh;
  48271. private _dragPlane;
  48272. private _scene;
  48273. private _pointerObserver;
  48274. private _beforeRenderObserver;
  48275. private static _planeScene;
  48276. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  48277. /**
  48278. * 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)
  48279. */
  48280. maxDragAngle: number;
  48281. /**
  48282. * @hidden
  48283. */
  48284. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  48285. /**
  48286. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48287. */
  48288. currentDraggingPointerID: number;
  48289. /**
  48290. * The last position where the pointer hit the drag plane in world space
  48291. */
  48292. lastDragPosition: Vector3;
  48293. /**
  48294. * If the behavior is currently in a dragging state
  48295. */
  48296. dragging: boolean;
  48297. /**
  48298. * 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)
  48299. */
  48300. dragDeltaRatio: number;
  48301. /**
  48302. * If the drag plane orientation should be updated during the dragging (Default: true)
  48303. */
  48304. updateDragPlane: boolean;
  48305. private _debugMode;
  48306. private _moving;
  48307. /**
  48308. * Fires each time the attached mesh is dragged with the pointer
  48309. * * delta between last drag position and current drag position in world space
  48310. * * dragDistance along the drag axis
  48311. * * dragPlaneNormal normal of the current drag plane used during the drag
  48312. * * dragPlanePoint in world space where the drag intersects the drag plane
  48313. */
  48314. onDragObservable: Observable<{
  48315. delta: Vector3;
  48316. dragPlanePoint: Vector3;
  48317. dragPlaneNormal: Vector3;
  48318. dragDistance: number;
  48319. pointerId: number;
  48320. }>;
  48321. /**
  48322. * Fires each time a drag begins (eg. mouse down on mesh)
  48323. */
  48324. onDragStartObservable: Observable<{
  48325. dragPlanePoint: Vector3;
  48326. pointerId: number;
  48327. }>;
  48328. /**
  48329. * Fires each time a drag ends (eg. mouse release after drag)
  48330. */
  48331. onDragEndObservable: Observable<{
  48332. dragPlanePoint: Vector3;
  48333. pointerId: number;
  48334. }>;
  48335. /**
  48336. * If the attached mesh should be moved when dragged
  48337. */
  48338. moveAttached: boolean;
  48339. /**
  48340. * If the drag behavior will react to drag events (Default: true)
  48341. */
  48342. enabled: boolean;
  48343. /**
  48344. * If pointer events should start and release the drag (Default: true)
  48345. */
  48346. startAndReleaseDragOnPointerEvents: boolean;
  48347. /**
  48348. * If camera controls should be detached during the drag
  48349. */
  48350. detachCameraControls: boolean;
  48351. /**
  48352. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  48353. */
  48354. useObjectOrientationForDragging: boolean;
  48355. private _options;
  48356. /**
  48357. * Gets the options used by the behavior
  48358. */
  48359. get options(): {
  48360. dragAxis?: Vector3;
  48361. dragPlaneNormal?: Vector3;
  48362. };
  48363. /**
  48364. * Sets the options used by the behavior
  48365. */
  48366. set options(options: {
  48367. dragAxis?: Vector3;
  48368. dragPlaneNormal?: Vector3;
  48369. });
  48370. /**
  48371. * Creates a pointer drag behavior that can be attached to a mesh
  48372. * @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)
  48373. */
  48374. constructor(options?: {
  48375. dragAxis?: Vector3;
  48376. dragPlaneNormal?: Vector3;
  48377. });
  48378. /**
  48379. * Predicate to determine if it is valid to move the object to a new position when it is moved
  48380. */
  48381. validateDrag: (targetPosition: Vector3) => boolean;
  48382. /**
  48383. * The name of the behavior
  48384. */
  48385. get name(): string;
  48386. /**
  48387. * Initializes the behavior
  48388. */
  48389. init(): void;
  48390. private _tmpVector;
  48391. private _alternatePickedPoint;
  48392. private _worldDragAxis;
  48393. private _targetPosition;
  48394. private _attachedElement;
  48395. /**
  48396. * Attaches the drag behavior the passed in mesh
  48397. * @param ownerNode The mesh that will be dragged around once attached
  48398. * @param predicate Predicate to use for pick filtering
  48399. */
  48400. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  48401. /**
  48402. * Force relase the drag action by code.
  48403. */
  48404. releaseDrag(): void;
  48405. private _startDragRay;
  48406. private _lastPointerRay;
  48407. /**
  48408. * Simulates the start of a pointer drag event on the behavior
  48409. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  48410. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  48411. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  48412. */
  48413. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48414. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48415. private _dragDelta;
  48416. protected _moveDrag(ray: Ray): void;
  48417. private _pickWithRayOnDragPlane;
  48418. private _pointA;
  48419. private _pointC;
  48420. private _localAxis;
  48421. private _lookAt;
  48422. private _updateDragPlanePosition;
  48423. /**
  48424. * Detaches the behavior from the mesh
  48425. */
  48426. detach(): void;
  48427. }
  48428. }
  48429. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  48430. import { Mesh } from "babylonjs/Meshes/mesh";
  48431. import { Behavior } from "babylonjs/Behaviors/behavior";
  48432. /**
  48433. * A behavior that when attached to a mesh will allow the mesh to be scaled
  48434. */
  48435. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  48436. private _dragBehaviorA;
  48437. private _dragBehaviorB;
  48438. private _startDistance;
  48439. private _initialScale;
  48440. private _targetScale;
  48441. private _ownerNode;
  48442. private _sceneRenderObserver;
  48443. /**
  48444. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  48445. */
  48446. constructor();
  48447. /**
  48448. * The name of the behavior
  48449. */
  48450. get name(): string;
  48451. /**
  48452. * Initializes the behavior
  48453. */
  48454. init(): void;
  48455. private _getCurrentDistance;
  48456. /**
  48457. * Attaches the scale behavior the passed in mesh
  48458. * @param ownerNode The mesh that will be scaled around once attached
  48459. */
  48460. attach(ownerNode: Mesh): void;
  48461. /**
  48462. * Detaches the behavior from the mesh
  48463. */
  48464. detach(): void;
  48465. }
  48466. }
  48467. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  48468. import { Behavior } from "babylonjs/Behaviors/behavior";
  48469. import { Mesh } from "babylonjs/Meshes/mesh";
  48470. import { Observable } from "babylonjs/Misc/observable";
  48471. /**
  48472. * 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
  48473. */
  48474. export class SixDofDragBehavior implements Behavior<Mesh> {
  48475. private static _virtualScene;
  48476. private _ownerNode;
  48477. private _sceneRenderObserver;
  48478. private _scene;
  48479. private _targetPosition;
  48480. private _virtualOriginMesh;
  48481. private _virtualDragMesh;
  48482. private _pointerObserver;
  48483. private _moving;
  48484. private _startingOrientation;
  48485. private _attachedElement;
  48486. /**
  48487. * 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)
  48488. */
  48489. private zDragFactor;
  48490. /**
  48491. * If the object should rotate to face the drag origin
  48492. */
  48493. rotateDraggedObject: boolean;
  48494. /**
  48495. * If the behavior is currently in a dragging state
  48496. */
  48497. dragging: boolean;
  48498. /**
  48499. * 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)
  48500. */
  48501. dragDeltaRatio: number;
  48502. /**
  48503. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48504. */
  48505. currentDraggingPointerID: number;
  48506. /**
  48507. * If camera controls should be detached during the drag
  48508. */
  48509. detachCameraControls: boolean;
  48510. /**
  48511. * Fires each time a drag starts
  48512. */
  48513. onDragStartObservable: Observable<{}>;
  48514. /**
  48515. * Fires each time a drag ends (eg. mouse release after drag)
  48516. */
  48517. onDragEndObservable: Observable<{}>;
  48518. /**
  48519. * 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
  48520. */
  48521. constructor();
  48522. /**
  48523. * The name of the behavior
  48524. */
  48525. get name(): string;
  48526. /**
  48527. * Initializes the behavior
  48528. */
  48529. init(): void;
  48530. /**
  48531. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  48532. */
  48533. private get _pointerCamera();
  48534. /**
  48535. * Attaches the scale behavior the passed in mesh
  48536. * @param ownerNode The mesh that will be scaled around once attached
  48537. */
  48538. attach(ownerNode: Mesh): void;
  48539. /**
  48540. * Detaches the behavior from the mesh
  48541. */
  48542. detach(): void;
  48543. }
  48544. }
  48545. declare module "babylonjs/Behaviors/Meshes/index" {
  48546. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  48547. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  48548. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  48549. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48550. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48551. }
  48552. declare module "babylonjs/Behaviors/index" {
  48553. export * from "babylonjs/Behaviors/behavior";
  48554. export * from "babylonjs/Behaviors/Cameras/index";
  48555. export * from "babylonjs/Behaviors/Meshes/index";
  48556. }
  48557. declare module "babylonjs/Bones/boneIKController" {
  48558. import { Bone } from "babylonjs/Bones/bone";
  48559. import { Vector3 } from "babylonjs/Maths/math.vector";
  48560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48561. import { Nullable } from "babylonjs/types";
  48562. /**
  48563. * Class used to apply inverse kinematics to bones
  48564. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  48565. */
  48566. export class BoneIKController {
  48567. private static _tmpVecs;
  48568. private static _tmpQuat;
  48569. private static _tmpMats;
  48570. /**
  48571. * Gets or sets the target mesh
  48572. */
  48573. targetMesh: AbstractMesh;
  48574. /** Gets or sets the mesh used as pole */
  48575. poleTargetMesh: AbstractMesh;
  48576. /**
  48577. * Gets or sets the bone used as pole
  48578. */
  48579. poleTargetBone: Nullable<Bone>;
  48580. /**
  48581. * Gets or sets the target position
  48582. */
  48583. targetPosition: Vector3;
  48584. /**
  48585. * Gets or sets the pole target position
  48586. */
  48587. poleTargetPosition: Vector3;
  48588. /**
  48589. * Gets or sets the pole target local offset
  48590. */
  48591. poleTargetLocalOffset: Vector3;
  48592. /**
  48593. * Gets or sets the pole angle
  48594. */
  48595. poleAngle: number;
  48596. /**
  48597. * Gets or sets the mesh associated with the controller
  48598. */
  48599. mesh: AbstractMesh;
  48600. /**
  48601. * 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)
  48602. */
  48603. slerpAmount: number;
  48604. private _bone1Quat;
  48605. private _bone1Mat;
  48606. private _bone2Ang;
  48607. private _bone1;
  48608. private _bone2;
  48609. private _bone1Length;
  48610. private _bone2Length;
  48611. private _maxAngle;
  48612. private _maxReach;
  48613. private _rightHandedSystem;
  48614. private _bendAxis;
  48615. private _slerping;
  48616. private _adjustRoll;
  48617. /**
  48618. * Gets or sets maximum allowed angle
  48619. */
  48620. get maxAngle(): number;
  48621. set maxAngle(value: number);
  48622. /**
  48623. * Creates a new BoneIKController
  48624. * @param mesh defines the mesh to control
  48625. * @param bone defines the bone to control
  48626. * @param options defines options to set up the controller
  48627. */
  48628. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  48629. targetMesh?: AbstractMesh;
  48630. poleTargetMesh?: AbstractMesh;
  48631. poleTargetBone?: Bone;
  48632. poleTargetLocalOffset?: Vector3;
  48633. poleAngle?: number;
  48634. bendAxis?: Vector3;
  48635. maxAngle?: number;
  48636. slerpAmount?: number;
  48637. });
  48638. private _setMaxAngle;
  48639. /**
  48640. * Force the controller to update the bones
  48641. */
  48642. update(): void;
  48643. }
  48644. }
  48645. declare module "babylonjs/Bones/boneLookController" {
  48646. import { Vector3 } from "babylonjs/Maths/math.vector";
  48647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48648. import { Bone } from "babylonjs/Bones/bone";
  48649. import { Space } from "babylonjs/Maths/math.axis";
  48650. /**
  48651. * Class used to make a bone look toward a point in space
  48652. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  48653. */
  48654. export class BoneLookController {
  48655. private static _tmpVecs;
  48656. private static _tmpQuat;
  48657. private static _tmpMats;
  48658. /**
  48659. * The target Vector3 that the bone will look at
  48660. */
  48661. target: Vector3;
  48662. /**
  48663. * The mesh that the bone is attached to
  48664. */
  48665. mesh: AbstractMesh;
  48666. /**
  48667. * The bone that will be looking to the target
  48668. */
  48669. bone: Bone;
  48670. /**
  48671. * The up axis of the coordinate system that is used when the bone is rotated
  48672. */
  48673. upAxis: Vector3;
  48674. /**
  48675. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  48676. */
  48677. upAxisSpace: Space;
  48678. /**
  48679. * Used to make an adjustment to the yaw of the bone
  48680. */
  48681. adjustYaw: number;
  48682. /**
  48683. * Used to make an adjustment to the pitch of the bone
  48684. */
  48685. adjustPitch: number;
  48686. /**
  48687. * Used to make an adjustment to the roll of the bone
  48688. */
  48689. adjustRoll: number;
  48690. /**
  48691. * 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)
  48692. */
  48693. slerpAmount: number;
  48694. private _minYaw;
  48695. private _maxYaw;
  48696. private _minPitch;
  48697. private _maxPitch;
  48698. private _minYawSin;
  48699. private _minYawCos;
  48700. private _maxYawSin;
  48701. private _maxYawCos;
  48702. private _midYawConstraint;
  48703. private _minPitchTan;
  48704. private _maxPitchTan;
  48705. private _boneQuat;
  48706. private _slerping;
  48707. private _transformYawPitch;
  48708. private _transformYawPitchInv;
  48709. private _firstFrameSkipped;
  48710. private _yawRange;
  48711. private _fowardAxis;
  48712. /**
  48713. * Gets or sets the minimum yaw angle that the bone can look to
  48714. */
  48715. get minYaw(): number;
  48716. set minYaw(value: number);
  48717. /**
  48718. * Gets or sets the maximum yaw angle that the bone can look to
  48719. */
  48720. get maxYaw(): number;
  48721. set maxYaw(value: number);
  48722. /**
  48723. * Gets or sets the minimum pitch angle that the bone can look to
  48724. */
  48725. get minPitch(): number;
  48726. set minPitch(value: number);
  48727. /**
  48728. * Gets or sets the maximum pitch angle that the bone can look to
  48729. */
  48730. get maxPitch(): number;
  48731. set maxPitch(value: number);
  48732. /**
  48733. * Create a BoneLookController
  48734. * @param mesh the mesh that the bone belongs to
  48735. * @param bone the bone that will be looking to the target
  48736. * @param target the target Vector3 to look at
  48737. * @param options optional settings:
  48738. * * maxYaw: the maximum angle the bone will yaw to
  48739. * * minYaw: the minimum angle the bone will yaw to
  48740. * * maxPitch: the maximum angle the bone will pitch to
  48741. * * minPitch: the minimum angle the bone will yaw to
  48742. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  48743. * * upAxis: the up axis of the coordinate system
  48744. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  48745. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  48746. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  48747. * * adjustYaw: used to make an adjustment to the yaw of the bone
  48748. * * adjustPitch: used to make an adjustment to the pitch of the bone
  48749. * * adjustRoll: used to make an adjustment to the roll of the bone
  48750. **/
  48751. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  48752. maxYaw?: number;
  48753. minYaw?: number;
  48754. maxPitch?: number;
  48755. minPitch?: number;
  48756. slerpAmount?: number;
  48757. upAxis?: Vector3;
  48758. upAxisSpace?: Space;
  48759. yawAxis?: Vector3;
  48760. pitchAxis?: Vector3;
  48761. adjustYaw?: number;
  48762. adjustPitch?: number;
  48763. adjustRoll?: number;
  48764. });
  48765. /**
  48766. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  48767. */
  48768. update(): void;
  48769. private _getAngleDiff;
  48770. private _getAngleBetween;
  48771. private _isAngleBetween;
  48772. }
  48773. }
  48774. declare module "babylonjs/Bones/index" {
  48775. export * from "babylonjs/Bones/bone";
  48776. export * from "babylonjs/Bones/boneIKController";
  48777. export * from "babylonjs/Bones/boneLookController";
  48778. export * from "babylonjs/Bones/skeleton";
  48779. }
  48780. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  48781. import { Nullable } from "babylonjs/types";
  48782. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48783. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48784. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  48785. /**
  48786. * Manage the gamepad inputs to control an arc rotate camera.
  48787. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48788. */
  48789. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  48790. /**
  48791. * Defines the camera the input is attached to.
  48792. */
  48793. camera: ArcRotateCamera;
  48794. /**
  48795. * Defines the gamepad the input is gathering event from.
  48796. */
  48797. gamepad: Nullable<Gamepad>;
  48798. /**
  48799. * Defines the gamepad rotation sensiblity.
  48800. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48801. */
  48802. gamepadRotationSensibility: number;
  48803. /**
  48804. * Defines the gamepad move sensiblity.
  48805. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48806. */
  48807. gamepadMoveSensibility: number;
  48808. private _yAxisScale;
  48809. /**
  48810. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48811. */
  48812. get invertYAxis(): boolean;
  48813. set invertYAxis(value: boolean);
  48814. private _onGamepadConnectedObserver;
  48815. private _onGamepadDisconnectedObserver;
  48816. /**
  48817. * Attach the input controls to a specific dom element to get the input from.
  48818. * @param element Defines the element the controls should be listened from
  48819. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48820. */
  48821. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48822. /**
  48823. * Detach the current controls from the specified dom element.
  48824. * @param element Defines the element to stop listening the inputs from
  48825. */
  48826. detachControl(element: Nullable<HTMLElement>): void;
  48827. /**
  48828. * Update the current camera state depending on the inputs that have been used this frame.
  48829. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48830. */
  48831. checkInputs(): void;
  48832. /**
  48833. * Gets the class name of the current intput.
  48834. * @returns the class name
  48835. */
  48836. getClassName(): string;
  48837. /**
  48838. * Get the friendly name associated with the input class.
  48839. * @returns the input friendly name
  48840. */
  48841. getSimpleName(): string;
  48842. }
  48843. }
  48844. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  48845. import { Nullable } from "babylonjs/types";
  48846. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48847. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48848. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  48849. interface ArcRotateCameraInputsManager {
  48850. /**
  48851. * Add orientation input support to the input manager.
  48852. * @returns the current input manager
  48853. */
  48854. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  48855. }
  48856. }
  48857. /**
  48858. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  48859. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48860. */
  48861. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  48862. /**
  48863. * Defines the camera the input is attached to.
  48864. */
  48865. camera: ArcRotateCamera;
  48866. /**
  48867. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  48868. */
  48869. alphaCorrection: number;
  48870. /**
  48871. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  48872. */
  48873. gammaCorrection: number;
  48874. private _alpha;
  48875. private _gamma;
  48876. private _dirty;
  48877. private _deviceOrientationHandler;
  48878. /**
  48879. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  48880. */
  48881. constructor();
  48882. /**
  48883. * Attach the input controls to a specific dom element to get the input from.
  48884. * @param element Defines the element the controls should be listened from
  48885. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48886. */
  48887. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48888. /** @hidden */
  48889. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  48890. /**
  48891. * Update the current camera state depending on the inputs that have been used this frame.
  48892. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48893. */
  48894. checkInputs(): void;
  48895. /**
  48896. * Detach the current controls from the specified dom element.
  48897. * @param element Defines the element to stop listening the inputs from
  48898. */
  48899. detachControl(element: Nullable<HTMLElement>): void;
  48900. /**
  48901. * Gets the class name of the current intput.
  48902. * @returns the class name
  48903. */
  48904. getClassName(): string;
  48905. /**
  48906. * Get the friendly name associated with the input class.
  48907. * @returns the input friendly name
  48908. */
  48909. getSimpleName(): string;
  48910. }
  48911. }
  48912. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  48913. import { Nullable } from "babylonjs/types";
  48914. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48915. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  48916. /**
  48917. * Listen to mouse events to control the camera.
  48918. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48919. */
  48920. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  48921. /**
  48922. * Defines the camera the input is attached to.
  48923. */
  48924. camera: FlyCamera;
  48925. /**
  48926. * Defines if touch is enabled. (Default is true.)
  48927. */
  48928. touchEnabled: boolean;
  48929. /**
  48930. * Defines the buttons associated with the input to handle camera rotation.
  48931. */
  48932. buttons: number[];
  48933. /**
  48934. * Assign buttons for Yaw control.
  48935. */
  48936. buttonsYaw: number[];
  48937. /**
  48938. * Assign buttons for Pitch control.
  48939. */
  48940. buttonsPitch: number[];
  48941. /**
  48942. * Assign buttons for Roll control.
  48943. */
  48944. buttonsRoll: number[];
  48945. /**
  48946. * Detect if any button is being pressed while mouse is moved.
  48947. * -1 = Mouse locked.
  48948. * 0 = Left button.
  48949. * 1 = Middle Button.
  48950. * 2 = Right Button.
  48951. */
  48952. activeButton: number;
  48953. /**
  48954. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  48955. * Higher values reduce its sensitivity.
  48956. */
  48957. angularSensibility: number;
  48958. private _observer;
  48959. private _rollObserver;
  48960. private previousPosition;
  48961. private noPreventDefault;
  48962. private element;
  48963. /**
  48964. * Listen to mouse events to control the camera.
  48965. * @param touchEnabled Define if touch is enabled. (Default is true.)
  48966. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48967. */
  48968. constructor(touchEnabled?: boolean);
  48969. /**
  48970. * Attach the mouse control to the HTML DOM element.
  48971. * @param element Defines the element that listens to the input events.
  48972. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  48973. */
  48974. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48975. /**
  48976. * Detach the current controls from the specified dom element.
  48977. * @param element Defines the element to stop listening the inputs from
  48978. */
  48979. detachControl(element: Nullable<HTMLElement>): void;
  48980. /**
  48981. * Gets the class name of the current input.
  48982. * @returns the class name.
  48983. */
  48984. getClassName(): string;
  48985. /**
  48986. * Get the friendly name associated with the input class.
  48987. * @returns the input's friendly name.
  48988. */
  48989. getSimpleName(): string;
  48990. private _pointerInput;
  48991. private _onMouseMove;
  48992. /**
  48993. * Rotate camera by mouse offset.
  48994. */
  48995. private rotateCamera;
  48996. }
  48997. }
  48998. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  48999. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49000. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49001. /**
  49002. * Default Inputs manager for the FlyCamera.
  49003. * It groups all the default supported inputs for ease of use.
  49004. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49005. */
  49006. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  49007. /**
  49008. * Instantiates a new FlyCameraInputsManager.
  49009. * @param camera Defines the camera the inputs belong to.
  49010. */
  49011. constructor(camera: FlyCamera);
  49012. /**
  49013. * Add keyboard input support to the input manager.
  49014. * @returns the new FlyCameraKeyboardMoveInput().
  49015. */
  49016. addKeyboard(): FlyCameraInputsManager;
  49017. /**
  49018. * Add mouse input support to the input manager.
  49019. * @param touchEnabled Enable touch screen support.
  49020. * @returns the new FlyCameraMouseInput().
  49021. */
  49022. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  49023. }
  49024. }
  49025. declare module "babylonjs/Cameras/flyCamera" {
  49026. import { Scene } from "babylonjs/scene";
  49027. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  49028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49029. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49030. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  49031. /**
  49032. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49033. * such as in a 3D Space Shooter or a Flight Simulator.
  49034. */
  49035. export class FlyCamera extends TargetCamera {
  49036. /**
  49037. * Define the collision ellipsoid of the camera.
  49038. * This is helpful for simulating a camera body, like a player's body.
  49039. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49040. */
  49041. ellipsoid: Vector3;
  49042. /**
  49043. * Define an offset for the position of the ellipsoid around the camera.
  49044. * This can be helpful if the camera is attached away from the player's body center,
  49045. * such as at its head.
  49046. */
  49047. ellipsoidOffset: Vector3;
  49048. /**
  49049. * Enable or disable collisions of the camera with the rest of the scene objects.
  49050. */
  49051. checkCollisions: boolean;
  49052. /**
  49053. * Enable or disable gravity on the camera.
  49054. */
  49055. applyGravity: boolean;
  49056. /**
  49057. * Define the current direction the camera is moving to.
  49058. */
  49059. cameraDirection: Vector3;
  49060. /**
  49061. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  49062. * This overrides and empties cameraRotation.
  49063. */
  49064. rotationQuaternion: Quaternion;
  49065. /**
  49066. * Track Roll to maintain the wanted Rolling when looking around.
  49067. */
  49068. _trackRoll: number;
  49069. /**
  49070. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  49071. */
  49072. rollCorrect: number;
  49073. /**
  49074. * Mimic a banked turn, Rolling the camera when Yawing.
  49075. * It's recommended to use rollCorrect = 10 for faster banking correction.
  49076. */
  49077. bankedTurn: boolean;
  49078. /**
  49079. * Limit in radians for how much Roll banking will add. (Default: 90°)
  49080. */
  49081. bankedTurnLimit: number;
  49082. /**
  49083. * Value of 0 disables the banked Roll.
  49084. * Value of 1 is equal to the Yaw angle in radians.
  49085. */
  49086. bankedTurnMultiplier: number;
  49087. /**
  49088. * The inputs manager loads all the input sources, such as keyboard and mouse.
  49089. */
  49090. inputs: FlyCameraInputsManager;
  49091. /**
  49092. * Gets the input sensibility for mouse input.
  49093. * Higher values reduce sensitivity.
  49094. */
  49095. get angularSensibility(): number;
  49096. /**
  49097. * Sets the input sensibility for a mouse input.
  49098. * Higher values reduce sensitivity.
  49099. */
  49100. set angularSensibility(value: number);
  49101. /**
  49102. * Get the keys for camera movement forward.
  49103. */
  49104. get keysForward(): number[];
  49105. /**
  49106. * Set the keys for camera movement forward.
  49107. */
  49108. set keysForward(value: number[]);
  49109. /**
  49110. * Get the keys for camera movement backward.
  49111. */
  49112. get keysBackward(): number[];
  49113. set keysBackward(value: number[]);
  49114. /**
  49115. * Get the keys for camera movement up.
  49116. */
  49117. get keysUp(): number[];
  49118. /**
  49119. * Set the keys for camera movement up.
  49120. */
  49121. set keysUp(value: number[]);
  49122. /**
  49123. * Get the keys for camera movement down.
  49124. */
  49125. get keysDown(): number[];
  49126. /**
  49127. * Set the keys for camera movement down.
  49128. */
  49129. set keysDown(value: number[]);
  49130. /**
  49131. * Get the keys for camera movement left.
  49132. */
  49133. get keysLeft(): number[];
  49134. /**
  49135. * Set the keys for camera movement left.
  49136. */
  49137. set keysLeft(value: number[]);
  49138. /**
  49139. * Set the keys for camera movement right.
  49140. */
  49141. get keysRight(): number[];
  49142. /**
  49143. * Set the keys for camera movement right.
  49144. */
  49145. set keysRight(value: number[]);
  49146. /**
  49147. * Event raised when the camera collides with a mesh in the scene.
  49148. */
  49149. onCollide: (collidedMesh: AbstractMesh) => void;
  49150. private _collider;
  49151. private _needMoveForGravity;
  49152. private _oldPosition;
  49153. private _diffPosition;
  49154. private _newPosition;
  49155. /** @hidden */
  49156. _localDirection: Vector3;
  49157. /** @hidden */
  49158. _transformedDirection: Vector3;
  49159. /**
  49160. * Instantiates a FlyCamera.
  49161. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49162. * such as in a 3D Space Shooter or a Flight Simulator.
  49163. * @param name Define the name of the camera in the scene.
  49164. * @param position Define the starting position of the camera in the scene.
  49165. * @param scene Define the scene the camera belongs to.
  49166. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  49167. */
  49168. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49169. /**
  49170. * Attach a control to the HTML DOM element.
  49171. * @param element Defines the element that listens to the input events.
  49172. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  49173. */
  49174. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49175. /**
  49176. * Detach a control from the HTML DOM element.
  49177. * The camera will stop reacting to that input.
  49178. * @param element Defines the element that listens to the input events.
  49179. */
  49180. detachControl(element: HTMLElement): void;
  49181. private _collisionMask;
  49182. /**
  49183. * Get the mask that the camera ignores in collision events.
  49184. */
  49185. get collisionMask(): number;
  49186. /**
  49187. * Set the mask that the camera ignores in collision events.
  49188. */
  49189. set collisionMask(mask: number);
  49190. /** @hidden */
  49191. _collideWithWorld(displacement: Vector3): void;
  49192. /** @hidden */
  49193. private _onCollisionPositionChange;
  49194. /** @hidden */
  49195. _checkInputs(): void;
  49196. /** @hidden */
  49197. _decideIfNeedsToMove(): boolean;
  49198. /** @hidden */
  49199. _updatePosition(): void;
  49200. /**
  49201. * Restore the Roll to its target value at the rate specified.
  49202. * @param rate - Higher means slower restoring.
  49203. * @hidden
  49204. */
  49205. restoreRoll(rate: number): void;
  49206. /**
  49207. * Destroy the camera and release the current resources held by it.
  49208. */
  49209. dispose(): void;
  49210. /**
  49211. * Get the current object class name.
  49212. * @returns the class name.
  49213. */
  49214. getClassName(): string;
  49215. }
  49216. }
  49217. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  49218. import { Nullable } from "babylonjs/types";
  49219. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49220. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49221. /**
  49222. * Listen to keyboard events to control the camera.
  49223. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49224. */
  49225. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  49226. /**
  49227. * Defines the camera the input is attached to.
  49228. */
  49229. camera: FlyCamera;
  49230. /**
  49231. * The list of keyboard keys used to control the forward move of the camera.
  49232. */
  49233. keysForward: number[];
  49234. /**
  49235. * The list of keyboard keys used to control the backward move of the camera.
  49236. */
  49237. keysBackward: number[];
  49238. /**
  49239. * The list of keyboard keys used to control the forward move of the camera.
  49240. */
  49241. keysUp: number[];
  49242. /**
  49243. * The list of keyboard keys used to control the backward move of the camera.
  49244. */
  49245. keysDown: number[];
  49246. /**
  49247. * The list of keyboard keys used to control the right strafe move of the camera.
  49248. */
  49249. keysRight: number[];
  49250. /**
  49251. * The list of keyboard keys used to control the left strafe move of the camera.
  49252. */
  49253. keysLeft: number[];
  49254. private _keys;
  49255. private _onCanvasBlurObserver;
  49256. private _onKeyboardObserver;
  49257. private _engine;
  49258. private _scene;
  49259. /**
  49260. * Attach the input controls to a specific dom element to get the input from.
  49261. * @param element Defines the element the controls should be listened from
  49262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49263. */
  49264. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49265. /**
  49266. * Detach the current controls from the specified dom element.
  49267. * @param element Defines the element to stop listening the inputs from
  49268. */
  49269. detachControl(element: Nullable<HTMLElement>): void;
  49270. /**
  49271. * Gets the class name of the current intput.
  49272. * @returns the class name
  49273. */
  49274. getClassName(): string;
  49275. /** @hidden */
  49276. _onLostFocus(e: FocusEvent): void;
  49277. /**
  49278. * Get the friendly name associated with the input class.
  49279. * @returns the input friendly name
  49280. */
  49281. getSimpleName(): string;
  49282. /**
  49283. * Update the current camera state depending on the inputs that have been used this frame.
  49284. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49285. */
  49286. checkInputs(): void;
  49287. }
  49288. }
  49289. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  49290. import { Nullable } from "babylonjs/types";
  49291. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49292. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49293. /**
  49294. * Manage the mouse wheel inputs to control a follow camera.
  49295. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49296. */
  49297. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  49298. /**
  49299. * Defines the camera the input is attached to.
  49300. */
  49301. camera: FollowCamera;
  49302. /**
  49303. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  49304. */
  49305. axisControlRadius: boolean;
  49306. /**
  49307. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  49308. */
  49309. axisControlHeight: boolean;
  49310. /**
  49311. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  49312. */
  49313. axisControlRotation: boolean;
  49314. /**
  49315. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  49316. * relation to mouseWheel events.
  49317. */
  49318. wheelPrecision: number;
  49319. /**
  49320. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49321. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49322. */
  49323. wheelDeltaPercentage: number;
  49324. private _wheel;
  49325. private _observer;
  49326. /**
  49327. * Attach the input controls to a specific dom element to get the input from.
  49328. * @param element Defines the element the controls should be listened from
  49329. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49330. */
  49331. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49332. /**
  49333. * Detach the current controls from the specified dom element.
  49334. * @param element Defines the element to stop listening the inputs from
  49335. */
  49336. detachControl(element: Nullable<HTMLElement>): void;
  49337. /**
  49338. * Gets the class name of the current intput.
  49339. * @returns the class name
  49340. */
  49341. getClassName(): string;
  49342. /**
  49343. * Get the friendly name associated with the input class.
  49344. * @returns the input friendly name
  49345. */
  49346. getSimpleName(): string;
  49347. }
  49348. }
  49349. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  49350. import { Nullable } from "babylonjs/types";
  49351. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49352. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  49353. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  49354. /**
  49355. * Manage the pointers inputs to control an follow camera.
  49356. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49357. */
  49358. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  49359. /**
  49360. * Defines the camera the input is attached to.
  49361. */
  49362. camera: FollowCamera;
  49363. /**
  49364. * Gets the class name of the current input.
  49365. * @returns the class name
  49366. */
  49367. getClassName(): string;
  49368. /**
  49369. * Defines the pointer angular sensibility along the X axis or how fast is
  49370. * the camera rotating.
  49371. * A negative number will reverse the axis direction.
  49372. */
  49373. angularSensibilityX: number;
  49374. /**
  49375. * Defines the pointer angular sensibility along the Y axis or how fast is
  49376. * the camera rotating.
  49377. * A negative number will reverse the axis direction.
  49378. */
  49379. angularSensibilityY: number;
  49380. /**
  49381. * Defines the pointer pinch precision or how fast is the camera zooming.
  49382. * A negative number will reverse the axis direction.
  49383. */
  49384. pinchPrecision: number;
  49385. /**
  49386. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49387. * from 0.
  49388. * It defines the percentage of current camera.radius to use as delta when
  49389. * pinch zoom is used.
  49390. */
  49391. pinchDeltaPercentage: number;
  49392. /**
  49393. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  49394. */
  49395. axisXControlRadius: boolean;
  49396. /**
  49397. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  49398. */
  49399. axisXControlHeight: boolean;
  49400. /**
  49401. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  49402. */
  49403. axisXControlRotation: boolean;
  49404. /**
  49405. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  49406. */
  49407. axisYControlRadius: boolean;
  49408. /**
  49409. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  49410. */
  49411. axisYControlHeight: boolean;
  49412. /**
  49413. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  49414. */
  49415. axisYControlRotation: boolean;
  49416. /**
  49417. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  49418. */
  49419. axisPinchControlRadius: boolean;
  49420. /**
  49421. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  49422. */
  49423. axisPinchControlHeight: boolean;
  49424. /**
  49425. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  49426. */
  49427. axisPinchControlRotation: boolean;
  49428. /**
  49429. * Log error messages if basic misconfiguration has occurred.
  49430. */
  49431. warningEnable: boolean;
  49432. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49433. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49434. private _warningCounter;
  49435. private _warning;
  49436. }
  49437. }
  49438. declare module "babylonjs/Cameras/followCameraInputsManager" {
  49439. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49440. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49441. /**
  49442. * Default Inputs manager for the FollowCamera.
  49443. * It groups all the default supported inputs for ease of use.
  49444. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49445. */
  49446. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  49447. /**
  49448. * Instantiates a new FollowCameraInputsManager.
  49449. * @param camera Defines the camera the inputs belong to
  49450. */
  49451. constructor(camera: FollowCamera);
  49452. /**
  49453. * Add keyboard input support to the input manager.
  49454. * @returns the current input manager
  49455. */
  49456. addKeyboard(): FollowCameraInputsManager;
  49457. /**
  49458. * Add mouse wheel input support to the input manager.
  49459. * @returns the current input manager
  49460. */
  49461. addMouseWheel(): FollowCameraInputsManager;
  49462. /**
  49463. * Add pointers input support to the input manager.
  49464. * @returns the current input manager
  49465. */
  49466. addPointers(): FollowCameraInputsManager;
  49467. /**
  49468. * Add orientation input support to the input manager.
  49469. * @returns the current input manager
  49470. */
  49471. addVRDeviceOrientation(): FollowCameraInputsManager;
  49472. }
  49473. }
  49474. declare module "babylonjs/Cameras/followCamera" {
  49475. import { Nullable } from "babylonjs/types";
  49476. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49477. import { Scene } from "babylonjs/scene";
  49478. import { Vector3 } from "babylonjs/Maths/math.vector";
  49479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49480. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  49481. /**
  49482. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  49483. * an arc rotate version arcFollowCamera are available.
  49484. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49485. */
  49486. export class FollowCamera extends TargetCamera {
  49487. /**
  49488. * Distance the follow camera should follow an object at
  49489. */
  49490. radius: number;
  49491. /**
  49492. * Minimum allowed distance of the camera to the axis of rotation
  49493. * (The camera can not get closer).
  49494. * This can help limiting how the Camera is able to move in the scene.
  49495. */
  49496. lowerRadiusLimit: Nullable<number>;
  49497. /**
  49498. * Maximum allowed distance of the camera to the axis of rotation
  49499. * (The camera can not get further).
  49500. * This can help limiting how the Camera is able to move in the scene.
  49501. */
  49502. upperRadiusLimit: Nullable<number>;
  49503. /**
  49504. * Define a rotation offset between the camera and the object it follows
  49505. */
  49506. rotationOffset: number;
  49507. /**
  49508. * Minimum allowed angle to camera position relative to target object.
  49509. * This can help limiting how the Camera is able to move in the scene.
  49510. */
  49511. lowerRotationOffsetLimit: Nullable<number>;
  49512. /**
  49513. * Maximum allowed angle to camera position relative to target object.
  49514. * This can help limiting how the Camera is able to move in the scene.
  49515. */
  49516. upperRotationOffsetLimit: Nullable<number>;
  49517. /**
  49518. * Define a height offset between the camera and the object it follows.
  49519. * It can help following an object from the top (like a car chaing a plane)
  49520. */
  49521. heightOffset: number;
  49522. /**
  49523. * Minimum allowed height of camera position relative to target object.
  49524. * This can help limiting how the Camera is able to move in the scene.
  49525. */
  49526. lowerHeightOffsetLimit: Nullable<number>;
  49527. /**
  49528. * Maximum allowed height of camera position relative to target object.
  49529. * This can help limiting how the Camera is able to move in the scene.
  49530. */
  49531. upperHeightOffsetLimit: Nullable<number>;
  49532. /**
  49533. * Define how fast the camera can accelerate to follow it s target.
  49534. */
  49535. cameraAcceleration: number;
  49536. /**
  49537. * Define the speed limit of the camera following an object.
  49538. */
  49539. maxCameraSpeed: number;
  49540. /**
  49541. * Define the target of the camera.
  49542. */
  49543. lockedTarget: Nullable<AbstractMesh>;
  49544. /**
  49545. * Defines the input associated with the camera.
  49546. */
  49547. inputs: FollowCameraInputsManager;
  49548. /**
  49549. * Instantiates the follow camera.
  49550. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49551. * @param name Define the name of the camera in the scene
  49552. * @param position Define the position of the camera
  49553. * @param scene Define the scene the camera belong to
  49554. * @param lockedTarget Define the target of the camera
  49555. */
  49556. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  49557. private _follow;
  49558. /**
  49559. * Attached controls to the current camera.
  49560. * @param element Defines the element the controls should be listened from
  49561. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49562. */
  49563. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49564. /**
  49565. * Detach the current controls from the camera.
  49566. * The camera will stop reacting to inputs.
  49567. * @param element Defines the element to stop listening the inputs from
  49568. */
  49569. detachControl(element: HTMLElement): void;
  49570. /** @hidden */
  49571. _checkInputs(): void;
  49572. private _checkLimits;
  49573. /**
  49574. * Gets the camera class name.
  49575. * @returns the class name
  49576. */
  49577. getClassName(): string;
  49578. }
  49579. /**
  49580. * Arc Rotate version of the follow camera.
  49581. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  49582. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49583. */
  49584. export class ArcFollowCamera extends TargetCamera {
  49585. /** The longitudinal angle of the camera */
  49586. alpha: number;
  49587. /** The latitudinal angle of the camera */
  49588. beta: number;
  49589. /** The radius of the camera from its target */
  49590. radius: number;
  49591. private _cartesianCoordinates;
  49592. /** Define the camera target (the mesh it should follow) */
  49593. private _meshTarget;
  49594. /**
  49595. * Instantiates a new ArcFollowCamera
  49596. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49597. * @param name Define the name of the camera
  49598. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  49599. * @param beta Define the rotation angle of the camera around the elevation axis
  49600. * @param radius Define the radius of the camera from its target point
  49601. * @param target Define the target of the camera
  49602. * @param scene Define the scene the camera belongs to
  49603. */
  49604. constructor(name: string,
  49605. /** The longitudinal angle of the camera */
  49606. alpha: number,
  49607. /** The latitudinal angle of the camera */
  49608. beta: number,
  49609. /** The radius of the camera from its target */
  49610. radius: number,
  49611. /** Define the camera target (the mesh it should follow) */
  49612. target: Nullable<AbstractMesh>, scene: Scene);
  49613. private _follow;
  49614. /** @hidden */
  49615. _checkInputs(): void;
  49616. /**
  49617. * Returns the class name of the object.
  49618. * It is mostly used internally for serialization purposes.
  49619. */
  49620. getClassName(): string;
  49621. }
  49622. }
  49623. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  49624. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49625. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49626. import { Nullable } from "babylonjs/types";
  49627. /**
  49628. * Manage the keyboard inputs to control the movement of a follow camera.
  49629. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49630. */
  49631. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  49632. /**
  49633. * Defines the camera the input is attached to.
  49634. */
  49635. camera: FollowCamera;
  49636. /**
  49637. * Defines the list of key codes associated with the up action (increase heightOffset)
  49638. */
  49639. keysHeightOffsetIncr: number[];
  49640. /**
  49641. * Defines the list of key codes associated with the down action (decrease heightOffset)
  49642. */
  49643. keysHeightOffsetDecr: number[];
  49644. /**
  49645. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  49646. */
  49647. keysHeightOffsetModifierAlt: boolean;
  49648. /**
  49649. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  49650. */
  49651. keysHeightOffsetModifierCtrl: boolean;
  49652. /**
  49653. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  49654. */
  49655. keysHeightOffsetModifierShift: boolean;
  49656. /**
  49657. * Defines the list of key codes associated with the left action (increase rotationOffset)
  49658. */
  49659. keysRotationOffsetIncr: number[];
  49660. /**
  49661. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  49662. */
  49663. keysRotationOffsetDecr: number[];
  49664. /**
  49665. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  49666. */
  49667. keysRotationOffsetModifierAlt: boolean;
  49668. /**
  49669. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  49670. */
  49671. keysRotationOffsetModifierCtrl: boolean;
  49672. /**
  49673. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  49674. */
  49675. keysRotationOffsetModifierShift: boolean;
  49676. /**
  49677. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  49678. */
  49679. keysRadiusIncr: number[];
  49680. /**
  49681. * Defines the list of key codes associated with the zoom-out action (increase radius)
  49682. */
  49683. keysRadiusDecr: number[];
  49684. /**
  49685. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  49686. */
  49687. keysRadiusModifierAlt: boolean;
  49688. /**
  49689. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  49690. */
  49691. keysRadiusModifierCtrl: boolean;
  49692. /**
  49693. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  49694. */
  49695. keysRadiusModifierShift: boolean;
  49696. /**
  49697. * Defines the rate of change of heightOffset.
  49698. */
  49699. heightSensibility: number;
  49700. /**
  49701. * Defines the rate of change of rotationOffset.
  49702. */
  49703. rotationSensibility: number;
  49704. /**
  49705. * Defines the rate of change of radius.
  49706. */
  49707. radiusSensibility: number;
  49708. private _keys;
  49709. private _ctrlPressed;
  49710. private _altPressed;
  49711. private _shiftPressed;
  49712. private _onCanvasBlurObserver;
  49713. private _onKeyboardObserver;
  49714. private _engine;
  49715. private _scene;
  49716. /**
  49717. * Attach the input controls to a specific dom element to get the input from.
  49718. * @param element Defines the element the controls should be listened from
  49719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49720. */
  49721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49722. /**
  49723. * Detach the current controls from the specified dom element.
  49724. * @param element Defines the element to stop listening the inputs from
  49725. */
  49726. detachControl(element: Nullable<HTMLElement>): void;
  49727. /**
  49728. * Update the current camera state depending on the inputs that have been used this frame.
  49729. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49730. */
  49731. checkInputs(): void;
  49732. /**
  49733. * Gets the class name of the current input.
  49734. * @returns the class name
  49735. */
  49736. getClassName(): string;
  49737. /**
  49738. * Get the friendly name associated with the input class.
  49739. * @returns the input friendly name
  49740. */
  49741. getSimpleName(): string;
  49742. /**
  49743. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49744. * allow modification of the heightOffset value.
  49745. */
  49746. private _modifierHeightOffset;
  49747. /**
  49748. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49749. * allow modification of the rotationOffset value.
  49750. */
  49751. private _modifierRotationOffset;
  49752. /**
  49753. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49754. * allow modification of the radius value.
  49755. */
  49756. private _modifierRadius;
  49757. }
  49758. }
  49759. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  49760. import { Nullable } from "babylonjs/types";
  49761. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49762. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49763. import { Observable } from "babylonjs/Misc/observable";
  49764. module "babylonjs/Cameras/freeCameraInputsManager" {
  49765. interface FreeCameraInputsManager {
  49766. /**
  49767. * @hidden
  49768. */
  49769. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  49770. /**
  49771. * Add orientation input support to the input manager.
  49772. * @returns the current input manager
  49773. */
  49774. addDeviceOrientation(): FreeCameraInputsManager;
  49775. }
  49776. }
  49777. /**
  49778. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  49779. * Screen rotation is taken into account.
  49780. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49781. */
  49782. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  49783. private _camera;
  49784. private _screenOrientationAngle;
  49785. private _constantTranform;
  49786. private _screenQuaternion;
  49787. private _alpha;
  49788. private _beta;
  49789. private _gamma;
  49790. /**
  49791. * Can be used to detect if a device orientation sensor is available on a device
  49792. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  49793. * @returns a promise that will resolve on orientation change
  49794. */
  49795. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  49796. /**
  49797. * @hidden
  49798. */
  49799. _onDeviceOrientationChangedObservable: Observable<void>;
  49800. /**
  49801. * Instantiates a new input
  49802. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49803. */
  49804. constructor();
  49805. /**
  49806. * Define the camera controlled by the input.
  49807. */
  49808. get camera(): FreeCamera;
  49809. set camera(camera: FreeCamera);
  49810. /**
  49811. * Attach the input controls to a specific dom element to get the input from.
  49812. * @param element Defines the element the controls should be listened from
  49813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49814. */
  49815. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49816. private _orientationChanged;
  49817. private _deviceOrientation;
  49818. /**
  49819. * Detach the current controls from the specified dom element.
  49820. * @param element Defines the element to stop listening the inputs from
  49821. */
  49822. detachControl(element: Nullable<HTMLElement>): void;
  49823. /**
  49824. * Update the current camera state depending on the inputs that have been used this frame.
  49825. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49826. */
  49827. checkInputs(): void;
  49828. /**
  49829. * Gets the class name of the current intput.
  49830. * @returns the class name
  49831. */
  49832. getClassName(): string;
  49833. /**
  49834. * Get the friendly name associated with the input class.
  49835. * @returns the input friendly name
  49836. */
  49837. getSimpleName(): string;
  49838. }
  49839. }
  49840. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  49841. import { Nullable } from "babylonjs/types";
  49842. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49843. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49844. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  49845. /**
  49846. * Manage the gamepad inputs to control a free camera.
  49847. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49848. */
  49849. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  49850. /**
  49851. * Define the camera the input is attached to.
  49852. */
  49853. camera: FreeCamera;
  49854. /**
  49855. * Define the Gamepad controlling the input
  49856. */
  49857. gamepad: Nullable<Gamepad>;
  49858. /**
  49859. * Defines the gamepad rotation sensiblity.
  49860. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49861. */
  49862. gamepadAngularSensibility: number;
  49863. /**
  49864. * Defines the gamepad move sensiblity.
  49865. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49866. */
  49867. gamepadMoveSensibility: number;
  49868. private _yAxisScale;
  49869. /**
  49870. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  49871. */
  49872. get invertYAxis(): boolean;
  49873. set invertYAxis(value: boolean);
  49874. private _onGamepadConnectedObserver;
  49875. private _onGamepadDisconnectedObserver;
  49876. private _cameraTransform;
  49877. private _deltaTransform;
  49878. private _vector3;
  49879. private _vector2;
  49880. /**
  49881. * Attach the input controls to a specific dom element to get the input from.
  49882. * @param element Defines the element the controls should be listened from
  49883. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49884. */
  49885. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49886. /**
  49887. * Detach the current controls from the specified dom element.
  49888. * @param element Defines the element to stop listening the inputs from
  49889. */
  49890. detachControl(element: Nullable<HTMLElement>): void;
  49891. /**
  49892. * Update the current camera state depending on the inputs that have been used this frame.
  49893. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49894. */
  49895. checkInputs(): void;
  49896. /**
  49897. * Gets the class name of the current intput.
  49898. * @returns the class name
  49899. */
  49900. getClassName(): string;
  49901. /**
  49902. * Get the friendly name associated with the input class.
  49903. * @returns the input friendly name
  49904. */
  49905. getSimpleName(): string;
  49906. }
  49907. }
  49908. declare module "babylonjs/Misc/virtualJoystick" {
  49909. import { Nullable } from "babylonjs/types";
  49910. import { Vector3 } from "babylonjs/Maths/math.vector";
  49911. /**
  49912. * Defines the potential axis of a Joystick
  49913. */
  49914. export enum JoystickAxis {
  49915. /** X axis */
  49916. X = 0,
  49917. /** Y axis */
  49918. Y = 1,
  49919. /** Z axis */
  49920. Z = 2
  49921. }
  49922. /**
  49923. * Represents the different customization options available
  49924. * for VirtualJoystick
  49925. */
  49926. interface VirtualJoystickCustomizations {
  49927. /**
  49928. * Size of the joystick's puck
  49929. */
  49930. puckSize: number;
  49931. /**
  49932. * Size of the joystick's container
  49933. */
  49934. containerSize: number;
  49935. /**
  49936. * Color of the joystick && puck
  49937. */
  49938. color: string;
  49939. /**
  49940. * Image URL for the joystick's puck
  49941. */
  49942. puckImage?: string;
  49943. /**
  49944. * Image URL for the joystick's container
  49945. */
  49946. containerImage?: string;
  49947. /**
  49948. * Defines the unmoving position of the joystick container
  49949. */
  49950. position?: {
  49951. x: number;
  49952. y: number;
  49953. };
  49954. /**
  49955. * Defines whether or not the joystick container is always visible
  49956. */
  49957. alwaysVisible: boolean;
  49958. /**
  49959. * Defines whether or not to limit the movement of the puck to the joystick's container
  49960. */
  49961. limitToContainer: boolean;
  49962. }
  49963. /**
  49964. * Class used to define virtual joystick (used in touch mode)
  49965. */
  49966. export class VirtualJoystick {
  49967. /**
  49968. * Gets or sets a boolean indicating that left and right values must be inverted
  49969. */
  49970. reverseLeftRight: boolean;
  49971. /**
  49972. * Gets or sets a boolean indicating that up and down values must be inverted
  49973. */
  49974. reverseUpDown: boolean;
  49975. /**
  49976. * Gets the offset value for the position (ie. the change of the position value)
  49977. */
  49978. deltaPosition: Vector3;
  49979. /**
  49980. * Gets a boolean indicating if the virtual joystick was pressed
  49981. */
  49982. pressed: boolean;
  49983. /**
  49984. * Canvas the virtual joystick will render onto, default z-index of this is 5
  49985. */
  49986. static Canvas: Nullable<HTMLCanvasElement>;
  49987. /**
  49988. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  49989. */
  49990. limitToContainer: boolean;
  49991. private static _globalJoystickIndex;
  49992. private static _alwaysVisibleSticks;
  49993. private static vjCanvasContext;
  49994. private static vjCanvasWidth;
  49995. private static vjCanvasHeight;
  49996. private static halfWidth;
  49997. private static _GetDefaultOptions;
  49998. private _action;
  49999. private _axisTargetedByLeftAndRight;
  50000. private _axisTargetedByUpAndDown;
  50001. private _joystickSensibility;
  50002. private _inversedSensibility;
  50003. private _joystickPointerID;
  50004. private _joystickColor;
  50005. private _joystickPointerPos;
  50006. private _joystickPreviousPointerPos;
  50007. private _joystickPointerStartPos;
  50008. private _deltaJoystickVector;
  50009. private _leftJoystick;
  50010. private _touches;
  50011. private _joystickPosition;
  50012. private _alwaysVisible;
  50013. private _puckImage;
  50014. private _containerImage;
  50015. private _joystickPuckSize;
  50016. private _joystickContainerSize;
  50017. private _clearPuckSize;
  50018. private _clearContainerSize;
  50019. private _clearPuckSizeOffset;
  50020. private _clearContainerSizeOffset;
  50021. private _onPointerDownHandlerRef;
  50022. private _onPointerMoveHandlerRef;
  50023. private _onPointerUpHandlerRef;
  50024. private _onResize;
  50025. /**
  50026. * Creates a new virtual joystick
  50027. * @param leftJoystick defines that the joystick is for left hand (false by default)
  50028. * @param customizations Defines the options we want to customize the VirtualJoystick
  50029. */
  50030. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  50031. /**
  50032. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  50033. * @param newJoystickSensibility defines the new sensibility
  50034. */
  50035. setJoystickSensibility(newJoystickSensibility: number): void;
  50036. private _onPointerDown;
  50037. private _onPointerMove;
  50038. private _onPointerUp;
  50039. /**
  50040. * Change the color of the virtual joystick
  50041. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  50042. */
  50043. setJoystickColor(newColor: string): void;
  50044. /**
  50045. * Size of the joystick's container
  50046. */
  50047. set containerSize(newSize: number);
  50048. get containerSize(): number;
  50049. /**
  50050. * Size of the joystick's puck
  50051. */
  50052. set puckSize(newSize: number);
  50053. get puckSize(): number;
  50054. /**
  50055. * Clears the set position of the joystick
  50056. */
  50057. clearPosition(): void;
  50058. /**
  50059. * Defines whether or not the joystick container is always visible
  50060. */
  50061. set alwaysVisible(value: boolean);
  50062. get alwaysVisible(): boolean;
  50063. /**
  50064. * Sets the constant position of the Joystick container
  50065. * @param x X axis coordinate
  50066. * @param y Y axis coordinate
  50067. */
  50068. setPosition(x: number, y: number): void;
  50069. /**
  50070. * Defines a callback to call when the joystick is touched
  50071. * @param action defines the callback
  50072. */
  50073. setActionOnTouch(action: () => any): void;
  50074. /**
  50075. * Defines which axis you'd like to control for left & right
  50076. * @param axis defines the axis to use
  50077. */
  50078. setAxisForLeftRight(axis: JoystickAxis): void;
  50079. /**
  50080. * Defines which axis you'd like to control for up & down
  50081. * @param axis defines the axis to use
  50082. */
  50083. setAxisForUpDown(axis: JoystickAxis): void;
  50084. /**
  50085. * Clears the canvas from the previous puck / container draw
  50086. */
  50087. private _clearPreviousDraw;
  50088. /**
  50089. * Loads `urlPath` to be used for the container's image
  50090. * @param urlPath defines the urlPath of an image to use
  50091. */
  50092. setContainerImage(urlPath: string): void;
  50093. /**
  50094. * Loads `urlPath` to be used for the puck's image
  50095. * @param urlPath defines the urlPath of an image to use
  50096. */
  50097. setPuckImage(urlPath: string): void;
  50098. /**
  50099. * Draws the Virtual Joystick's container
  50100. */
  50101. private _drawContainer;
  50102. /**
  50103. * Draws the Virtual Joystick's puck
  50104. */
  50105. private _drawPuck;
  50106. private _drawVirtualJoystick;
  50107. /**
  50108. * Release internal HTML canvas
  50109. */
  50110. releaseCanvas(): void;
  50111. }
  50112. }
  50113. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  50114. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  50115. import { Nullable } from "babylonjs/types";
  50116. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50117. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50118. module "babylonjs/Cameras/freeCameraInputsManager" {
  50119. interface FreeCameraInputsManager {
  50120. /**
  50121. * Add virtual joystick input support to the input manager.
  50122. * @returns the current input manager
  50123. */
  50124. addVirtualJoystick(): FreeCameraInputsManager;
  50125. }
  50126. }
  50127. /**
  50128. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  50129. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50130. */
  50131. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  50132. /**
  50133. * Defines the camera the input is attached to.
  50134. */
  50135. camera: FreeCamera;
  50136. private _leftjoystick;
  50137. private _rightjoystick;
  50138. /**
  50139. * Gets the left stick of the virtual joystick.
  50140. * @returns The virtual Joystick
  50141. */
  50142. getLeftJoystick(): VirtualJoystick;
  50143. /**
  50144. * Gets the right stick of the virtual joystick.
  50145. * @returns The virtual Joystick
  50146. */
  50147. getRightJoystick(): VirtualJoystick;
  50148. /**
  50149. * Update the current camera state depending on the inputs that have been used this frame.
  50150. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50151. */
  50152. checkInputs(): void;
  50153. /**
  50154. * Attach the input controls to a specific dom element to get the input from.
  50155. * @param element Defines the element the controls should be listened from
  50156. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50157. */
  50158. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  50159. /**
  50160. * Detach the current controls from the specified dom element.
  50161. * @param element Defines the element to stop listening the inputs from
  50162. */
  50163. detachControl(element: Nullable<HTMLElement>): void;
  50164. /**
  50165. * Gets the class name of the current intput.
  50166. * @returns the class name
  50167. */
  50168. getClassName(): string;
  50169. /**
  50170. * Get the friendly name associated with the input class.
  50171. * @returns the input friendly name
  50172. */
  50173. getSimpleName(): string;
  50174. }
  50175. }
  50176. declare module "babylonjs/Cameras/Inputs/index" {
  50177. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  50178. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  50179. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  50180. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  50181. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  50182. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  50183. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  50184. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  50185. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  50186. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  50187. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50188. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  50189. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  50190. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  50191. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  50192. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  50193. }
  50194. declare module "babylonjs/Cameras/touchCamera" {
  50195. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50196. import { Scene } from "babylonjs/scene";
  50197. import { Vector3 } from "babylonjs/Maths/math.vector";
  50198. /**
  50199. * This represents a FPS type of camera controlled by touch.
  50200. * This is like a universal camera minus the Gamepad controls.
  50201. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50202. */
  50203. export class TouchCamera extends FreeCamera {
  50204. /**
  50205. * Defines the touch sensibility for rotation.
  50206. * The higher the faster.
  50207. */
  50208. get touchAngularSensibility(): number;
  50209. set touchAngularSensibility(value: number);
  50210. /**
  50211. * Defines the touch sensibility for move.
  50212. * The higher the faster.
  50213. */
  50214. get touchMoveSensibility(): number;
  50215. set touchMoveSensibility(value: number);
  50216. /**
  50217. * Instantiates a new touch camera.
  50218. * This represents a FPS type of camera controlled by touch.
  50219. * This is like a universal camera minus the Gamepad controls.
  50220. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50221. * @param name Define the name of the camera in the scene
  50222. * @param position Define the start position of the camera in the scene
  50223. * @param scene Define the scene the camera belongs to
  50224. */
  50225. constructor(name: string, position: Vector3, scene: Scene);
  50226. /**
  50227. * Gets the current object class name.
  50228. * @return the class name
  50229. */
  50230. getClassName(): string;
  50231. /** @hidden */
  50232. _setupInputs(): void;
  50233. }
  50234. }
  50235. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  50236. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50237. import { Scene } from "babylonjs/scene";
  50238. import { Vector3 } from "babylonjs/Maths/math.vector";
  50239. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50240. import { Axis } from "babylonjs/Maths/math.axis";
  50241. /**
  50242. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  50243. * being tilted forward or back and left or right.
  50244. */
  50245. export class DeviceOrientationCamera extends FreeCamera {
  50246. private _initialQuaternion;
  50247. private _quaternionCache;
  50248. private _tmpDragQuaternion;
  50249. private _disablePointerInputWhenUsingDeviceOrientation;
  50250. /**
  50251. * Creates a new device orientation camera
  50252. * @param name The name of the camera
  50253. * @param position The start position camera
  50254. * @param scene The scene the camera belongs to
  50255. */
  50256. constructor(name: string, position: Vector3, scene: Scene);
  50257. /**
  50258. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  50259. */
  50260. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  50261. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  50262. private _dragFactor;
  50263. /**
  50264. * Enabled turning on the y axis when the orientation sensor is active
  50265. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  50266. */
  50267. enableHorizontalDragging(dragFactor?: number): void;
  50268. /**
  50269. * Gets the current instance class name ("DeviceOrientationCamera").
  50270. * This helps avoiding instanceof at run time.
  50271. * @returns the class name
  50272. */
  50273. getClassName(): string;
  50274. /**
  50275. * @hidden
  50276. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  50277. */
  50278. _checkInputs(): void;
  50279. /**
  50280. * Reset the camera to its default orientation on the specified axis only.
  50281. * @param axis The axis to reset
  50282. */
  50283. resetToCurrentRotation(axis?: Axis): void;
  50284. }
  50285. }
  50286. declare module "babylonjs/Gamepads/xboxGamepad" {
  50287. import { Observable } from "babylonjs/Misc/observable";
  50288. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50289. /**
  50290. * Defines supported buttons for XBox360 compatible gamepads
  50291. */
  50292. export enum Xbox360Button {
  50293. /** A */
  50294. A = 0,
  50295. /** B */
  50296. B = 1,
  50297. /** X */
  50298. X = 2,
  50299. /** Y */
  50300. Y = 3,
  50301. /** Left button */
  50302. LB = 4,
  50303. /** Right button */
  50304. RB = 5,
  50305. /** Back */
  50306. Back = 8,
  50307. /** Start */
  50308. Start = 9,
  50309. /** Left stick */
  50310. LeftStick = 10,
  50311. /** Right stick */
  50312. RightStick = 11
  50313. }
  50314. /** Defines values for XBox360 DPad */
  50315. export enum Xbox360Dpad {
  50316. /** Up */
  50317. Up = 12,
  50318. /** Down */
  50319. Down = 13,
  50320. /** Left */
  50321. Left = 14,
  50322. /** Right */
  50323. Right = 15
  50324. }
  50325. /**
  50326. * Defines a XBox360 gamepad
  50327. */
  50328. export class Xbox360Pad extends Gamepad {
  50329. private _leftTrigger;
  50330. private _rightTrigger;
  50331. private _onlefttriggerchanged;
  50332. private _onrighttriggerchanged;
  50333. private _onbuttondown;
  50334. private _onbuttonup;
  50335. private _ondpaddown;
  50336. private _ondpadup;
  50337. /** Observable raised when a button is pressed */
  50338. onButtonDownObservable: Observable<Xbox360Button>;
  50339. /** Observable raised when a button is released */
  50340. onButtonUpObservable: Observable<Xbox360Button>;
  50341. /** Observable raised when a pad is pressed */
  50342. onPadDownObservable: Observable<Xbox360Dpad>;
  50343. /** Observable raised when a pad is released */
  50344. onPadUpObservable: Observable<Xbox360Dpad>;
  50345. private _buttonA;
  50346. private _buttonB;
  50347. private _buttonX;
  50348. private _buttonY;
  50349. private _buttonBack;
  50350. private _buttonStart;
  50351. private _buttonLB;
  50352. private _buttonRB;
  50353. private _buttonLeftStick;
  50354. private _buttonRightStick;
  50355. private _dPadUp;
  50356. private _dPadDown;
  50357. private _dPadLeft;
  50358. private _dPadRight;
  50359. private _isXboxOnePad;
  50360. /**
  50361. * Creates a new XBox360 gamepad object
  50362. * @param id defines the id of this gamepad
  50363. * @param index defines its index
  50364. * @param gamepad defines the internal HTML gamepad object
  50365. * @param xboxOne defines if it is a XBox One gamepad
  50366. */
  50367. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  50368. /**
  50369. * Defines the callback to call when left trigger is pressed
  50370. * @param callback defines the callback to use
  50371. */
  50372. onlefttriggerchanged(callback: (value: number) => void): void;
  50373. /**
  50374. * Defines the callback to call when right trigger is pressed
  50375. * @param callback defines the callback to use
  50376. */
  50377. onrighttriggerchanged(callback: (value: number) => void): void;
  50378. /**
  50379. * Gets the left trigger value
  50380. */
  50381. get leftTrigger(): number;
  50382. /**
  50383. * Sets the left trigger value
  50384. */
  50385. set leftTrigger(newValue: number);
  50386. /**
  50387. * Gets the right trigger value
  50388. */
  50389. get rightTrigger(): number;
  50390. /**
  50391. * Sets the right trigger value
  50392. */
  50393. set rightTrigger(newValue: number);
  50394. /**
  50395. * Defines the callback to call when a button is pressed
  50396. * @param callback defines the callback to use
  50397. */
  50398. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  50399. /**
  50400. * Defines the callback to call when a button is released
  50401. * @param callback defines the callback to use
  50402. */
  50403. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  50404. /**
  50405. * Defines the callback to call when a pad is pressed
  50406. * @param callback defines the callback to use
  50407. */
  50408. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  50409. /**
  50410. * Defines the callback to call when a pad is released
  50411. * @param callback defines the callback to use
  50412. */
  50413. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  50414. private _setButtonValue;
  50415. private _setDPadValue;
  50416. /**
  50417. * Gets the value of the `A` button
  50418. */
  50419. get buttonA(): number;
  50420. /**
  50421. * Sets the value of the `A` button
  50422. */
  50423. set buttonA(value: number);
  50424. /**
  50425. * Gets the value of the `B` button
  50426. */
  50427. get buttonB(): number;
  50428. /**
  50429. * Sets the value of the `B` button
  50430. */
  50431. set buttonB(value: number);
  50432. /**
  50433. * Gets the value of the `X` button
  50434. */
  50435. get buttonX(): number;
  50436. /**
  50437. * Sets the value of the `X` button
  50438. */
  50439. set buttonX(value: number);
  50440. /**
  50441. * Gets the value of the `Y` button
  50442. */
  50443. get buttonY(): number;
  50444. /**
  50445. * Sets the value of the `Y` button
  50446. */
  50447. set buttonY(value: number);
  50448. /**
  50449. * Gets the value of the `Start` button
  50450. */
  50451. get buttonStart(): number;
  50452. /**
  50453. * Sets the value of the `Start` button
  50454. */
  50455. set buttonStart(value: number);
  50456. /**
  50457. * Gets the value of the `Back` button
  50458. */
  50459. get buttonBack(): number;
  50460. /**
  50461. * Sets the value of the `Back` button
  50462. */
  50463. set buttonBack(value: number);
  50464. /**
  50465. * Gets the value of the `Left` button
  50466. */
  50467. get buttonLB(): number;
  50468. /**
  50469. * Sets the value of the `Left` button
  50470. */
  50471. set buttonLB(value: number);
  50472. /**
  50473. * Gets the value of the `Right` button
  50474. */
  50475. get buttonRB(): number;
  50476. /**
  50477. * Sets the value of the `Right` button
  50478. */
  50479. set buttonRB(value: number);
  50480. /**
  50481. * Gets the value of the Left joystick
  50482. */
  50483. get buttonLeftStick(): number;
  50484. /**
  50485. * Sets the value of the Left joystick
  50486. */
  50487. set buttonLeftStick(value: number);
  50488. /**
  50489. * Gets the value of the Right joystick
  50490. */
  50491. get buttonRightStick(): number;
  50492. /**
  50493. * Sets the value of the Right joystick
  50494. */
  50495. set buttonRightStick(value: number);
  50496. /**
  50497. * Gets the value of D-pad up
  50498. */
  50499. get dPadUp(): number;
  50500. /**
  50501. * Sets the value of D-pad up
  50502. */
  50503. set dPadUp(value: number);
  50504. /**
  50505. * Gets the value of D-pad down
  50506. */
  50507. get dPadDown(): number;
  50508. /**
  50509. * Sets the value of D-pad down
  50510. */
  50511. set dPadDown(value: number);
  50512. /**
  50513. * Gets the value of D-pad left
  50514. */
  50515. get dPadLeft(): number;
  50516. /**
  50517. * Sets the value of D-pad left
  50518. */
  50519. set dPadLeft(value: number);
  50520. /**
  50521. * Gets the value of D-pad right
  50522. */
  50523. get dPadRight(): number;
  50524. /**
  50525. * Sets the value of D-pad right
  50526. */
  50527. set dPadRight(value: number);
  50528. /**
  50529. * Force the gamepad to synchronize with device values
  50530. */
  50531. update(): void;
  50532. /**
  50533. * Disposes the gamepad
  50534. */
  50535. dispose(): void;
  50536. }
  50537. }
  50538. declare module "babylonjs/Gamepads/dualShockGamepad" {
  50539. import { Observable } from "babylonjs/Misc/observable";
  50540. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50541. /**
  50542. * Defines supported buttons for DualShock compatible gamepads
  50543. */
  50544. export enum DualShockButton {
  50545. /** Cross */
  50546. Cross = 0,
  50547. /** Circle */
  50548. Circle = 1,
  50549. /** Square */
  50550. Square = 2,
  50551. /** Triangle */
  50552. Triangle = 3,
  50553. /** L1 */
  50554. L1 = 4,
  50555. /** R1 */
  50556. R1 = 5,
  50557. /** Share */
  50558. Share = 8,
  50559. /** Options */
  50560. Options = 9,
  50561. /** Left stick */
  50562. LeftStick = 10,
  50563. /** Right stick */
  50564. RightStick = 11
  50565. }
  50566. /** Defines values for DualShock DPad */
  50567. export enum DualShockDpad {
  50568. /** Up */
  50569. Up = 12,
  50570. /** Down */
  50571. Down = 13,
  50572. /** Left */
  50573. Left = 14,
  50574. /** Right */
  50575. Right = 15
  50576. }
  50577. /**
  50578. * Defines a DualShock gamepad
  50579. */
  50580. export class DualShockPad extends Gamepad {
  50581. private _leftTrigger;
  50582. private _rightTrigger;
  50583. private _onlefttriggerchanged;
  50584. private _onrighttriggerchanged;
  50585. private _onbuttondown;
  50586. private _onbuttonup;
  50587. private _ondpaddown;
  50588. private _ondpadup;
  50589. /** Observable raised when a button is pressed */
  50590. onButtonDownObservable: Observable<DualShockButton>;
  50591. /** Observable raised when a button is released */
  50592. onButtonUpObservable: Observable<DualShockButton>;
  50593. /** Observable raised when a pad is pressed */
  50594. onPadDownObservable: Observable<DualShockDpad>;
  50595. /** Observable raised when a pad is released */
  50596. onPadUpObservable: Observable<DualShockDpad>;
  50597. private _buttonCross;
  50598. private _buttonCircle;
  50599. private _buttonSquare;
  50600. private _buttonTriangle;
  50601. private _buttonShare;
  50602. private _buttonOptions;
  50603. private _buttonL1;
  50604. private _buttonR1;
  50605. private _buttonLeftStick;
  50606. private _buttonRightStick;
  50607. private _dPadUp;
  50608. private _dPadDown;
  50609. private _dPadLeft;
  50610. private _dPadRight;
  50611. /**
  50612. * Creates a new DualShock gamepad object
  50613. * @param id defines the id of this gamepad
  50614. * @param index defines its index
  50615. * @param gamepad defines the internal HTML gamepad object
  50616. */
  50617. constructor(id: string, index: number, gamepad: any);
  50618. /**
  50619. * Defines the callback to call when left trigger is pressed
  50620. * @param callback defines the callback to use
  50621. */
  50622. onlefttriggerchanged(callback: (value: number) => void): void;
  50623. /**
  50624. * Defines the callback to call when right trigger is pressed
  50625. * @param callback defines the callback to use
  50626. */
  50627. onrighttriggerchanged(callback: (value: number) => void): void;
  50628. /**
  50629. * Gets the left trigger value
  50630. */
  50631. get leftTrigger(): number;
  50632. /**
  50633. * Sets the left trigger value
  50634. */
  50635. set leftTrigger(newValue: number);
  50636. /**
  50637. * Gets the right trigger value
  50638. */
  50639. get rightTrigger(): number;
  50640. /**
  50641. * Sets the right trigger value
  50642. */
  50643. set rightTrigger(newValue: number);
  50644. /**
  50645. * Defines the callback to call when a button is pressed
  50646. * @param callback defines the callback to use
  50647. */
  50648. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  50649. /**
  50650. * Defines the callback to call when a button is released
  50651. * @param callback defines the callback to use
  50652. */
  50653. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  50654. /**
  50655. * Defines the callback to call when a pad is pressed
  50656. * @param callback defines the callback to use
  50657. */
  50658. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  50659. /**
  50660. * Defines the callback to call when a pad is released
  50661. * @param callback defines the callback to use
  50662. */
  50663. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  50664. private _setButtonValue;
  50665. private _setDPadValue;
  50666. /**
  50667. * Gets the value of the `Cross` button
  50668. */
  50669. get buttonCross(): number;
  50670. /**
  50671. * Sets the value of the `Cross` button
  50672. */
  50673. set buttonCross(value: number);
  50674. /**
  50675. * Gets the value of the `Circle` button
  50676. */
  50677. get buttonCircle(): number;
  50678. /**
  50679. * Sets the value of the `Circle` button
  50680. */
  50681. set buttonCircle(value: number);
  50682. /**
  50683. * Gets the value of the `Square` button
  50684. */
  50685. get buttonSquare(): number;
  50686. /**
  50687. * Sets the value of the `Square` button
  50688. */
  50689. set buttonSquare(value: number);
  50690. /**
  50691. * Gets the value of the `Triangle` button
  50692. */
  50693. get buttonTriangle(): number;
  50694. /**
  50695. * Sets the value of the `Triangle` button
  50696. */
  50697. set buttonTriangle(value: number);
  50698. /**
  50699. * Gets the value of the `Options` button
  50700. */
  50701. get buttonOptions(): number;
  50702. /**
  50703. * Sets the value of the `Options` button
  50704. */
  50705. set buttonOptions(value: number);
  50706. /**
  50707. * Gets the value of the `Share` button
  50708. */
  50709. get buttonShare(): number;
  50710. /**
  50711. * Sets the value of the `Share` button
  50712. */
  50713. set buttonShare(value: number);
  50714. /**
  50715. * Gets the value of the `L1` button
  50716. */
  50717. get buttonL1(): number;
  50718. /**
  50719. * Sets the value of the `L1` button
  50720. */
  50721. set buttonL1(value: number);
  50722. /**
  50723. * Gets the value of the `R1` button
  50724. */
  50725. get buttonR1(): number;
  50726. /**
  50727. * Sets the value of the `R1` button
  50728. */
  50729. set buttonR1(value: number);
  50730. /**
  50731. * Gets the value of the Left joystick
  50732. */
  50733. get buttonLeftStick(): number;
  50734. /**
  50735. * Sets the value of the Left joystick
  50736. */
  50737. set buttonLeftStick(value: number);
  50738. /**
  50739. * Gets the value of the Right joystick
  50740. */
  50741. get buttonRightStick(): number;
  50742. /**
  50743. * Sets the value of the Right joystick
  50744. */
  50745. set buttonRightStick(value: number);
  50746. /**
  50747. * Gets the value of D-pad up
  50748. */
  50749. get dPadUp(): number;
  50750. /**
  50751. * Sets the value of D-pad up
  50752. */
  50753. set dPadUp(value: number);
  50754. /**
  50755. * Gets the value of D-pad down
  50756. */
  50757. get dPadDown(): number;
  50758. /**
  50759. * Sets the value of D-pad down
  50760. */
  50761. set dPadDown(value: number);
  50762. /**
  50763. * Gets the value of D-pad left
  50764. */
  50765. get dPadLeft(): number;
  50766. /**
  50767. * Sets the value of D-pad left
  50768. */
  50769. set dPadLeft(value: number);
  50770. /**
  50771. * Gets the value of D-pad right
  50772. */
  50773. get dPadRight(): number;
  50774. /**
  50775. * Sets the value of D-pad right
  50776. */
  50777. set dPadRight(value: number);
  50778. /**
  50779. * Force the gamepad to synchronize with device values
  50780. */
  50781. update(): void;
  50782. /**
  50783. * Disposes the gamepad
  50784. */
  50785. dispose(): void;
  50786. }
  50787. }
  50788. declare module "babylonjs/Gamepads/gamepadManager" {
  50789. import { Observable } from "babylonjs/Misc/observable";
  50790. import { Nullable } from "babylonjs/types";
  50791. import { Scene } from "babylonjs/scene";
  50792. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50793. /**
  50794. * Manager for handling gamepads
  50795. */
  50796. export class GamepadManager {
  50797. private _scene?;
  50798. private _babylonGamepads;
  50799. private _oneGamepadConnected;
  50800. /** @hidden */
  50801. _isMonitoring: boolean;
  50802. private _gamepadEventSupported;
  50803. private _gamepadSupport?;
  50804. /**
  50805. * observable to be triggered when the gamepad controller has been connected
  50806. */
  50807. onGamepadConnectedObservable: Observable<Gamepad>;
  50808. /**
  50809. * observable to be triggered when the gamepad controller has been disconnected
  50810. */
  50811. onGamepadDisconnectedObservable: Observable<Gamepad>;
  50812. private _onGamepadConnectedEvent;
  50813. private _onGamepadDisconnectedEvent;
  50814. /**
  50815. * Initializes the gamepad manager
  50816. * @param _scene BabylonJS scene
  50817. */
  50818. constructor(_scene?: Scene | undefined);
  50819. /**
  50820. * The gamepads in the game pad manager
  50821. */
  50822. get gamepads(): Gamepad[];
  50823. /**
  50824. * Get the gamepad controllers based on type
  50825. * @param type The type of gamepad controller
  50826. * @returns Nullable gamepad
  50827. */
  50828. getGamepadByType(type?: number): Nullable<Gamepad>;
  50829. /**
  50830. * Disposes the gamepad manager
  50831. */
  50832. dispose(): void;
  50833. private _addNewGamepad;
  50834. private _startMonitoringGamepads;
  50835. private _stopMonitoringGamepads;
  50836. /** @hidden */
  50837. _checkGamepadsStatus(): void;
  50838. private _updateGamepadObjects;
  50839. }
  50840. }
  50841. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  50842. import { Nullable } from "babylonjs/types";
  50843. import { Scene } from "babylonjs/scene";
  50844. import { ISceneComponent } from "babylonjs/sceneComponent";
  50845. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  50846. module "babylonjs/scene" {
  50847. interface Scene {
  50848. /** @hidden */
  50849. _gamepadManager: Nullable<GamepadManager>;
  50850. /**
  50851. * Gets the gamepad manager associated with the scene
  50852. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  50853. */
  50854. gamepadManager: GamepadManager;
  50855. }
  50856. }
  50857. module "babylonjs/Cameras/freeCameraInputsManager" {
  50858. /**
  50859. * Interface representing a free camera inputs manager
  50860. */
  50861. interface FreeCameraInputsManager {
  50862. /**
  50863. * Adds gamepad input support to the FreeCameraInputsManager.
  50864. * @returns the FreeCameraInputsManager
  50865. */
  50866. addGamepad(): FreeCameraInputsManager;
  50867. }
  50868. }
  50869. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  50870. /**
  50871. * Interface representing an arc rotate camera inputs manager
  50872. */
  50873. interface ArcRotateCameraInputsManager {
  50874. /**
  50875. * Adds gamepad input support to the ArcRotateCamera InputManager.
  50876. * @returns the camera inputs manager
  50877. */
  50878. addGamepad(): ArcRotateCameraInputsManager;
  50879. }
  50880. }
  50881. /**
  50882. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  50883. */
  50884. export class GamepadSystemSceneComponent implements ISceneComponent {
  50885. /**
  50886. * The component name helpfull to identify the component in the list of scene components.
  50887. */
  50888. readonly name: string;
  50889. /**
  50890. * The scene the component belongs to.
  50891. */
  50892. scene: Scene;
  50893. /**
  50894. * Creates a new instance of the component for the given scene
  50895. * @param scene Defines the scene to register the component in
  50896. */
  50897. constructor(scene: Scene);
  50898. /**
  50899. * Registers the component in a given scene
  50900. */
  50901. register(): void;
  50902. /**
  50903. * Rebuilds the elements related to this component in case of
  50904. * context lost for instance.
  50905. */
  50906. rebuild(): void;
  50907. /**
  50908. * Disposes the component and the associated ressources
  50909. */
  50910. dispose(): void;
  50911. private _beforeCameraUpdate;
  50912. }
  50913. }
  50914. declare module "babylonjs/Cameras/universalCamera" {
  50915. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  50916. import { Scene } from "babylonjs/scene";
  50917. import { Vector3 } from "babylonjs/Maths/math.vector";
  50918. import "babylonjs/Gamepads/gamepadSceneComponent";
  50919. /**
  50920. * 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,
  50921. * which still works and will still be found in many Playgrounds.
  50922. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50923. */
  50924. export class UniversalCamera extends TouchCamera {
  50925. /**
  50926. * Defines the gamepad rotation sensiblity.
  50927. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50928. */
  50929. get gamepadAngularSensibility(): number;
  50930. set gamepadAngularSensibility(value: number);
  50931. /**
  50932. * Defines the gamepad move sensiblity.
  50933. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50934. */
  50935. get gamepadMoveSensibility(): number;
  50936. set gamepadMoveSensibility(value: number);
  50937. /**
  50938. * 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,
  50939. * which still works and will still be found in many Playgrounds.
  50940. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50941. * @param name Define the name of the camera in the scene
  50942. * @param position Define the start position of the camera in the scene
  50943. * @param scene Define the scene the camera belongs to
  50944. */
  50945. constructor(name: string, position: Vector3, scene: Scene);
  50946. /**
  50947. * Gets the current object class name.
  50948. * @return the class name
  50949. */
  50950. getClassName(): string;
  50951. }
  50952. }
  50953. declare module "babylonjs/Cameras/gamepadCamera" {
  50954. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  50955. import { Scene } from "babylonjs/scene";
  50956. import { Vector3 } from "babylonjs/Maths/math.vector";
  50957. /**
  50958. * This represents a FPS type of camera. This is only here for back compat purpose.
  50959. * Please use the UniversalCamera instead as both are identical.
  50960. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50961. */
  50962. export class GamepadCamera extends UniversalCamera {
  50963. /**
  50964. * Instantiates a new Gamepad Camera
  50965. * This represents a FPS type of camera. This is only here for back compat purpose.
  50966. * Please use the UniversalCamera instead as both are identical.
  50967. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50968. * @param name Define the name of the camera in the scene
  50969. * @param position Define the start position of the camera in the scene
  50970. * @param scene Define the scene the camera belongs to
  50971. */
  50972. constructor(name: string, position: Vector3, scene: Scene);
  50973. /**
  50974. * Gets the current object class name.
  50975. * @return the class name
  50976. */
  50977. getClassName(): string;
  50978. }
  50979. }
  50980. declare module "babylonjs/Shaders/pass.fragment" {
  50981. /** @hidden */
  50982. export var passPixelShader: {
  50983. name: string;
  50984. shader: string;
  50985. };
  50986. }
  50987. declare module "babylonjs/Shaders/passCube.fragment" {
  50988. /** @hidden */
  50989. export var passCubePixelShader: {
  50990. name: string;
  50991. shader: string;
  50992. };
  50993. }
  50994. declare module "babylonjs/PostProcesses/passPostProcess" {
  50995. import { Nullable } from "babylonjs/types";
  50996. import { Camera } from "babylonjs/Cameras/camera";
  50997. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50998. import { Engine } from "babylonjs/Engines/engine";
  50999. import "babylonjs/Shaders/pass.fragment";
  51000. import "babylonjs/Shaders/passCube.fragment";
  51001. import { Scene } from "babylonjs/scene";
  51002. /**
  51003. * PassPostProcess which produces an output the same as it's input
  51004. */
  51005. export class PassPostProcess extends PostProcess {
  51006. /**
  51007. * Gets a string identifying the name of the class
  51008. * @returns "PassPostProcess" string
  51009. */
  51010. getClassName(): string;
  51011. /**
  51012. * Creates the PassPostProcess
  51013. * @param name The name of the effect.
  51014. * @param options The required width/height ratio to downsize to before computing the render pass.
  51015. * @param camera The camera to apply the render pass to.
  51016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51017. * @param engine The engine which the post process will be applied. (default: current engine)
  51018. * @param reusable If the post process can be reused on the same frame. (default: false)
  51019. * @param textureType The type of texture to be used when performing the post processing.
  51020. * @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)
  51021. */
  51022. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51023. /** @hidden */
  51024. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  51025. }
  51026. /**
  51027. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  51028. */
  51029. export class PassCubePostProcess extends PostProcess {
  51030. private _face;
  51031. /**
  51032. * Gets or sets the cube face to display.
  51033. * * 0 is +X
  51034. * * 1 is -X
  51035. * * 2 is +Y
  51036. * * 3 is -Y
  51037. * * 4 is +Z
  51038. * * 5 is -Z
  51039. */
  51040. get face(): number;
  51041. set face(value: number);
  51042. /**
  51043. * Gets a string identifying the name of the class
  51044. * @returns "PassCubePostProcess" string
  51045. */
  51046. getClassName(): string;
  51047. /**
  51048. * Creates the PassCubePostProcess
  51049. * @param name The name of the effect.
  51050. * @param options The required width/height ratio to downsize to before computing the render pass.
  51051. * @param camera The camera to apply the render pass to.
  51052. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51053. * @param engine The engine which the post process will be applied. (default: current engine)
  51054. * @param reusable If the post process can be reused on the same frame. (default: false)
  51055. * @param textureType The type of texture to be used when performing the post processing.
  51056. * @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)
  51057. */
  51058. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51059. /** @hidden */
  51060. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  51061. }
  51062. }
  51063. declare module "babylonjs/Shaders/anaglyph.fragment" {
  51064. /** @hidden */
  51065. export var anaglyphPixelShader: {
  51066. name: string;
  51067. shader: string;
  51068. };
  51069. }
  51070. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  51071. import { Engine } from "babylonjs/Engines/engine";
  51072. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51073. import { Camera } from "babylonjs/Cameras/camera";
  51074. import "babylonjs/Shaders/anaglyph.fragment";
  51075. /**
  51076. * Postprocess used to generate anaglyphic rendering
  51077. */
  51078. export class AnaglyphPostProcess extends PostProcess {
  51079. private _passedProcess;
  51080. /**
  51081. * Gets a string identifying the name of the class
  51082. * @returns "AnaglyphPostProcess" string
  51083. */
  51084. getClassName(): string;
  51085. /**
  51086. * Creates a new AnaglyphPostProcess
  51087. * @param name defines postprocess name
  51088. * @param options defines creation options or target ratio scale
  51089. * @param rigCameras defines cameras using this postprocess
  51090. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  51091. * @param engine defines hosting engine
  51092. * @param reusable defines if the postprocess will be reused multiple times per frame
  51093. */
  51094. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  51095. }
  51096. }
  51097. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  51098. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  51099. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51100. import { Scene } from "babylonjs/scene";
  51101. import { Vector3 } from "babylonjs/Maths/math.vector";
  51102. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51103. /**
  51104. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  51105. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51106. */
  51107. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  51108. /**
  51109. * Creates a new AnaglyphArcRotateCamera
  51110. * @param name defines camera name
  51111. * @param alpha defines alpha angle (in radians)
  51112. * @param beta defines beta angle (in radians)
  51113. * @param radius defines radius
  51114. * @param target defines camera target
  51115. * @param interaxialDistance defines distance between each color axis
  51116. * @param scene defines the hosting scene
  51117. */
  51118. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  51119. /**
  51120. * Gets camera class name
  51121. * @returns AnaglyphArcRotateCamera
  51122. */
  51123. getClassName(): string;
  51124. }
  51125. }
  51126. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  51127. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51128. import { Scene } from "babylonjs/scene";
  51129. import { Vector3 } from "babylonjs/Maths/math.vector";
  51130. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51131. /**
  51132. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  51133. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51134. */
  51135. export class AnaglyphFreeCamera extends FreeCamera {
  51136. /**
  51137. * Creates a new AnaglyphFreeCamera
  51138. * @param name defines camera name
  51139. * @param position defines initial position
  51140. * @param interaxialDistance defines distance between each color axis
  51141. * @param scene defines the hosting scene
  51142. */
  51143. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51144. /**
  51145. * Gets camera class name
  51146. * @returns AnaglyphFreeCamera
  51147. */
  51148. getClassName(): string;
  51149. }
  51150. }
  51151. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  51152. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51153. import { Scene } from "babylonjs/scene";
  51154. import { Vector3 } from "babylonjs/Maths/math.vector";
  51155. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51156. /**
  51157. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  51158. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51159. */
  51160. export class AnaglyphGamepadCamera extends GamepadCamera {
  51161. /**
  51162. * Creates a new AnaglyphGamepadCamera
  51163. * @param name defines camera name
  51164. * @param position defines initial position
  51165. * @param interaxialDistance defines distance between each color axis
  51166. * @param scene defines the hosting scene
  51167. */
  51168. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51169. /**
  51170. * Gets camera class name
  51171. * @returns AnaglyphGamepadCamera
  51172. */
  51173. getClassName(): string;
  51174. }
  51175. }
  51176. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  51177. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51178. import { Scene } from "babylonjs/scene";
  51179. import { Vector3 } from "babylonjs/Maths/math.vector";
  51180. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51181. /**
  51182. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  51183. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51184. */
  51185. export class AnaglyphUniversalCamera extends UniversalCamera {
  51186. /**
  51187. * Creates a new AnaglyphUniversalCamera
  51188. * @param name defines camera name
  51189. * @param position defines initial position
  51190. * @param interaxialDistance defines distance between each color axis
  51191. * @param scene defines the hosting scene
  51192. */
  51193. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51194. /**
  51195. * Gets camera class name
  51196. * @returns AnaglyphUniversalCamera
  51197. */
  51198. getClassName(): string;
  51199. }
  51200. }
  51201. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  51202. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  51203. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51204. import { Scene } from "babylonjs/scene";
  51205. import { Vector3 } from "babylonjs/Maths/math.vector";
  51206. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51207. /**
  51208. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  51209. * @see https://doc.babylonjs.com/features/cameras
  51210. */
  51211. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  51212. /**
  51213. * Creates a new StereoscopicArcRotateCamera
  51214. * @param name defines camera name
  51215. * @param alpha defines alpha angle (in radians)
  51216. * @param beta defines beta angle (in radians)
  51217. * @param radius defines radius
  51218. * @param target defines camera target
  51219. * @param interaxialDistance defines distance between each color axis
  51220. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51221. * @param scene defines the hosting scene
  51222. */
  51223. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51224. /**
  51225. * Gets camera class name
  51226. * @returns StereoscopicArcRotateCamera
  51227. */
  51228. getClassName(): string;
  51229. }
  51230. }
  51231. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  51232. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51233. import { Scene } from "babylonjs/scene";
  51234. import { Vector3 } from "babylonjs/Maths/math.vector";
  51235. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51236. /**
  51237. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  51238. * @see https://doc.babylonjs.com/features/cameras
  51239. */
  51240. export class StereoscopicFreeCamera extends FreeCamera {
  51241. /**
  51242. * Creates a new StereoscopicFreeCamera
  51243. * @param name defines camera name
  51244. * @param position defines initial position
  51245. * @param interaxialDistance defines distance between each color axis
  51246. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51247. * @param scene defines the hosting scene
  51248. */
  51249. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51250. /**
  51251. * Gets camera class name
  51252. * @returns StereoscopicFreeCamera
  51253. */
  51254. getClassName(): string;
  51255. }
  51256. }
  51257. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  51258. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51259. import { Scene } from "babylonjs/scene";
  51260. import { Vector3 } from "babylonjs/Maths/math.vector";
  51261. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51262. /**
  51263. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  51264. * @see https://doc.babylonjs.com/features/cameras
  51265. */
  51266. export class StereoscopicGamepadCamera extends GamepadCamera {
  51267. /**
  51268. * Creates a new StereoscopicGamepadCamera
  51269. * @param name defines camera name
  51270. * @param position defines initial position
  51271. * @param interaxialDistance defines distance between each color axis
  51272. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51273. * @param scene defines the hosting scene
  51274. */
  51275. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51276. /**
  51277. * Gets camera class name
  51278. * @returns StereoscopicGamepadCamera
  51279. */
  51280. getClassName(): string;
  51281. }
  51282. }
  51283. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  51284. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51285. import { Scene } from "babylonjs/scene";
  51286. import { Vector3 } from "babylonjs/Maths/math.vector";
  51287. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51288. /**
  51289. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  51290. * @see https://doc.babylonjs.com/features/cameras
  51291. */
  51292. export class StereoscopicUniversalCamera extends UniversalCamera {
  51293. /**
  51294. * Creates a new StereoscopicUniversalCamera
  51295. * @param name defines camera name
  51296. * @param position defines initial position
  51297. * @param interaxialDistance defines distance between each color axis
  51298. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51299. * @param scene defines the hosting scene
  51300. */
  51301. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51302. /**
  51303. * Gets camera class name
  51304. * @returns StereoscopicUniversalCamera
  51305. */
  51306. getClassName(): string;
  51307. }
  51308. }
  51309. declare module "babylonjs/Cameras/Stereoscopic/index" {
  51310. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  51311. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  51312. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  51313. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  51314. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  51315. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  51316. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  51317. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  51318. }
  51319. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  51320. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51321. import { Scene } from "babylonjs/scene";
  51322. import { Vector3 } from "babylonjs/Maths/math.vector";
  51323. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  51324. /**
  51325. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  51326. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51327. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51328. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51329. */
  51330. export class VirtualJoysticksCamera extends FreeCamera {
  51331. /**
  51332. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  51333. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51334. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51335. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51336. * @param name Define the name of the camera in the scene
  51337. * @param position Define the start position of the camera in the scene
  51338. * @param scene Define the scene the camera belongs to
  51339. */
  51340. constructor(name: string, position: Vector3, scene: Scene);
  51341. /**
  51342. * Gets the current object class name.
  51343. * @return the class name
  51344. */
  51345. getClassName(): string;
  51346. }
  51347. }
  51348. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  51349. import { Matrix } from "babylonjs/Maths/math.vector";
  51350. /**
  51351. * This represents all the required metrics to create a VR camera.
  51352. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  51353. */
  51354. export class VRCameraMetrics {
  51355. /**
  51356. * Define the horizontal resolution off the screen.
  51357. */
  51358. hResolution: number;
  51359. /**
  51360. * Define the vertical resolution off the screen.
  51361. */
  51362. vResolution: number;
  51363. /**
  51364. * Define the horizontal screen size.
  51365. */
  51366. hScreenSize: number;
  51367. /**
  51368. * Define the vertical screen size.
  51369. */
  51370. vScreenSize: number;
  51371. /**
  51372. * Define the vertical screen center position.
  51373. */
  51374. vScreenCenter: number;
  51375. /**
  51376. * Define the distance of the eyes to the screen.
  51377. */
  51378. eyeToScreenDistance: number;
  51379. /**
  51380. * Define the distance between both lenses
  51381. */
  51382. lensSeparationDistance: number;
  51383. /**
  51384. * Define the distance between both viewer's eyes.
  51385. */
  51386. interpupillaryDistance: number;
  51387. /**
  51388. * Define the distortion factor of the VR postprocess.
  51389. * Please, touch with care.
  51390. */
  51391. distortionK: number[];
  51392. /**
  51393. * Define the chromatic aberration correction factors for the VR post process.
  51394. */
  51395. chromaAbCorrection: number[];
  51396. /**
  51397. * Define the scale factor of the post process.
  51398. * The smaller the better but the slower.
  51399. */
  51400. postProcessScaleFactor: number;
  51401. /**
  51402. * Define an offset for the lens center.
  51403. */
  51404. lensCenterOffset: number;
  51405. /**
  51406. * Define if the current vr camera should compensate the distortion of the lense or not.
  51407. */
  51408. compensateDistortion: boolean;
  51409. /**
  51410. * Defines if multiview should be enabled when rendering (Default: false)
  51411. */
  51412. multiviewEnabled: boolean;
  51413. /**
  51414. * Gets the rendering aspect ratio based on the provided resolutions.
  51415. */
  51416. get aspectRatio(): number;
  51417. /**
  51418. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  51419. */
  51420. get aspectRatioFov(): number;
  51421. /**
  51422. * @hidden
  51423. */
  51424. get leftHMatrix(): Matrix;
  51425. /**
  51426. * @hidden
  51427. */
  51428. get rightHMatrix(): Matrix;
  51429. /**
  51430. * @hidden
  51431. */
  51432. get leftPreViewMatrix(): Matrix;
  51433. /**
  51434. * @hidden
  51435. */
  51436. get rightPreViewMatrix(): Matrix;
  51437. /**
  51438. * Get the default VRMetrics based on the most generic setup.
  51439. * @returns the default vr metrics
  51440. */
  51441. static GetDefault(): VRCameraMetrics;
  51442. }
  51443. }
  51444. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  51445. /** @hidden */
  51446. export var vrDistortionCorrectionPixelShader: {
  51447. name: string;
  51448. shader: string;
  51449. };
  51450. }
  51451. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  51452. import { Camera } from "babylonjs/Cameras/camera";
  51453. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51454. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51455. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  51456. /**
  51457. * VRDistortionCorrectionPostProcess used for mobile VR
  51458. */
  51459. export class VRDistortionCorrectionPostProcess extends PostProcess {
  51460. private _isRightEye;
  51461. private _distortionFactors;
  51462. private _postProcessScaleFactor;
  51463. private _lensCenterOffset;
  51464. private _scaleIn;
  51465. private _scaleFactor;
  51466. private _lensCenter;
  51467. /**
  51468. * Gets a string identifying the name of the class
  51469. * @returns "VRDistortionCorrectionPostProcess" string
  51470. */
  51471. getClassName(): string;
  51472. /**
  51473. * Initializes the VRDistortionCorrectionPostProcess
  51474. * @param name The name of the effect.
  51475. * @param camera The camera to apply the render pass to.
  51476. * @param isRightEye If this is for the right eye distortion
  51477. * @param vrMetrics All the required metrics for the VR camera
  51478. */
  51479. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  51480. }
  51481. }
  51482. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  51483. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  51484. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51485. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51486. import { Scene } from "babylonjs/scene";
  51487. import { Vector3 } from "babylonjs/Maths/math.vector";
  51488. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  51489. import "babylonjs/Cameras/RigModes/vrRigMode";
  51490. /**
  51491. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  51492. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51493. */
  51494. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  51495. /**
  51496. * Creates a new VRDeviceOrientationArcRotateCamera
  51497. * @param name defines camera name
  51498. * @param alpha defines the camera rotation along the logitudinal axis
  51499. * @param beta defines the camera rotation along the latitudinal axis
  51500. * @param radius defines the camera distance from its target
  51501. * @param target defines the camera target
  51502. * @param scene defines the scene the camera belongs to
  51503. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51504. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51505. */
  51506. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51507. /**
  51508. * Gets camera class name
  51509. * @returns VRDeviceOrientationArcRotateCamera
  51510. */
  51511. getClassName(): string;
  51512. }
  51513. }
  51514. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  51515. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51516. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51517. import { Scene } from "babylonjs/scene";
  51518. import { Vector3 } from "babylonjs/Maths/math.vector";
  51519. import "babylonjs/Cameras/RigModes/vrRigMode";
  51520. /**
  51521. * Camera used to simulate VR rendering (based on FreeCamera)
  51522. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51523. */
  51524. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  51525. /**
  51526. * Creates a new VRDeviceOrientationFreeCamera
  51527. * @param name defines camera name
  51528. * @param position defines the start position of the camera
  51529. * @param scene defines the scene the camera belongs to
  51530. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51531. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51532. */
  51533. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51534. /**
  51535. * Gets camera class name
  51536. * @returns VRDeviceOrientationFreeCamera
  51537. */
  51538. getClassName(): string;
  51539. }
  51540. }
  51541. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  51542. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51543. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51544. import { Scene } from "babylonjs/scene";
  51545. import { Vector3 } from "babylonjs/Maths/math.vector";
  51546. import "babylonjs/Gamepads/gamepadSceneComponent";
  51547. /**
  51548. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  51549. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51550. */
  51551. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  51552. /**
  51553. * Creates a new VRDeviceOrientationGamepadCamera
  51554. * @param name defines camera name
  51555. * @param position defines the start position of the camera
  51556. * @param scene defines the scene the camera belongs to
  51557. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51558. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51559. */
  51560. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51561. /**
  51562. * Gets camera class name
  51563. * @returns VRDeviceOrientationGamepadCamera
  51564. */
  51565. getClassName(): string;
  51566. }
  51567. }
  51568. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  51569. import { Scene } from "babylonjs/scene";
  51570. import { Texture } from "babylonjs/Materials/Textures/texture";
  51571. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  51572. /**
  51573. * A class extending Texture allowing drawing on a texture
  51574. * @see https://doc.babylonjs.com/how_to/dynamictexture
  51575. */
  51576. export class DynamicTexture extends Texture {
  51577. private _generateMipMaps;
  51578. private _canvas;
  51579. private _context;
  51580. /**
  51581. * Creates a DynamicTexture
  51582. * @param name defines the name of the texture
  51583. * @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
  51584. * @param scene defines the scene where you want the texture
  51585. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  51586. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51587. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  51588. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  51589. */
  51590. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  51591. /**
  51592. * Get the current class name of the texture useful for serialization or dynamic coding.
  51593. * @returns "DynamicTexture"
  51594. */
  51595. getClassName(): string;
  51596. /**
  51597. * Gets the current state of canRescale
  51598. */
  51599. get canRescale(): boolean;
  51600. private _recreate;
  51601. /**
  51602. * Scales the texture
  51603. * @param ratio the scale factor to apply to both width and height
  51604. */
  51605. scale(ratio: number): void;
  51606. /**
  51607. * Resizes the texture
  51608. * @param width the new width
  51609. * @param height the new height
  51610. */
  51611. scaleTo(width: number, height: number): void;
  51612. /**
  51613. * Gets the context of the canvas used by the texture
  51614. * @returns the canvas context of the dynamic texture
  51615. */
  51616. getContext(): CanvasRenderingContext2D;
  51617. /**
  51618. * Clears the texture
  51619. */
  51620. clear(): void;
  51621. /**
  51622. * Updates the texture
  51623. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51624. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  51625. */
  51626. update(invertY?: boolean, premulAlpha?: boolean): void;
  51627. /**
  51628. * Draws text onto the texture
  51629. * @param text defines the text to be drawn
  51630. * @param x defines the placement of the text from the left
  51631. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  51632. * @param font defines the font to be used with font-style, font-size, font-name
  51633. * @param color defines the color used for the text
  51634. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  51635. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51636. * @param update defines whether texture is immediately update (default is true)
  51637. */
  51638. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  51639. /**
  51640. * Clones the texture
  51641. * @returns the clone of the texture.
  51642. */
  51643. clone(): DynamicTexture;
  51644. /**
  51645. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  51646. * @returns a serialized dynamic texture object
  51647. */
  51648. serialize(): any;
  51649. private _IsCanvasElement;
  51650. /** @hidden */
  51651. _rebuild(): void;
  51652. }
  51653. }
  51654. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  51655. import { Scene } from "babylonjs/scene";
  51656. import { Color3 } from "babylonjs/Maths/math.color";
  51657. import { Mesh } from "babylonjs/Meshes/mesh";
  51658. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  51659. import { Nullable } from "babylonjs/types";
  51660. /**
  51661. * Class containing static functions to help procedurally build meshes
  51662. */
  51663. export class GroundBuilder {
  51664. /**
  51665. * Creates a ground mesh
  51666. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51667. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51669. * @param name defines the name of the mesh
  51670. * @param options defines the options used to create the mesh
  51671. * @param scene defines the hosting scene
  51672. * @returns the ground mesh
  51673. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51674. */
  51675. static CreateGround(name: string, options: {
  51676. width?: number;
  51677. height?: number;
  51678. subdivisions?: number;
  51679. subdivisionsX?: number;
  51680. subdivisionsY?: number;
  51681. updatable?: boolean;
  51682. }, scene: any): Mesh;
  51683. /**
  51684. * Creates a tiled ground mesh
  51685. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51686. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51687. * * 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
  51688. * * 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
  51689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51690. * @param name defines the name of the mesh
  51691. * @param options defines the options used to create the mesh
  51692. * @param scene defines the hosting scene
  51693. * @returns the tiled ground mesh
  51694. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51695. */
  51696. static CreateTiledGround(name: string, options: {
  51697. xmin: number;
  51698. zmin: number;
  51699. xmax: number;
  51700. zmax: number;
  51701. subdivisions?: {
  51702. w: number;
  51703. h: number;
  51704. };
  51705. precision?: {
  51706. w: number;
  51707. h: number;
  51708. };
  51709. updatable?: boolean;
  51710. }, scene?: Nullable<Scene>): Mesh;
  51711. /**
  51712. * Creates a ground mesh from a height map
  51713. * * The parameter `url` sets the URL of the height map image resource.
  51714. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51715. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51716. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51717. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51718. * * 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.
  51719. * * 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).
  51720. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51722. * @param name defines the name of the mesh
  51723. * @param url defines the url to the height map
  51724. * @param options defines the options used to create the mesh
  51725. * @param scene defines the hosting scene
  51726. * @returns the ground mesh
  51727. * @see https://doc.babylonjs.com/babylon101/height_map
  51728. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51729. */
  51730. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51731. width?: number;
  51732. height?: number;
  51733. subdivisions?: number;
  51734. minHeight?: number;
  51735. maxHeight?: number;
  51736. colorFilter?: Color3;
  51737. alphaFilter?: number;
  51738. updatable?: boolean;
  51739. onReady?: (mesh: GroundMesh) => void;
  51740. }, scene?: Nullable<Scene>): GroundMesh;
  51741. }
  51742. }
  51743. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  51744. import { Vector4 } from "babylonjs/Maths/math.vector";
  51745. import { Mesh } from "babylonjs/Meshes/mesh";
  51746. /**
  51747. * Class containing static functions to help procedurally build meshes
  51748. */
  51749. export class TorusBuilder {
  51750. /**
  51751. * Creates a torus mesh
  51752. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51753. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51754. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51755. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51756. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51758. * @param name defines the name of the mesh
  51759. * @param options defines the options used to create the mesh
  51760. * @param scene defines the hosting scene
  51761. * @returns the torus mesh
  51762. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51763. */
  51764. static CreateTorus(name: string, options: {
  51765. diameter?: number;
  51766. thickness?: number;
  51767. tessellation?: number;
  51768. updatable?: boolean;
  51769. sideOrientation?: number;
  51770. frontUVs?: Vector4;
  51771. backUVs?: Vector4;
  51772. }, scene: any): Mesh;
  51773. }
  51774. }
  51775. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  51776. import { Vector4 } from "babylonjs/Maths/math.vector";
  51777. import { Color4 } from "babylonjs/Maths/math.color";
  51778. import { Mesh } from "babylonjs/Meshes/mesh";
  51779. /**
  51780. * Class containing static functions to help procedurally build meshes
  51781. */
  51782. export class CylinderBuilder {
  51783. /**
  51784. * Creates a cylinder or a cone mesh
  51785. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  51786. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  51787. * * 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.
  51788. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  51789. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  51790. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  51791. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  51792. * * 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).
  51793. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  51794. * * 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).
  51795. * * 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
  51796. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  51797. * * 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
  51798. * * 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.
  51799. * * If `enclose` is false, a ring surface is one element.
  51800. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  51801. * * 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
  51802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51803. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51805. * @param name defines the name of the mesh
  51806. * @param options defines the options used to create the mesh
  51807. * @param scene defines the hosting scene
  51808. * @returns the cylinder mesh
  51809. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  51810. */
  51811. static CreateCylinder(name: string, options: {
  51812. height?: number;
  51813. diameterTop?: number;
  51814. diameterBottom?: number;
  51815. diameter?: number;
  51816. tessellation?: number;
  51817. subdivisions?: number;
  51818. arc?: number;
  51819. faceColors?: Color4[];
  51820. faceUV?: Vector4[];
  51821. updatable?: boolean;
  51822. hasRings?: boolean;
  51823. enclose?: boolean;
  51824. cap?: number;
  51825. sideOrientation?: number;
  51826. frontUVs?: Vector4;
  51827. backUVs?: Vector4;
  51828. }, scene: any): Mesh;
  51829. }
  51830. }
  51831. declare module "babylonjs/XR/webXRTypes" {
  51832. import { Nullable } from "babylonjs/types";
  51833. import { IDisposable } from "babylonjs/scene";
  51834. /**
  51835. * States of the webXR experience
  51836. */
  51837. export enum WebXRState {
  51838. /**
  51839. * Transitioning to being in XR mode
  51840. */
  51841. ENTERING_XR = 0,
  51842. /**
  51843. * Transitioning to non XR mode
  51844. */
  51845. EXITING_XR = 1,
  51846. /**
  51847. * In XR mode and presenting
  51848. */
  51849. IN_XR = 2,
  51850. /**
  51851. * Not entered XR mode
  51852. */
  51853. NOT_IN_XR = 3
  51854. }
  51855. /**
  51856. * The state of the XR camera's tracking
  51857. */
  51858. export enum WebXRTrackingState {
  51859. /**
  51860. * No transformation received, device is not being tracked
  51861. */
  51862. NOT_TRACKING = 0,
  51863. /**
  51864. * Tracking lost - using emulated position
  51865. */
  51866. TRACKING_LOST = 1,
  51867. /**
  51868. * Transformation tracking works normally
  51869. */
  51870. TRACKING = 2
  51871. }
  51872. /**
  51873. * Abstraction of the XR render target
  51874. */
  51875. export interface WebXRRenderTarget extends IDisposable {
  51876. /**
  51877. * xrpresent context of the canvas which can be used to display/mirror xr content
  51878. */
  51879. canvasContext: WebGLRenderingContext;
  51880. /**
  51881. * xr layer for the canvas
  51882. */
  51883. xrLayer: Nullable<XRWebGLLayer>;
  51884. /**
  51885. * Initializes the xr layer for the session
  51886. * @param xrSession xr session
  51887. * @returns a promise that will resolve once the XR Layer has been created
  51888. */
  51889. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  51890. }
  51891. }
  51892. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  51893. import { Nullable } from "babylonjs/types";
  51894. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51895. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51896. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51897. import { Observable } from "babylonjs/Misc/observable";
  51898. /**
  51899. * COnfiguration object for WebXR output canvas
  51900. */
  51901. export class WebXRManagedOutputCanvasOptions {
  51902. /**
  51903. * An optional canvas in case you wish to create it yourself and provide it here.
  51904. * If not provided, a new canvas will be created
  51905. */
  51906. canvasElement?: HTMLCanvasElement;
  51907. /**
  51908. * Options for this XR Layer output
  51909. */
  51910. canvasOptions?: XRWebGLLayerOptions;
  51911. /**
  51912. * CSS styling for a newly created canvas (if not provided)
  51913. */
  51914. newCanvasCssStyle?: string;
  51915. /**
  51916. * Get the default values of the configuration object
  51917. * @param engine defines the engine to use (can be null)
  51918. * @returns default values of this configuration object
  51919. */
  51920. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  51921. }
  51922. /**
  51923. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  51924. */
  51925. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  51926. private _options;
  51927. private _canvas;
  51928. private _engine;
  51929. private _originalCanvasSize;
  51930. /**
  51931. * Rendering context of the canvas which can be used to display/mirror xr content
  51932. */
  51933. canvasContext: WebGLRenderingContext;
  51934. /**
  51935. * xr layer for the canvas
  51936. */
  51937. xrLayer: Nullable<XRWebGLLayer>;
  51938. /**
  51939. * Obseervers registered here will be triggered when the xr layer was initialized
  51940. */
  51941. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  51942. /**
  51943. * Initializes the canvas to be added/removed upon entering/exiting xr
  51944. * @param _xrSessionManager The XR Session manager
  51945. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  51946. */
  51947. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  51948. /**
  51949. * Disposes of the object
  51950. */
  51951. dispose(): void;
  51952. /**
  51953. * Initializes the xr layer for the session
  51954. * @param xrSession xr session
  51955. * @returns a promise that will resolve once the XR Layer has been created
  51956. */
  51957. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  51958. private _addCanvas;
  51959. private _removeCanvas;
  51960. private _setCanvasSize;
  51961. private _setManagedOutputCanvas;
  51962. }
  51963. }
  51964. declare module "babylonjs/XR/webXRSessionManager" {
  51965. import { Observable } from "babylonjs/Misc/observable";
  51966. import { Nullable } from "babylonjs/types";
  51967. import { IDisposable, Scene } from "babylonjs/scene";
  51968. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51969. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51970. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51971. /**
  51972. * Manages an XRSession to work with Babylon's engine
  51973. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  51974. */
  51975. export class WebXRSessionManager implements IDisposable {
  51976. /** The scene which the session should be created for */
  51977. scene: Scene;
  51978. private _referenceSpace;
  51979. private _rttProvider;
  51980. private _sessionEnded;
  51981. private _xrNavigator;
  51982. private baseLayer;
  51983. /**
  51984. * The base reference space from which the session started. good if you want to reset your
  51985. * reference space
  51986. */
  51987. baseReferenceSpace: XRReferenceSpace;
  51988. /**
  51989. * Current XR frame
  51990. */
  51991. currentFrame: Nullable<XRFrame>;
  51992. /** WebXR timestamp updated every frame */
  51993. currentTimestamp: number;
  51994. /**
  51995. * Used just in case of a failure to initialize an immersive session.
  51996. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  51997. */
  51998. defaultHeightCompensation: number;
  51999. /**
  52000. * Fires every time a new xrFrame arrives which can be used to update the camera
  52001. */
  52002. onXRFrameObservable: Observable<XRFrame>;
  52003. /**
  52004. * Fires when the reference space changed
  52005. */
  52006. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  52007. /**
  52008. * Fires when the xr session is ended either by the device or manually done
  52009. */
  52010. onXRSessionEnded: Observable<any>;
  52011. /**
  52012. * Fires when the xr session is ended either by the device or manually done
  52013. */
  52014. onXRSessionInit: Observable<XRSession>;
  52015. /**
  52016. * Underlying xr session
  52017. */
  52018. session: XRSession;
  52019. /**
  52020. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  52021. * or get the offset the player is currently at.
  52022. */
  52023. viewerReferenceSpace: XRReferenceSpace;
  52024. /**
  52025. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  52026. * @param scene The scene which the session should be created for
  52027. */
  52028. constructor(
  52029. /** The scene which the session should be created for */
  52030. scene: Scene);
  52031. /**
  52032. * The current reference space used in this session. This reference space can constantly change!
  52033. * It is mainly used to offset the camera's position.
  52034. */
  52035. get referenceSpace(): XRReferenceSpace;
  52036. /**
  52037. * Set a new reference space and triggers the observable
  52038. */
  52039. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  52040. /**
  52041. * Disposes of the session manager
  52042. */
  52043. dispose(): void;
  52044. /**
  52045. * Stops the xrSession and restores the render loop
  52046. * @returns Promise which resolves after it exits XR
  52047. */
  52048. exitXRAsync(): Promise<void>;
  52049. /**
  52050. * Gets the correct render target texture to be rendered this frame for this eye
  52051. * @param eye the eye for which to get the render target
  52052. * @returns the render target for the specified eye
  52053. */
  52054. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  52055. /**
  52056. * Creates a WebXRRenderTarget object for the XR session
  52057. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  52058. * @param options optional options to provide when creating a new render target
  52059. * @returns a WebXR render target to which the session can render
  52060. */
  52061. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  52062. /**
  52063. * Initializes the manager
  52064. * After initialization enterXR can be called to start an XR session
  52065. * @returns Promise which resolves after it is initialized
  52066. */
  52067. initializeAsync(): Promise<void>;
  52068. /**
  52069. * Initializes an xr session
  52070. * @param xrSessionMode mode to initialize
  52071. * @param xrSessionInit defines optional and required values to pass to the session builder
  52072. * @returns a promise which will resolve once the session has been initialized
  52073. */
  52074. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  52075. /**
  52076. * Checks if a session would be supported for the creation options specified
  52077. * @param sessionMode session mode to check if supported eg. immersive-vr
  52078. * @returns A Promise that resolves to true if supported and false if not
  52079. */
  52080. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52081. /**
  52082. * Resets the reference space to the one started the session
  52083. */
  52084. resetReferenceSpace(): void;
  52085. /**
  52086. * Starts rendering to the xr layer
  52087. */
  52088. runXRRenderLoop(): void;
  52089. /**
  52090. * Sets the reference space on the xr session
  52091. * @param referenceSpaceType space to set
  52092. * @returns a promise that will resolve once the reference space has been set
  52093. */
  52094. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  52095. /**
  52096. * Updates the render state of the session
  52097. * @param state state to set
  52098. * @returns a promise that resolves once the render state has been updated
  52099. */
  52100. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  52101. /**
  52102. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  52103. * @param sessionMode defines the session to test
  52104. * @returns a promise with boolean as final value
  52105. */
  52106. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52107. private _createRenderTargetTexture;
  52108. }
  52109. }
  52110. declare module "babylonjs/XR/webXRCamera" {
  52111. import { Vector3 } from "babylonjs/Maths/math.vector";
  52112. import { Scene } from "babylonjs/scene";
  52113. import { Camera } from "babylonjs/Cameras/camera";
  52114. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  52115. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52116. import { Observable } from "babylonjs/Misc/observable";
  52117. import { WebXRTrackingState } from "babylonjs/XR/webXRTypes";
  52118. /**
  52119. * WebXR Camera which holds the views for the xrSession
  52120. * @see https://doc.babylonjs.com/how_to/webxr_camera
  52121. */
  52122. export class WebXRCamera extends FreeCamera {
  52123. private _xrSessionManager;
  52124. private _firstFrame;
  52125. private _referenceQuaternion;
  52126. private _referencedPosition;
  52127. private _xrInvPositionCache;
  52128. private _xrInvQuaternionCache;
  52129. private _trackingState;
  52130. /**
  52131. * Observable raised before camera teleportation
  52132. */
  52133. onBeforeCameraTeleport: Observable<Vector3>;
  52134. /**
  52135. * Observable raised after camera teleportation
  52136. */
  52137. onAfterCameraTeleport: Observable<Vector3>;
  52138. /**
  52139. * Notifies when the camera's tracking state has changed.
  52140. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  52141. */
  52142. onTrackingStateChanged: Observable<WebXRTrackingState>;
  52143. /**
  52144. * Should position compensation execute on first frame.
  52145. * This is used when copying the position from a native (non XR) camera
  52146. */
  52147. compensateOnFirstFrame: boolean;
  52148. /**
  52149. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  52150. * @param name the name of the camera
  52151. * @param scene the scene to add the camera to
  52152. * @param _xrSessionManager a constructed xr session manager
  52153. */
  52154. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  52155. /**
  52156. * Get the current XR tracking state of the camera
  52157. */
  52158. get trackingState(): WebXRTrackingState;
  52159. private _setTrackingState;
  52160. /**
  52161. * Return the user's height, unrelated to the current ground.
  52162. * This will be the y position of this camera, when ground level is 0.
  52163. */
  52164. get realWorldHeight(): number;
  52165. /** @hidden */
  52166. _updateForDualEyeDebugging(): void;
  52167. /**
  52168. * Sets this camera's transformation based on a non-vr camera
  52169. * @param otherCamera the non-vr camera to copy the transformation from
  52170. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  52171. */
  52172. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  52173. /**
  52174. * Gets the current instance class name ("WebXRCamera").
  52175. * @returns the class name
  52176. */
  52177. getClassName(): string;
  52178. private _rotate180;
  52179. private _updateFromXRSession;
  52180. private _updateNumberOfRigCameras;
  52181. private _updateReferenceSpace;
  52182. private _updateReferenceSpaceOffset;
  52183. }
  52184. }
  52185. declare module "babylonjs/XR/webXRFeaturesManager" {
  52186. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52187. import { IDisposable } from "babylonjs/scene";
  52188. /**
  52189. * Defining the interface required for a (webxr) feature
  52190. */
  52191. export interface IWebXRFeature extends IDisposable {
  52192. /**
  52193. * Is this feature attached
  52194. */
  52195. attached: boolean;
  52196. /**
  52197. * Should auto-attach be disabled?
  52198. */
  52199. disableAutoAttach: boolean;
  52200. /**
  52201. * Attach the feature to the session
  52202. * Will usually be called by the features manager
  52203. *
  52204. * @param force should attachment be forced (even when already attached)
  52205. * @returns true if successful.
  52206. */
  52207. attach(force?: boolean): boolean;
  52208. /**
  52209. * Detach the feature from the session
  52210. * Will usually be called by the features manager
  52211. *
  52212. * @returns true if successful.
  52213. */
  52214. detach(): boolean;
  52215. /**
  52216. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52217. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52218. *
  52219. * @returns whether or not the feature is compatible in this environment
  52220. */
  52221. isCompatible(): boolean;
  52222. /**
  52223. * Was this feature disposed;
  52224. */
  52225. isDisposed: boolean;
  52226. /**
  52227. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  52228. */
  52229. xrNativeFeatureName?: string;
  52230. /**
  52231. * A list of (Babylon WebXR) features this feature depends on
  52232. */
  52233. dependsOn?: string[];
  52234. }
  52235. /**
  52236. * A list of the currently available features without referencing them
  52237. */
  52238. export class WebXRFeatureName {
  52239. /**
  52240. * The name of the anchor system feature
  52241. */
  52242. static readonly ANCHOR_SYSTEM: string;
  52243. /**
  52244. * The name of the background remover feature
  52245. */
  52246. static readonly BACKGROUND_REMOVER: string;
  52247. /**
  52248. * The name of the hit test feature
  52249. */
  52250. static readonly HIT_TEST: string;
  52251. /**
  52252. * physics impostors for xr controllers feature
  52253. */
  52254. static readonly PHYSICS_CONTROLLERS: string;
  52255. /**
  52256. * The name of the plane detection feature
  52257. */
  52258. static readonly PLANE_DETECTION: string;
  52259. /**
  52260. * The name of the pointer selection feature
  52261. */
  52262. static readonly POINTER_SELECTION: string;
  52263. /**
  52264. * The name of the teleportation feature
  52265. */
  52266. static readonly TELEPORTATION: string;
  52267. /**
  52268. * The name of the feature points feature.
  52269. */
  52270. static readonly FEATURE_POINTS: string;
  52271. /**
  52272. * The name of the hand tracking feature.
  52273. */
  52274. static readonly HAND_TRACKING: string;
  52275. }
  52276. /**
  52277. * Defining the constructor of a feature. Used to register the modules.
  52278. */
  52279. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  52280. /**
  52281. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  52282. * It is mainly used in AR sessions.
  52283. *
  52284. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  52285. */
  52286. export class WebXRFeaturesManager implements IDisposable {
  52287. private _xrSessionManager;
  52288. private static readonly _AvailableFeatures;
  52289. private _features;
  52290. /**
  52291. * constructs a new features manages.
  52292. *
  52293. * @param _xrSessionManager an instance of WebXRSessionManager
  52294. */
  52295. constructor(_xrSessionManager: WebXRSessionManager);
  52296. /**
  52297. * Used to register a module. After calling this function a developer can use this feature in the scene.
  52298. * Mainly used internally.
  52299. *
  52300. * @param featureName the name of the feature to register
  52301. * @param constructorFunction the function used to construct the module
  52302. * @param version the (babylon) version of the module
  52303. * @param stable is that a stable version of this module
  52304. */
  52305. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  52306. /**
  52307. * Returns a constructor of a specific feature.
  52308. *
  52309. * @param featureName the name of the feature to construct
  52310. * @param version the version of the feature to load
  52311. * @param xrSessionManager the xrSessionManager. Used to construct the module
  52312. * @param options optional options provided to the module.
  52313. * @returns a function that, when called, will return a new instance of this feature
  52314. */
  52315. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  52316. /**
  52317. * Can be used to return the list of features currently registered
  52318. *
  52319. * @returns an Array of available features
  52320. */
  52321. static GetAvailableFeatures(): string[];
  52322. /**
  52323. * Gets the versions available for a specific feature
  52324. * @param featureName the name of the feature
  52325. * @returns an array with the available versions
  52326. */
  52327. static GetAvailableVersions(featureName: string): string[];
  52328. /**
  52329. * Return the latest unstable version of this feature
  52330. * @param featureName the name of the feature to search
  52331. * @returns the version number. if not found will return -1
  52332. */
  52333. static GetLatestVersionOfFeature(featureName: string): number;
  52334. /**
  52335. * Return the latest stable version of this feature
  52336. * @param featureName the name of the feature to search
  52337. * @returns the version number. if not found will return -1
  52338. */
  52339. static GetStableVersionOfFeature(featureName: string): number;
  52340. /**
  52341. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  52342. * Can be used during a session to start a feature
  52343. * @param featureName the name of feature to attach
  52344. */
  52345. attachFeature(featureName: string): void;
  52346. /**
  52347. * Can be used inside a session or when the session ends to detach a specific feature
  52348. * @param featureName the name of the feature to detach
  52349. */
  52350. detachFeature(featureName: string): void;
  52351. /**
  52352. * Used to disable an already-enabled feature
  52353. * The feature will be disposed and will be recreated once enabled.
  52354. * @param featureName the feature to disable
  52355. * @returns true if disable was successful
  52356. */
  52357. disableFeature(featureName: string | {
  52358. Name: string;
  52359. }): boolean;
  52360. /**
  52361. * dispose this features manager
  52362. */
  52363. dispose(): void;
  52364. /**
  52365. * 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.
  52366. * 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.
  52367. *
  52368. * @param featureName the name of the feature to load or the class of the feature
  52369. * @param version optional version to load. if not provided the latest version will be enabled
  52370. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  52371. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  52372. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  52373. * @returns a new constructed feature or throws an error if feature not found.
  52374. */
  52375. enableFeature(featureName: string | {
  52376. Name: string;
  52377. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  52378. /**
  52379. * get the implementation of an enabled feature.
  52380. * @param featureName the name of the feature to load
  52381. * @returns the feature class, if found
  52382. */
  52383. getEnabledFeature(featureName: string): IWebXRFeature;
  52384. /**
  52385. * Get the list of enabled features
  52386. * @returns an array of enabled features
  52387. */
  52388. getEnabledFeatures(): string[];
  52389. /**
  52390. * This function will exten the session creation configuration object with enabled features.
  52391. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  52392. * according to the defined "required" variable, provided during enableFeature call
  52393. * @param xrSessionInit the xr Session init object to extend
  52394. *
  52395. * @returns an extended XRSessionInit object
  52396. */
  52397. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  52398. }
  52399. }
  52400. declare module "babylonjs/XR/webXRExperienceHelper" {
  52401. import { Observable } from "babylonjs/Misc/observable";
  52402. import { IDisposable, Scene } from "babylonjs/scene";
  52403. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52404. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  52405. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52406. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  52407. /**
  52408. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  52409. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  52410. */
  52411. export class WebXRExperienceHelper implements IDisposable {
  52412. private scene;
  52413. private _nonVRCamera;
  52414. private _originalSceneAutoClear;
  52415. private _supported;
  52416. /**
  52417. * Camera used to render xr content
  52418. */
  52419. camera: WebXRCamera;
  52420. /** A features manager for this xr session */
  52421. featuresManager: WebXRFeaturesManager;
  52422. /**
  52423. * Observers registered here will be triggered after the camera's initial transformation is set
  52424. * This can be used to set a different ground level or an extra rotation.
  52425. *
  52426. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  52427. * to the position set after this observable is done executing.
  52428. */
  52429. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  52430. /**
  52431. * Fires when the state of the experience helper has changed
  52432. */
  52433. onStateChangedObservable: Observable<WebXRState>;
  52434. /** Session manager used to keep track of xr session */
  52435. sessionManager: WebXRSessionManager;
  52436. /**
  52437. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  52438. */
  52439. state: WebXRState;
  52440. /**
  52441. * Creates a WebXRExperienceHelper
  52442. * @param scene The scene the helper should be created in
  52443. */
  52444. private constructor();
  52445. /**
  52446. * Creates the experience helper
  52447. * @param scene the scene to attach the experience helper to
  52448. * @returns a promise for the experience helper
  52449. */
  52450. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  52451. /**
  52452. * Disposes of the experience helper
  52453. */
  52454. dispose(): void;
  52455. /**
  52456. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  52457. * @param sessionMode options for the XR session
  52458. * @param referenceSpaceType frame of reference of the XR session
  52459. * @param renderTarget the output canvas that will be used to enter XR mode
  52460. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  52461. * @returns promise that resolves after xr mode has entered
  52462. */
  52463. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  52464. /**
  52465. * Exits XR mode and returns the scene to its original state
  52466. * @returns promise that resolves after xr mode has exited
  52467. */
  52468. exitXRAsync(): Promise<void>;
  52469. private _nonXRToXRCamera;
  52470. private _setState;
  52471. }
  52472. }
  52473. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  52474. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  52475. import { Observable } from "babylonjs/Misc/observable";
  52476. import { IDisposable } from "babylonjs/scene";
  52477. /**
  52478. * X-Y values for axes in WebXR
  52479. */
  52480. export interface IWebXRMotionControllerAxesValue {
  52481. /**
  52482. * The value of the x axis
  52483. */
  52484. x: number;
  52485. /**
  52486. * The value of the y-axis
  52487. */
  52488. y: number;
  52489. }
  52490. /**
  52491. * changed / previous values for the values of this component
  52492. */
  52493. export interface IWebXRMotionControllerComponentChangesValues<T> {
  52494. /**
  52495. * current (this frame) value
  52496. */
  52497. current: T;
  52498. /**
  52499. * previous (last change) value
  52500. */
  52501. previous: T;
  52502. }
  52503. /**
  52504. * Represents changes in the component between current frame and last values recorded
  52505. */
  52506. export interface IWebXRMotionControllerComponentChanges {
  52507. /**
  52508. * will be populated with previous and current values if axes changed
  52509. */
  52510. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  52511. /**
  52512. * will be populated with previous and current values if pressed changed
  52513. */
  52514. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52515. /**
  52516. * will be populated with previous and current values if touched changed
  52517. */
  52518. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52519. /**
  52520. * will be populated with previous and current values if value changed
  52521. */
  52522. value?: IWebXRMotionControllerComponentChangesValues<number>;
  52523. }
  52524. /**
  52525. * This class represents a single component (for example button or thumbstick) of a motion controller
  52526. */
  52527. export class WebXRControllerComponent implements IDisposable {
  52528. /**
  52529. * the id of this component
  52530. */
  52531. id: string;
  52532. /**
  52533. * the type of the component
  52534. */
  52535. type: MotionControllerComponentType;
  52536. private _buttonIndex;
  52537. private _axesIndices;
  52538. private _axes;
  52539. private _changes;
  52540. private _currentValue;
  52541. private _hasChanges;
  52542. private _pressed;
  52543. private _touched;
  52544. /**
  52545. * button component type
  52546. */
  52547. static BUTTON_TYPE: MotionControllerComponentType;
  52548. /**
  52549. * squeeze component type
  52550. */
  52551. static SQUEEZE_TYPE: MotionControllerComponentType;
  52552. /**
  52553. * Thumbstick component type
  52554. */
  52555. static THUMBSTICK_TYPE: MotionControllerComponentType;
  52556. /**
  52557. * Touchpad component type
  52558. */
  52559. static TOUCHPAD_TYPE: MotionControllerComponentType;
  52560. /**
  52561. * trigger component type
  52562. */
  52563. static TRIGGER_TYPE: MotionControllerComponentType;
  52564. /**
  52565. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  52566. * the axes data changes
  52567. */
  52568. onAxisValueChangedObservable: Observable<{
  52569. x: number;
  52570. y: number;
  52571. }>;
  52572. /**
  52573. * Observers registered here will be triggered when the state of a button changes
  52574. * State change is either pressed / touched / value
  52575. */
  52576. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  52577. /**
  52578. * Creates a new component for a motion controller.
  52579. * It is created by the motion controller itself
  52580. *
  52581. * @param id the id of this component
  52582. * @param type the type of the component
  52583. * @param _buttonIndex index in the buttons array of the gamepad
  52584. * @param _axesIndices indices of the values in the axes array of the gamepad
  52585. */
  52586. constructor(
  52587. /**
  52588. * the id of this component
  52589. */
  52590. id: string,
  52591. /**
  52592. * the type of the component
  52593. */
  52594. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  52595. /**
  52596. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  52597. */
  52598. get axes(): IWebXRMotionControllerAxesValue;
  52599. /**
  52600. * Get the changes. Elements will be populated only if they changed with their previous and current value
  52601. */
  52602. get changes(): IWebXRMotionControllerComponentChanges;
  52603. /**
  52604. * Return whether or not the component changed the last frame
  52605. */
  52606. get hasChanges(): boolean;
  52607. /**
  52608. * is the button currently pressed
  52609. */
  52610. get pressed(): boolean;
  52611. /**
  52612. * is the button currently touched
  52613. */
  52614. get touched(): boolean;
  52615. /**
  52616. * Get the current value of this component
  52617. */
  52618. get value(): number;
  52619. /**
  52620. * Dispose this component
  52621. */
  52622. dispose(): void;
  52623. /**
  52624. * Are there axes correlating to this component
  52625. * @return true is axes data is available
  52626. */
  52627. isAxes(): boolean;
  52628. /**
  52629. * Is this component a button (hence - pressable)
  52630. * @returns true if can be pressed
  52631. */
  52632. isButton(): boolean;
  52633. /**
  52634. * update this component using the gamepad object it is in. Called on every frame
  52635. * @param nativeController the native gamepad controller object
  52636. */
  52637. update(nativeController: IMinimalMotionControllerObject): void;
  52638. }
  52639. }
  52640. declare module "babylonjs/Loading/sceneLoader" {
  52641. import { Observable } from "babylonjs/Misc/observable";
  52642. import { Nullable } from "babylonjs/types";
  52643. import { Scene } from "babylonjs/scene";
  52644. import { Engine } from "babylonjs/Engines/engine";
  52645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52646. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  52647. import { AssetContainer } from "babylonjs/assetContainer";
  52648. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52649. import { Skeleton } from "babylonjs/Bones/skeleton";
  52650. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  52651. import { WebRequest } from "babylonjs/Misc/webRequest";
  52652. /**
  52653. * Interface used to represent data loading progression
  52654. */
  52655. export interface ISceneLoaderProgressEvent {
  52656. /**
  52657. * Defines if data length to load can be evaluated
  52658. */
  52659. readonly lengthComputable: boolean;
  52660. /**
  52661. * Defines the loaded data length
  52662. */
  52663. readonly loaded: number;
  52664. /**
  52665. * Defines the data length to load
  52666. */
  52667. readonly total: number;
  52668. }
  52669. /**
  52670. * Interface used by SceneLoader plugins to define supported file extensions
  52671. */
  52672. export interface ISceneLoaderPluginExtensions {
  52673. /**
  52674. * Defines the list of supported extensions
  52675. */
  52676. [extension: string]: {
  52677. isBinary: boolean;
  52678. };
  52679. }
  52680. /**
  52681. * Interface used by SceneLoader plugin factory
  52682. */
  52683. export interface ISceneLoaderPluginFactory {
  52684. /**
  52685. * Defines the name of the factory
  52686. */
  52687. name: string;
  52688. /**
  52689. * Function called to create a new plugin
  52690. * @return the new plugin
  52691. */
  52692. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  52693. /**
  52694. * The callback that returns true if the data can be directly loaded.
  52695. * @param data string containing the file data
  52696. * @returns if the data can be loaded directly
  52697. */
  52698. canDirectLoad?(data: string): boolean;
  52699. }
  52700. /**
  52701. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  52702. */
  52703. export interface ISceneLoaderPluginBase {
  52704. /**
  52705. * The friendly name of this plugin.
  52706. */
  52707. name: string;
  52708. /**
  52709. * The file extensions supported by this plugin.
  52710. */
  52711. extensions: string | ISceneLoaderPluginExtensions;
  52712. /**
  52713. * The callback called when loading from a url.
  52714. * @param scene scene loading this url
  52715. * @param url url to load
  52716. * @param onSuccess callback called when the file successfully loads
  52717. * @param onProgress callback called while file is loading (if the server supports this mode)
  52718. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  52719. * @param onError callback called when the file fails to load
  52720. * @returns a file request object
  52721. */
  52722. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  52723. /**
  52724. * The callback called when loading from a file object.
  52725. * @param scene scene loading this file
  52726. * @param file defines the file to load
  52727. * @param onSuccess defines the callback to call when data is loaded
  52728. * @param onProgress defines the callback to call during loading process
  52729. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  52730. * @param onError defines the callback to call when an error occurs
  52731. * @returns a file request object
  52732. */
  52733. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  52734. /**
  52735. * The callback that returns true if the data can be directly loaded.
  52736. * @param data string containing the file data
  52737. * @returns if the data can be loaded directly
  52738. */
  52739. canDirectLoad?(data: string): boolean;
  52740. /**
  52741. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  52742. * @param scene scene loading this data
  52743. * @param data string containing the data
  52744. * @returns data to pass to the plugin
  52745. */
  52746. directLoad?(scene: Scene, data: string): any;
  52747. /**
  52748. * The callback that allows custom handling of the root url based on the response url.
  52749. * @param rootUrl the original root url
  52750. * @param responseURL the response url if available
  52751. * @returns the new root url
  52752. */
  52753. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  52754. }
  52755. /**
  52756. * Interface used to define a SceneLoader plugin
  52757. */
  52758. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  52759. /**
  52760. * Import meshes into a scene.
  52761. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52762. * @param scene The scene to import into
  52763. * @param data The data to import
  52764. * @param rootUrl The root url for scene and resources
  52765. * @param meshes The meshes array to import into
  52766. * @param particleSystems The particle systems array to import into
  52767. * @param skeletons The skeletons array to import into
  52768. * @param onError The callback when import fails
  52769. * @returns True if successful or false otherwise
  52770. */
  52771. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  52772. /**
  52773. * Load into a scene.
  52774. * @param scene The scene to load into
  52775. * @param data The data to import
  52776. * @param rootUrl The root url for scene and resources
  52777. * @param onError The callback when import fails
  52778. * @returns True if successful or false otherwise
  52779. */
  52780. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  52781. /**
  52782. * Load into an asset container.
  52783. * @param scene The scene to load into
  52784. * @param data The data to import
  52785. * @param rootUrl The root url for scene and resources
  52786. * @param onError The callback when import fails
  52787. * @returns The loaded asset container
  52788. */
  52789. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  52790. }
  52791. /**
  52792. * Interface used to define an async SceneLoader plugin
  52793. */
  52794. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  52795. /**
  52796. * Import meshes into a scene.
  52797. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52798. * @param scene The scene to import into
  52799. * @param data The data to import
  52800. * @param rootUrl The root url for scene and resources
  52801. * @param onProgress The callback when the load progresses
  52802. * @param fileName Defines the name of the file to load
  52803. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  52804. */
  52805. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  52806. meshes: AbstractMesh[];
  52807. particleSystems: IParticleSystem[];
  52808. skeletons: Skeleton[];
  52809. animationGroups: AnimationGroup[];
  52810. }>;
  52811. /**
  52812. * Load into a scene.
  52813. * @param scene The scene to load into
  52814. * @param data The data to import
  52815. * @param rootUrl The root url for scene and resources
  52816. * @param onProgress The callback when the load progresses
  52817. * @param fileName Defines the name of the file to load
  52818. * @returns Nothing
  52819. */
  52820. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  52821. /**
  52822. * Load into an asset container.
  52823. * @param scene The scene to load into
  52824. * @param data The data to import
  52825. * @param rootUrl The root url for scene and resources
  52826. * @param onProgress The callback when the load progresses
  52827. * @param fileName Defines the name of the file to load
  52828. * @returns The loaded asset container
  52829. */
  52830. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  52831. }
  52832. /**
  52833. * Mode that determines how to handle old animation groups before loading new ones.
  52834. */
  52835. export enum SceneLoaderAnimationGroupLoadingMode {
  52836. /**
  52837. * Reset all old animations to initial state then dispose them.
  52838. */
  52839. Clean = 0,
  52840. /**
  52841. * Stop all old animations.
  52842. */
  52843. Stop = 1,
  52844. /**
  52845. * Restart old animations from first frame.
  52846. */
  52847. Sync = 2,
  52848. /**
  52849. * Old animations remains untouched.
  52850. */
  52851. NoSync = 3
  52852. }
  52853. /**
  52854. * Defines a plugin registered by the SceneLoader
  52855. */
  52856. interface IRegisteredPlugin {
  52857. /**
  52858. * Defines the plugin to use
  52859. */
  52860. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  52861. /**
  52862. * Defines if the plugin supports binary data
  52863. */
  52864. isBinary: boolean;
  52865. }
  52866. /**
  52867. * Class used to load scene from various file formats using registered plugins
  52868. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  52869. */
  52870. export class SceneLoader {
  52871. /**
  52872. * No logging while loading
  52873. */
  52874. static readonly NO_LOGGING: number;
  52875. /**
  52876. * Minimal logging while loading
  52877. */
  52878. static readonly MINIMAL_LOGGING: number;
  52879. /**
  52880. * Summary logging while loading
  52881. */
  52882. static readonly SUMMARY_LOGGING: number;
  52883. /**
  52884. * Detailled logging while loading
  52885. */
  52886. static readonly DETAILED_LOGGING: number;
  52887. /**
  52888. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  52889. */
  52890. static get ForceFullSceneLoadingForIncremental(): boolean;
  52891. static set ForceFullSceneLoadingForIncremental(value: boolean);
  52892. /**
  52893. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  52894. */
  52895. static get ShowLoadingScreen(): boolean;
  52896. static set ShowLoadingScreen(value: boolean);
  52897. /**
  52898. * Defines the current logging level (while loading the scene)
  52899. * @ignorenaming
  52900. */
  52901. static get loggingLevel(): number;
  52902. static set loggingLevel(value: number);
  52903. /**
  52904. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  52905. */
  52906. static get CleanBoneMatrixWeights(): boolean;
  52907. static set CleanBoneMatrixWeights(value: boolean);
  52908. /**
  52909. * Event raised when a plugin is used to load a scene
  52910. */
  52911. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  52912. private static _registeredPlugins;
  52913. private static _showingLoadingScreen;
  52914. /**
  52915. * Gets the default plugin (used to load Babylon files)
  52916. * @returns the .babylon plugin
  52917. */
  52918. static GetDefaultPlugin(): IRegisteredPlugin;
  52919. private static _GetPluginForExtension;
  52920. private static _GetPluginForDirectLoad;
  52921. private static _GetPluginForFilename;
  52922. private static _GetDirectLoad;
  52923. private static _LoadData;
  52924. private static _GetFileInfo;
  52925. /**
  52926. * Gets a plugin that can load the given extension
  52927. * @param extension defines the extension to load
  52928. * @returns a plugin or null if none works
  52929. */
  52930. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  52931. /**
  52932. * Gets a boolean indicating that the given extension can be loaded
  52933. * @param extension defines the extension to load
  52934. * @returns true if the extension is supported
  52935. */
  52936. static IsPluginForExtensionAvailable(extension: string): boolean;
  52937. /**
  52938. * Adds a new plugin to the list of registered plugins
  52939. * @param plugin defines the plugin to add
  52940. */
  52941. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  52942. /**
  52943. * Import meshes into a scene
  52944. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52945. * @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)
  52946. * @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)
  52947. * @param scene the instance of BABYLON.Scene to append to
  52948. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  52949. * @param onProgress a callback with a progress event for each file being loaded
  52950. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52951. * @param pluginExtension the extension used to determine the plugin
  52952. * @returns The loaded plugin
  52953. */
  52954. 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>;
  52955. /**
  52956. * Import meshes into a scene
  52957. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52958. * @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)
  52959. * @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)
  52960. * @param scene the instance of BABYLON.Scene to append to
  52961. * @param onProgress a callback with a progress event for each file being loaded
  52962. * @param pluginExtension the extension used to determine the plugin
  52963. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  52964. */
  52965. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  52966. meshes: AbstractMesh[];
  52967. particleSystems: IParticleSystem[];
  52968. skeletons: Skeleton[];
  52969. animationGroups: AnimationGroup[];
  52970. }>;
  52971. /**
  52972. * Load a scene
  52973. * @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)
  52974. * @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)
  52975. * @param engine is the instance of BABYLON.Engine to use to create the scene
  52976. * @param onSuccess a callback with the scene when import succeeds
  52977. * @param onProgress a callback with a progress event for each file being loaded
  52978. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52979. * @param pluginExtension the extension used to determine the plugin
  52980. * @returns The loaded plugin
  52981. */
  52982. 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>;
  52983. /**
  52984. * Load a scene
  52985. * @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)
  52986. * @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)
  52987. * @param engine is the instance of BABYLON.Engine to use to create the scene
  52988. * @param onProgress a callback with a progress event for each file being loaded
  52989. * @param pluginExtension the extension used to determine the plugin
  52990. * @returns The loaded scene
  52991. */
  52992. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  52993. /**
  52994. * Append a scene
  52995. * @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)
  52996. * @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)
  52997. * @param scene is the instance of BABYLON.Scene to append to
  52998. * @param onSuccess a callback with the scene when import succeeds
  52999. * @param onProgress a callback with a progress event for each file being loaded
  53000. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53001. * @param pluginExtension the extension used to determine the plugin
  53002. * @returns The loaded plugin
  53003. */
  53004. 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>;
  53005. /**
  53006. * Append a scene
  53007. * @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)
  53008. * @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)
  53009. * @param scene is the instance of BABYLON.Scene to append to
  53010. * @param onProgress a callback with a progress event for each file being loaded
  53011. * @param pluginExtension the extension used to determine the plugin
  53012. * @returns The given scene
  53013. */
  53014. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  53015. /**
  53016. * Load a scene into an asset container
  53017. * @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)
  53018. * @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)
  53019. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53020. * @param onSuccess a callback with the scene when import succeeds
  53021. * @param onProgress a callback with a progress event for each file being loaded
  53022. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53023. * @param pluginExtension the extension used to determine the plugin
  53024. * @returns The loaded plugin
  53025. */
  53026. 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>;
  53027. /**
  53028. * Load a scene into an asset container
  53029. * @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)
  53030. * @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)
  53031. * @param scene is the instance of Scene to append to
  53032. * @param onProgress a callback with a progress event for each file being loaded
  53033. * @param pluginExtension the extension used to determine the plugin
  53034. * @returns The loaded asset container
  53035. */
  53036. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  53037. /**
  53038. * Import animations from a file into a scene
  53039. * @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)
  53040. * @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)
  53041. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53042. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53043. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53044. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53045. * @param onSuccess a callback with the scene when import succeeds
  53046. * @param onProgress a callback with a progress event for each file being loaded
  53047. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53048. * @param pluginExtension the extension used to determine the plugin
  53049. */
  53050. 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;
  53051. /**
  53052. * Import animations from a file into a scene
  53053. * @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)
  53054. * @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)
  53055. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53056. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53057. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53058. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53059. * @param onSuccess a callback with the scene when import succeeds
  53060. * @param onProgress a callback with a progress event for each file being loaded
  53061. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53062. * @param pluginExtension the extension used to determine the plugin
  53063. * @returns the updated scene with imported animations
  53064. */
  53065. 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>;
  53066. }
  53067. }
  53068. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  53069. import { IDisposable, Scene } from "babylonjs/scene";
  53070. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  53071. import { Observable } from "babylonjs/Misc/observable";
  53072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53073. import { Nullable } from "babylonjs/types";
  53074. /**
  53075. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  53076. */
  53077. export type MotionControllerHandedness = "none" | "left" | "right";
  53078. /**
  53079. * The type of components available in motion controllers.
  53080. * This is not the name of the component.
  53081. */
  53082. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  53083. /**
  53084. * The state of a controller component
  53085. */
  53086. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  53087. /**
  53088. * The schema of motion controller layout.
  53089. * No object will be initialized using this interface
  53090. * This is used just to define the profile.
  53091. */
  53092. export interface IMotionControllerLayout {
  53093. /**
  53094. * Path to load the assets. Usually relative to the base path
  53095. */
  53096. assetPath: string;
  53097. /**
  53098. * Available components (unsorted)
  53099. */
  53100. components: {
  53101. /**
  53102. * A map of component Ids
  53103. */
  53104. [componentId: string]: {
  53105. /**
  53106. * The type of input the component outputs
  53107. */
  53108. type: MotionControllerComponentType;
  53109. /**
  53110. * The indices of this component in the gamepad object
  53111. */
  53112. gamepadIndices: {
  53113. /**
  53114. * Index of button
  53115. */
  53116. button?: number;
  53117. /**
  53118. * If available, index of x-axis
  53119. */
  53120. xAxis?: number;
  53121. /**
  53122. * If available, index of y-axis
  53123. */
  53124. yAxis?: number;
  53125. };
  53126. /**
  53127. * The mesh's root node name
  53128. */
  53129. rootNodeName: string;
  53130. /**
  53131. * Animation definitions for this model
  53132. */
  53133. visualResponses: {
  53134. [stateKey: string]: {
  53135. /**
  53136. * What property will be animated
  53137. */
  53138. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  53139. /**
  53140. * What states influence this visual response
  53141. */
  53142. states: MotionControllerComponentStateType[];
  53143. /**
  53144. * Type of animation - movement or visibility
  53145. */
  53146. valueNodeProperty: "transform" | "visibility";
  53147. /**
  53148. * Base node name to move. Its position will be calculated according to the min and max nodes
  53149. */
  53150. valueNodeName?: string;
  53151. /**
  53152. * Minimum movement node
  53153. */
  53154. minNodeName?: string;
  53155. /**
  53156. * Max movement node
  53157. */
  53158. maxNodeName?: string;
  53159. };
  53160. };
  53161. /**
  53162. * If touch enabled, what is the name of node to display user feedback
  53163. */
  53164. touchPointNodeName?: string;
  53165. };
  53166. };
  53167. /**
  53168. * Is it xr standard mapping or not
  53169. */
  53170. gamepadMapping: "" | "xr-standard";
  53171. /**
  53172. * Base root node of this entire model
  53173. */
  53174. rootNodeName: string;
  53175. /**
  53176. * Defines the main button component id
  53177. */
  53178. selectComponentId: string;
  53179. }
  53180. /**
  53181. * A definition for the layout map in the input profile
  53182. */
  53183. export interface IMotionControllerLayoutMap {
  53184. /**
  53185. * Layouts with handedness type as a key
  53186. */
  53187. [handedness: string]: IMotionControllerLayout;
  53188. }
  53189. /**
  53190. * The XR Input profile schema
  53191. * Profiles can be found here:
  53192. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  53193. */
  53194. export interface IMotionControllerProfile {
  53195. /**
  53196. * fallback profiles for this profileId
  53197. */
  53198. fallbackProfileIds: string[];
  53199. /**
  53200. * The layout map, with handedness as key
  53201. */
  53202. layouts: IMotionControllerLayoutMap;
  53203. /**
  53204. * The id of this profile
  53205. * correlates to the profile(s) in the xrInput.profiles array
  53206. */
  53207. profileId: string;
  53208. }
  53209. /**
  53210. * A helper-interface for the 3 meshes needed for controller button animation
  53211. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  53212. */
  53213. export interface IMotionControllerButtonMeshMap {
  53214. /**
  53215. * the mesh that defines the pressed value mesh position.
  53216. * This is used to find the max-position of this button
  53217. */
  53218. pressedMesh: AbstractMesh;
  53219. /**
  53220. * the mesh that defines the unpressed value mesh position.
  53221. * This is used to find the min (or initial) position of this button
  53222. */
  53223. unpressedMesh: AbstractMesh;
  53224. /**
  53225. * The mesh that will be changed when value changes
  53226. */
  53227. valueMesh: AbstractMesh;
  53228. }
  53229. /**
  53230. * A helper-interface for the 3 meshes needed for controller axis animation.
  53231. * This will be expanded when touchpad animations are fully supported
  53232. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  53233. */
  53234. export interface IMotionControllerMeshMap {
  53235. /**
  53236. * the mesh that defines the maximum value mesh position.
  53237. */
  53238. maxMesh?: AbstractMesh;
  53239. /**
  53240. * the mesh that defines the minimum value mesh position.
  53241. */
  53242. minMesh?: AbstractMesh;
  53243. /**
  53244. * The mesh that will be changed when axis value changes
  53245. */
  53246. valueMesh?: AbstractMesh;
  53247. }
  53248. /**
  53249. * The elements needed for change-detection of the gamepad objects in motion controllers
  53250. */
  53251. export interface IMinimalMotionControllerObject {
  53252. /**
  53253. * Available axes of this controller
  53254. */
  53255. axes: number[];
  53256. /**
  53257. * An array of available buttons
  53258. */
  53259. buttons: Array<{
  53260. /**
  53261. * Value of the button/trigger
  53262. */
  53263. value: number;
  53264. /**
  53265. * If the button/trigger is currently touched
  53266. */
  53267. touched: boolean;
  53268. /**
  53269. * If the button/trigger is currently pressed
  53270. */
  53271. pressed: boolean;
  53272. }>;
  53273. /**
  53274. * EXPERIMENTAL haptic support.
  53275. */
  53276. hapticActuators?: Array<{
  53277. pulse: (value: number, duration: number) => Promise<boolean>;
  53278. }>;
  53279. }
  53280. /**
  53281. * An Abstract Motion controller
  53282. * This class receives an xrInput and a profile layout and uses those to initialize the components
  53283. * Each component has an observable to check for changes in value and state
  53284. */
  53285. export abstract class WebXRAbstractMotionController implements IDisposable {
  53286. protected scene: Scene;
  53287. protected layout: IMotionControllerLayout;
  53288. /**
  53289. * The gamepad object correlating to this controller
  53290. */
  53291. gamepadObject: IMinimalMotionControllerObject;
  53292. /**
  53293. * handedness (left/right/none) of this controller
  53294. */
  53295. handedness: MotionControllerHandedness;
  53296. private _initComponent;
  53297. private _modelReady;
  53298. /**
  53299. * A map of components (WebXRControllerComponent) in this motion controller
  53300. * Components have a ComponentType and can also have both button and axis definitions
  53301. */
  53302. readonly components: {
  53303. [id: string]: WebXRControllerComponent;
  53304. };
  53305. /**
  53306. * Disable the model's animation. Can be set at any time.
  53307. */
  53308. disableAnimation: boolean;
  53309. /**
  53310. * Observers registered here will be triggered when the model of this controller is done loading
  53311. */
  53312. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  53313. /**
  53314. * The profile id of this motion controller
  53315. */
  53316. abstract profileId: string;
  53317. /**
  53318. * The root mesh of the model. It is null if the model was not yet initialized
  53319. */
  53320. rootMesh: Nullable<AbstractMesh>;
  53321. /**
  53322. * constructs a new abstract motion controller
  53323. * @param scene the scene to which the model of the controller will be added
  53324. * @param layout The profile layout to load
  53325. * @param gamepadObject The gamepad object correlating to this controller
  53326. * @param handedness handedness (left/right/none) of this controller
  53327. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  53328. */
  53329. constructor(scene: Scene, layout: IMotionControllerLayout,
  53330. /**
  53331. * The gamepad object correlating to this controller
  53332. */
  53333. gamepadObject: IMinimalMotionControllerObject,
  53334. /**
  53335. * handedness (left/right/none) of this controller
  53336. */
  53337. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  53338. /**
  53339. * Dispose this controller, the model mesh and all its components
  53340. */
  53341. dispose(): void;
  53342. /**
  53343. * Returns all components of specific type
  53344. * @param type the type to search for
  53345. * @return an array of components with this type
  53346. */
  53347. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  53348. /**
  53349. * get a component based an its component id as defined in layout.components
  53350. * @param id the id of the component
  53351. * @returns the component correlates to the id or undefined if not found
  53352. */
  53353. getComponent(id: string): WebXRControllerComponent;
  53354. /**
  53355. * Get the list of components available in this motion controller
  53356. * @returns an array of strings correlating to available components
  53357. */
  53358. getComponentIds(): string[];
  53359. /**
  53360. * Get the first component of specific type
  53361. * @param type type of component to find
  53362. * @return a controller component or null if not found
  53363. */
  53364. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  53365. /**
  53366. * Get the main (Select) component of this controller as defined in the layout
  53367. * @returns the main component of this controller
  53368. */
  53369. getMainComponent(): WebXRControllerComponent;
  53370. /**
  53371. * Loads the model correlating to this controller
  53372. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  53373. * @returns A promise fulfilled with the result of the model loading
  53374. */
  53375. loadModel(): Promise<boolean>;
  53376. /**
  53377. * Update this model using the current XRFrame
  53378. * @param xrFrame the current xr frame to use and update the model
  53379. */
  53380. updateFromXRFrame(xrFrame: XRFrame): void;
  53381. /**
  53382. * Backwards compatibility due to a deeply-integrated typo
  53383. */
  53384. get handness(): XREye;
  53385. /**
  53386. * Pulse (vibrate) this controller
  53387. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  53388. * Consecutive calls to this function will cancel the last pulse call
  53389. *
  53390. * @param value the strength of the pulse in 0.0...1.0 range
  53391. * @param duration Duration of the pulse in milliseconds
  53392. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  53393. * @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
  53394. */
  53395. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  53396. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53397. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53398. /**
  53399. * Moves the axis on the controller mesh based on its current state
  53400. * @param axis the index of the axis
  53401. * @param axisValue the value of the axis which determines the meshes new position
  53402. * @hidden
  53403. */
  53404. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  53405. /**
  53406. * Update the model itself with the current frame data
  53407. * @param xrFrame the frame to use for updating the model mesh
  53408. */
  53409. protected updateModel(xrFrame: XRFrame): void;
  53410. /**
  53411. * Get the filename and path for this controller's model
  53412. * @returns a map of filename and path
  53413. */
  53414. protected abstract _getFilenameAndPath(): {
  53415. filename: string;
  53416. path: string;
  53417. };
  53418. /**
  53419. * This function is called before the mesh is loaded. It checks for loading constraints.
  53420. * For example, this function can check if the GLB loader is available
  53421. * If this function returns false, the generic controller will be loaded instead
  53422. * @returns Is the client ready to load the mesh
  53423. */
  53424. protected abstract _getModelLoadingConstraints(): boolean;
  53425. /**
  53426. * This function will be called after the model was successfully loaded and can be used
  53427. * for mesh transformations before it is available for the user
  53428. * @param meshes the loaded meshes
  53429. */
  53430. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  53431. /**
  53432. * Set the root mesh for this controller. Important for the WebXR controller class
  53433. * @param meshes the loaded meshes
  53434. */
  53435. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  53436. /**
  53437. * A function executed each frame that updates the mesh (if needed)
  53438. * @param xrFrame the current xrFrame
  53439. */
  53440. protected abstract _updateModel(xrFrame: XRFrame): void;
  53441. private _getGenericFilenameAndPath;
  53442. private _getGenericParentMesh;
  53443. }
  53444. }
  53445. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  53446. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53448. import { Scene } from "babylonjs/scene";
  53449. /**
  53450. * A generic trigger-only motion controller for WebXR
  53451. */
  53452. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  53453. /**
  53454. * Static version of the profile id of this controller
  53455. */
  53456. static ProfileId: string;
  53457. profileId: string;
  53458. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  53459. protected _getFilenameAndPath(): {
  53460. filename: string;
  53461. path: string;
  53462. };
  53463. protected _getModelLoadingConstraints(): boolean;
  53464. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  53465. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53466. protected _updateModel(): void;
  53467. }
  53468. }
  53469. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  53470. import { Vector4 } from "babylonjs/Maths/math.vector";
  53471. import { Mesh } from "babylonjs/Meshes/mesh";
  53472. import { Scene } from "babylonjs/scene";
  53473. import { Nullable } from "babylonjs/types";
  53474. /**
  53475. * Class containing static functions to help procedurally build meshes
  53476. */
  53477. export class SphereBuilder {
  53478. /**
  53479. * Creates a sphere mesh
  53480. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53481. * * 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`)
  53482. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53483. * * 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
  53484. * * 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)
  53485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53488. * @param name defines the name of the mesh
  53489. * @param options defines the options used to create the mesh
  53490. * @param scene defines the hosting scene
  53491. * @returns the sphere mesh
  53492. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53493. */
  53494. static CreateSphere(name: string, options: {
  53495. segments?: number;
  53496. diameter?: number;
  53497. diameterX?: number;
  53498. diameterY?: number;
  53499. diameterZ?: number;
  53500. arc?: number;
  53501. slice?: number;
  53502. sideOrientation?: number;
  53503. frontUVs?: Vector4;
  53504. backUVs?: Vector4;
  53505. updatable?: boolean;
  53506. }, scene?: Nullable<Scene>): Mesh;
  53507. }
  53508. }
  53509. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  53510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53511. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53512. import { Scene } from "babylonjs/scene";
  53513. /**
  53514. * A profiled motion controller has its profile loaded from an online repository.
  53515. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  53516. */
  53517. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  53518. private _repositoryUrl;
  53519. private _buttonMeshMapping;
  53520. private _touchDots;
  53521. /**
  53522. * The profile ID of this controller. Will be populated when the controller initializes.
  53523. */
  53524. profileId: string;
  53525. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  53526. dispose(): void;
  53527. protected _getFilenameAndPath(): {
  53528. filename: string;
  53529. path: string;
  53530. };
  53531. protected _getModelLoadingConstraints(): boolean;
  53532. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  53533. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53534. protected _updateModel(_xrFrame: XRFrame): void;
  53535. }
  53536. }
  53537. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  53538. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53539. import { Scene } from "babylonjs/scene";
  53540. /**
  53541. * A construction function type to create a new controller based on an xrInput object
  53542. */
  53543. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  53544. /**
  53545. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  53546. *
  53547. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  53548. * it should be replaced with auto-loaded controllers.
  53549. *
  53550. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  53551. */
  53552. export class WebXRMotionControllerManager {
  53553. private static _AvailableControllers;
  53554. private static _Fallbacks;
  53555. private static _ProfileLoadingPromises;
  53556. private static _ProfilesList;
  53557. /**
  53558. * The base URL of the online controller repository. Can be changed at any time.
  53559. */
  53560. static BaseRepositoryUrl: string;
  53561. /**
  53562. * Which repository gets priority - local or online
  53563. */
  53564. static PrioritizeOnlineRepository: boolean;
  53565. /**
  53566. * Use the online repository, or use only locally-defined controllers
  53567. */
  53568. static UseOnlineRepository: boolean;
  53569. /**
  53570. * Clear the cache used for profile loading and reload when requested again
  53571. */
  53572. static ClearProfilesCache(): void;
  53573. /**
  53574. * Register the default fallbacks.
  53575. * This function is called automatically when this file is imported.
  53576. */
  53577. static DefaultFallbacks(): void;
  53578. /**
  53579. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  53580. * @param profileId the profile to which a fallback needs to be found
  53581. * @return an array with corresponding fallback profiles
  53582. */
  53583. static FindFallbackWithProfileId(profileId: string): string[];
  53584. /**
  53585. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  53586. * The order of search:
  53587. *
  53588. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  53589. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  53590. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  53591. * 4) return the generic trigger controller if none were found
  53592. *
  53593. * @param xrInput the xrInput to which a new controller is initialized
  53594. * @param scene the scene to which the model will be added
  53595. * @param forceProfile force a certain profile for this controller
  53596. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  53597. */
  53598. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  53599. /**
  53600. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  53601. *
  53602. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  53603. *
  53604. * @param type the profile type to register
  53605. * @param constructFunction the function to be called when loading this profile
  53606. */
  53607. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  53608. /**
  53609. * Register a fallback to a specific profile.
  53610. * @param profileId the profileId that will receive the fallbacks
  53611. * @param fallbacks A list of fallback profiles
  53612. */
  53613. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  53614. /**
  53615. * Will update the list of profiles available in the repository
  53616. * @return a promise that resolves to a map of profiles available online
  53617. */
  53618. static UpdateProfilesList(): Promise<{
  53619. [profile: string]: string;
  53620. }>;
  53621. private static _LoadProfileFromRepository;
  53622. private static _LoadProfilesFromAvailableControllers;
  53623. }
  53624. }
  53625. declare module "babylonjs/XR/webXRInputSource" {
  53626. import { Observable } from "babylonjs/Misc/observable";
  53627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53628. import { Ray } from "babylonjs/Culling/ray";
  53629. import { Scene } from "babylonjs/scene";
  53630. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53631. /**
  53632. * Configuration options for the WebXR controller creation
  53633. */
  53634. export interface IWebXRControllerOptions {
  53635. /**
  53636. * Should the controller mesh be animated when a user interacts with it
  53637. * The pressed buttons / thumbstick and touchpad animations will be disabled
  53638. */
  53639. disableMotionControllerAnimation?: boolean;
  53640. /**
  53641. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  53642. */
  53643. doNotLoadControllerMesh?: boolean;
  53644. /**
  53645. * Force a specific controller type for this controller.
  53646. * This can be used when creating your own profile or when testing different controllers
  53647. */
  53648. forceControllerProfile?: string;
  53649. /**
  53650. * Defines a rendering group ID for meshes that will be loaded.
  53651. * This is for the default controllers only.
  53652. */
  53653. renderingGroupId?: number;
  53654. }
  53655. /**
  53656. * Represents an XR controller
  53657. */
  53658. export class WebXRInputSource {
  53659. private _scene;
  53660. /** The underlying input source for the controller */
  53661. inputSource: XRInputSource;
  53662. private _options;
  53663. private _tmpVector;
  53664. private _uniqueId;
  53665. private _disposed;
  53666. /**
  53667. * 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
  53668. */
  53669. grip?: AbstractMesh;
  53670. /**
  53671. * If available, this is the gamepad object related to this controller.
  53672. * Using this object it is possible to get click events and trackpad changes of the
  53673. * webxr controller that is currently being used.
  53674. */
  53675. motionController?: WebXRAbstractMotionController;
  53676. /**
  53677. * Event that fires when the controller is removed/disposed.
  53678. * The object provided as event data is this controller, after associated assets were disposed.
  53679. * uniqueId is still available.
  53680. */
  53681. onDisposeObservable: Observable<WebXRInputSource>;
  53682. /**
  53683. * Will be triggered when the mesh associated with the motion controller is done loading.
  53684. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  53685. * A shortened version of controller -> motion controller -> on mesh loaded.
  53686. */
  53687. onMeshLoadedObservable: Observable<AbstractMesh>;
  53688. /**
  53689. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  53690. */
  53691. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  53692. /**
  53693. * Pointer which can be used to select objects or attach a visible laser to
  53694. */
  53695. pointer: AbstractMesh;
  53696. /**
  53697. * Creates the input source object
  53698. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  53699. * @param _scene the scene which the controller should be associated to
  53700. * @param inputSource the underlying input source for the controller
  53701. * @param _options options for this controller creation
  53702. */
  53703. constructor(_scene: Scene,
  53704. /** The underlying input source for the controller */
  53705. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  53706. /**
  53707. * Get this controllers unique id
  53708. */
  53709. get uniqueId(): string;
  53710. /**
  53711. * Disposes of the object
  53712. */
  53713. dispose(): void;
  53714. /**
  53715. * Gets a world space ray coming from the pointer or grip
  53716. * @param result the resulting ray
  53717. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  53718. */
  53719. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  53720. /**
  53721. * Updates the controller pose based on the given XRFrame
  53722. * @param xrFrame xr frame to update the pose with
  53723. * @param referenceSpace reference space to use
  53724. */
  53725. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  53726. }
  53727. }
  53728. declare module "babylonjs/XR/webXRInput" {
  53729. import { Observable } from "babylonjs/Misc/observable";
  53730. import { IDisposable } from "babylonjs/scene";
  53731. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  53732. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53733. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53734. /**
  53735. * The schema for initialization options of the XR Input class
  53736. */
  53737. export interface IWebXRInputOptions {
  53738. /**
  53739. * If set to true no model will be automatically loaded
  53740. */
  53741. doNotLoadControllerMeshes?: boolean;
  53742. /**
  53743. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  53744. * If not found, the xr input profile data will be used.
  53745. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  53746. */
  53747. forceInputProfile?: string;
  53748. /**
  53749. * Do not send a request to the controller repository to load the profile.
  53750. *
  53751. * Instead, use the controllers available in babylon itself.
  53752. */
  53753. disableOnlineControllerRepository?: boolean;
  53754. /**
  53755. * A custom URL for the controllers repository
  53756. */
  53757. customControllersRepositoryURL?: string;
  53758. /**
  53759. * Should the controller model's components not move according to the user input
  53760. */
  53761. disableControllerAnimation?: boolean;
  53762. /**
  53763. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  53764. */
  53765. controllerOptions?: IWebXRControllerOptions;
  53766. }
  53767. /**
  53768. * XR input used to track XR inputs such as controllers/rays
  53769. */
  53770. export class WebXRInput implements IDisposable {
  53771. /**
  53772. * the xr session manager for this session
  53773. */
  53774. xrSessionManager: WebXRSessionManager;
  53775. /**
  53776. * the WebXR camera for this session. Mainly used for teleportation
  53777. */
  53778. xrCamera: WebXRCamera;
  53779. private readonly options;
  53780. /**
  53781. * XR controllers being tracked
  53782. */
  53783. controllers: Array<WebXRInputSource>;
  53784. private _frameObserver;
  53785. private _sessionEndedObserver;
  53786. private _sessionInitObserver;
  53787. /**
  53788. * Event when a controller has been connected/added
  53789. */
  53790. onControllerAddedObservable: Observable<WebXRInputSource>;
  53791. /**
  53792. * Event when a controller has been removed/disconnected
  53793. */
  53794. onControllerRemovedObservable: Observable<WebXRInputSource>;
  53795. /**
  53796. * Initializes the WebXRInput
  53797. * @param xrSessionManager the xr session manager for this session
  53798. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  53799. * @param options = initialization options for this xr input
  53800. */
  53801. constructor(
  53802. /**
  53803. * the xr session manager for this session
  53804. */
  53805. xrSessionManager: WebXRSessionManager,
  53806. /**
  53807. * the WebXR camera for this session. Mainly used for teleportation
  53808. */
  53809. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  53810. private _onInputSourcesChange;
  53811. private _addAndRemoveControllers;
  53812. /**
  53813. * Disposes of the object
  53814. */
  53815. dispose(): void;
  53816. }
  53817. }
  53818. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  53819. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  53820. import { Observable, EventState } from "babylonjs/Misc/observable";
  53821. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53822. /**
  53823. * This is the base class for all WebXR features.
  53824. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  53825. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  53826. */
  53827. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  53828. protected _xrSessionManager: WebXRSessionManager;
  53829. private _attached;
  53830. private _removeOnDetach;
  53831. /**
  53832. * Is this feature disposed?
  53833. */
  53834. isDisposed: boolean;
  53835. /**
  53836. * Should auto-attach be disabled?
  53837. */
  53838. disableAutoAttach: boolean;
  53839. /**
  53840. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  53841. */
  53842. xrNativeFeatureName: string;
  53843. /**
  53844. * Construct a new (abstract) WebXR feature
  53845. * @param _xrSessionManager the xr session manager for this feature
  53846. */
  53847. constructor(_xrSessionManager: WebXRSessionManager);
  53848. /**
  53849. * Is this feature attached
  53850. */
  53851. get attached(): boolean;
  53852. /**
  53853. * attach this feature
  53854. *
  53855. * @param force should attachment be forced (even when already attached)
  53856. * @returns true if successful, false is failed or already attached
  53857. */
  53858. attach(force?: boolean): boolean;
  53859. /**
  53860. * detach this feature.
  53861. *
  53862. * @returns true if successful, false if failed or already detached
  53863. */
  53864. detach(): boolean;
  53865. /**
  53866. * Dispose this feature and all of the resources attached
  53867. */
  53868. dispose(): void;
  53869. /**
  53870. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  53871. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  53872. *
  53873. * @returns whether or not the feature is compatible in this environment
  53874. */
  53875. isCompatible(): boolean;
  53876. /**
  53877. * This is used to register callbacks that will automatically be removed when detach is called.
  53878. * @param observable the observable to which the observer will be attached
  53879. * @param callback the callback to register
  53880. */
  53881. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  53882. /**
  53883. * Code in this function will be executed on each xrFrame received from the browser.
  53884. * This function will not execute after the feature is detached.
  53885. * @param _xrFrame the current frame
  53886. */
  53887. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  53888. }
  53889. }
  53890. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  53891. import { IDisposable, Scene } from "babylonjs/scene";
  53892. import { Nullable } from "babylonjs/types";
  53893. import { Observable } from "babylonjs/Misc/observable";
  53894. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53895. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  53896. import { Camera } from "babylonjs/Cameras/camera";
  53897. /**
  53898. * Renders a layer on top of an existing scene
  53899. */
  53900. export class UtilityLayerRenderer implements IDisposable {
  53901. /** the original scene that will be rendered on top of */
  53902. originalScene: Scene;
  53903. private _pointerCaptures;
  53904. private _lastPointerEvents;
  53905. private static _DefaultUtilityLayer;
  53906. private static _DefaultKeepDepthUtilityLayer;
  53907. private _sharedGizmoLight;
  53908. private _renderCamera;
  53909. /**
  53910. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  53911. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  53912. * @returns the camera that is used when rendering the utility layer
  53913. */
  53914. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  53915. /**
  53916. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  53917. * @param cam the camera that should be used when rendering the utility layer
  53918. */
  53919. setRenderCamera(cam: Nullable<Camera>): void;
  53920. /**
  53921. * @hidden
  53922. * Light which used by gizmos to get light shading
  53923. */
  53924. _getSharedGizmoLight(): HemisphericLight;
  53925. /**
  53926. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  53927. */
  53928. pickUtilitySceneFirst: boolean;
  53929. /**
  53930. * 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)
  53931. */
  53932. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  53933. /**
  53934. * 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)
  53935. */
  53936. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  53937. /**
  53938. * The scene that is rendered on top of the original scene
  53939. */
  53940. utilityLayerScene: Scene;
  53941. /**
  53942. * If the utility layer should automatically be rendered on top of existing scene
  53943. */
  53944. shouldRender: boolean;
  53945. /**
  53946. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  53947. */
  53948. onlyCheckPointerDownEvents: boolean;
  53949. /**
  53950. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  53951. */
  53952. processAllEvents: boolean;
  53953. /**
  53954. * Observable raised when the pointer move from the utility layer scene to the main scene
  53955. */
  53956. onPointerOutObservable: Observable<number>;
  53957. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  53958. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  53959. private _afterRenderObserver;
  53960. private _sceneDisposeObserver;
  53961. private _originalPointerObserver;
  53962. /**
  53963. * Instantiates a UtilityLayerRenderer
  53964. * @param originalScene the original scene that will be rendered on top of
  53965. * @param handleEvents boolean indicating if the utility layer should handle events
  53966. */
  53967. constructor(
  53968. /** the original scene that will be rendered on top of */
  53969. originalScene: Scene, handleEvents?: boolean);
  53970. private _notifyObservers;
  53971. /**
  53972. * Renders the utility layers scene on top of the original scene
  53973. */
  53974. render(): void;
  53975. /**
  53976. * Disposes of the renderer
  53977. */
  53978. dispose(): void;
  53979. private _updateCamera;
  53980. }
  53981. }
  53982. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  53983. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53985. import { WebXRInput } from "babylonjs/XR/webXRInput";
  53986. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  53987. import { Scene } from "babylonjs/scene";
  53988. import { Nullable } from "babylonjs/types";
  53989. import { Color3 } from "babylonjs/Maths/math.color";
  53990. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  53991. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53992. /**
  53993. * Options interface for the pointer selection module
  53994. */
  53995. export interface IWebXRControllerPointerSelectionOptions {
  53996. /**
  53997. * if provided, this scene will be used to render meshes.
  53998. */
  53999. customUtilityLayerScene?: Scene;
  54000. /**
  54001. * 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)
  54002. * If not disabled, the last picked point will be used to execute a pointer up event
  54003. * If disabled, pointer up event will be triggered right after the pointer down event.
  54004. * Used in screen and gaze target ray mode only
  54005. */
  54006. disablePointerUpOnTouchOut: boolean;
  54007. /**
  54008. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  54009. */
  54010. forceGazeMode: boolean;
  54011. /**
  54012. * 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
  54013. * to start a new countdown to the pointer down event.
  54014. * Defaults to 1.
  54015. */
  54016. gazeModePointerMovedFactor?: number;
  54017. /**
  54018. * Different button type to use instead of the main component
  54019. */
  54020. overrideButtonId?: string;
  54021. /**
  54022. * use this rendering group id for the meshes (optional)
  54023. */
  54024. renderingGroupId?: number;
  54025. /**
  54026. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  54027. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  54028. * 3000 means 3 seconds between pointing at something and selecting it
  54029. */
  54030. timeToSelect?: number;
  54031. /**
  54032. * Should meshes created here be added to a utility layer or the main scene
  54033. */
  54034. useUtilityLayer?: boolean;
  54035. /**
  54036. * Optional WebXR camera to be used for gaze selection
  54037. */
  54038. gazeCamera?: WebXRCamera;
  54039. /**
  54040. * the xr input to use with this pointer selection
  54041. */
  54042. xrInput: WebXRInput;
  54043. /**
  54044. * Should the scene pointerX and pointerY update be disabled
  54045. * This is required for fullscreen AR GUI, but might slow down other experiences.
  54046. * Disable in VR, if not needed.
  54047. * The first rig camera (left eye) will be used to calculate the projection
  54048. */
  54049. disableScenePointerVectorUpdate: boolean;
  54050. /**
  54051. * Enable pointer selection on all controllers instead of switching between them
  54052. */
  54053. enablePointerSelectionOnAllControllers?: boolean;
  54054. /**
  54055. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  54056. * If switch is enabled, it will still allow the user to switch between the different controllers
  54057. */
  54058. preferredHandedness?: XRHandedness;
  54059. /**
  54060. * Disable switching the pointer selection from one controller to the other.
  54061. * If the preferred hand is set it will be fixed on this hand, and if not it will be fixed on the first controller added to the scene
  54062. */
  54063. disableSwitchOnClick?: boolean;
  54064. /**
  54065. * The maximum distance of the pointer selection feature. Defaults to 100.
  54066. */
  54067. maxPointerDistance?: number;
  54068. }
  54069. /**
  54070. * A module that will enable pointer selection for motion controllers of XR Input Sources
  54071. */
  54072. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  54073. private readonly _options;
  54074. private static _idCounter;
  54075. private _attachController;
  54076. private _controllers;
  54077. private _scene;
  54078. private _tmpVectorForPickCompare;
  54079. private _attachedController;
  54080. /**
  54081. * The module's name
  54082. */
  54083. static readonly Name: string;
  54084. /**
  54085. * The (Babylon) version of this module.
  54086. * This is an integer representing the implementation version.
  54087. * This number does not correspond to the WebXR specs version
  54088. */
  54089. static readonly Version: number;
  54090. /**
  54091. * Disable lighting on the laser pointer (so it will always be visible)
  54092. */
  54093. disablePointerLighting: boolean;
  54094. /**
  54095. * Disable lighting on the selection mesh (so it will always be visible)
  54096. */
  54097. disableSelectionMeshLighting: boolean;
  54098. /**
  54099. * Should the laser pointer be displayed
  54100. */
  54101. displayLaserPointer: boolean;
  54102. /**
  54103. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  54104. */
  54105. displaySelectionMesh: boolean;
  54106. /**
  54107. * This color will be set to the laser pointer when selection is triggered
  54108. */
  54109. laserPointerPickedColor: Color3;
  54110. /**
  54111. * Default color of the laser pointer
  54112. */
  54113. laserPointerDefaultColor: Color3;
  54114. /**
  54115. * default color of the selection ring
  54116. */
  54117. selectionMeshDefaultColor: Color3;
  54118. /**
  54119. * This color will be applied to the selection ring when selection is triggered
  54120. */
  54121. selectionMeshPickedColor: Color3;
  54122. /**
  54123. * Optional filter to be used for ray selection. This predicate shares behavior with
  54124. * scene.pointerMovePredicate which takes priority if it is also assigned.
  54125. */
  54126. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  54127. /**
  54128. * constructs a new background remover module
  54129. * @param _xrSessionManager the session manager for this module
  54130. * @param _options read-only options to be used in this module
  54131. */
  54132. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  54133. /**
  54134. * attach this feature
  54135. * Will usually be called by the features manager
  54136. *
  54137. * @returns true if successful.
  54138. */
  54139. attach(): boolean;
  54140. /**
  54141. * detach this feature.
  54142. * Will usually be called by the features manager
  54143. *
  54144. * @returns true if successful.
  54145. */
  54146. detach(): boolean;
  54147. /**
  54148. * Will get the mesh under a specific pointer.
  54149. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  54150. * @param controllerId the controllerId to check
  54151. * @returns The mesh under pointer or null if no mesh is under the pointer
  54152. */
  54153. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  54154. /**
  54155. * Get the xr controller that correlates to the pointer id in the pointer event
  54156. *
  54157. * @param id the pointer id to search for
  54158. * @returns the controller that correlates to this id or null if not found
  54159. */
  54160. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  54161. private _identityMatrix;
  54162. private _screenCoordinatesRef;
  54163. private _viewportRef;
  54164. protected _onXRFrame(_xrFrame: XRFrame): void;
  54165. private _attachGazeMode;
  54166. private _attachScreenRayMode;
  54167. private _attachTrackedPointerRayMode;
  54168. private _convertNormalToDirectionOfRay;
  54169. private _detachController;
  54170. private _generateNewMeshPair;
  54171. private _pickingMoved;
  54172. private _updatePointerDistance;
  54173. /** @hidden */
  54174. get lasterPointerDefaultColor(): Color3;
  54175. }
  54176. }
  54177. declare module "babylonjs/XR/webXREnterExitUI" {
  54178. import { Nullable } from "babylonjs/types";
  54179. import { Observable } from "babylonjs/Misc/observable";
  54180. import { IDisposable, Scene } from "babylonjs/scene";
  54181. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54182. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54183. /**
  54184. * Button which can be used to enter a different mode of XR
  54185. */
  54186. export class WebXREnterExitUIButton {
  54187. /** button element */
  54188. element: HTMLElement;
  54189. /** XR initialization options for the button */
  54190. sessionMode: XRSessionMode;
  54191. /** Reference space type */
  54192. referenceSpaceType: XRReferenceSpaceType;
  54193. /**
  54194. * Creates a WebXREnterExitUIButton
  54195. * @param element button element
  54196. * @param sessionMode XR initialization session mode
  54197. * @param referenceSpaceType the type of reference space to be used
  54198. */
  54199. constructor(
  54200. /** button element */
  54201. element: HTMLElement,
  54202. /** XR initialization options for the button */
  54203. sessionMode: XRSessionMode,
  54204. /** Reference space type */
  54205. referenceSpaceType: XRReferenceSpaceType);
  54206. /**
  54207. * Extendable function which can be used to update the button's visuals when the state changes
  54208. * @param activeButton the current active button in the UI
  54209. */
  54210. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  54211. }
  54212. /**
  54213. * Options to create the webXR UI
  54214. */
  54215. export class WebXREnterExitUIOptions {
  54216. /**
  54217. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  54218. */
  54219. customButtons?: Array<WebXREnterExitUIButton>;
  54220. /**
  54221. * A reference space type to use when creating the default button.
  54222. * Default is local-floor
  54223. */
  54224. referenceSpaceType?: XRReferenceSpaceType;
  54225. /**
  54226. * Context to enter xr with
  54227. */
  54228. renderTarget?: Nullable<WebXRRenderTarget>;
  54229. /**
  54230. * A session mode to use when creating the default button.
  54231. * Default is immersive-vr
  54232. */
  54233. sessionMode?: XRSessionMode;
  54234. /**
  54235. * A list of optional features to init the session with
  54236. */
  54237. optionalFeatures?: string[];
  54238. /**
  54239. * A list of optional features to init the session with
  54240. */
  54241. requiredFeatures?: string[];
  54242. }
  54243. /**
  54244. * UI to allow the user to enter/exit XR mode
  54245. */
  54246. export class WebXREnterExitUI implements IDisposable {
  54247. private scene;
  54248. /** version of the options passed to this UI */
  54249. options: WebXREnterExitUIOptions;
  54250. private _activeButton;
  54251. private _buttons;
  54252. /**
  54253. * The HTML Div Element to which buttons are added.
  54254. */
  54255. readonly overlay: HTMLDivElement;
  54256. /**
  54257. * Fired every time the active button is changed.
  54258. *
  54259. * When xr is entered via a button that launches xr that button will be the callback parameter
  54260. *
  54261. * When exiting xr the callback parameter will be null)
  54262. */
  54263. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  54264. /**
  54265. *
  54266. * @param scene babylon scene object to use
  54267. * @param options (read-only) version of the options passed to this UI
  54268. */
  54269. private constructor();
  54270. /**
  54271. * Creates UI to allow the user to enter/exit XR mode
  54272. * @param scene the scene to add the ui to
  54273. * @param helper the xr experience helper to enter/exit xr with
  54274. * @param options options to configure the UI
  54275. * @returns the created ui
  54276. */
  54277. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  54278. /**
  54279. * Disposes of the XR UI component
  54280. */
  54281. dispose(): void;
  54282. private _updateButtons;
  54283. }
  54284. }
  54285. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  54286. import { Vector3 } from "babylonjs/Maths/math.vector";
  54287. import { Color4 } from "babylonjs/Maths/math.color";
  54288. import { Nullable } from "babylonjs/types";
  54289. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54290. import { Scene } from "babylonjs/scene";
  54291. /**
  54292. * Class containing static functions to help procedurally build meshes
  54293. */
  54294. export class LinesBuilder {
  54295. /**
  54296. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54297. * * 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
  54298. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54299. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54300. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54301. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54302. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54303. * * 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
  54304. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54306. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54307. * @param name defines the name of the new line system
  54308. * @param options defines the options used to create the line system
  54309. * @param scene defines the hosting scene
  54310. * @returns a new line system mesh
  54311. */
  54312. static CreateLineSystem(name: string, options: {
  54313. lines: Vector3[][];
  54314. updatable?: boolean;
  54315. instance?: Nullable<LinesMesh>;
  54316. colors?: Nullable<Color4[][]>;
  54317. useVertexAlpha?: boolean;
  54318. }, scene: Nullable<Scene>): LinesMesh;
  54319. /**
  54320. * Creates a line mesh
  54321. * 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
  54322. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54323. * * The parameter `points` is an array successive Vector3
  54324. * * 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
  54325. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54326. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54327. * * When updating an instance, remember that only point positions can change, not the number of points
  54328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54329. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54330. * @param name defines the name of the new line system
  54331. * @param options defines the options used to create the line system
  54332. * @param scene defines the hosting scene
  54333. * @returns a new line mesh
  54334. */
  54335. static CreateLines(name: string, options: {
  54336. points: Vector3[];
  54337. updatable?: boolean;
  54338. instance?: Nullable<LinesMesh>;
  54339. colors?: Color4[];
  54340. useVertexAlpha?: boolean;
  54341. }, scene?: Nullable<Scene>): LinesMesh;
  54342. /**
  54343. * Creates a dashed line mesh
  54344. * * 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
  54345. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54346. * * The parameter `points` is an array successive Vector3
  54347. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54348. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54349. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54350. * * 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
  54351. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54352. * * When updating an instance, remember that only point positions can change, not the number of points
  54353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54354. * @param name defines the name of the mesh
  54355. * @param options defines the options used to create the mesh
  54356. * @param scene defines the hosting scene
  54357. * @returns the dashed line mesh
  54358. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54359. */
  54360. static CreateDashedLines(name: string, options: {
  54361. points: Vector3[];
  54362. dashSize?: number;
  54363. gapSize?: number;
  54364. dashNb?: number;
  54365. updatable?: boolean;
  54366. instance?: LinesMesh;
  54367. useVertexAlpha?: boolean;
  54368. }, scene?: Nullable<Scene>): LinesMesh;
  54369. }
  54370. }
  54371. declare module "babylonjs/Misc/timer" {
  54372. import { Observable, Observer } from "babylonjs/Misc/observable";
  54373. import { Nullable } from "babylonjs/types";
  54374. import { IDisposable } from "babylonjs/scene";
  54375. /**
  54376. * Construction options for a timer
  54377. */
  54378. export interface ITimerOptions<T> {
  54379. /**
  54380. * Time-to-end
  54381. */
  54382. timeout: number;
  54383. /**
  54384. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  54385. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  54386. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  54387. */
  54388. contextObservable: Observable<T>;
  54389. /**
  54390. * Optional parameters when adding an observer to the observable
  54391. */
  54392. observableParameters?: {
  54393. mask?: number;
  54394. insertFirst?: boolean;
  54395. scope?: any;
  54396. };
  54397. /**
  54398. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  54399. */
  54400. breakCondition?: (data?: ITimerData<T>) => boolean;
  54401. /**
  54402. * Will be triggered when the time condition has met
  54403. */
  54404. onEnded?: (data: ITimerData<any>) => void;
  54405. /**
  54406. * Will be triggered when the break condition has met (prematurely ended)
  54407. */
  54408. onAborted?: (data: ITimerData<any>) => void;
  54409. /**
  54410. * Optional function to execute on each tick (or count)
  54411. */
  54412. onTick?: (data: ITimerData<any>) => void;
  54413. }
  54414. /**
  54415. * An interface defining the data sent by the timer
  54416. */
  54417. export interface ITimerData<T> {
  54418. /**
  54419. * When did it start
  54420. */
  54421. startTime: number;
  54422. /**
  54423. * Time now
  54424. */
  54425. currentTime: number;
  54426. /**
  54427. * Time passed since started
  54428. */
  54429. deltaTime: number;
  54430. /**
  54431. * How much is completed, in [0.0...1.0].
  54432. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  54433. */
  54434. completeRate: number;
  54435. /**
  54436. * What the registered observable sent in the last count
  54437. */
  54438. payload: T;
  54439. }
  54440. /**
  54441. * The current state of the timer
  54442. */
  54443. export enum TimerState {
  54444. /**
  54445. * Timer initialized, not yet started
  54446. */
  54447. INIT = 0,
  54448. /**
  54449. * Timer started and counting
  54450. */
  54451. STARTED = 1,
  54452. /**
  54453. * Timer ended (whether aborted or time reached)
  54454. */
  54455. ENDED = 2
  54456. }
  54457. /**
  54458. * A simple version of the timer. Will take options and start the timer immediately after calling it
  54459. *
  54460. * @param options options with which to initialize this timer
  54461. */
  54462. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  54463. /**
  54464. * An advanced implementation of a timer class
  54465. */
  54466. export class AdvancedTimer<T = any> implements IDisposable {
  54467. /**
  54468. * Will notify each time the timer calculates the remaining time
  54469. */
  54470. onEachCountObservable: Observable<ITimerData<T>>;
  54471. /**
  54472. * Will trigger when the timer was aborted due to the break condition
  54473. */
  54474. onTimerAbortedObservable: Observable<ITimerData<T>>;
  54475. /**
  54476. * Will trigger when the timer ended successfully
  54477. */
  54478. onTimerEndedObservable: Observable<ITimerData<T>>;
  54479. /**
  54480. * Will trigger when the timer state has changed
  54481. */
  54482. onStateChangedObservable: Observable<TimerState>;
  54483. private _observer;
  54484. private _contextObservable;
  54485. private _observableParameters;
  54486. private _startTime;
  54487. private _timer;
  54488. private _state;
  54489. private _breakCondition;
  54490. private _timeToEnd;
  54491. private _breakOnNextTick;
  54492. /**
  54493. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  54494. * @param options construction options for this advanced timer
  54495. */
  54496. constructor(options: ITimerOptions<T>);
  54497. /**
  54498. * set a breaking condition for this timer. Default is to never break during count
  54499. * @param predicate the new break condition. Returns true to break, false otherwise
  54500. */
  54501. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  54502. /**
  54503. * Reset ALL associated observables in this advanced timer
  54504. */
  54505. clearObservables(): void;
  54506. /**
  54507. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  54508. *
  54509. * @param timeToEnd how much time to measure until timer ended
  54510. */
  54511. start(timeToEnd?: number): void;
  54512. /**
  54513. * Will force a stop on the next tick.
  54514. */
  54515. stop(): void;
  54516. /**
  54517. * Dispose this timer, clearing all resources
  54518. */
  54519. dispose(): void;
  54520. private _setState;
  54521. private _tick;
  54522. private _stop;
  54523. }
  54524. }
  54525. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  54526. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54527. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54528. import { Nullable } from "babylonjs/types";
  54529. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54531. import { Vector3 } from "babylonjs/Maths/math.vector";
  54532. import { Material } from "babylonjs/Materials/material";
  54533. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54534. import { Scene } from "babylonjs/scene";
  54535. /**
  54536. * The options container for the teleportation module
  54537. */
  54538. export interface IWebXRTeleportationOptions {
  54539. /**
  54540. * if provided, this scene will be used to render meshes.
  54541. */
  54542. customUtilityLayerScene?: Scene;
  54543. /**
  54544. * Values to configure the default target mesh
  54545. */
  54546. defaultTargetMeshOptions?: {
  54547. /**
  54548. * Fill color of the teleportation area
  54549. */
  54550. teleportationFillColor?: string;
  54551. /**
  54552. * Border color for the teleportation area
  54553. */
  54554. teleportationBorderColor?: string;
  54555. /**
  54556. * Disable the mesh's animation sequence
  54557. */
  54558. disableAnimation?: boolean;
  54559. /**
  54560. * Disable lighting on the material or the ring and arrow
  54561. */
  54562. disableLighting?: boolean;
  54563. /**
  54564. * Override the default material of the torus and arrow
  54565. */
  54566. torusArrowMaterial?: Material;
  54567. };
  54568. /**
  54569. * A list of meshes to use as floor meshes.
  54570. * Meshes can be added and removed after initializing the feature using the
  54571. * addFloorMesh and removeFloorMesh functions
  54572. * If empty, rotation will still work
  54573. */
  54574. floorMeshes?: AbstractMesh[];
  54575. /**
  54576. * use this rendering group id for the meshes (optional)
  54577. */
  54578. renderingGroupId?: number;
  54579. /**
  54580. * Should teleportation move only to snap points
  54581. */
  54582. snapPointsOnly?: boolean;
  54583. /**
  54584. * An array of points to which the teleportation will snap to.
  54585. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  54586. */
  54587. snapPositions?: Vector3[];
  54588. /**
  54589. * How close should the teleportation ray be in order to snap to position.
  54590. * Default to 0.8 units (meters)
  54591. */
  54592. snapToPositionRadius?: number;
  54593. /**
  54594. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  54595. * If you want to support rotation, make sure your mesh has a direction indicator.
  54596. *
  54597. * When left untouched, the default mesh will be initialized.
  54598. */
  54599. teleportationTargetMesh?: AbstractMesh;
  54600. /**
  54601. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  54602. */
  54603. timeToTeleport?: number;
  54604. /**
  54605. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  54606. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  54607. */
  54608. useMainComponentOnly?: boolean;
  54609. /**
  54610. * Should meshes created here be added to a utility layer or the main scene
  54611. */
  54612. useUtilityLayer?: boolean;
  54613. /**
  54614. * Babylon XR Input class for controller
  54615. */
  54616. xrInput: WebXRInput;
  54617. /**
  54618. * Meshes that the teleportation ray cannot go through
  54619. */
  54620. pickBlockerMeshes?: AbstractMesh[];
  54621. }
  54622. /**
  54623. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  54624. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  54625. * the input of the attached controllers.
  54626. */
  54627. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  54628. private _options;
  54629. private _controllers;
  54630. private _currentTeleportationControllerId;
  54631. private _floorMeshes;
  54632. private _quadraticBezierCurve;
  54633. private _selectionFeature;
  54634. private _snapToPositions;
  54635. private _snappedToPoint;
  54636. private _teleportationRingMaterial?;
  54637. private _tmpRay;
  54638. private _tmpVector;
  54639. private _tmpQuaternion;
  54640. /**
  54641. * The module's name
  54642. */
  54643. static readonly Name: string;
  54644. /**
  54645. * The (Babylon) version of this module.
  54646. * This is an integer representing the implementation version.
  54647. * This number does not correspond to the webxr specs version
  54648. */
  54649. static readonly Version: number;
  54650. /**
  54651. * Is movement backwards enabled
  54652. */
  54653. backwardsMovementEnabled: boolean;
  54654. /**
  54655. * Distance to travel when moving backwards
  54656. */
  54657. backwardsTeleportationDistance: number;
  54658. /**
  54659. * The distance from the user to the inspection point in the direction of the controller
  54660. * A higher number will allow the user to move further
  54661. * defaults to 5 (meters, in xr units)
  54662. */
  54663. parabolicCheckRadius: number;
  54664. /**
  54665. * Should the module support parabolic ray on top of direct ray
  54666. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  54667. * Very helpful when moving between floors / different heights
  54668. */
  54669. parabolicRayEnabled: boolean;
  54670. /**
  54671. * How much rotation should be applied when rotating right and left
  54672. */
  54673. rotationAngle: number;
  54674. /**
  54675. * Is rotation enabled when moving forward?
  54676. * Disabling this feature will prevent the user from deciding the direction when teleporting
  54677. */
  54678. rotationEnabled: boolean;
  54679. /**
  54680. * constructs a new anchor system
  54681. * @param _xrSessionManager an instance of WebXRSessionManager
  54682. * @param _options configuration object for this feature
  54683. */
  54684. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  54685. /**
  54686. * Get the snapPointsOnly flag
  54687. */
  54688. get snapPointsOnly(): boolean;
  54689. /**
  54690. * Sets the snapPointsOnly flag
  54691. * @param snapToPoints should teleportation be exclusively to snap points
  54692. */
  54693. set snapPointsOnly(snapToPoints: boolean);
  54694. /**
  54695. * Add a new mesh to the floor meshes array
  54696. * @param mesh the mesh to use as floor mesh
  54697. */
  54698. addFloorMesh(mesh: AbstractMesh): void;
  54699. /**
  54700. * Add a new snap-to point to fix teleportation to this position
  54701. * @param newSnapPoint The new Snap-To point
  54702. */
  54703. addSnapPoint(newSnapPoint: Vector3): void;
  54704. attach(): boolean;
  54705. detach(): boolean;
  54706. dispose(): void;
  54707. /**
  54708. * Remove a mesh from the floor meshes array
  54709. * @param mesh the mesh to remove
  54710. */
  54711. removeFloorMesh(mesh: AbstractMesh): void;
  54712. /**
  54713. * Remove a mesh from the floor meshes array using its name
  54714. * @param name the mesh name to remove
  54715. */
  54716. removeFloorMeshByName(name: string): void;
  54717. /**
  54718. * 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
  54719. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  54720. * @returns was the point found and removed or not
  54721. */
  54722. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  54723. /**
  54724. * This function sets a selection feature that will be disabled when
  54725. * the forward ray is shown and will be reattached when hidden.
  54726. * This is used to remove the selection rays when moving.
  54727. * @param selectionFeature the feature to disable when forward movement is enabled
  54728. */
  54729. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  54730. protected _onXRFrame(_xrFrame: XRFrame): void;
  54731. private _attachController;
  54732. private _createDefaultTargetMesh;
  54733. private _detachController;
  54734. private _findClosestSnapPointWithRadius;
  54735. private _setTargetMeshPosition;
  54736. private _setTargetMeshVisibility;
  54737. private _showParabolicPath;
  54738. private _teleportForward;
  54739. }
  54740. }
  54741. declare module "babylonjs/XR/webXRDefaultExperience" {
  54742. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54743. import { Scene } from "babylonjs/scene";
  54744. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  54745. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  54746. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54747. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  54748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54749. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  54750. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  54751. /**
  54752. * Options for the default xr helper
  54753. */
  54754. export class WebXRDefaultExperienceOptions {
  54755. /**
  54756. * Enable or disable default UI to enter XR
  54757. */
  54758. disableDefaultUI?: boolean;
  54759. /**
  54760. * Should teleportation not initialize. defaults to false.
  54761. */
  54762. disableTeleportation?: boolean;
  54763. /**
  54764. * Floor meshes that will be used for teleport
  54765. */
  54766. floorMeshes?: Array<AbstractMesh>;
  54767. /**
  54768. * If set to true, the first frame will not be used to reset position
  54769. * The first frame is mainly used when copying transformation from the old camera
  54770. * Mainly used in AR
  54771. */
  54772. ignoreNativeCameraTransformation?: boolean;
  54773. /**
  54774. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  54775. */
  54776. inputOptions?: IWebXRInputOptions;
  54777. /**
  54778. * optional configuration for the output canvas
  54779. */
  54780. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  54781. /**
  54782. * optional UI options. This can be used among other to change session mode and reference space type
  54783. */
  54784. uiOptions?: WebXREnterExitUIOptions;
  54785. /**
  54786. * When loading teleportation and pointer select, use stable versions instead of latest.
  54787. */
  54788. useStablePlugins?: boolean;
  54789. /**
  54790. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  54791. */
  54792. renderingGroupId?: number;
  54793. /**
  54794. * A list of optional features to init the session with
  54795. * If set to true, all features we support will be added
  54796. */
  54797. optionalFeatures?: boolean | string[];
  54798. }
  54799. /**
  54800. * Default experience which provides a similar setup to the previous webVRExperience
  54801. */
  54802. export class WebXRDefaultExperience {
  54803. /**
  54804. * Base experience
  54805. */
  54806. baseExperience: WebXRExperienceHelper;
  54807. /**
  54808. * Enables ui for entering/exiting xr
  54809. */
  54810. enterExitUI: WebXREnterExitUI;
  54811. /**
  54812. * Input experience extension
  54813. */
  54814. input: WebXRInput;
  54815. /**
  54816. * Enables laser pointer and selection
  54817. */
  54818. pointerSelection: WebXRControllerPointerSelection;
  54819. /**
  54820. * Default target xr should render to
  54821. */
  54822. renderTarget: WebXRRenderTarget;
  54823. /**
  54824. * Enables teleportation
  54825. */
  54826. teleportation: WebXRMotionControllerTeleportation;
  54827. private constructor();
  54828. /**
  54829. * Creates the default xr experience
  54830. * @param scene scene
  54831. * @param options options for basic configuration
  54832. * @returns resulting WebXRDefaultExperience
  54833. */
  54834. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54835. /**
  54836. * DIsposes of the experience helper
  54837. */
  54838. dispose(): void;
  54839. }
  54840. }
  54841. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  54842. import { Observable } from "babylonjs/Misc/observable";
  54843. import { Nullable } from "babylonjs/types";
  54844. import { Camera } from "babylonjs/Cameras/camera";
  54845. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  54846. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  54847. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  54848. import { Scene } from "babylonjs/scene";
  54849. import { Vector3 } from "babylonjs/Maths/math.vector";
  54850. import { Color3 } from "babylonjs/Maths/math.color";
  54851. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54853. import { Mesh } from "babylonjs/Meshes/mesh";
  54854. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  54855. import { EasingFunction } from "babylonjs/Animations/easing";
  54856. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  54857. import "babylonjs/Meshes/Builders/groundBuilder";
  54858. import "babylonjs/Meshes/Builders/torusBuilder";
  54859. import "babylonjs/Meshes/Builders/cylinderBuilder";
  54860. import "babylonjs/Gamepads/gamepadSceneComponent";
  54861. import "babylonjs/Animations/animatable";
  54862. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  54863. /**
  54864. * Options to modify the vr teleportation behavior.
  54865. */
  54866. export interface VRTeleportationOptions {
  54867. /**
  54868. * The name of the mesh which should be used as the teleportation floor. (default: null)
  54869. */
  54870. floorMeshName?: string;
  54871. /**
  54872. * A list of meshes to be used as the teleportation floor. (default: empty)
  54873. */
  54874. floorMeshes?: Mesh[];
  54875. /**
  54876. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  54877. */
  54878. teleportationMode?: number;
  54879. /**
  54880. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  54881. */
  54882. teleportationTime?: number;
  54883. /**
  54884. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  54885. */
  54886. teleportationSpeed?: number;
  54887. /**
  54888. * The easing function used in the animation or null for Linear. (default CircleEase)
  54889. */
  54890. easingFunction?: EasingFunction;
  54891. }
  54892. /**
  54893. * Options to modify the vr experience helper's behavior.
  54894. */
  54895. export interface VRExperienceHelperOptions extends WebVROptions {
  54896. /**
  54897. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  54898. */
  54899. createDeviceOrientationCamera?: boolean;
  54900. /**
  54901. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  54902. */
  54903. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  54904. /**
  54905. * Uses the main button on the controller to toggle the laser casted. (default: true)
  54906. */
  54907. laserToggle?: boolean;
  54908. /**
  54909. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  54910. */
  54911. floorMeshes?: Mesh[];
  54912. /**
  54913. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  54914. */
  54915. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  54916. /**
  54917. * Defines if WebXR should be used instead of WebVR (if available)
  54918. */
  54919. useXR?: boolean;
  54920. }
  54921. /**
  54922. * Event containing information after VR has been entered
  54923. */
  54924. export class OnAfterEnteringVRObservableEvent {
  54925. /**
  54926. * If entering vr was successful
  54927. */
  54928. success: boolean;
  54929. }
  54930. /**
  54931. * Helps to quickly add VR support to an existing scene.
  54932. * See https://doc.babylonjs.com/how_to/webvr_helper
  54933. */
  54934. export class VRExperienceHelper {
  54935. /** Options to modify the vr experience helper's behavior. */
  54936. webVROptions: VRExperienceHelperOptions;
  54937. private _scene;
  54938. private _position;
  54939. private _btnVR;
  54940. private _btnVRDisplayed;
  54941. private _webVRsupported;
  54942. private _webVRready;
  54943. private _webVRrequesting;
  54944. private _webVRpresenting;
  54945. private _hasEnteredVR;
  54946. private _fullscreenVRpresenting;
  54947. private _inputElement;
  54948. private _webVRCamera;
  54949. private _vrDeviceOrientationCamera;
  54950. private _deviceOrientationCamera;
  54951. private _existingCamera;
  54952. private _onKeyDown;
  54953. private _onVrDisplayPresentChange;
  54954. private _onVRDisplayChanged;
  54955. private _onVRRequestPresentStart;
  54956. private _onVRRequestPresentComplete;
  54957. /**
  54958. * 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)
  54959. */
  54960. enableGazeEvenWhenNoPointerLock: boolean;
  54961. /**
  54962. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  54963. */
  54964. exitVROnDoubleTap: boolean;
  54965. /**
  54966. * Observable raised right before entering VR.
  54967. */
  54968. onEnteringVRObservable: Observable<VRExperienceHelper>;
  54969. /**
  54970. * Observable raised when entering VR has completed.
  54971. */
  54972. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  54973. /**
  54974. * Observable raised when exiting VR.
  54975. */
  54976. onExitingVRObservable: Observable<VRExperienceHelper>;
  54977. /**
  54978. * Observable raised when controller mesh is loaded.
  54979. */
  54980. onControllerMeshLoadedObservable: Observable<WebVRController>;
  54981. /** Return this.onEnteringVRObservable
  54982. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  54983. */
  54984. get onEnteringVR(): Observable<VRExperienceHelper>;
  54985. /** Return this.onExitingVRObservable
  54986. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  54987. */
  54988. get onExitingVR(): Observable<VRExperienceHelper>;
  54989. /** Return this.onControllerMeshLoadedObservable
  54990. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  54991. */
  54992. get onControllerMeshLoaded(): Observable<WebVRController>;
  54993. private _rayLength;
  54994. private _useCustomVRButton;
  54995. private _teleportationRequested;
  54996. private _teleportActive;
  54997. private _floorMeshName;
  54998. private _floorMeshesCollection;
  54999. private _teleportationMode;
  55000. private _teleportationTime;
  55001. private _teleportationSpeed;
  55002. private _teleportationEasing;
  55003. private _rotationAllowed;
  55004. private _teleportBackwardsVector;
  55005. private _teleportationTarget;
  55006. private _isDefaultTeleportationTarget;
  55007. private _postProcessMove;
  55008. private _teleportationFillColor;
  55009. private _teleportationBorderColor;
  55010. private _rotationAngle;
  55011. private _haloCenter;
  55012. private _cameraGazer;
  55013. private _padSensibilityUp;
  55014. private _padSensibilityDown;
  55015. private _leftController;
  55016. private _rightController;
  55017. private _gazeColor;
  55018. private _laserColor;
  55019. private _pickedLaserColor;
  55020. private _pickedGazeColor;
  55021. /**
  55022. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  55023. */
  55024. onNewMeshSelected: Observable<AbstractMesh>;
  55025. /**
  55026. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  55027. * This observable will provide the mesh and the controller used to select the mesh
  55028. */
  55029. onMeshSelectedWithController: Observable<{
  55030. mesh: AbstractMesh;
  55031. controller: WebVRController;
  55032. }>;
  55033. /**
  55034. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  55035. */
  55036. onNewMeshPicked: Observable<PickingInfo>;
  55037. private _circleEase;
  55038. /**
  55039. * Observable raised before camera teleportation
  55040. */
  55041. onBeforeCameraTeleport: Observable<Vector3>;
  55042. /**
  55043. * Observable raised after camera teleportation
  55044. */
  55045. onAfterCameraTeleport: Observable<Vector3>;
  55046. /**
  55047. * Observable raised when current selected mesh gets unselected
  55048. */
  55049. onSelectedMeshUnselected: Observable<AbstractMesh>;
  55050. private _raySelectionPredicate;
  55051. /**
  55052. * To be optionaly changed by user to define custom ray selection
  55053. */
  55054. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55055. /**
  55056. * To be optionaly changed by user to define custom selection logic (after ray selection)
  55057. */
  55058. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55059. /**
  55060. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  55061. */
  55062. teleportationEnabled: boolean;
  55063. private _defaultHeight;
  55064. private _teleportationInitialized;
  55065. private _interactionsEnabled;
  55066. private _interactionsRequested;
  55067. private _displayGaze;
  55068. private _displayLaserPointer;
  55069. /**
  55070. * The mesh used to display where the user is going to teleport.
  55071. */
  55072. get teleportationTarget(): Mesh;
  55073. /**
  55074. * Sets the mesh to be used to display where the user is going to teleport.
  55075. */
  55076. set teleportationTarget(value: Mesh);
  55077. /**
  55078. * 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
  55079. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  55080. * See https://doc.babylonjs.com/resources/baking_transformations
  55081. */
  55082. get gazeTrackerMesh(): Mesh;
  55083. set gazeTrackerMesh(value: Mesh);
  55084. /**
  55085. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  55086. */
  55087. updateGazeTrackerScale: boolean;
  55088. /**
  55089. * If the gaze trackers color should be updated when selecting meshes
  55090. */
  55091. updateGazeTrackerColor: boolean;
  55092. /**
  55093. * If the controller laser color should be updated when selecting meshes
  55094. */
  55095. updateControllerLaserColor: boolean;
  55096. /**
  55097. * The gaze tracking mesh corresponding to the left controller
  55098. */
  55099. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  55100. /**
  55101. * The gaze tracking mesh corresponding to the right controller
  55102. */
  55103. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  55104. /**
  55105. * If the ray of the gaze should be displayed.
  55106. */
  55107. get displayGaze(): boolean;
  55108. /**
  55109. * Sets if the ray of the gaze should be displayed.
  55110. */
  55111. set displayGaze(value: boolean);
  55112. /**
  55113. * If the ray of the LaserPointer should be displayed.
  55114. */
  55115. get displayLaserPointer(): boolean;
  55116. /**
  55117. * Sets if the ray of the LaserPointer should be displayed.
  55118. */
  55119. set displayLaserPointer(value: boolean);
  55120. /**
  55121. * The deviceOrientationCamera used as the camera when not in VR.
  55122. */
  55123. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  55124. /**
  55125. * Based on the current WebVR support, returns the current VR camera used.
  55126. */
  55127. get currentVRCamera(): Nullable<Camera>;
  55128. /**
  55129. * The webVRCamera which is used when in VR.
  55130. */
  55131. get webVRCamera(): WebVRFreeCamera;
  55132. /**
  55133. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  55134. */
  55135. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  55136. /**
  55137. * The html button that is used to trigger entering into VR.
  55138. */
  55139. get vrButton(): Nullable<HTMLButtonElement>;
  55140. private get _teleportationRequestInitiated();
  55141. /**
  55142. * Defines whether or not Pointer lock should be requested when switching to
  55143. * full screen.
  55144. */
  55145. requestPointerLockOnFullScreen: boolean;
  55146. /**
  55147. * If asking to force XR, this will be populated with the default xr experience
  55148. */
  55149. xr: WebXRDefaultExperience;
  55150. /**
  55151. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  55152. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  55153. */
  55154. xrTestDone: boolean;
  55155. /**
  55156. * Instantiates a VRExperienceHelper.
  55157. * Helps to quickly add VR support to an existing scene.
  55158. * @param scene The scene the VRExperienceHelper belongs to.
  55159. * @param webVROptions Options to modify the vr experience helper's behavior.
  55160. */
  55161. constructor(scene: Scene,
  55162. /** Options to modify the vr experience helper's behavior. */
  55163. webVROptions?: VRExperienceHelperOptions);
  55164. private completeVRInit;
  55165. private _onDefaultMeshLoaded;
  55166. private _onResize;
  55167. private _onFullscreenChange;
  55168. /**
  55169. * Gets a value indicating if we are currently in VR mode.
  55170. */
  55171. get isInVRMode(): boolean;
  55172. private onVrDisplayPresentChange;
  55173. private onVRDisplayChanged;
  55174. private moveButtonToBottomRight;
  55175. private displayVRButton;
  55176. private updateButtonVisibility;
  55177. private _cachedAngularSensibility;
  55178. /**
  55179. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  55180. * Otherwise, will use the fullscreen API.
  55181. */
  55182. enterVR(): void;
  55183. /**
  55184. * Attempt to exit VR, or fullscreen.
  55185. */
  55186. exitVR(): void;
  55187. /**
  55188. * The position of the vr experience helper.
  55189. */
  55190. get position(): Vector3;
  55191. /**
  55192. * Sets the position of the vr experience helper.
  55193. */
  55194. set position(value: Vector3);
  55195. /**
  55196. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  55197. */
  55198. enableInteractions(): void;
  55199. private get _noControllerIsActive();
  55200. private beforeRender;
  55201. private _isTeleportationFloor;
  55202. /**
  55203. * Adds a floor mesh to be used for teleportation.
  55204. * @param floorMesh the mesh to be used for teleportation.
  55205. */
  55206. addFloorMesh(floorMesh: Mesh): void;
  55207. /**
  55208. * Removes a floor mesh from being used for teleportation.
  55209. * @param floorMesh the mesh to be removed.
  55210. */
  55211. removeFloorMesh(floorMesh: Mesh): void;
  55212. /**
  55213. * Enables interactions and teleportation using the VR controllers and gaze.
  55214. * @param vrTeleportationOptions options to modify teleportation behavior.
  55215. */
  55216. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  55217. private _onNewGamepadConnected;
  55218. private _tryEnableInteractionOnController;
  55219. private _onNewGamepadDisconnected;
  55220. private _enableInteractionOnController;
  55221. private _checkTeleportWithRay;
  55222. private _checkRotate;
  55223. private _checkTeleportBackwards;
  55224. private _enableTeleportationOnController;
  55225. private _createTeleportationCircles;
  55226. private _displayTeleportationTarget;
  55227. private _hideTeleportationTarget;
  55228. private _rotateCamera;
  55229. private _moveTeleportationSelectorTo;
  55230. private _workingVector;
  55231. private _workingQuaternion;
  55232. private _workingMatrix;
  55233. /**
  55234. * Time Constant Teleportation Mode
  55235. */
  55236. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  55237. /**
  55238. * Speed Constant Teleportation Mode
  55239. */
  55240. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  55241. /**
  55242. * Teleports the users feet to the desired location
  55243. * @param location The location where the user's feet should be placed
  55244. */
  55245. teleportCamera(location: Vector3): void;
  55246. private _convertNormalToDirectionOfRay;
  55247. private _castRayAndSelectObject;
  55248. private _notifySelectedMeshUnselected;
  55249. /**
  55250. * Permanently set new colors for the laser pointer
  55251. * @param color the new laser color
  55252. * @param pickedColor the new laser color when picked mesh detected
  55253. */
  55254. setLaserColor(color: Color3, pickedColor?: Color3): void;
  55255. /**
  55256. * Set lighting enabled / disabled on the laser pointer of both controllers
  55257. * @param enabled should the lighting be enabled on the laser pointer
  55258. */
  55259. setLaserLightingState(enabled?: boolean): void;
  55260. /**
  55261. * Permanently set new colors for the gaze pointer
  55262. * @param color the new gaze color
  55263. * @param pickedColor the new gaze color when picked mesh detected
  55264. */
  55265. setGazeColor(color: Color3, pickedColor?: Color3): void;
  55266. /**
  55267. * Sets the color of the laser ray from the vr controllers.
  55268. * @param color new color for the ray.
  55269. */
  55270. changeLaserColor(color: Color3): void;
  55271. /**
  55272. * Sets the color of the ray from the vr headsets gaze.
  55273. * @param color new color for the ray.
  55274. */
  55275. changeGazeColor(color: Color3): void;
  55276. /**
  55277. * Exits VR and disposes of the vr experience helper
  55278. */
  55279. dispose(): void;
  55280. /**
  55281. * Gets the name of the VRExperienceHelper class
  55282. * @returns "VRExperienceHelper"
  55283. */
  55284. getClassName(): string;
  55285. }
  55286. }
  55287. declare module "babylonjs/Cameras/VR/index" {
  55288. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  55289. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  55290. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55291. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  55292. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  55293. export * from "babylonjs/Cameras/VR/webVRCamera";
  55294. }
  55295. declare module "babylonjs/Cameras/RigModes/index" {
  55296. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55297. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55298. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  55299. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  55300. }
  55301. declare module "babylonjs/Cameras/index" {
  55302. export * from "babylonjs/Cameras/Inputs/index";
  55303. export * from "babylonjs/Cameras/cameraInputsManager";
  55304. export * from "babylonjs/Cameras/camera";
  55305. export * from "babylonjs/Cameras/targetCamera";
  55306. export * from "babylonjs/Cameras/freeCamera";
  55307. export * from "babylonjs/Cameras/freeCameraInputsManager";
  55308. export * from "babylonjs/Cameras/touchCamera";
  55309. export * from "babylonjs/Cameras/arcRotateCamera";
  55310. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  55311. export * from "babylonjs/Cameras/deviceOrientationCamera";
  55312. export * from "babylonjs/Cameras/flyCamera";
  55313. export * from "babylonjs/Cameras/flyCameraInputsManager";
  55314. export * from "babylonjs/Cameras/followCamera";
  55315. export * from "babylonjs/Cameras/followCameraInputsManager";
  55316. export * from "babylonjs/Cameras/gamepadCamera";
  55317. export * from "babylonjs/Cameras/Stereoscopic/index";
  55318. export * from "babylonjs/Cameras/universalCamera";
  55319. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  55320. export * from "babylonjs/Cameras/VR/index";
  55321. export * from "babylonjs/Cameras/RigModes/index";
  55322. }
  55323. declare module "babylonjs/Collisions/index" {
  55324. export * from "babylonjs/Collisions/collider";
  55325. export * from "babylonjs/Collisions/collisionCoordinator";
  55326. export * from "babylonjs/Collisions/pickingInfo";
  55327. export * from "babylonjs/Collisions/intersectionInfo";
  55328. export * from "babylonjs/Collisions/meshCollisionData";
  55329. }
  55330. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  55331. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  55332. import { Vector3 } from "babylonjs/Maths/math.vector";
  55333. import { Ray } from "babylonjs/Culling/ray";
  55334. import { Plane } from "babylonjs/Maths/math.plane";
  55335. /**
  55336. * Contains an array of blocks representing the octree
  55337. */
  55338. export interface IOctreeContainer<T> {
  55339. /**
  55340. * Blocks within the octree
  55341. */
  55342. blocks: Array<OctreeBlock<T>>;
  55343. }
  55344. /**
  55345. * Class used to store a cell in an octree
  55346. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55347. */
  55348. export class OctreeBlock<T> {
  55349. /**
  55350. * Gets the content of the current block
  55351. */
  55352. entries: T[];
  55353. /**
  55354. * Gets the list of block children
  55355. */
  55356. blocks: Array<OctreeBlock<T>>;
  55357. private _depth;
  55358. private _maxDepth;
  55359. private _capacity;
  55360. private _minPoint;
  55361. private _maxPoint;
  55362. private _boundingVectors;
  55363. private _creationFunc;
  55364. /**
  55365. * Creates a new block
  55366. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  55367. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  55368. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55369. * @param depth defines the current depth of this block in the octree
  55370. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  55371. * @param creationFunc defines a callback to call when an element is added to the block
  55372. */
  55373. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  55374. /**
  55375. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55376. */
  55377. get capacity(): number;
  55378. /**
  55379. * Gets the minimum vector (in world space) of the block's bounding box
  55380. */
  55381. get minPoint(): Vector3;
  55382. /**
  55383. * Gets the maximum vector (in world space) of the block's bounding box
  55384. */
  55385. get maxPoint(): Vector3;
  55386. /**
  55387. * Add a new element to this block
  55388. * @param entry defines the element to add
  55389. */
  55390. addEntry(entry: T): void;
  55391. /**
  55392. * Remove an element from this block
  55393. * @param entry defines the element to remove
  55394. */
  55395. removeEntry(entry: T): void;
  55396. /**
  55397. * Add an array of elements to this block
  55398. * @param entries defines the array of elements to add
  55399. */
  55400. addEntries(entries: T[]): void;
  55401. /**
  55402. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  55403. * @param frustumPlanes defines the frustum planes to test
  55404. * @param selection defines the array to store current content if selection is positive
  55405. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55406. */
  55407. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55408. /**
  55409. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  55410. * @param sphereCenter defines the bounding sphere center
  55411. * @param sphereRadius defines the bounding sphere radius
  55412. * @param selection defines the array to store current content if selection is positive
  55413. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55414. */
  55415. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55416. /**
  55417. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  55418. * @param ray defines the ray to test with
  55419. * @param selection defines the array to store current content if selection is positive
  55420. */
  55421. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  55422. /**
  55423. * Subdivide the content into child blocks (this block will then be empty)
  55424. */
  55425. createInnerBlocks(): void;
  55426. /**
  55427. * @hidden
  55428. */
  55429. 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;
  55430. }
  55431. }
  55432. declare module "babylonjs/Culling/Octrees/octree" {
  55433. import { SmartArray } from "babylonjs/Misc/smartArray";
  55434. import { Vector3 } from "babylonjs/Maths/math.vector";
  55435. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55437. import { Ray } from "babylonjs/Culling/ray";
  55438. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  55439. import { Plane } from "babylonjs/Maths/math.plane";
  55440. /**
  55441. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  55442. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55443. */
  55444. export class Octree<T> {
  55445. /** 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.) */
  55446. maxDepth: number;
  55447. /**
  55448. * Blocks within the octree containing objects
  55449. */
  55450. blocks: Array<OctreeBlock<T>>;
  55451. /**
  55452. * Content stored in the octree
  55453. */
  55454. dynamicContent: T[];
  55455. private _maxBlockCapacity;
  55456. private _selectionContent;
  55457. private _creationFunc;
  55458. /**
  55459. * Creates a octree
  55460. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55461. * @param creationFunc function to be used to instatiate the octree
  55462. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  55463. * @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.)
  55464. */
  55465. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  55466. /** 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.) */
  55467. maxDepth?: number);
  55468. /**
  55469. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  55470. * @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);
  55471. * @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);
  55472. * @param entries meshes to be added to the octree blocks
  55473. */
  55474. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  55475. /**
  55476. * Adds a mesh to the octree
  55477. * @param entry Mesh to add to the octree
  55478. */
  55479. addMesh(entry: T): void;
  55480. /**
  55481. * Remove an element from the octree
  55482. * @param entry defines the element to remove
  55483. */
  55484. removeMesh(entry: T): void;
  55485. /**
  55486. * Selects an array of meshes within the frustum
  55487. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  55488. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  55489. * @returns array of meshes within the frustum
  55490. */
  55491. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  55492. /**
  55493. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  55494. * @param sphereCenter defines the bounding sphere center
  55495. * @param sphereRadius defines the bounding sphere radius
  55496. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55497. * @returns an array of objects that intersect the sphere
  55498. */
  55499. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  55500. /**
  55501. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  55502. * @param ray defines the ray to test with
  55503. * @returns array of intersected objects
  55504. */
  55505. intersectsRay(ray: Ray): SmartArray<T>;
  55506. /**
  55507. * Adds a mesh into the octree block if it intersects the block
  55508. */
  55509. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  55510. /**
  55511. * Adds a submesh into the octree block if it intersects the block
  55512. */
  55513. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  55514. }
  55515. }
  55516. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  55517. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  55518. import { Scene } from "babylonjs/scene";
  55519. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55521. import { Ray } from "babylonjs/Culling/ray";
  55522. import { Octree } from "babylonjs/Culling/Octrees/octree";
  55523. import { Collider } from "babylonjs/Collisions/collider";
  55524. module "babylonjs/scene" {
  55525. interface Scene {
  55526. /**
  55527. * @hidden
  55528. * Backing Filed
  55529. */
  55530. _selectionOctree: Octree<AbstractMesh>;
  55531. /**
  55532. * Gets the octree used to boost mesh selection (picking)
  55533. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55534. */
  55535. selectionOctree: Octree<AbstractMesh>;
  55536. /**
  55537. * Creates or updates the octree used to boost selection (picking)
  55538. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55539. * @param maxCapacity defines the maximum capacity per leaf
  55540. * @param maxDepth defines the maximum depth of the octree
  55541. * @returns an octree of AbstractMesh
  55542. */
  55543. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  55544. }
  55545. }
  55546. module "babylonjs/Meshes/abstractMesh" {
  55547. interface AbstractMesh {
  55548. /**
  55549. * @hidden
  55550. * Backing Field
  55551. */
  55552. _submeshesOctree: Octree<SubMesh>;
  55553. /**
  55554. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  55555. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  55556. * @param maxCapacity defines the maximum size of each block (64 by default)
  55557. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  55558. * @returns the new octree
  55559. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  55560. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55561. */
  55562. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  55563. }
  55564. }
  55565. /**
  55566. * Defines the octree scene component responsible to manage any octrees
  55567. * in a given scene.
  55568. */
  55569. export class OctreeSceneComponent {
  55570. /**
  55571. * The component name help to identify the component in the list of scene components.
  55572. */
  55573. readonly name: string;
  55574. /**
  55575. * The scene the component belongs to.
  55576. */
  55577. scene: Scene;
  55578. /**
  55579. * Indicates if the meshes have been checked to make sure they are isEnabled()
  55580. */
  55581. readonly checksIsEnabled: boolean;
  55582. /**
  55583. * Creates a new instance of the component for the given scene
  55584. * @param scene Defines the scene to register the component in
  55585. */
  55586. constructor(scene: Scene);
  55587. /**
  55588. * Registers the component in a given scene
  55589. */
  55590. register(): void;
  55591. /**
  55592. * Return the list of active meshes
  55593. * @returns the list of active meshes
  55594. */
  55595. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  55596. /**
  55597. * Return the list of active sub meshes
  55598. * @param mesh The mesh to get the candidates sub meshes from
  55599. * @returns the list of active sub meshes
  55600. */
  55601. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  55602. private _tempRay;
  55603. /**
  55604. * Return the list of sub meshes intersecting with a given local ray
  55605. * @param mesh defines the mesh to find the submesh for
  55606. * @param localRay defines the ray in local space
  55607. * @returns the list of intersecting sub meshes
  55608. */
  55609. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  55610. /**
  55611. * Return the list of sub meshes colliding with a collider
  55612. * @param mesh defines the mesh to find the submesh for
  55613. * @param collider defines the collider to evaluate the collision against
  55614. * @returns the list of colliding sub meshes
  55615. */
  55616. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  55617. /**
  55618. * Rebuilds the elements related to this component in case of
  55619. * context lost for instance.
  55620. */
  55621. rebuild(): void;
  55622. /**
  55623. * Disposes the component and the associated ressources.
  55624. */
  55625. dispose(): void;
  55626. }
  55627. }
  55628. declare module "babylonjs/Culling/Octrees/index" {
  55629. export * from "babylonjs/Culling/Octrees/octree";
  55630. export * from "babylonjs/Culling/Octrees/octreeBlock";
  55631. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  55632. }
  55633. declare module "babylonjs/Culling/index" {
  55634. export * from "babylonjs/Culling/boundingBox";
  55635. export * from "babylonjs/Culling/boundingInfo";
  55636. export * from "babylonjs/Culling/boundingSphere";
  55637. export * from "babylonjs/Culling/Octrees/index";
  55638. export * from "babylonjs/Culling/ray";
  55639. }
  55640. declare module "babylonjs/Gizmos/gizmo" {
  55641. import { Nullable } from "babylonjs/types";
  55642. import { IDisposable } from "babylonjs/scene";
  55643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55644. import { Mesh } from "babylonjs/Meshes/mesh";
  55645. import { Node } from "babylonjs/node";
  55646. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55647. /**
  55648. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  55649. */
  55650. export class Gizmo implements IDisposable {
  55651. /** The utility layer the gizmo will be added to */
  55652. gizmoLayer: UtilityLayerRenderer;
  55653. /**
  55654. * The root mesh of the gizmo
  55655. */
  55656. _rootMesh: Mesh;
  55657. private _attachedMesh;
  55658. private _attachedNode;
  55659. /**
  55660. * Ratio for the scale of the gizmo (Default: 1)
  55661. */
  55662. protected _scaleRatio: number;
  55663. /**
  55664. * boolean updated by pointermove when a gizmo mesh is hovered
  55665. */
  55666. protected _isHovered: boolean;
  55667. /**
  55668. * Ratio for the scale of the gizmo (Default: 1)
  55669. */
  55670. set scaleRatio(value: number);
  55671. get scaleRatio(): number;
  55672. /**
  55673. * True when the mouse pointer is hovered a gizmo mesh
  55674. */
  55675. get isHovered(): boolean;
  55676. /**
  55677. * If a custom mesh has been set (Default: false)
  55678. */
  55679. protected _customMeshSet: boolean;
  55680. /**
  55681. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  55682. * * When set, interactions will be enabled
  55683. */
  55684. get attachedMesh(): Nullable<AbstractMesh>;
  55685. set attachedMesh(value: Nullable<AbstractMesh>);
  55686. /**
  55687. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  55688. * * When set, interactions will be enabled
  55689. */
  55690. get attachedNode(): Nullable<Node>;
  55691. set attachedNode(value: Nullable<Node>);
  55692. /**
  55693. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55694. * @param mesh The mesh to replace the default mesh of the gizmo
  55695. */
  55696. setCustomMesh(mesh: Mesh): void;
  55697. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  55698. /**
  55699. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  55700. */
  55701. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55702. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55703. /**
  55704. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  55705. */
  55706. updateGizmoPositionToMatchAttachedMesh: boolean;
  55707. /**
  55708. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  55709. */
  55710. updateScale: boolean;
  55711. protected _interactionsEnabled: boolean;
  55712. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55713. private _beforeRenderObserver;
  55714. private _tempQuaternion;
  55715. private _tempVector;
  55716. private _tempVector2;
  55717. private _tempMatrix1;
  55718. private _tempMatrix2;
  55719. private _rightHandtoLeftHandMatrix;
  55720. /**
  55721. * Creates a gizmo
  55722. * @param gizmoLayer The utility layer the gizmo will be added to
  55723. */
  55724. constructor(
  55725. /** The utility layer the gizmo will be added to */
  55726. gizmoLayer?: UtilityLayerRenderer);
  55727. /**
  55728. * Updates the gizmo to match the attached mesh's position/rotation
  55729. */
  55730. protected _update(): void;
  55731. /**
  55732. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  55733. * @param value Node, TransformNode or mesh
  55734. */
  55735. protected _matrixChanged(): void;
  55736. /**
  55737. * Disposes of the gizmo
  55738. */
  55739. dispose(): void;
  55740. }
  55741. }
  55742. declare module "babylonjs/Gizmos/planeDragGizmo" {
  55743. import { Observable } from "babylonjs/Misc/observable";
  55744. import { Nullable } from "babylonjs/types";
  55745. import { Vector3 } from "babylonjs/Maths/math.vector";
  55746. import { Color3 } from "babylonjs/Maths/math.color";
  55747. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55748. import { Node } from "babylonjs/node";
  55749. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55750. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55751. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55752. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55753. import { Scene } from "babylonjs/scene";
  55754. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55755. /**
  55756. * Single plane drag gizmo
  55757. */
  55758. export class PlaneDragGizmo extends Gizmo {
  55759. /**
  55760. * Drag behavior responsible for the gizmos dragging interactions
  55761. */
  55762. dragBehavior: PointerDragBehavior;
  55763. private _pointerObserver;
  55764. /**
  55765. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55766. */
  55767. snapDistance: number;
  55768. /**
  55769. * Event that fires each time the gizmo snaps to a new location.
  55770. * * snapDistance is the the change in distance
  55771. */
  55772. onSnapObservable: Observable<{
  55773. snapDistance: number;
  55774. }>;
  55775. private _plane;
  55776. private _coloredMaterial;
  55777. private _hoverMaterial;
  55778. private _isEnabled;
  55779. private _parent;
  55780. /** @hidden */
  55781. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  55782. /** @hidden */
  55783. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55784. /**
  55785. * Creates a PlaneDragGizmo
  55786. * @param gizmoLayer The utility layer the gizmo will be added to
  55787. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  55788. * @param color The color of the gizmo
  55789. */
  55790. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  55791. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55792. /**
  55793. * If the gizmo is enabled
  55794. */
  55795. set isEnabled(value: boolean);
  55796. get isEnabled(): boolean;
  55797. /**
  55798. * Disposes of the gizmo
  55799. */
  55800. dispose(): void;
  55801. }
  55802. }
  55803. declare module "babylonjs/Gizmos/positionGizmo" {
  55804. import { Observable } from "babylonjs/Misc/observable";
  55805. import { Nullable } from "babylonjs/types";
  55806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55807. import { Node } from "babylonjs/node";
  55808. import { Mesh } from "babylonjs/Meshes/mesh";
  55809. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55810. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  55811. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  55812. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55813. /**
  55814. * Gizmo that enables dragging a mesh along 3 axis
  55815. */
  55816. export class PositionGizmo extends Gizmo {
  55817. /**
  55818. * Internal gizmo used for interactions on the x axis
  55819. */
  55820. xGizmo: AxisDragGizmo;
  55821. /**
  55822. * Internal gizmo used for interactions on the y axis
  55823. */
  55824. yGizmo: AxisDragGizmo;
  55825. /**
  55826. * Internal gizmo used for interactions on the z axis
  55827. */
  55828. zGizmo: AxisDragGizmo;
  55829. /**
  55830. * Internal gizmo used for interactions on the yz plane
  55831. */
  55832. xPlaneGizmo: PlaneDragGizmo;
  55833. /**
  55834. * Internal gizmo used for interactions on the xz plane
  55835. */
  55836. yPlaneGizmo: PlaneDragGizmo;
  55837. /**
  55838. * Internal gizmo used for interactions on the xy plane
  55839. */
  55840. zPlaneGizmo: PlaneDragGizmo;
  55841. /**
  55842. * private variables
  55843. */
  55844. private _meshAttached;
  55845. private _nodeAttached;
  55846. private _snapDistance;
  55847. /** Fires an event when any of it's sub gizmos are dragged */
  55848. onDragStartObservable: Observable<unknown>;
  55849. /** Fires an event when any of it's sub gizmos are released from dragging */
  55850. onDragEndObservable: Observable<unknown>;
  55851. /**
  55852. * If set to true, planar drag is enabled
  55853. */
  55854. private _planarGizmoEnabled;
  55855. get attachedMesh(): Nullable<AbstractMesh>;
  55856. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55857. get attachedNode(): Nullable<Node>;
  55858. set attachedNode(node: Nullable<Node>);
  55859. /**
  55860. * True when the mouse pointer is hovering a gizmo mesh
  55861. */
  55862. get isHovered(): boolean;
  55863. /**
  55864. * Creates a PositionGizmo
  55865. * @param gizmoLayer The utility layer the gizmo will be added to
  55866. @param thickness display gizmo axis thickness
  55867. */
  55868. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55869. /**
  55870. * If the planar drag gizmo is enabled
  55871. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  55872. */
  55873. set planarGizmoEnabled(value: boolean);
  55874. get planarGizmoEnabled(): boolean;
  55875. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55876. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55877. /**
  55878. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55879. */
  55880. set snapDistance(value: number);
  55881. get snapDistance(): number;
  55882. /**
  55883. * Ratio for the scale of the gizmo (Default: 1)
  55884. */
  55885. set scaleRatio(value: number);
  55886. get scaleRatio(): number;
  55887. /**
  55888. * Disposes of the gizmo
  55889. */
  55890. dispose(): void;
  55891. /**
  55892. * CustomMeshes are not supported by this gizmo
  55893. * @param mesh The mesh to replace the default mesh of the gizmo
  55894. */
  55895. setCustomMesh(mesh: Mesh): void;
  55896. }
  55897. }
  55898. declare module "babylonjs/Gizmos/axisDragGizmo" {
  55899. import { Observable } from "babylonjs/Misc/observable";
  55900. import { Nullable } from "babylonjs/types";
  55901. import { Vector3 } from "babylonjs/Maths/math.vector";
  55902. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55903. import { Node } from "babylonjs/node";
  55904. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55905. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55906. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55907. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55908. import { Scene } from "babylonjs/scene";
  55909. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55910. import { Color3 } from "babylonjs/Maths/math.color";
  55911. /**
  55912. * Single axis drag gizmo
  55913. */
  55914. export class AxisDragGizmo extends Gizmo {
  55915. /**
  55916. * Drag behavior responsible for the gizmos dragging interactions
  55917. */
  55918. dragBehavior: PointerDragBehavior;
  55919. private _pointerObserver;
  55920. /**
  55921. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55922. */
  55923. snapDistance: number;
  55924. /**
  55925. * Event that fires each time the gizmo snaps to a new location.
  55926. * * snapDistance is the the change in distance
  55927. */
  55928. onSnapObservable: Observable<{
  55929. snapDistance: number;
  55930. }>;
  55931. private _isEnabled;
  55932. private _parent;
  55933. private _arrow;
  55934. private _coloredMaterial;
  55935. private _hoverMaterial;
  55936. /** @hidden */
  55937. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  55938. /** @hidden */
  55939. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55940. /**
  55941. * Creates an AxisDragGizmo
  55942. * @param gizmoLayer The utility layer the gizmo will be added to
  55943. * @param dragAxis The axis which the gizmo will be able to drag on
  55944. * @param color The color of the gizmo
  55945. * @param thickness display gizmo axis thickness
  55946. */
  55947. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  55948. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55949. /**
  55950. * If the gizmo is enabled
  55951. */
  55952. set isEnabled(value: boolean);
  55953. get isEnabled(): boolean;
  55954. /**
  55955. * Disposes of the gizmo
  55956. */
  55957. dispose(): void;
  55958. }
  55959. }
  55960. declare module "babylonjs/Debug/axesViewer" {
  55961. import { Vector3 } from "babylonjs/Maths/math.vector";
  55962. import { Nullable } from "babylonjs/types";
  55963. import { Scene } from "babylonjs/scene";
  55964. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55965. /**
  55966. * The Axes viewer will show 3 axes in a specific point in space
  55967. */
  55968. export class AxesViewer {
  55969. private _xAxis;
  55970. private _yAxis;
  55971. private _zAxis;
  55972. private _scaleLinesFactor;
  55973. private _instanced;
  55974. /**
  55975. * Gets the hosting scene
  55976. */
  55977. scene: Nullable<Scene>;
  55978. /**
  55979. * Gets or sets a number used to scale line length
  55980. */
  55981. scaleLines: number;
  55982. /** Gets the node hierarchy used to render x-axis */
  55983. get xAxis(): TransformNode;
  55984. /** Gets the node hierarchy used to render y-axis */
  55985. get yAxis(): TransformNode;
  55986. /** Gets the node hierarchy used to render z-axis */
  55987. get zAxis(): TransformNode;
  55988. /**
  55989. * Creates a new AxesViewer
  55990. * @param scene defines the hosting scene
  55991. * @param scaleLines defines a number used to scale line length (1 by default)
  55992. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  55993. * @param xAxis defines the node hierarchy used to render the x-axis
  55994. * @param yAxis defines the node hierarchy used to render the y-axis
  55995. * @param zAxis defines the node hierarchy used to render the z-axis
  55996. */
  55997. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  55998. /**
  55999. * Force the viewer to update
  56000. * @param position defines the position of the viewer
  56001. * @param xaxis defines the x axis of the viewer
  56002. * @param yaxis defines the y axis of the viewer
  56003. * @param zaxis defines the z axis of the viewer
  56004. */
  56005. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  56006. /**
  56007. * Creates an instance of this axes viewer.
  56008. * @returns a new axes viewer with instanced meshes
  56009. */
  56010. createInstance(): AxesViewer;
  56011. /** Releases resources */
  56012. dispose(): void;
  56013. private static _SetRenderingGroupId;
  56014. }
  56015. }
  56016. declare module "babylonjs/Debug/boneAxesViewer" {
  56017. import { Nullable } from "babylonjs/types";
  56018. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  56019. import { Vector3 } from "babylonjs/Maths/math.vector";
  56020. import { Mesh } from "babylonjs/Meshes/mesh";
  56021. import { Bone } from "babylonjs/Bones/bone";
  56022. import { Scene } from "babylonjs/scene";
  56023. /**
  56024. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  56025. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  56026. */
  56027. export class BoneAxesViewer extends AxesViewer {
  56028. /**
  56029. * Gets or sets the target mesh where to display the axes viewer
  56030. */
  56031. mesh: Nullable<Mesh>;
  56032. /**
  56033. * Gets or sets the target bone where to display the axes viewer
  56034. */
  56035. bone: Nullable<Bone>;
  56036. /** Gets current position */
  56037. pos: Vector3;
  56038. /** Gets direction of X axis */
  56039. xaxis: Vector3;
  56040. /** Gets direction of Y axis */
  56041. yaxis: Vector3;
  56042. /** Gets direction of Z axis */
  56043. zaxis: Vector3;
  56044. /**
  56045. * Creates a new BoneAxesViewer
  56046. * @param scene defines the hosting scene
  56047. * @param bone defines the target bone
  56048. * @param mesh defines the target mesh
  56049. * @param scaleLines defines a scaling factor for line length (1 by default)
  56050. */
  56051. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  56052. /**
  56053. * Force the viewer to update
  56054. */
  56055. update(): void;
  56056. /** Releases resources */
  56057. dispose(): void;
  56058. }
  56059. }
  56060. declare module "babylonjs/Debug/debugLayer" {
  56061. import { Scene } from "babylonjs/scene";
  56062. /**
  56063. * Interface used to define scene explorer extensibility option
  56064. */
  56065. export interface IExplorerExtensibilityOption {
  56066. /**
  56067. * Define the option label
  56068. */
  56069. label: string;
  56070. /**
  56071. * Defines the action to execute on click
  56072. */
  56073. action: (entity: any) => void;
  56074. }
  56075. /**
  56076. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  56077. */
  56078. export interface IExplorerExtensibilityGroup {
  56079. /**
  56080. * Defines a predicate to test if a given type mut be extended
  56081. */
  56082. predicate: (entity: any) => boolean;
  56083. /**
  56084. * Gets the list of options added to a type
  56085. */
  56086. entries: IExplorerExtensibilityOption[];
  56087. }
  56088. /**
  56089. * Interface used to define the options to use to create the Inspector
  56090. */
  56091. export interface IInspectorOptions {
  56092. /**
  56093. * Display in overlay mode (default: false)
  56094. */
  56095. overlay?: boolean;
  56096. /**
  56097. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  56098. */
  56099. globalRoot?: HTMLElement;
  56100. /**
  56101. * Display the Scene explorer
  56102. */
  56103. showExplorer?: boolean;
  56104. /**
  56105. * Display the property inspector
  56106. */
  56107. showInspector?: boolean;
  56108. /**
  56109. * Display in embed mode (both panes on the right)
  56110. */
  56111. embedMode?: boolean;
  56112. /**
  56113. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  56114. */
  56115. handleResize?: boolean;
  56116. /**
  56117. * Allow the panes to popup (default: true)
  56118. */
  56119. enablePopup?: boolean;
  56120. /**
  56121. * Allow the panes to be closed by users (default: true)
  56122. */
  56123. enableClose?: boolean;
  56124. /**
  56125. * Optional list of extensibility entries
  56126. */
  56127. explorerExtensibility?: IExplorerExtensibilityGroup[];
  56128. /**
  56129. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  56130. */
  56131. inspectorURL?: string;
  56132. /**
  56133. * Optional initial tab (default to DebugLayerTab.Properties)
  56134. */
  56135. initialTab?: DebugLayerTab;
  56136. }
  56137. module "babylonjs/scene" {
  56138. interface Scene {
  56139. /**
  56140. * @hidden
  56141. * Backing field
  56142. */
  56143. _debugLayer: DebugLayer;
  56144. /**
  56145. * Gets the debug layer (aka Inspector) associated with the scene
  56146. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56147. */
  56148. debugLayer: DebugLayer;
  56149. }
  56150. }
  56151. /**
  56152. * Enum of inspector action tab
  56153. */
  56154. export enum DebugLayerTab {
  56155. /**
  56156. * Properties tag (default)
  56157. */
  56158. Properties = 0,
  56159. /**
  56160. * Debug tab
  56161. */
  56162. Debug = 1,
  56163. /**
  56164. * Statistics tab
  56165. */
  56166. Statistics = 2,
  56167. /**
  56168. * Tools tab
  56169. */
  56170. Tools = 3,
  56171. /**
  56172. * Settings tab
  56173. */
  56174. Settings = 4
  56175. }
  56176. /**
  56177. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56178. * what is happening in your scene
  56179. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56180. */
  56181. export class DebugLayer {
  56182. /**
  56183. * Define the url to get the inspector script from.
  56184. * By default it uses the babylonjs CDN.
  56185. * @ignoreNaming
  56186. */
  56187. static InspectorURL: string;
  56188. private _scene;
  56189. private BJSINSPECTOR;
  56190. private _onPropertyChangedObservable?;
  56191. /**
  56192. * Observable triggered when a property is changed through the inspector.
  56193. */
  56194. get onPropertyChangedObservable(): any;
  56195. /**
  56196. * Instantiates a new debug layer.
  56197. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56198. * what is happening in your scene
  56199. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56200. * @param scene Defines the scene to inspect
  56201. */
  56202. constructor(scene: Scene);
  56203. /** Creates the inspector window. */
  56204. private _createInspector;
  56205. /**
  56206. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  56207. * @param entity defines the entity to select
  56208. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  56209. */
  56210. select(entity: any, lineContainerTitles?: string | string[]): void;
  56211. /** Get the inspector from bundle or global */
  56212. private _getGlobalInspector;
  56213. /**
  56214. * Get if the inspector is visible or not.
  56215. * @returns true if visible otherwise, false
  56216. */
  56217. isVisible(): boolean;
  56218. /**
  56219. * Hide the inspector and close its window.
  56220. */
  56221. hide(): void;
  56222. /**
  56223. * Update the scene in the inspector
  56224. */
  56225. setAsActiveScene(): void;
  56226. /**
  56227. * Launch the debugLayer.
  56228. * @param config Define the configuration of the inspector
  56229. * @return a promise fulfilled when the debug layer is visible
  56230. */
  56231. show(config?: IInspectorOptions): Promise<DebugLayer>;
  56232. }
  56233. }
  56234. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  56235. import { Nullable } from "babylonjs/types";
  56236. import { Scene } from "babylonjs/scene";
  56237. import { Vector4 } from "babylonjs/Maths/math.vector";
  56238. import { Color4 } from "babylonjs/Maths/math.color";
  56239. import { Mesh } from "babylonjs/Meshes/mesh";
  56240. /**
  56241. * Class containing static functions to help procedurally build meshes
  56242. */
  56243. export class BoxBuilder {
  56244. /**
  56245. * Creates a box mesh
  56246. * * The parameter `size` sets the size (float) of each box side (default 1)
  56247. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56248. * * 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)
  56249. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56253. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56254. * @param name defines the name of the mesh
  56255. * @param options defines the options used to create the mesh
  56256. * @param scene defines the hosting scene
  56257. * @returns the box mesh
  56258. */
  56259. static CreateBox(name: string, options: {
  56260. size?: number;
  56261. width?: number;
  56262. height?: number;
  56263. depth?: number;
  56264. faceUV?: Vector4[];
  56265. faceColors?: Color4[];
  56266. sideOrientation?: number;
  56267. frontUVs?: Vector4;
  56268. backUVs?: Vector4;
  56269. wrap?: boolean;
  56270. topBaseAt?: number;
  56271. bottomBaseAt?: number;
  56272. updatable?: boolean;
  56273. }, scene?: Nullable<Scene>): Mesh;
  56274. }
  56275. }
  56276. declare module "babylonjs/Debug/physicsViewer" {
  56277. import { Nullable } from "babylonjs/types";
  56278. import { Scene } from "babylonjs/scene";
  56279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56280. import { Mesh } from "babylonjs/Meshes/mesh";
  56281. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56282. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56283. /**
  56284. * Used to show the physics impostor around the specific mesh
  56285. */
  56286. export class PhysicsViewer {
  56287. /** @hidden */
  56288. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  56289. /** @hidden */
  56290. protected _meshes: Array<Nullable<AbstractMesh>>;
  56291. /** @hidden */
  56292. protected _scene: Nullable<Scene>;
  56293. /** @hidden */
  56294. protected _numMeshes: number;
  56295. /** @hidden */
  56296. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  56297. private _renderFunction;
  56298. private _utilityLayer;
  56299. private _debugBoxMesh;
  56300. private _debugSphereMesh;
  56301. private _debugCylinderMesh;
  56302. private _debugMaterial;
  56303. private _debugMeshMeshes;
  56304. /**
  56305. * Creates a new PhysicsViewer
  56306. * @param scene defines the hosting scene
  56307. */
  56308. constructor(scene: Scene);
  56309. /** @hidden */
  56310. protected _updateDebugMeshes(): void;
  56311. /**
  56312. * Renders a specified physic impostor
  56313. * @param impostor defines the impostor to render
  56314. * @param targetMesh defines the mesh represented by the impostor
  56315. * @returns the new debug mesh used to render the impostor
  56316. */
  56317. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  56318. /**
  56319. * Hides a specified physic impostor
  56320. * @param impostor defines the impostor to hide
  56321. */
  56322. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  56323. private _getDebugMaterial;
  56324. private _getDebugBoxMesh;
  56325. private _getDebugSphereMesh;
  56326. private _getDebugCylinderMesh;
  56327. private _getDebugMeshMesh;
  56328. private _getDebugMesh;
  56329. /** Releases all resources */
  56330. dispose(): void;
  56331. }
  56332. }
  56333. declare module "babylonjs/Debug/rayHelper" {
  56334. import { Nullable } from "babylonjs/types";
  56335. import { Ray } from "babylonjs/Culling/ray";
  56336. import { Vector3 } from "babylonjs/Maths/math.vector";
  56337. import { Color3 } from "babylonjs/Maths/math.color";
  56338. import { Scene } from "babylonjs/scene";
  56339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56340. import "babylonjs/Meshes/Builders/linesBuilder";
  56341. /**
  56342. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56343. * in order to better appreciate the issue one might have.
  56344. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56345. */
  56346. export class RayHelper {
  56347. /**
  56348. * Defines the ray we are currently tryin to visualize.
  56349. */
  56350. ray: Nullable<Ray>;
  56351. private _renderPoints;
  56352. private _renderLine;
  56353. private _renderFunction;
  56354. private _scene;
  56355. private _onAfterRenderObserver;
  56356. private _onAfterStepObserver;
  56357. private _attachedToMesh;
  56358. private _meshSpaceDirection;
  56359. private _meshSpaceOrigin;
  56360. /**
  56361. * Helper function to create a colored helper in a scene in one line.
  56362. * @param ray Defines the ray we are currently tryin to visualize
  56363. * @param scene Defines the scene the ray is used in
  56364. * @param color Defines the color we want to see the ray in
  56365. * @returns The newly created ray helper.
  56366. */
  56367. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  56368. /**
  56369. * Instantiate a new ray helper.
  56370. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56371. * in order to better appreciate the issue one might have.
  56372. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56373. * @param ray Defines the ray we are currently tryin to visualize
  56374. */
  56375. constructor(ray: Ray);
  56376. /**
  56377. * Shows the ray we are willing to debug.
  56378. * @param scene Defines the scene the ray needs to be rendered in
  56379. * @param color Defines the color the ray needs to be rendered in
  56380. */
  56381. show(scene: Scene, color?: Color3): void;
  56382. /**
  56383. * Hides the ray we are debugging.
  56384. */
  56385. hide(): void;
  56386. private _render;
  56387. /**
  56388. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  56389. * @param mesh Defines the mesh we want the helper attached to
  56390. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  56391. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  56392. * @param length Defines the length of the ray
  56393. */
  56394. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  56395. /**
  56396. * Detach the ray helper from the mesh it has previously been attached to.
  56397. */
  56398. detachFromMesh(): void;
  56399. private _updateToMesh;
  56400. /**
  56401. * Dispose the helper and release its associated resources.
  56402. */
  56403. dispose(): void;
  56404. }
  56405. }
  56406. declare module "babylonjs/Debug/ISkeletonViewer" {
  56407. import { Skeleton } from "babylonjs/Bones/skeleton";
  56408. import { Color3 } from "babylonjs/Maths/math.color";
  56409. /**
  56410. * Defines the options associated with the creation of a SkeletonViewer.
  56411. */
  56412. export interface ISkeletonViewerOptions {
  56413. /** Should the system pause animations before building the Viewer? */
  56414. pauseAnimations: boolean;
  56415. /** Should the system return the skeleton to rest before building? */
  56416. returnToRest: boolean;
  56417. /** public Display Mode of the Viewer */
  56418. displayMode: number;
  56419. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56420. displayOptions: ISkeletonViewerDisplayOptions;
  56421. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56422. computeBonesUsingShaders: boolean;
  56423. /** Flag ignore non weighted bones */
  56424. useAllBones: boolean;
  56425. }
  56426. /**
  56427. * Defines how to display the various bone meshes for the viewer.
  56428. */
  56429. export interface ISkeletonViewerDisplayOptions {
  56430. /** How far down to start tapering the bone spurs */
  56431. midStep?: number;
  56432. /** How big is the midStep? */
  56433. midStepFactor?: number;
  56434. /** Base for the Sphere Size */
  56435. sphereBaseSize?: number;
  56436. /** The ratio of the sphere to the longest bone in units */
  56437. sphereScaleUnit?: number;
  56438. /** Ratio for the Sphere Size */
  56439. sphereFactor?: number;
  56440. /** Whether a spur should attach its far end to the child bone position */
  56441. spurFollowsChild?: boolean;
  56442. /** Whether to show local axes or not */
  56443. showLocalAxes?: boolean;
  56444. /** Length of each local axis */
  56445. localAxesSize?: number;
  56446. }
  56447. /**
  56448. * Defines the constructor options for the BoneWeight Shader.
  56449. */
  56450. export interface IBoneWeightShaderOptions {
  56451. /** Skeleton to Map */
  56452. skeleton: Skeleton;
  56453. /** Colors for Uninfluenced bones */
  56454. colorBase?: Color3;
  56455. /** Colors for 0.0-0.25 Weight bones */
  56456. colorZero?: Color3;
  56457. /** Color for 0.25-0.5 Weight Influence */
  56458. colorQuarter?: Color3;
  56459. /** Color for 0.5-0.75 Weight Influence */
  56460. colorHalf?: Color3;
  56461. /** Color for 0.75-1 Weight Influence */
  56462. colorFull?: Color3;
  56463. /** Color for Zero Weight Influence */
  56464. targetBoneIndex?: number;
  56465. }
  56466. /**
  56467. * Simple structure of the gradient steps for the Color Map.
  56468. */
  56469. export interface ISkeletonMapShaderColorMapKnot {
  56470. /** Color of the Knot */
  56471. color: Color3;
  56472. /** Location of the Knot */
  56473. location: number;
  56474. }
  56475. /**
  56476. * Defines the constructor options for the SkeletonMap Shader.
  56477. */
  56478. export interface ISkeletonMapShaderOptions {
  56479. /** Skeleton to Map */
  56480. skeleton: Skeleton;
  56481. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  56482. colorMap?: ISkeletonMapShaderColorMapKnot[];
  56483. }
  56484. }
  56485. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  56486. import { Nullable } from "babylonjs/types";
  56487. import { Scene } from "babylonjs/scene";
  56488. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  56489. import { Color4 } from "babylonjs/Maths/math.color";
  56490. import { Mesh } from "babylonjs/Meshes/mesh";
  56491. /**
  56492. * Class containing static functions to help procedurally build meshes
  56493. */
  56494. export class RibbonBuilder {
  56495. /**
  56496. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56497. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56498. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56499. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56500. * * 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
  56501. * * 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
  56502. * * 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
  56503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56505. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56506. * * 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
  56507. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56508. * * 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
  56509. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56511. * @param name defines the name of the mesh
  56512. * @param options defines the options used to create the mesh
  56513. * @param scene defines the hosting scene
  56514. * @returns the ribbon mesh
  56515. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56516. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56517. */
  56518. static CreateRibbon(name: string, options: {
  56519. pathArray: Vector3[][];
  56520. closeArray?: boolean;
  56521. closePath?: boolean;
  56522. offset?: number;
  56523. updatable?: boolean;
  56524. sideOrientation?: number;
  56525. frontUVs?: Vector4;
  56526. backUVs?: Vector4;
  56527. instance?: Mesh;
  56528. invertUV?: boolean;
  56529. uvs?: Vector2[];
  56530. colors?: Color4[];
  56531. }, scene?: Nullable<Scene>): Mesh;
  56532. }
  56533. }
  56534. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  56535. import { Nullable } from "babylonjs/types";
  56536. import { Scene } from "babylonjs/scene";
  56537. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56538. import { Mesh } from "babylonjs/Meshes/mesh";
  56539. /**
  56540. * Class containing static functions to help procedurally build meshes
  56541. */
  56542. export class ShapeBuilder {
  56543. /**
  56544. * 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.
  56545. * * 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.
  56546. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56547. * * 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.
  56548. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56549. * * 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
  56550. * * 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
  56551. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56554. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56556. * @param name defines the name of the mesh
  56557. * @param options defines the options used to create the mesh
  56558. * @param scene defines the hosting scene
  56559. * @returns the extruded shape mesh
  56560. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56561. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56562. */
  56563. static ExtrudeShape(name: string, options: {
  56564. shape: Vector3[];
  56565. path: Vector3[];
  56566. scale?: number;
  56567. rotation?: number;
  56568. cap?: number;
  56569. updatable?: boolean;
  56570. sideOrientation?: number;
  56571. frontUVs?: Vector4;
  56572. backUVs?: Vector4;
  56573. instance?: Mesh;
  56574. invertUV?: boolean;
  56575. }, scene?: Nullable<Scene>): Mesh;
  56576. /**
  56577. * Creates an custom extruded shape mesh.
  56578. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56579. * * 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.
  56580. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56581. * * 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
  56582. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56583. * * 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
  56584. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56585. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56586. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56587. * * 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
  56588. * * 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
  56589. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56591. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56592. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56594. * @param name defines the name of the mesh
  56595. * @param options defines the options used to create the mesh
  56596. * @param scene defines the hosting scene
  56597. * @returns the custom extruded shape mesh
  56598. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56599. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56600. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56601. */
  56602. static ExtrudeShapeCustom(name: string, options: {
  56603. shape: Vector3[];
  56604. path: Vector3[];
  56605. scaleFunction?: any;
  56606. rotationFunction?: any;
  56607. ribbonCloseArray?: boolean;
  56608. ribbonClosePath?: boolean;
  56609. cap?: number;
  56610. updatable?: boolean;
  56611. sideOrientation?: number;
  56612. frontUVs?: Vector4;
  56613. backUVs?: Vector4;
  56614. instance?: Mesh;
  56615. invertUV?: boolean;
  56616. }, scene?: Nullable<Scene>): Mesh;
  56617. private static _ExtrudeShapeGeneric;
  56618. }
  56619. }
  56620. declare module "babylonjs/Debug/skeletonViewer" {
  56621. import { Color3 } from "babylonjs/Maths/math.color";
  56622. import { Scene } from "babylonjs/scene";
  56623. import { Nullable } from "babylonjs/types";
  56624. import { Skeleton } from "babylonjs/Bones/skeleton";
  56625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56626. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56627. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56628. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  56629. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  56630. /**
  56631. * Class used to render a debug view of a given skeleton
  56632. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  56633. */
  56634. export class SkeletonViewer {
  56635. /** defines the skeleton to render */
  56636. skeleton: Skeleton;
  56637. /** defines the mesh attached to the skeleton */
  56638. mesh: AbstractMesh;
  56639. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56640. autoUpdateBonesMatrices: boolean;
  56641. /** defines the rendering group id to use with the viewer */
  56642. renderingGroupId: number;
  56643. /** is the options for the viewer */
  56644. options: Partial<ISkeletonViewerOptions>;
  56645. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  56646. static readonly DISPLAY_LINES: number;
  56647. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  56648. static readonly DISPLAY_SPHERES: number;
  56649. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  56650. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  56651. /** public static method to create a BoneWeight Shader
  56652. * @param options The constructor options
  56653. * @param scene The scene that the shader is scoped to
  56654. * @returns The created ShaderMaterial
  56655. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  56656. */
  56657. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  56658. /** public static method to create a BoneWeight Shader
  56659. * @param options The constructor options
  56660. * @param scene The scene that the shader is scoped to
  56661. * @returns The created ShaderMaterial
  56662. */
  56663. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  56664. /** private static method to create a BoneWeight Shader
  56665. * @param size The size of the buffer to create (usually the bone count)
  56666. * @param colorMap The gradient data to generate
  56667. * @param scene The scene that the shader is scoped to
  56668. * @returns an Array of floats from the color gradient values
  56669. */
  56670. private static _CreateBoneMapColorBuffer;
  56671. /** If SkeletonViewer scene scope. */
  56672. private _scene;
  56673. /** Gets or sets the color used to render the skeleton */
  56674. color: Color3;
  56675. /** Array of the points of the skeleton fo the line view. */
  56676. private _debugLines;
  56677. /** The SkeletonViewers Mesh. */
  56678. private _debugMesh;
  56679. /** The local axes Meshes. */
  56680. private _localAxes;
  56681. /** If SkeletonViewer is enabled. */
  56682. private _isEnabled;
  56683. /** If SkeletonViewer is ready. */
  56684. private _ready;
  56685. /** SkeletonViewer render observable. */
  56686. private _obs;
  56687. /** The Utility Layer to render the gizmos in. */
  56688. private _utilityLayer;
  56689. private _boneIndices;
  56690. /** Gets the Scene. */
  56691. get scene(): Scene;
  56692. /** Gets the utilityLayer. */
  56693. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  56694. /** Checks Ready Status. */
  56695. get isReady(): Boolean;
  56696. /** Sets Ready Status. */
  56697. set ready(value: boolean);
  56698. /** Gets the debugMesh */
  56699. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  56700. /** Sets the debugMesh */
  56701. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  56702. /** Gets the displayMode */
  56703. get displayMode(): number;
  56704. /** Sets the displayMode */
  56705. set displayMode(value: number);
  56706. /**
  56707. * Creates a new SkeletonViewer
  56708. * @param skeleton defines the skeleton to render
  56709. * @param mesh defines the mesh attached to the skeleton
  56710. * @param scene defines the hosting scene
  56711. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  56712. * @param renderingGroupId defines the rendering group id to use with the viewer
  56713. * @param options All of the extra constructor options for the SkeletonViewer
  56714. */
  56715. constructor(
  56716. /** defines the skeleton to render */
  56717. skeleton: Skeleton,
  56718. /** defines the mesh attached to the skeleton */
  56719. mesh: AbstractMesh,
  56720. /** The Scene scope*/
  56721. scene: Scene,
  56722. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56723. autoUpdateBonesMatrices?: boolean,
  56724. /** defines the rendering group id to use with the viewer */
  56725. renderingGroupId?: number,
  56726. /** is the options for the viewer */
  56727. options?: Partial<ISkeletonViewerOptions>);
  56728. /** The Dynamic bindings for the update functions */
  56729. private _bindObs;
  56730. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  56731. update(): void;
  56732. /** Gets or sets a boolean indicating if the viewer is enabled */
  56733. set isEnabled(value: boolean);
  56734. get isEnabled(): boolean;
  56735. private _getBonePosition;
  56736. private _getLinesForBonesWithLength;
  56737. private _getLinesForBonesNoLength;
  56738. /** function to revert the mesh and scene back to the initial state. */
  56739. private _revert;
  56740. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  56741. private _getAbsoluteBindPoseToRef;
  56742. /** function to build and bind sphere joint points and spur bone representations. */
  56743. private _buildSpheresAndSpurs;
  56744. private _buildLocalAxes;
  56745. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  56746. private _displayLinesUpdate;
  56747. /** Changes the displayMode of the skeleton viewer
  56748. * @param mode The displayMode numerical value
  56749. */
  56750. changeDisplayMode(mode: number): void;
  56751. /** Sets a display option of the skeleton viewer
  56752. *
  56753. * | Option | Type | Default | Description |
  56754. * | ---------------- | ------- | ------- | ----------- |
  56755. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  56756. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  56757. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  56758. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  56759. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  56760. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  56761. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  56762. *
  56763. * @param option String of the option name
  56764. * @param value The numerical option value
  56765. */
  56766. changeDisplayOptions(option: string, value: number): void;
  56767. /** Release associated resources */
  56768. dispose(): void;
  56769. }
  56770. }
  56771. declare module "babylonjs/Debug/index" {
  56772. export * from "babylonjs/Debug/axesViewer";
  56773. export * from "babylonjs/Debug/boneAxesViewer";
  56774. export * from "babylonjs/Debug/debugLayer";
  56775. export * from "babylonjs/Debug/physicsViewer";
  56776. export * from "babylonjs/Debug/rayHelper";
  56777. export * from "babylonjs/Debug/skeletonViewer";
  56778. export * from "babylonjs/Debug/ISkeletonViewer";
  56779. }
  56780. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  56781. /**
  56782. * Enum for Device Types
  56783. */
  56784. export enum DeviceType {
  56785. /** Generic */
  56786. Generic = 0,
  56787. /** Keyboard */
  56788. Keyboard = 1,
  56789. /** Mouse */
  56790. Mouse = 2,
  56791. /** Touch Pointers */
  56792. Touch = 3,
  56793. /** PS4 Dual Shock */
  56794. DualShock = 4,
  56795. /** Xbox */
  56796. Xbox = 5,
  56797. /** Switch Controller */
  56798. Switch = 6
  56799. }
  56800. /**
  56801. * Enum for All Pointers (Touch/Mouse)
  56802. */
  56803. export enum PointerInput {
  56804. /** Horizontal Axis */
  56805. Horizontal = 0,
  56806. /** Vertical Axis */
  56807. Vertical = 1,
  56808. /** Left Click or Touch */
  56809. LeftClick = 2,
  56810. /** Middle Click */
  56811. MiddleClick = 3,
  56812. /** Right Click */
  56813. RightClick = 4,
  56814. /** Browser Back */
  56815. BrowserBack = 5,
  56816. /** Browser Forward */
  56817. BrowserForward = 6
  56818. }
  56819. /**
  56820. * Enum for Dual Shock Gamepad
  56821. */
  56822. export enum DualShockInput {
  56823. /** Cross */
  56824. Cross = 0,
  56825. /** Circle */
  56826. Circle = 1,
  56827. /** Square */
  56828. Square = 2,
  56829. /** Triangle */
  56830. Triangle = 3,
  56831. /** L1 */
  56832. L1 = 4,
  56833. /** R1 */
  56834. R1 = 5,
  56835. /** L2 */
  56836. L2 = 6,
  56837. /** R2 */
  56838. R2 = 7,
  56839. /** Share */
  56840. Share = 8,
  56841. /** Options */
  56842. Options = 9,
  56843. /** L3 */
  56844. L3 = 10,
  56845. /** R3 */
  56846. R3 = 11,
  56847. /** DPadUp */
  56848. DPadUp = 12,
  56849. /** DPadDown */
  56850. DPadDown = 13,
  56851. /** DPadLeft */
  56852. DPadLeft = 14,
  56853. /** DRight */
  56854. DPadRight = 15,
  56855. /** Home */
  56856. Home = 16,
  56857. /** TouchPad */
  56858. TouchPad = 17,
  56859. /** LStickXAxis */
  56860. LStickXAxis = 18,
  56861. /** LStickYAxis */
  56862. LStickYAxis = 19,
  56863. /** RStickXAxis */
  56864. RStickXAxis = 20,
  56865. /** RStickYAxis */
  56866. RStickYAxis = 21
  56867. }
  56868. /**
  56869. * Enum for Xbox Gamepad
  56870. */
  56871. export enum XboxInput {
  56872. /** A */
  56873. A = 0,
  56874. /** B */
  56875. B = 1,
  56876. /** X */
  56877. X = 2,
  56878. /** Y */
  56879. Y = 3,
  56880. /** LB */
  56881. LB = 4,
  56882. /** RB */
  56883. RB = 5,
  56884. /** LT */
  56885. LT = 6,
  56886. /** RT */
  56887. RT = 7,
  56888. /** Back */
  56889. Back = 8,
  56890. /** Start */
  56891. Start = 9,
  56892. /** LS */
  56893. LS = 10,
  56894. /** RS */
  56895. RS = 11,
  56896. /** DPadUp */
  56897. DPadUp = 12,
  56898. /** DPadDown */
  56899. DPadDown = 13,
  56900. /** DPadLeft */
  56901. DPadLeft = 14,
  56902. /** DRight */
  56903. DPadRight = 15,
  56904. /** Home */
  56905. Home = 16,
  56906. /** LStickXAxis */
  56907. LStickXAxis = 17,
  56908. /** LStickYAxis */
  56909. LStickYAxis = 18,
  56910. /** RStickXAxis */
  56911. RStickXAxis = 19,
  56912. /** RStickYAxis */
  56913. RStickYAxis = 20
  56914. }
  56915. /**
  56916. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  56917. */
  56918. export enum SwitchInput {
  56919. /** B */
  56920. B = 0,
  56921. /** A */
  56922. A = 1,
  56923. /** Y */
  56924. Y = 2,
  56925. /** X */
  56926. X = 3,
  56927. /** L */
  56928. L = 4,
  56929. /** R */
  56930. R = 5,
  56931. /** ZL */
  56932. ZL = 6,
  56933. /** ZR */
  56934. ZR = 7,
  56935. /** Minus */
  56936. Minus = 8,
  56937. /** Plus */
  56938. Plus = 9,
  56939. /** LS */
  56940. LS = 10,
  56941. /** RS */
  56942. RS = 11,
  56943. /** DPadUp */
  56944. DPadUp = 12,
  56945. /** DPadDown */
  56946. DPadDown = 13,
  56947. /** DPadLeft */
  56948. DPadLeft = 14,
  56949. /** DRight */
  56950. DPadRight = 15,
  56951. /** Home */
  56952. Home = 16,
  56953. /** Capture */
  56954. Capture = 17,
  56955. /** LStickXAxis */
  56956. LStickXAxis = 18,
  56957. /** LStickYAxis */
  56958. LStickYAxis = 19,
  56959. /** RStickXAxis */
  56960. RStickXAxis = 20,
  56961. /** RStickYAxis */
  56962. RStickYAxis = 21
  56963. }
  56964. }
  56965. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  56966. import { Engine } from "babylonjs/Engines/engine";
  56967. import { IDisposable } from "babylonjs/scene";
  56968. import { Nullable } from "babylonjs/types";
  56969. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  56970. /**
  56971. * This class will take all inputs from Keyboard, Pointer, and
  56972. * any Gamepads and provide a polling system that all devices
  56973. * will use. This class assumes that there will only be one
  56974. * pointer device and one keyboard.
  56975. */
  56976. export class DeviceInputSystem implements IDisposable {
  56977. /**
  56978. * Callback to be triggered when a device is connected
  56979. */
  56980. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  56981. /**
  56982. * Callback to be triggered when a device is disconnected
  56983. */
  56984. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  56985. /**
  56986. * Callback to be triggered when event driven input is updated
  56987. */
  56988. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  56989. private _inputs;
  56990. private _gamepads;
  56991. private _keyboardActive;
  56992. private _pointerActive;
  56993. private _elementToAttachTo;
  56994. private _keyboardDownEvent;
  56995. private _keyboardUpEvent;
  56996. private _pointerMoveEvent;
  56997. private _pointerDownEvent;
  56998. private _pointerUpEvent;
  56999. private _gamepadConnectedEvent;
  57000. private _gamepadDisconnectedEvent;
  57001. private static _MAX_KEYCODES;
  57002. private static _MAX_POINTER_INPUTS;
  57003. private constructor();
  57004. /**
  57005. * Creates a new DeviceInputSystem instance
  57006. * @param engine Engine to pull input element from
  57007. * @returns The new instance
  57008. */
  57009. static Create(engine: Engine): DeviceInputSystem;
  57010. /**
  57011. * Checks for current device input value, given an id and input index
  57012. * @param deviceName Id of connected device
  57013. * @param inputIndex Index of device input
  57014. * @returns Current value of input
  57015. */
  57016. /**
  57017. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  57018. * @param deviceType Enum specifiying device type
  57019. * @param deviceSlot "Slot" or index that device is referenced in
  57020. * @param inputIndex Id of input to be checked
  57021. * @returns Current value of input
  57022. */
  57023. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  57024. /**
  57025. * Dispose of all the eventlisteners
  57026. */
  57027. dispose(): void;
  57028. /**
  57029. * Add device and inputs to device array
  57030. * @param deviceType Enum specifiying device type
  57031. * @param deviceSlot "Slot" or index that device is referenced in
  57032. * @param numberOfInputs Number of input entries to create for given device
  57033. */
  57034. private _registerDevice;
  57035. /**
  57036. * Given a specific device name, remove that device from the device map
  57037. * @param deviceType Enum specifiying device type
  57038. * @param deviceSlot "Slot" or index that device is referenced in
  57039. */
  57040. private _unregisterDevice;
  57041. /**
  57042. * Handle all actions that come from keyboard interaction
  57043. */
  57044. private _handleKeyActions;
  57045. /**
  57046. * Handle all actions that come from pointer interaction
  57047. */
  57048. private _handlePointerActions;
  57049. /**
  57050. * Handle all actions that come from gamepad interaction
  57051. */
  57052. private _handleGamepadActions;
  57053. /**
  57054. * Update all non-event based devices with each frame
  57055. * @param deviceType Enum specifiying device type
  57056. * @param deviceSlot "Slot" or index that device is referenced in
  57057. * @param inputIndex Id of input to be checked
  57058. */
  57059. private _updateDevice;
  57060. /**
  57061. * Gets DeviceType from the device name
  57062. * @param deviceName Name of Device from DeviceInputSystem
  57063. * @returns DeviceType enum value
  57064. */
  57065. private _getGamepadDeviceType;
  57066. }
  57067. }
  57068. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  57069. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57070. /**
  57071. * Type to handle enforcement of inputs
  57072. */
  57073. 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;
  57074. }
  57075. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  57076. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  57077. import { Engine } from "babylonjs/Engines/engine";
  57078. import { IDisposable } from "babylonjs/scene";
  57079. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57080. import { Nullable } from "babylonjs/types";
  57081. import { Observable } from "babylonjs/Misc/observable";
  57082. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  57083. /**
  57084. * Class that handles all input for a specific device
  57085. */
  57086. export class DeviceSource<T extends DeviceType> {
  57087. /** Type of device */
  57088. readonly deviceType: DeviceType;
  57089. /** "Slot" or index that device is referenced in */
  57090. readonly deviceSlot: number;
  57091. /**
  57092. * Observable to handle device input changes per device
  57093. */
  57094. readonly onInputChangedObservable: Observable<{
  57095. inputIndex: DeviceInput<T>;
  57096. previousState: Nullable<number>;
  57097. currentState: Nullable<number>;
  57098. }>;
  57099. private readonly _deviceInputSystem;
  57100. /**
  57101. * Default Constructor
  57102. * @param deviceInputSystem Reference to DeviceInputSystem
  57103. * @param deviceType Type of device
  57104. * @param deviceSlot "Slot" or index that device is referenced in
  57105. */
  57106. constructor(deviceInputSystem: DeviceInputSystem,
  57107. /** Type of device */
  57108. deviceType: DeviceType,
  57109. /** "Slot" or index that device is referenced in */
  57110. deviceSlot?: number);
  57111. /**
  57112. * Get input for specific input
  57113. * @param inputIndex index of specific input on device
  57114. * @returns Input value from DeviceInputSystem
  57115. */
  57116. getInput(inputIndex: DeviceInput<T>): number;
  57117. }
  57118. /**
  57119. * Class to keep track of devices
  57120. */
  57121. export class DeviceSourceManager implements IDisposable {
  57122. /**
  57123. * Observable to be triggered when before a device is connected
  57124. */
  57125. readonly onBeforeDeviceConnectedObservable: Observable<{
  57126. deviceType: DeviceType;
  57127. deviceSlot: number;
  57128. }>;
  57129. /**
  57130. * Observable to be triggered when before a device is disconnected
  57131. */
  57132. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  57133. deviceType: DeviceType;
  57134. deviceSlot: number;
  57135. }>;
  57136. /**
  57137. * Observable to be triggered when after a device is connected
  57138. */
  57139. readonly onAfterDeviceConnectedObservable: Observable<{
  57140. deviceType: DeviceType;
  57141. deviceSlot: number;
  57142. }>;
  57143. /**
  57144. * Observable to be triggered when after a device is disconnected
  57145. */
  57146. readonly onAfterDeviceDisconnectedObservable: Observable<{
  57147. deviceType: DeviceType;
  57148. deviceSlot: number;
  57149. }>;
  57150. private readonly _devices;
  57151. private readonly _firstDevice;
  57152. private readonly _deviceInputSystem;
  57153. /**
  57154. * Default Constructor
  57155. * @param engine engine to pull input element from
  57156. */
  57157. constructor(engine: Engine);
  57158. /**
  57159. * Gets a DeviceSource, given a type and slot
  57160. * @param deviceType Enum specifying device type
  57161. * @param deviceSlot "Slot" or index that device is referenced in
  57162. * @returns DeviceSource object
  57163. */
  57164. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  57165. /**
  57166. * Gets an array of DeviceSource objects for a given device type
  57167. * @param deviceType Enum specifying device type
  57168. * @returns Array of DeviceSource objects
  57169. */
  57170. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  57171. /**
  57172. * Dispose of DeviceInputSystem and other parts
  57173. */
  57174. dispose(): void;
  57175. /**
  57176. * Function to add device name to device list
  57177. * @param deviceType Enum specifying device type
  57178. * @param deviceSlot "Slot" or index that device is referenced in
  57179. */
  57180. private _addDevice;
  57181. /**
  57182. * Function to remove device name to device list
  57183. * @param deviceType Enum specifying device type
  57184. * @param deviceSlot "Slot" or index that device is referenced in
  57185. */
  57186. private _removeDevice;
  57187. /**
  57188. * Updates array storing first connected device of each type
  57189. * @param type Type of Device
  57190. */
  57191. private _updateFirstDevices;
  57192. }
  57193. }
  57194. declare module "babylonjs/DeviceInput/index" {
  57195. export * from "babylonjs/DeviceInput/deviceInputSystem";
  57196. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57197. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  57198. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57199. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57200. }
  57201. declare module "babylonjs/Engines/nullEngine" {
  57202. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  57203. import { Engine } from "babylonjs/Engines/engine";
  57204. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  57205. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  57206. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57207. import { Effect } from "babylonjs/Materials/effect";
  57208. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  57209. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57210. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  57211. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  57212. /**
  57213. * Options to create the null engine
  57214. */
  57215. export class NullEngineOptions {
  57216. /**
  57217. * Render width (Default: 512)
  57218. */
  57219. renderWidth: number;
  57220. /**
  57221. * Render height (Default: 256)
  57222. */
  57223. renderHeight: number;
  57224. /**
  57225. * Texture size (Default: 512)
  57226. */
  57227. textureSize: number;
  57228. /**
  57229. * If delta time between frames should be constant
  57230. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57231. */
  57232. deterministicLockstep: boolean;
  57233. /**
  57234. * Maximum about of steps between frames (Default: 4)
  57235. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57236. */
  57237. lockstepMaxSteps: number;
  57238. /**
  57239. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  57240. */
  57241. useHighPrecisionMatrix?: boolean;
  57242. }
  57243. /**
  57244. * The null engine class provides support for headless version of babylon.js.
  57245. * This can be used in server side scenario or for testing purposes
  57246. */
  57247. export class NullEngine extends Engine {
  57248. private _options;
  57249. /**
  57250. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  57251. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57252. * @returns true if engine is in deterministic lock step mode
  57253. */
  57254. isDeterministicLockStep(): boolean;
  57255. /**
  57256. * Gets the max steps when engine is running in deterministic lock step
  57257. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57258. * @returns the max steps
  57259. */
  57260. getLockstepMaxSteps(): number;
  57261. /**
  57262. * Gets the current hardware scaling level.
  57263. * By default the hardware scaling level is computed from the window device ratio.
  57264. * 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.
  57265. * @returns a number indicating the current hardware scaling level
  57266. */
  57267. getHardwareScalingLevel(): number;
  57268. constructor(options?: NullEngineOptions);
  57269. /**
  57270. * Creates a vertex buffer
  57271. * @param vertices the data for the vertex buffer
  57272. * @returns the new WebGL static buffer
  57273. */
  57274. createVertexBuffer(vertices: FloatArray): DataBuffer;
  57275. /**
  57276. * Creates a new index buffer
  57277. * @param indices defines the content of the index buffer
  57278. * @param updatable defines if the index buffer must be updatable
  57279. * @returns a new webGL buffer
  57280. */
  57281. createIndexBuffer(indices: IndicesArray): DataBuffer;
  57282. /**
  57283. * Clear the current render buffer or the current render target (if any is set up)
  57284. * @param color defines the color to use
  57285. * @param backBuffer defines if the back buffer must be cleared
  57286. * @param depth defines if the depth buffer must be cleared
  57287. * @param stencil defines if the stencil buffer must be cleared
  57288. */
  57289. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  57290. /**
  57291. * Gets the current render width
  57292. * @param useScreen defines if screen size must be used (or the current render target if any)
  57293. * @returns a number defining the current render width
  57294. */
  57295. getRenderWidth(useScreen?: boolean): number;
  57296. /**
  57297. * Gets the current render height
  57298. * @param useScreen defines if screen size must be used (or the current render target if any)
  57299. * @returns a number defining the current render height
  57300. */
  57301. getRenderHeight(useScreen?: boolean): number;
  57302. /**
  57303. * Set the WebGL's viewport
  57304. * @param viewport defines the viewport element to be used
  57305. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  57306. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  57307. */
  57308. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  57309. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  57310. /**
  57311. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  57312. * @param pipelineContext defines the pipeline context to use
  57313. * @param uniformsNames defines the list of uniform names
  57314. * @returns an array of webGL uniform locations
  57315. */
  57316. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  57317. /**
  57318. * Gets the lsit of active attributes for a given webGL program
  57319. * @param pipelineContext defines the pipeline context to use
  57320. * @param attributesNames defines the list of attribute names to get
  57321. * @returns an array of indices indicating the offset of each attribute
  57322. */
  57323. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  57324. /**
  57325. * Binds an effect to the webGL context
  57326. * @param effect defines the effect to bind
  57327. */
  57328. bindSamplers(effect: Effect): void;
  57329. /**
  57330. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  57331. * @param effect defines the effect to activate
  57332. */
  57333. enableEffect(effect: Effect): void;
  57334. /**
  57335. * Set various states to the webGL context
  57336. * @param culling defines backface culling state
  57337. * @param zOffset defines the value to apply to zOffset (0 by default)
  57338. * @param force defines if states must be applied even if cache is up to date
  57339. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  57340. */
  57341. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57342. /**
  57343. * Set the value of an uniform to an array of int32
  57344. * @param uniform defines the webGL uniform location where to store the value
  57345. * @param array defines the array of int32 to store
  57346. * @returns true if value was set
  57347. */
  57348. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57349. /**
  57350. * Set the value of an uniform to an array of int32 (stored as vec2)
  57351. * @param uniform defines the webGL uniform location where to store the value
  57352. * @param array defines the array of int32 to store
  57353. * @returns true if value was set
  57354. */
  57355. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57356. /**
  57357. * Set the value of an uniform to an array of int32 (stored as vec3)
  57358. * @param uniform defines the webGL uniform location where to store the value
  57359. * @param array defines the array of int32 to store
  57360. * @returns true if value was set
  57361. */
  57362. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57363. /**
  57364. * Set the value of an uniform to an array of int32 (stored as vec4)
  57365. * @param uniform defines the webGL uniform location where to store the value
  57366. * @param array defines the array of int32 to store
  57367. * @returns true if value was set
  57368. */
  57369. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57370. /**
  57371. * Set the value of an uniform to an array of float32
  57372. * @param uniform defines the webGL uniform location where to store the value
  57373. * @param array defines the array of float32 to store
  57374. * @returns true if value was set
  57375. */
  57376. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57377. /**
  57378. * Set the value of an uniform to an array of float32 (stored as vec2)
  57379. * @param uniform defines the webGL uniform location where to store the value
  57380. * @param array defines the array of float32 to store
  57381. * @returns true if value was set
  57382. */
  57383. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57384. /**
  57385. * Set the value of an uniform to an array of float32 (stored as vec3)
  57386. * @param uniform defines the webGL uniform location where to store the value
  57387. * @param array defines the array of float32 to store
  57388. * @returns true if value was set
  57389. */
  57390. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57391. /**
  57392. * Set the value of an uniform to an array of float32 (stored as vec4)
  57393. * @param uniform defines the webGL uniform location where to store the value
  57394. * @param array defines the array of float32 to store
  57395. * @returns true if value was set
  57396. */
  57397. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57398. /**
  57399. * Set the value of an uniform to an array of number
  57400. * @param uniform defines the webGL uniform location where to store the value
  57401. * @param array defines the array of number to store
  57402. * @returns true if value was set
  57403. */
  57404. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57405. /**
  57406. * Set the value of an uniform to an array of number (stored as vec2)
  57407. * @param uniform defines the webGL uniform location where to store the value
  57408. * @param array defines the array of number to store
  57409. * @returns true if value was set
  57410. */
  57411. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57412. /**
  57413. * Set the value of an uniform to an array of number (stored as vec3)
  57414. * @param uniform defines the webGL uniform location where to store the value
  57415. * @param array defines the array of number to store
  57416. * @returns true if value was set
  57417. */
  57418. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57419. /**
  57420. * Set the value of an uniform to an array of number (stored as vec4)
  57421. * @param uniform defines the webGL uniform location where to store the value
  57422. * @param array defines the array of number to store
  57423. * @returns true if value was set
  57424. */
  57425. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57426. /**
  57427. * Set the value of an uniform to an array of float32 (stored as matrices)
  57428. * @param uniform defines the webGL uniform location where to store the value
  57429. * @param matrices defines the array of float32 to store
  57430. * @returns true if value was set
  57431. */
  57432. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57433. /**
  57434. * Set the value of an uniform to a matrix (3x3)
  57435. * @param uniform defines the webGL uniform location where to store the value
  57436. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  57437. * @returns true if value was set
  57438. */
  57439. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57440. /**
  57441. * Set the value of an uniform to a matrix (2x2)
  57442. * @param uniform defines the webGL uniform location where to store the value
  57443. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  57444. * @returns true if value was set
  57445. */
  57446. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57447. /**
  57448. * Set the value of an uniform to a number (float)
  57449. * @param uniform defines the webGL uniform location where to store the value
  57450. * @param value defines the float number to store
  57451. * @returns true if value was set
  57452. */
  57453. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57454. /**
  57455. * Set the value of an uniform to a vec2
  57456. * @param uniform defines the webGL uniform location where to store the value
  57457. * @param x defines the 1st component of the value
  57458. * @param y defines the 2nd component of the value
  57459. * @returns true if value was set
  57460. */
  57461. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57462. /**
  57463. * Set the value of an uniform to a vec3
  57464. * @param uniform defines the webGL uniform location where to store the value
  57465. * @param x defines the 1st component of the value
  57466. * @param y defines the 2nd component of the value
  57467. * @param z defines the 3rd component of the value
  57468. * @returns true if value was set
  57469. */
  57470. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57471. /**
  57472. * Set the value of an uniform to a boolean
  57473. * @param uniform defines the webGL uniform location where to store the value
  57474. * @param bool defines the boolean to store
  57475. * @returns true if value was set
  57476. */
  57477. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  57478. /**
  57479. * Set the value of an uniform to a vec4
  57480. * @param uniform defines the webGL uniform location where to store the value
  57481. * @param x defines the 1st component of the value
  57482. * @param y defines the 2nd component of the value
  57483. * @param z defines the 3rd component of the value
  57484. * @param w defines the 4th component of the value
  57485. * @returns true if value was set
  57486. */
  57487. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57488. /**
  57489. * Sets the current alpha mode
  57490. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  57491. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57492. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57493. */
  57494. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57495. /**
  57496. * Bind webGl buffers directly to the webGL context
  57497. * @param vertexBuffers defines the vertex buffer to bind
  57498. * @param indexBuffer defines the index buffer to bind
  57499. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  57500. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  57501. * @param effect defines the effect associated with the vertex buffer
  57502. */
  57503. bindBuffers(vertexBuffers: {
  57504. [key: string]: VertexBuffer;
  57505. }, indexBuffer: DataBuffer, effect: Effect): void;
  57506. /**
  57507. * Force the entire cache to be cleared
  57508. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  57509. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  57510. */
  57511. wipeCaches(bruteForce?: boolean): void;
  57512. /**
  57513. * Send a draw order
  57514. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  57515. * @param indexStart defines the starting index
  57516. * @param indexCount defines the number of index to draw
  57517. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57518. */
  57519. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  57520. /**
  57521. * Draw a list of indexed primitives
  57522. * @param fillMode defines the primitive to use
  57523. * @param indexStart defines the starting index
  57524. * @param indexCount defines the number of index to draw
  57525. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57526. */
  57527. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  57528. /**
  57529. * Draw a list of unindexed primitives
  57530. * @param fillMode defines the primitive to use
  57531. * @param verticesStart defines the index of first vertex to draw
  57532. * @param verticesCount defines the count of vertices to draw
  57533. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57534. */
  57535. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  57536. /** @hidden */
  57537. _createTexture(): WebGLTexture;
  57538. /** @hidden */
  57539. _releaseTexture(texture: InternalTexture): void;
  57540. /**
  57541. * Usually called from Texture.ts.
  57542. * Passed information to create a WebGLTexture
  57543. * @param urlArg defines a value which contains one of the following:
  57544. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57545. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57546. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57547. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57548. * @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)
  57549. * @param scene needed for loading to the correct scene
  57550. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57551. * @param onLoad optional callback to be called upon successful completion
  57552. * @param onError optional callback to be called upon failure
  57553. * @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
  57554. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57555. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57556. * @param forcedExtension defines the extension to use to pick the right loader
  57557. * @param mimeType defines an optional mime type
  57558. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57559. */
  57560. 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;
  57561. /**
  57562. * Creates a new render target texture
  57563. * @param size defines the size of the texture
  57564. * @param options defines the options used to create the texture
  57565. * @returns a new render target texture stored in an InternalTexture
  57566. */
  57567. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  57568. /**
  57569. * Update the sampling mode of a given texture
  57570. * @param samplingMode defines the required sampling mode
  57571. * @param texture defines the texture to update
  57572. */
  57573. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57574. /**
  57575. * Binds the frame buffer to the specified texture.
  57576. * @param texture The texture to render to or null for the default canvas
  57577. * @param faceIndex The face of the texture to render to in case of cube texture
  57578. * @param requiredWidth The width of the target to render to
  57579. * @param requiredHeight The height of the target to render to
  57580. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  57581. * @param lodLevel defines le lod level to bind to the frame buffer
  57582. */
  57583. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57584. /**
  57585. * Unbind the current render target texture from the webGL context
  57586. * @param texture defines the render target texture to unbind
  57587. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  57588. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  57589. */
  57590. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57591. /**
  57592. * Creates a dynamic vertex buffer
  57593. * @param vertices the data for the dynamic vertex buffer
  57594. * @returns the new WebGL dynamic buffer
  57595. */
  57596. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  57597. /**
  57598. * Update the content of a dynamic texture
  57599. * @param texture defines the texture to update
  57600. * @param canvas defines the canvas containing the source
  57601. * @param invertY defines if data must be stored with Y axis inverted
  57602. * @param premulAlpha defines if alpha is stored as premultiplied
  57603. * @param format defines the format of the data
  57604. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57605. */
  57606. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57607. /**
  57608. * Gets a boolean indicating if all created effects are ready
  57609. * @returns true if all effects are ready
  57610. */
  57611. areAllEffectsReady(): boolean;
  57612. /**
  57613. * @hidden
  57614. * Get the current error code of the webGL context
  57615. * @returns the error code
  57616. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  57617. */
  57618. getError(): number;
  57619. /** @hidden */
  57620. _getUnpackAlignement(): number;
  57621. /** @hidden */
  57622. _unpackFlipY(value: boolean): void;
  57623. /**
  57624. * Update a dynamic index buffer
  57625. * @param indexBuffer defines the target index buffer
  57626. * @param indices defines the data to update
  57627. * @param offset defines the offset in the target index buffer where update should start
  57628. */
  57629. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  57630. /**
  57631. * Updates a dynamic vertex buffer.
  57632. * @param vertexBuffer the vertex buffer to update
  57633. * @param vertices the data used to update the vertex buffer
  57634. * @param byteOffset the byte offset of the data (optional)
  57635. * @param byteLength the byte length of the data (optional)
  57636. */
  57637. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  57638. /** @hidden */
  57639. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  57640. /** @hidden */
  57641. _bindTexture(channel: number, texture: InternalTexture): void;
  57642. protected _deleteBuffer(buffer: WebGLBuffer): void;
  57643. /**
  57644. * 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
  57645. */
  57646. releaseEffects(): void;
  57647. displayLoadingUI(): void;
  57648. hideLoadingUI(): void;
  57649. /** @hidden */
  57650. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57651. /** @hidden */
  57652. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57653. /** @hidden */
  57654. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57655. /** @hidden */
  57656. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57657. }
  57658. }
  57659. declare module "babylonjs/Instrumentation/timeToken" {
  57660. import { Nullable } from "babylonjs/types";
  57661. /**
  57662. * @hidden
  57663. **/
  57664. export class _TimeToken {
  57665. _startTimeQuery: Nullable<WebGLQuery>;
  57666. _endTimeQuery: Nullable<WebGLQuery>;
  57667. _timeElapsedQuery: Nullable<WebGLQuery>;
  57668. _timeElapsedQueryEnded: boolean;
  57669. }
  57670. }
  57671. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  57672. import { Nullable, int } from "babylonjs/types";
  57673. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  57674. /** @hidden */
  57675. export class _OcclusionDataStorage {
  57676. /** @hidden */
  57677. occlusionInternalRetryCounter: number;
  57678. /** @hidden */
  57679. isOcclusionQueryInProgress: boolean;
  57680. /** @hidden */
  57681. isOccluded: boolean;
  57682. /** @hidden */
  57683. occlusionRetryCount: number;
  57684. /** @hidden */
  57685. occlusionType: number;
  57686. /** @hidden */
  57687. occlusionQueryAlgorithmType: number;
  57688. }
  57689. module "babylonjs/Engines/engine" {
  57690. interface Engine {
  57691. /**
  57692. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  57693. * @return the new query
  57694. */
  57695. createQuery(): WebGLQuery;
  57696. /**
  57697. * Delete and release a webGL query
  57698. * @param query defines the query to delete
  57699. * @return the current engine
  57700. */
  57701. deleteQuery(query: WebGLQuery): Engine;
  57702. /**
  57703. * Check if a given query has resolved and got its value
  57704. * @param query defines the query to check
  57705. * @returns true if the query got its value
  57706. */
  57707. isQueryResultAvailable(query: WebGLQuery): boolean;
  57708. /**
  57709. * Gets the value of a given query
  57710. * @param query defines the query to check
  57711. * @returns the value of the query
  57712. */
  57713. getQueryResult(query: WebGLQuery): number;
  57714. /**
  57715. * Initiates an occlusion query
  57716. * @param algorithmType defines the algorithm to use
  57717. * @param query defines the query to use
  57718. * @returns the current engine
  57719. * @see https://doc.babylonjs.com/features/occlusionquery
  57720. */
  57721. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  57722. /**
  57723. * Ends an occlusion query
  57724. * @see https://doc.babylonjs.com/features/occlusionquery
  57725. * @param algorithmType defines the algorithm to use
  57726. * @returns the current engine
  57727. */
  57728. endOcclusionQuery(algorithmType: number): Engine;
  57729. /**
  57730. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  57731. * Please note that only one query can be issued at a time
  57732. * @returns a time token used to track the time span
  57733. */
  57734. startTimeQuery(): Nullable<_TimeToken>;
  57735. /**
  57736. * Ends a time query
  57737. * @param token defines the token used to measure the time span
  57738. * @returns the time spent (in ns)
  57739. */
  57740. endTimeQuery(token: _TimeToken): int;
  57741. /** @hidden */
  57742. _currentNonTimestampToken: Nullable<_TimeToken>;
  57743. /** @hidden */
  57744. _createTimeQuery(): WebGLQuery;
  57745. /** @hidden */
  57746. _deleteTimeQuery(query: WebGLQuery): void;
  57747. /** @hidden */
  57748. _getGlAlgorithmType(algorithmType: number): number;
  57749. /** @hidden */
  57750. _getTimeQueryResult(query: WebGLQuery): any;
  57751. /** @hidden */
  57752. _getTimeQueryAvailability(query: WebGLQuery): any;
  57753. }
  57754. }
  57755. module "babylonjs/Meshes/abstractMesh" {
  57756. interface AbstractMesh {
  57757. /**
  57758. * Backing filed
  57759. * @hidden
  57760. */
  57761. __occlusionDataStorage: _OcclusionDataStorage;
  57762. /**
  57763. * Access property
  57764. * @hidden
  57765. */
  57766. _occlusionDataStorage: _OcclusionDataStorage;
  57767. /**
  57768. * 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.
  57769. * The default value is -1 which means don't break the query and wait till the result
  57770. * @see https://doc.babylonjs.com/features/occlusionquery
  57771. */
  57772. occlusionRetryCount: number;
  57773. /**
  57774. * 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:
  57775. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  57776. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  57777. * * 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.
  57778. * @see https://doc.babylonjs.com/features/occlusionquery
  57779. */
  57780. occlusionType: number;
  57781. /**
  57782. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  57783. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  57784. * * 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.
  57785. * @see https://doc.babylonjs.com/features/occlusionquery
  57786. */
  57787. occlusionQueryAlgorithmType: number;
  57788. /**
  57789. * 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
  57790. * @see https://doc.babylonjs.com/features/occlusionquery
  57791. */
  57792. isOccluded: boolean;
  57793. /**
  57794. * Flag to check the progress status of the query
  57795. * @see https://doc.babylonjs.com/features/occlusionquery
  57796. */
  57797. isOcclusionQueryInProgress: boolean;
  57798. }
  57799. }
  57800. }
  57801. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  57802. import { Nullable } from "babylonjs/types";
  57803. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57804. /** @hidden */
  57805. export var _forceTransformFeedbackToBundle: boolean;
  57806. module "babylonjs/Engines/engine" {
  57807. interface Engine {
  57808. /**
  57809. * Creates a webGL transform feedback object
  57810. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  57811. * @returns the webGL transform feedback object
  57812. */
  57813. createTransformFeedback(): WebGLTransformFeedback;
  57814. /**
  57815. * Delete a webGL transform feedback object
  57816. * @param value defines the webGL transform feedback object to delete
  57817. */
  57818. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  57819. /**
  57820. * Bind a webGL transform feedback object to the webgl context
  57821. * @param value defines the webGL transform feedback object to bind
  57822. */
  57823. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  57824. /**
  57825. * Begins a transform feedback operation
  57826. * @param usePoints defines if points or triangles must be used
  57827. */
  57828. beginTransformFeedback(usePoints: boolean): void;
  57829. /**
  57830. * Ends a transform feedback operation
  57831. */
  57832. endTransformFeedback(): void;
  57833. /**
  57834. * Specify the varyings to use with transform feedback
  57835. * @param program defines the associated webGL program
  57836. * @param value defines the list of strings representing the varying names
  57837. */
  57838. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  57839. /**
  57840. * Bind a webGL buffer for a transform feedback operation
  57841. * @param value defines the webGL buffer to bind
  57842. */
  57843. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  57844. }
  57845. }
  57846. }
  57847. declare module "babylonjs/Engines/Extensions/engine.views" {
  57848. import { Camera } from "babylonjs/Cameras/camera";
  57849. import { Nullable } from "babylonjs/types";
  57850. /**
  57851. * Class used to define an additional view for the engine
  57852. * @see https://doc.babylonjs.com/how_to/multi_canvases
  57853. */
  57854. export class EngineView {
  57855. /** Defines the canvas where to render the view */
  57856. target: HTMLCanvasElement;
  57857. /** Defines an optional camera used to render the view (will use active camera else) */
  57858. camera?: Camera;
  57859. }
  57860. module "babylonjs/Engines/engine" {
  57861. interface Engine {
  57862. /**
  57863. * Gets or sets the HTML element to use for attaching events
  57864. */
  57865. inputElement: Nullable<HTMLElement>;
  57866. /**
  57867. * Gets the current engine view
  57868. * @see https://doc.babylonjs.com/how_to/multi_canvases
  57869. */
  57870. activeView: Nullable<EngineView>;
  57871. /** Gets or sets the list of views */
  57872. views: EngineView[];
  57873. /**
  57874. * Register a new child canvas
  57875. * @param canvas defines the canvas to register
  57876. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  57877. * @returns the associated view
  57878. */
  57879. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  57880. /**
  57881. * Remove a registered child canvas
  57882. * @param canvas defines the canvas to remove
  57883. * @returns the current engine
  57884. */
  57885. unRegisterView(canvas: HTMLCanvasElement): Engine;
  57886. }
  57887. }
  57888. }
  57889. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  57890. import { Nullable } from "babylonjs/types";
  57891. module "babylonjs/Engines/engine" {
  57892. interface Engine {
  57893. /** @hidden */
  57894. _excludedCompressedTextures: string[];
  57895. /** @hidden */
  57896. _textureFormatInUse: string;
  57897. /**
  57898. * Gets the list of texture formats supported
  57899. */
  57900. readonly texturesSupported: Array<string>;
  57901. /**
  57902. * Gets the texture format in use
  57903. */
  57904. readonly textureFormatInUse: Nullable<string>;
  57905. /**
  57906. * Set the compressed texture extensions or file names to skip.
  57907. *
  57908. * @param skippedFiles defines the list of those texture files you want to skip
  57909. * Example: [".dds", ".env", "myfile.png"]
  57910. */
  57911. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  57912. /**
  57913. * Set the compressed texture format to use, based on the formats you have, and the formats
  57914. * supported by the hardware / browser.
  57915. *
  57916. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  57917. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  57918. * to API arguments needed to compressed textures. This puts the burden on the container
  57919. * generator to house the arcane code for determining these for current & future formats.
  57920. *
  57921. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57922. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57923. *
  57924. * Note: The result of this call is not taken into account when a texture is base64.
  57925. *
  57926. * @param formatsAvailable defines the list of those format families you have created
  57927. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  57928. *
  57929. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  57930. * @returns The extension selected.
  57931. */
  57932. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  57933. }
  57934. }
  57935. }
  57936. declare module "babylonjs/Engines/Extensions/index" {
  57937. export * from "babylonjs/Engines/Extensions/engine.alpha";
  57938. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  57939. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  57940. export * from "babylonjs/Engines/Extensions/engine.multiview";
  57941. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  57942. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  57943. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  57944. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  57945. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  57946. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  57947. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  57948. export * from "babylonjs/Engines/Extensions/engine.webVR";
  57949. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  57950. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  57951. export * from "babylonjs/Engines/Extensions/engine.views";
  57952. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  57953. import "babylonjs/Engines/Extensions/engine.textureSelector";
  57954. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  57955. }
  57956. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  57957. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57958. /** @hidden */
  57959. export var rgbdEncodePixelShader: {
  57960. name: string;
  57961. shader: string;
  57962. };
  57963. }
  57964. declare module "babylonjs/Misc/environmentTextureTools" {
  57965. import { Nullable } from "babylonjs/types";
  57966. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  57967. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57968. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57969. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  57970. import "babylonjs/Engines/Extensions/engine.readTexture";
  57971. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57972. import "babylonjs/Shaders/rgbdEncode.fragment";
  57973. import "babylonjs/Shaders/rgbdDecode.fragment";
  57974. /**
  57975. * Raw texture data and descriptor sufficient for WebGL texture upload
  57976. */
  57977. export interface EnvironmentTextureInfo {
  57978. /**
  57979. * Version of the environment map
  57980. */
  57981. version: number;
  57982. /**
  57983. * Width of image
  57984. */
  57985. width: number;
  57986. /**
  57987. * Irradiance information stored in the file.
  57988. */
  57989. irradiance: any;
  57990. /**
  57991. * Specular information stored in the file.
  57992. */
  57993. specular: any;
  57994. }
  57995. /**
  57996. * Defines One Image in the file. It requires only the position in the file
  57997. * as well as the length.
  57998. */
  57999. interface BufferImageData {
  58000. /**
  58001. * Length of the image data.
  58002. */
  58003. length: number;
  58004. /**
  58005. * Position of the data from the null terminator delimiting the end of the JSON.
  58006. */
  58007. position: number;
  58008. }
  58009. /**
  58010. * Defines the specular data enclosed in the file.
  58011. * This corresponds to the version 1 of the data.
  58012. */
  58013. export interface EnvironmentTextureSpecularInfoV1 {
  58014. /**
  58015. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  58016. */
  58017. specularDataPosition?: number;
  58018. /**
  58019. * This contains all the images data needed to reconstruct the cubemap.
  58020. */
  58021. mipmaps: Array<BufferImageData>;
  58022. /**
  58023. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  58024. */
  58025. lodGenerationScale: number;
  58026. }
  58027. /**
  58028. * Sets of helpers addressing the serialization and deserialization of environment texture
  58029. * stored in a BabylonJS env file.
  58030. * Those files are usually stored as .env files.
  58031. */
  58032. export class EnvironmentTextureTools {
  58033. /**
  58034. * Magic number identifying the env file.
  58035. */
  58036. private static _MagicBytes;
  58037. /**
  58038. * Gets the environment info from an env file.
  58039. * @param data The array buffer containing the .env bytes.
  58040. * @returns the environment file info (the json header) if successfully parsed.
  58041. */
  58042. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  58043. /**
  58044. * Creates an environment texture from a loaded cube texture.
  58045. * @param texture defines the cube texture to convert in env file
  58046. * @return a promise containing the environment data if succesfull.
  58047. */
  58048. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  58049. /**
  58050. * Creates a JSON representation of the spherical data.
  58051. * @param texture defines the texture containing the polynomials
  58052. * @return the JSON representation of the spherical info
  58053. */
  58054. private static _CreateEnvTextureIrradiance;
  58055. /**
  58056. * Creates the ArrayBufferViews used for initializing environment texture image data.
  58057. * @param data the image data
  58058. * @param info parameters that determine what views will be created for accessing the underlying buffer
  58059. * @return the views described by info providing access to the underlying buffer
  58060. */
  58061. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  58062. /**
  58063. * Uploads the texture info contained in the env file to the GPU.
  58064. * @param texture defines the internal texture to upload to
  58065. * @param data defines the data to load
  58066. * @param info defines the texture info retrieved through the GetEnvInfo method
  58067. * @returns a promise
  58068. */
  58069. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  58070. private static _OnImageReadyAsync;
  58071. /**
  58072. * Uploads the levels of image data to the GPU.
  58073. * @param texture defines the internal texture to upload to
  58074. * @param imageData defines the array buffer views of image data [mipmap][face]
  58075. * @returns a promise
  58076. */
  58077. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  58078. /**
  58079. * Uploads spherical polynomials information to the texture.
  58080. * @param texture defines the texture we are trying to upload the information to
  58081. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  58082. */
  58083. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  58084. /** @hidden */
  58085. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58086. }
  58087. }
  58088. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  58089. /**
  58090. * Class used to inline functions in shader code
  58091. */
  58092. export class ShaderCodeInliner {
  58093. private static readonly _RegexpFindFunctionNameAndType;
  58094. private _sourceCode;
  58095. private _functionDescr;
  58096. private _numMaxIterations;
  58097. /** Gets or sets the token used to mark the functions to inline */
  58098. inlineToken: string;
  58099. /** Gets or sets the debug mode */
  58100. debug: boolean;
  58101. /** Gets the code after the inlining process */
  58102. get code(): string;
  58103. /**
  58104. * Initializes the inliner
  58105. * @param sourceCode shader code source to inline
  58106. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  58107. */
  58108. constructor(sourceCode: string, numMaxIterations?: number);
  58109. /**
  58110. * Start the processing of the shader code
  58111. */
  58112. processCode(): void;
  58113. private _collectFunctions;
  58114. private _processInlining;
  58115. private _extractBetweenMarkers;
  58116. private _skipWhitespaces;
  58117. private _removeComments;
  58118. private _replaceFunctionCallsByCode;
  58119. private _findBackward;
  58120. private _escapeRegExp;
  58121. private _replaceNames;
  58122. }
  58123. }
  58124. declare module "babylonjs/Engines/nativeEngine" {
  58125. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  58126. import { Engine } from "babylonjs/Engines/engine";
  58127. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  58128. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58129. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58130. import { Effect } from "babylonjs/Materials/effect";
  58131. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  58132. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  58133. import { IColor4Like } from "babylonjs/Maths/math.like";
  58134. import { Scene } from "babylonjs/scene";
  58135. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  58136. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  58137. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  58138. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  58139. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  58140. /**
  58141. * Container for accessors for natively-stored mesh data buffers.
  58142. */
  58143. class NativeDataBuffer extends DataBuffer {
  58144. /**
  58145. * Accessor value used to identify/retrieve a natively-stored index buffer.
  58146. */
  58147. nativeIndexBuffer?: any;
  58148. /**
  58149. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  58150. */
  58151. nativeVertexBuffer?: any;
  58152. }
  58153. /** @hidden */
  58154. class NativeTexture extends InternalTexture {
  58155. getInternalTexture(): InternalTexture;
  58156. getViewCount(): number;
  58157. }
  58158. /** @hidden */
  58159. export class NativeEngine extends Engine {
  58160. private readonly _native;
  58161. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  58162. private readonly INVALID_HANDLE;
  58163. private _boundBuffersVertexArray;
  58164. private _currentDepthTest;
  58165. getHardwareScalingLevel(): number;
  58166. constructor();
  58167. dispose(): void;
  58168. /**
  58169. * Can be used to override the current requestAnimationFrame requester.
  58170. * @hidden
  58171. */
  58172. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  58173. /**
  58174. * Override default engine behavior.
  58175. * @param color
  58176. * @param backBuffer
  58177. * @param depth
  58178. * @param stencil
  58179. */
  58180. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  58181. /**
  58182. * Gets host document
  58183. * @returns the host document object
  58184. */
  58185. getHostDocument(): Nullable<Document>;
  58186. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58187. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  58188. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  58189. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  58190. [key: string]: VertexBuffer;
  58191. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58192. bindBuffers(vertexBuffers: {
  58193. [key: string]: VertexBuffer;
  58194. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58195. recordVertexArrayObject(vertexBuffers: {
  58196. [key: string]: VertexBuffer;
  58197. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  58198. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58199. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58200. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58201. /**
  58202. * Draw a list of indexed primitives
  58203. * @param fillMode defines the primitive to use
  58204. * @param indexStart defines the starting index
  58205. * @param indexCount defines the number of index to draw
  58206. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58207. */
  58208. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  58209. /**
  58210. * Draw a list of unindexed primitives
  58211. * @param fillMode defines the primitive to use
  58212. * @param verticesStart defines the index of first vertex to draw
  58213. * @param verticesCount defines the count of vertices to draw
  58214. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58215. */
  58216. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  58217. createPipelineContext(): IPipelineContext;
  58218. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  58219. /** @hidden */
  58220. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  58221. /** @hidden */
  58222. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  58223. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58224. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58225. protected _setProgram(program: WebGLProgram): void;
  58226. _releaseEffect(effect: Effect): void;
  58227. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  58228. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  58229. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  58230. bindSamplers(effect: Effect): void;
  58231. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  58232. getRenderWidth(useScreen?: boolean): number;
  58233. getRenderHeight(useScreen?: boolean): number;
  58234. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  58235. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58236. /**
  58237. * Set the z offset to apply to current rendering
  58238. * @param value defines the offset to apply
  58239. */
  58240. setZOffset(value: number): void;
  58241. /**
  58242. * Gets the current value of the zOffset
  58243. * @returns the current zOffset state
  58244. */
  58245. getZOffset(): number;
  58246. /**
  58247. * Enable or disable depth buffering
  58248. * @param enable defines the state to set
  58249. */
  58250. setDepthBuffer(enable: boolean): void;
  58251. /**
  58252. * Gets a boolean indicating if depth writing is enabled
  58253. * @returns the current depth writing state
  58254. */
  58255. getDepthWrite(): boolean;
  58256. setDepthFunctionToGreater(): void;
  58257. setDepthFunctionToGreaterOrEqual(): void;
  58258. setDepthFunctionToLess(): void;
  58259. setDepthFunctionToLessOrEqual(): void;
  58260. /**
  58261. * Enable or disable depth writing
  58262. * @param enable defines the state to set
  58263. */
  58264. setDepthWrite(enable: boolean): void;
  58265. /**
  58266. * Enable or disable color writing
  58267. * @param enable defines the state to set
  58268. */
  58269. setColorWrite(enable: boolean): void;
  58270. /**
  58271. * Gets a boolean indicating if color writing is enabled
  58272. * @returns the current color writing state
  58273. */
  58274. getColorWrite(): boolean;
  58275. /**
  58276. * Sets alpha constants used by some alpha blending modes
  58277. * @param r defines the red component
  58278. * @param g defines the green component
  58279. * @param b defines the blue component
  58280. * @param a defines the alpha component
  58281. */
  58282. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  58283. /**
  58284. * Sets the current alpha mode
  58285. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  58286. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  58287. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58288. */
  58289. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  58290. /**
  58291. * Gets the current alpha mode
  58292. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58293. * @returns the current alpha mode
  58294. */
  58295. getAlphaMode(): number;
  58296. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  58297. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58298. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58299. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58300. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58301. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58302. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58303. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58304. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58305. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  58306. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  58307. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  58308. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  58309. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  58310. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58311. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58312. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  58313. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  58314. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  58315. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  58316. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  58317. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  58318. wipeCaches(bruteForce?: boolean): void;
  58319. _createTexture(): WebGLTexture;
  58320. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  58321. /**
  58322. * Update the content of a dynamic texture
  58323. * @param texture defines the texture to update
  58324. * @param canvas defines the canvas containing the source
  58325. * @param invertY defines if data must be stored with Y axis inverted
  58326. * @param premulAlpha defines if alpha is stored as premultiplied
  58327. * @param format defines the format of the data
  58328. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  58329. */
  58330. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  58331. /**
  58332. * Usually called from Texture.ts.
  58333. * Passed information to create a WebGLTexture
  58334. * @param url defines a value which contains one of the following:
  58335. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  58336. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  58337. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  58338. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  58339. * @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)
  58340. * @param scene needed for loading to the correct scene
  58341. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  58342. * @param onLoad optional callback to be called upon successful completion
  58343. * @param onError optional callback to be called upon failure
  58344. * @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
  58345. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  58346. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  58347. * @param forcedExtension defines the extension to use to pick the right loader
  58348. * @param mimeType defines an optional mime type
  58349. * @param loaderOptions options to be passed to the loader
  58350. * @returns a InternalTexture for assignment back into BABYLON.Texture
  58351. */
  58352. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  58353. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  58354. _releaseFramebufferObjects(texture: InternalTexture): void;
  58355. /**
  58356. * Creates a cube texture
  58357. * @param rootUrl defines the url where the files to load is located
  58358. * @param scene defines the current scene
  58359. * @param files defines the list of files to load (1 per face)
  58360. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  58361. * @param onLoad defines an optional callback raised when the texture is loaded
  58362. * @param onError defines an optional callback raised if there is an issue to load the texture
  58363. * @param format defines the format of the data
  58364. * @param forcedExtension defines the extension to use to pick the right loader
  58365. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  58366. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58367. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58368. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  58369. * @returns the cube texture as an InternalTexture
  58370. */
  58371. 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;
  58372. createRenderTargetTexture(size: number | {
  58373. width: number;
  58374. height: number;
  58375. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  58376. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  58377. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  58378. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  58379. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  58380. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  58381. /**
  58382. * Updates a dynamic vertex buffer.
  58383. * @param vertexBuffer the vertex buffer to update
  58384. * @param data the data used to update the vertex buffer
  58385. * @param byteOffset the byte offset of the data (optional)
  58386. * @param byteLength the byte length of the data (optional)
  58387. */
  58388. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  58389. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  58390. private _updateAnisotropicLevel;
  58391. private _getAddressMode;
  58392. /** @hidden */
  58393. _bindTexture(channel: number, texture: InternalTexture): void;
  58394. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  58395. releaseEffects(): void;
  58396. /** @hidden */
  58397. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58398. /** @hidden */
  58399. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58400. /** @hidden */
  58401. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58402. /** @hidden */
  58403. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  58404. private _getNativeSamplingMode;
  58405. private _getNativeTextureFormat;
  58406. private _getNativeAlphaMode;
  58407. private _getNativeAttribType;
  58408. }
  58409. }
  58410. declare module "babylonjs/Engines/index" {
  58411. export * from "babylonjs/Engines/constants";
  58412. export * from "babylonjs/Engines/engineCapabilities";
  58413. export * from "babylonjs/Engines/instancingAttributeInfo";
  58414. export * from "babylonjs/Engines/thinEngine";
  58415. export * from "babylonjs/Engines/engine";
  58416. export * from "babylonjs/Engines/engineStore";
  58417. export * from "babylonjs/Engines/nullEngine";
  58418. export * from "babylonjs/Engines/Extensions/index";
  58419. export * from "babylonjs/Engines/IPipelineContext";
  58420. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  58421. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  58422. export * from "babylonjs/Engines/nativeEngine";
  58423. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  58424. export * from "babylonjs/Engines/performanceConfigurator";
  58425. }
  58426. declare module "babylonjs/Events/clipboardEvents" {
  58427. /**
  58428. * Gather the list of clipboard event types as constants.
  58429. */
  58430. export class ClipboardEventTypes {
  58431. /**
  58432. * The clipboard event is fired when a copy command is active (pressed).
  58433. */
  58434. static readonly COPY: number;
  58435. /**
  58436. * The clipboard event is fired when a cut command is active (pressed).
  58437. */
  58438. static readonly CUT: number;
  58439. /**
  58440. * The clipboard event is fired when a paste command is active (pressed).
  58441. */
  58442. static readonly PASTE: number;
  58443. }
  58444. /**
  58445. * This class is used to store clipboard related info for the onClipboardObservable event.
  58446. */
  58447. export class ClipboardInfo {
  58448. /**
  58449. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58450. */
  58451. type: number;
  58452. /**
  58453. * Defines the related dom event
  58454. */
  58455. event: ClipboardEvent;
  58456. /**
  58457. *Creates an instance of ClipboardInfo.
  58458. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  58459. * @param event Defines the related dom event
  58460. */
  58461. constructor(
  58462. /**
  58463. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58464. */
  58465. type: number,
  58466. /**
  58467. * Defines the related dom event
  58468. */
  58469. event: ClipboardEvent);
  58470. /**
  58471. * Get the clipboard event's type from the keycode.
  58472. * @param keyCode Defines the keyCode for the current keyboard event.
  58473. * @return {number}
  58474. */
  58475. static GetTypeFromCharacter(keyCode: number): number;
  58476. }
  58477. }
  58478. declare module "babylonjs/Events/index" {
  58479. export * from "babylonjs/Events/keyboardEvents";
  58480. export * from "babylonjs/Events/pointerEvents";
  58481. export * from "babylonjs/Events/clipboardEvents";
  58482. }
  58483. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  58484. import { Scene } from "babylonjs/scene";
  58485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58486. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58487. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58488. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58489. /**
  58490. * Google Daydream controller
  58491. */
  58492. export class DaydreamController extends WebVRController {
  58493. /**
  58494. * Base Url for the controller model.
  58495. */
  58496. static MODEL_BASE_URL: string;
  58497. /**
  58498. * File name for the controller model.
  58499. */
  58500. static MODEL_FILENAME: string;
  58501. /**
  58502. * Gamepad Id prefix used to identify Daydream Controller.
  58503. */
  58504. static readonly GAMEPAD_ID_PREFIX: string;
  58505. /**
  58506. * Creates a new DaydreamController from a gamepad
  58507. * @param vrGamepad the gamepad that the controller should be created from
  58508. */
  58509. constructor(vrGamepad: any);
  58510. /**
  58511. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58512. * @param scene scene in which to add meshes
  58513. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58514. */
  58515. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58516. /**
  58517. * Called once for each button that changed state since the last frame
  58518. * @param buttonIdx Which button index changed
  58519. * @param state New state of the button
  58520. * @param changes Which properties on the state changed since last frame
  58521. */
  58522. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58523. }
  58524. }
  58525. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  58526. import { Scene } from "babylonjs/scene";
  58527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58528. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58529. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58530. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58531. /**
  58532. * Gear VR Controller
  58533. */
  58534. export class GearVRController extends WebVRController {
  58535. /**
  58536. * Base Url for the controller model.
  58537. */
  58538. static MODEL_BASE_URL: string;
  58539. /**
  58540. * File name for the controller model.
  58541. */
  58542. static MODEL_FILENAME: string;
  58543. /**
  58544. * Gamepad Id prefix used to identify this controller.
  58545. */
  58546. static readonly GAMEPAD_ID_PREFIX: string;
  58547. private readonly _buttonIndexToObservableNameMap;
  58548. /**
  58549. * Creates a new GearVRController from a gamepad
  58550. * @param vrGamepad the gamepad that the controller should be created from
  58551. */
  58552. constructor(vrGamepad: any);
  58553. /**
  58554. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58555. * @param scene scene in which to add meshes
  58556. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58557. */
  58558. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58559. /**
  58560. * Called once for each button that changed state since the last frame
  58561. * @param buttonIdx Which button index changed
  58562. * @param state New state of the button
  58563. * @param changes Which properties on the state changed since last frame
  58564. */
  58565. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58566. }
  58567. }
  58568. declare module "babylonjs/Gamepads/Controllers/genericController" {
  58569. import { Scene } from "babylonjs/scene";
  58570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58571. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58572. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58573. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58574. /**
  58575. * Generic Controller
  58576. */
  58577. export class GenericController extends WebVRController {
  58578. /**
  58579. * Base Url for the controller model.
  58580. */
  58581. static readonly MODEL_BASE_URL: string;
  58582. /**
  58583. * File name for the controller model.
  58584. */
  58585. static readonly MODEL_FILENAME: string;
  58586. /**
  58587. * Creates a new GenericController from a gamepad
  58588. * @param vrGamepad the gamepad that the controller should be created from
  58589. */
  58590. constructor(vrGamepad: any);
  58591. /**
  58592. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58593. * @param scene scene in which to add meshes
  58594. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58595. */
  58596. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58597. /**
  58598. * Called once for each button that changed state since the last frame
  58599. * @param buttonIdx Which button index changed
  58600. * @param state New state of the button
  58601. * @param changes Which properties on the state changed since last frame
  58602. */
  58603. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58604. }
  58605. }
  58606. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  58607. import { Observable } from "babylonjs/Misc/observable";
  58608. import { Scene } from "babylonjs/scene";
  58609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58610. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58611. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58612. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58613. /**
  58614. * Oculus Touch Controller
  58615. */
  58616. export class OculusTouchController extends WebVRController {
  58617. /**
  58618. * Base Url for the controller model.
  58619. */
  58620. static MODEL_BASE_URL: string;
  58621. /**
  58622. * File name for the left controller model.
  58623. */
  58624. static MODEL_LEFT_FILENAME: string;
  58625. /**
  58626. * File name for the right controller model.
  58627. */
  58628. static MODEL_RIGHT_FILENAME: string;
  58629. /**
  58630. * Base Url for the Quest controller model.
  58631. */
  58632. static QUEST_MODEL_BASE_URL: string;
  58633. /**
  58634. * @hidden
  58635. * If the controllers are running on a device that needs the updated Quest controller models
  58636. */
  58637. static _IsQuest: boolean;
  58638. /**
  58639. * Fired when the secondary trigger on this controller is modified
  58640. */
  58641. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  58642. /**
  58643. * Fired when the thumb rest on this controller is modified
  58644. */
  58645. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  58646. /**
  58647. * Creates a new OculusTouchController from a gamepad
  58648. * @param vrGamepad the gamepad that the controller should be created from
  58649. */
  58650. constructor(vrGamepad: any);
  58651. /**
  58652. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58653. * @param scene scene in which to add meshes
  58654. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58655. */
  58656. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58657. /**
  58658. * Fired when the A button on this controller is modified
  58659. */
  58660. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58661. /**
  58662. * Fired when the B button on this controller is modified
  58663. */
  58664. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58665. /**
  58666. * Fired when the X button on this controller is modified
  58667. */
  58668. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58669. /**
  58670. * Fired when the Y button on this controller is modified
  58671. */
  58672. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58673. /**
  58674. * Called once for each button that changed state since the last frame
  58675. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  58676. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  58677. * 2) secondary trigger (same)
  58678. * 3) A (right) X (left), touch, pressed = value
  58679. * 4) B / Y
  58680. * 5) thumb rest
  58681. * @param buttonIdx Which button index changed
  58682. * @param state New state of the button
  58683. * @param changes Which properties on the state changed since last frame
  58684. */
  58685. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58686. }
  58687. }
  58688. declare module "babylonjs/Gamepads/Controllers/viveController" {
  58689. import { Scene } from "babylonjs/scene";
  58690. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58691. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58692. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58693. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58694. import { Observable } from "babylonjs/Misc/observable";
  58695. /**
  58696. * Vive Controller
  58697. */
  58698. export class ViveController extends WebVRController {
  58699. /**
  58700. * Base Url for the controller model.
  58701. */
  58702. static MODEL_BASE_URL: string;
  58703. /**
  58704. * File name for the controller model.
  58705. */
  58706. static MODEL_FILENAME: string;
  58707. /**
  58708. * Creates a new ViveController from a gamepad
  58709. * @param vrGamepad the gamepad that the controller should be created from
  58710. */
  58711. constructor(vrGamepad: any);
  58712. /**
  58713. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58714. * @param scene scene in which to add meshes
  58715. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58716. */
  58717. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58718. /**
  58719. * Fired when the left button on this controller is modified
  58720. */
  58721. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58722. /**
  58723. * Fired when the right button on this controller is modified
  58724. */
  58725. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58726. /**
  58727. * Fired when the menu button on this controller is modified
  58728. */
  58729. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58730. /**
  58731. * Called once for each button that changed state since the last frame
  58732. * Vive mapping:
  58733. * 0: touchpad
  58734. * 1: trigger
  58735. * 2: left AND right buttons
  58736. * 3: menu button
  58737. * @param buttonIdx Which button index changed
  58738. * @param state New state of the button
  58739. * @param changes Which properties on the state changed since last frame
  58740. */
  58741. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58742. }
  58743. }
  58744. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  58745. import { Observable } from "babylonjs/Misc/observable";
  58746. import { Scene } from "babylonjs/scene";
  58747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58748. import { Ray } from "babylonjs/Culling/ray";
  58749. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58750. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58751. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58752. /**
  58753. * Defines the WindowsMotionController object that the state of the windows motion controller
  58754. */
  58755. export class WindowsMotionController extends WebVRController {
  58756. /**
  58757. * The base url used to load the left and right controller models
  58758. */
  58759. static MODEL_BASE_URL: string;
  58760. /**
  58761. * The name of the left controller model file
  58762. */
  58763. static MODEL_LEFT_FILENAME: string;
  58764. /**
  58765. * The name of the right controller model file
  58766. */
  58767. static MODEL_RIGHT_FILENAME: string;
  58768. /**
  58769. * The controller name prefix for this controller type
  58770. */
  58771. static readonly GAMEPAD_ID_PREFIX: string;
  58772. /**
  58773. * The controller id pattern for this controller type
  58774. */
  58775. private static readonly GAMEPAD_ID_PATTERN;
  58776. private _loadedMeshInfo;
  58777. protected readonly _mapping: {
  58778. buttons: string[];
  58779. buttonMeshNames: {
  58780. trigger: string;
  58781. menu: string;
  58782. grip: string;
  58783. thumbstick: string;
  58784. trackpad: string;
  58785. };
  58786. buttonObservableNames: {
  58787. trigger: string;
  58788. menu: string;
  58789. grip: string;
  58790. thumbstick: string;
  58791. trackpad: string;
  58792. };
  58793. axisMeshNames: string[];
  58794. pointingPoseMeshName: string;
  58795. };
  58796. /**
  58797. * Fired when the trackpad on this controller is clicked
  58798. */
  58799. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  58800. /**
  58801. * Fired when the trackpad on this controller is modified
  58802. */
  58803. onTrackpadValuesChangedObservable: Observable<StickValues>;
  58804. /**
  58805. * The current x and y values of this controller's trackpad
  58806. */
  58807. trackpad: StickValues;
  58808. /**
  58809. * Creates a new WindowsMotionController from a gamepad
  58810. * @param vrGamepad the gamepad that the controller should be created from
  58811. */
  58812. constructor(vrGamepad: any);
  58813. /**
  58814. * Fired when the trigger on this controller is modified
  58815. */
  58816. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58817. /**
  58818. * Fired when the menu button on this controller is modified
  58819. */
  58820. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58821. /**
  58822. * Fired when the grip button on this controller is modified
  58823. */
  58824. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58825. /**
  58826. * Fired when the thumbstick button on this controller is modified
  58827. */
  58828. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58829. /**
  58830. * Fired when the touchpad button on this controller is modified
  58831. */
  58832. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58833. /**
  58834. * Fired when the touchpad values on this controller are modified
  58835. */
  58836. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  58837. protected _updateTrackpad(): void;
  58838. /**
  58839. * Called once per frame by the engine.
  58840. */
  58841. update(): void;
  58842. /**
  58843. * Called once for each button that changed state since the last frame
  58844. * @param buttonIdx Which button index changed
  58845. * @param state New state of the button
  58846. * @param changes Which properties on the state changed since last frame
  58847. */
  58848. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58849. /**
  58850. * Moves the buttons on the controller mesh based on their current state
  58851. * @param buttonName the name of the button to move
  58852. * @param buttonValue the value of the button which determines the buttons new position
  58853. */
  58854. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  58855. /**
  58856. * Moves the axis on the controller mesh based on its current state
  58857. * @param axis the index of the axis
  58858. * @param axisValue the value of the axis which determines the meshes new position
  58859. * @hidden
  58860. */
  58861. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  58862. /**
  58863. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58864. * @param scene scene in which to add meshes
  58865. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58866. */
  58867. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  58868. /**
  58869. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  58870. * can be transformed by button presses and axes values, based on this._mapping.
  58871. *
  58872. * @param scene scene in which the meshes exist
  58873. * @param meshes list of meshes that make up the controller model to process
  58874. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  58875. */
  58876. private processModel;
  58877. private createMeshInfo;
  58878. /**
  58879. * Gets the ray of the controller in the direction the controller is pointing
  58880. * @param length the length the resulting ray should be
  58881. * @returns a ray in the direction the controller is pointing
  58882. */
  58883. getForwardRay(length?: number): Ray;
  58884. /**
  58885. * Disposes of the controller
  58886. */
  58887. dispose(): void;
  58888. }
  58889. /**
  58890. * This class represents a new windows motion controller in XR.
  58891. */
  58892. export class XRWindowsMotionController extends WindowsMotionController {
  58893. /**
  58894. * Changing the original WIndowsMotionController mapping to fir the new mapping
  58895. */
  58896. protected readonly _mapping: {
  58897. buttons: string[];
  58898. buttonMeshNames: {
  58899. trigger: string;
  58900. menu: string;
  58901. grip: string;
  58902. thumbstick: string;
  58903. trackpad: string;
  58904. };
  58905. buttonObservableNames: {
  58906. trigger: string;
  58907. menu: string;
  58908. grip: string;
  58909. thumbstick: string;
  58910. trackpad: string;
  58911. };
  58912. axisMeshNames: string[];
  58913. pointingPoseMeshName: string;
  58914. };
  58915. /**
  58916. * Construct a new XR-Based windows motion controller
  58917. *
  58918. * @param gamepadInfo the gamepad object from the browser
  58919. */
  58920. constructor(gamepadInfo: any);
  58921. /**
  58922. * holds the thumbstick values (X,Y)
  58923. */
  58924. thumbstickValues: StickValues;
  58925. /**
  58926. * Fired when the thumbstick on this controller is clicked
  58927. */
  58928. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  58929. /**
  58930. * Fired when the thumbstick on this controller is modified
  58931. */
  58932. onThumbstickValuesChangedObservable: Observable<StickValues>;
  58933. /**
  58934. * Fired when the touchpad button on this controller is modified
  58935. */
  58936. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  58937. /**
  58938. * Fired when the touchpad values on this controller are modified
  58939. */
  58940. onTrackpadValuesChangedObservable: Observable<StickValues>;
  58941. /**
  58942. * Fired when the thumbstick button on this controller is modified
  58943. * here to prevent breaking changes
  58944. */
  58945. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58946. /**
  58947. * updating the thumbstick(!) and not the trackpad.
  58948. * This is named this way due to the difference between WebVR and XR and to avoid
  58949. * changing the parent class.
  58950. */
  58951. protected _updateTrackpad(): void;
  58952. /**
  58953. * Disposes the class with joy
  58954. */
  58955. dispose(): void;
  58956. }
  58957. }
  58958. declare module "babylonjs/Gamepads/Controllers/index" {
  58959. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  58960. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  58961. export * from "babylonjs/Gamepads/Controllers/genericController";
  58962. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  58963. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58964. export * from "babylonjs/Gamepads/Controllers/viveController";
  58965. export * from "babylonjs/Gamepads/Controllers/webVRController";
  58966. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  58967. }
  58968. declare module "babylonjs/Gamepads/index" {
  58969. export * from "babylonjs/Gamepads/Controllers/index";
  58970. export * from "babylonjs/Gamepads/gamepad";
  58971. export * from "babylonjs/Gamepads/gamepadManager";
  58972. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  58973. export * from "babylonjs/Gamepads/xboxGamepad";
  58974. export * from "babylonjs/Gamepads/dualShockGamepad";
  58975. }
  58976. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  58977. import { Scene } from "babylonjs/scene";
  58978. import { Vector4 } from "babylonjs/Maths/math.vector";
  58979. import { Color4 } from "babylonjs/Maths/math.color";
  58980. import { Mesh } from "babylonjs/Meshes/mesh";
  58981. import { Nullable } from "babylonjs/types";
  58982. /**
  58983. * Class containing static functions to help procedurally build meshes
  58984. */
  58985. export class PolyhedronBuilder {
  58986. /**
  58987. * Creates a polyhedron mesh
  58988. * * 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
  58989. * * The parameter `size` (positive float, default 1) sets the polygon size
  58990. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58991. * * 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`
  58992. * * 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
  58993. * * 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)`)
  58994. * * 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
  58995. * * 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
  58996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58997. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58999. * @param name defines the name of the mesh
  59000. * @param options defines the options used to create the mesh
  59001. * @param scene defines the hosting scene
  59002. * @returns the polyhedron mesh
  59003. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59004. */
  59005. static CreatePolyhedron(name: string, options: {
  59006. type?: number;
  59007. size?: number;
  59008. sizeX?: number;
  59009. sizeY?: number;
  59010. sizeZ?: number;
  59011. custom?: any;
  59012. faceUV?: Vector4[];
  59013. faceColors?: Color4[];
  59014. flat?: boolean;
  59015. updatable?: boolean;
  59016. sideOrientation?: number;
  59017. frontUVs?: Vector4;
  59018. backUVs?: Vector4;
  59019. }, scene?: Nullable<Scene>): Mesh;
  59020. }
  59021. }
  59022. declare module "babylonjs/Gizmos/scaleGizmo" {
  59023. import { Observable } from "babylonjs/Misc/observable";
  59024. import { Nullable } from "babylonjs/types";
  59025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59026. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59027. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  59028. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59029. import { Node } from "babylonjs/node";
  59030. /**
  59031. * Gizmo that enables scaling a mesh along 3 axis
  59032. */
  59033. export class ScaleGizmo extends Gizmo {
  59034. /**
  59035. * Internal gizmo used for interactions on the x axis
  59036. */
  59037. xGizmo: AxisScaleGizmo;
  59038. /**
  59039. * Internal gizmo used for interactions on the y axis
  59040. */
  59041. yGizmo: AxisScaleGizmo;
  59042. /**
  59043. * Internal gizmo used for interactions on the z axis
  59044. */
  59045. zGizmo: AxisScaleGizmo;
  59046. /**
  59047. * Internal gizmo used to scale all axis equally
  59048. */
  59049. uniformScaleGizmo: AxisScaleGizmo;
  59050. private _meshAttached;
  59051. private _nodeAttached;
  59052. private _snapDistance;
  59053. private _uniformScalingMesh;
  59054. private _octahedron;
  59055. private _sensitivity;
  59056. /** Fires an event when any of it's sub gizmos are dragged */
  59057. onDragStartObservable: Observable<unknown>;
  59058. /** Fires an event when any of it's sub gizmos are released from dragging */
  59059. onDragEndObservable: Observable<unknown>;
  59060. get attachedMesh(): Nullable<AbstractMesh>;
  59061. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59062. get attachedNode(): Nullable<Node>;
  59063. set attachedNode(node: Nullable<Node>);
  59064. /**
  59065. * True when the mouse pointer is hovering a gizmo mesh
  59066. */
  59067. get isHovered(): boolean;
  59068. /**
  59069. * Creates a ScaleGizmo
  59070. * @param gizmoLayer The utility layer the gizmo will be added to
  59071. * @param thickness display gizmo axis thickness
  59072. */
  59073. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  59074. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59075. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59076. /**
  59077. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59078. */
  59079. set snapDistance(value: number);
  59080. get snapDistance(): number;
  59081. /**
  59082. * Ratio for the scale of the gizmo (Default: 1)
  59083. */
  59084. set scaleRatio(value: number);
  59085. get scaleRatio(): number;
  59086. /**
  59087. * Sensitivity factor for dragging (Default: 1)
  59088. */
  59089. set sensitivity(value: number);
  59090. get sensitivity(): number;
  59091. /**
  59092. * Disposes of the gizmo
  59093. */
  59094. dispose(): void;
  59095. }
  59096. }
  59097. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  59098. import { Observable } from "babylonjs/Misc/observable";
  59099. import { Nullable } from "babylonjs/types";
  59100. import { Vector3 } from "babylonjs/Maths/math.vector";
  59101. import { Node } from "babylonjs/node";
  59102. import { Mesh } from "babylonjs/Meshes/mesh";
  59103. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59104. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59105. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59106. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59107. import { Color3 } from "babylonjs/Maths/math.color";
  59108. /**
  59109. * Single axis scale gizmo
  59110. */
  59111. export class AxisScaleGizmo extends Gizmo {
  59112. /**
  59113. * Drag behavior responsible for the gizmos dragging interactions
  59114. */
  59115. dragBehavior: PointerDragBehavior;
  59116. private _pointerObserver;
  59117. /**
  59118. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59119. */
  59120. snapDistance: number;
  59121. /**
  59122. * Event that fires each time the gizmo snaps to a new location.
  59123. * * snapDistance is the the change in distance
  59124. */
  59125. onSnapObservable: Observable<{
  59126. snapDistance: number;
  59127. }>;
  59128. /**
  59129. * If the scaling operation should be done on all axis (default: false)
  59130. */
  59131. uniformScaling: boolean;
  59132. /**
  59133. * Custom sensitivity value for the drag strength
  59134. */
  59135. sensitivity: number;
  59136. private _isEnabled;
  59137. private _parent;
  59138. private _arrow;
  59139. private _coloredMaterial;
  59140. private _hoverMaterial;
  59141. /**
  59142. * Creates an AxisScaleGizmo
  59143. * @param gizmoLayer The utility layer the gizmo will be added to
  59144. * @param dragAxis The axis which the gizmo will be able to scale on
  59145. * @param color The color of the gizmo
  59146. * @param thickness display gizmo axis thickness
  59147. */
  59148. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  59149. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59150. /**
  59151. * If the gizmo is enabled
  59152. */
  59153. set isEnabled(value: boolean);
  59154. get isEnabled(): boolean;
  59155. /**
  59156. * Disposes of the gizmo
  59157. */
  59158. dispose(): void;
  59159. /**
  59160. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  59161. * @param mesh The mesh to replace the default mesh of the gizmo
  59162. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  59163. */
  59164. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  59165. }
  59166. }
  59167. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  59168. import { Observable } from "babylonjs/Misc/observable";
  59169. import { Nullable } from "babylonjs/types";
  59170. import { Vector3 } from "babylonjs/Maths/math.vector";
  59171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59172. import { Mesh } from "babylonjs/Meshes/mesh";
  59173. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59174. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59175. import { Color3 } from "babylonjs/Maths/math.color";
  59176. import "babylonjs/Meshes/Builders/boxBuilder";
  59177. /**
  59178. * Bounding box gizmo
  59179. */
  59180. export class BoundingBoxGizmo extends Gizmo {
  59181. private _lineBoundingBox;
  59182. private _rotateSpheresParent;
  59183. private _scaleBoxesParent;
  59184. private _boundingDimensions;
  59185. private _renderObserver;
  59186. private _pointerObserver;
  59187. private _scaleDragSpeed;
  59188. private _tmpQuaternion;
  59189. private _tmpVector;
  59190. private _tmpRotationMatrix;
  59191. /**
  59192. * 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)
  59193. */
  59194. ignoreChildren: boolean;
  59195. /**
  59196. * 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)
  59197. */
  59198. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  59199. /**
  59200. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  59201. */
  59202. rotationSphereSize: number;
  59203. /**
  59204. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  59205. */
  59206. scaleBoxSize: number;
  59207. /**
  59208. * 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)
  59209. */
  59210. fixedDragMeshScreenSize: boolean;
  59211. /**
  59212. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  59213. */
  59214. fixedDragMeshScreenSizeDistanceFactor: number;
  59215. /**
  59216. * Fired when a rotation sphere or scale box is dragged
  59217. */
  59218. onDragStartObservable: Observable<{}>;
  59219. /**
  59220. * Fired when a scale box is dragged
  59221. */
  59222. onScaleBoxDragObservable: Observable<{}>;
  59223. /**
  59224. * Fired when a scale box drag is ended
  59225. */
  59226. onScaleBoxDragEndObservable: Observable<{}>;
  59227. /**
  59228. * Fired when a rotation sphere is dragged
  59229. */
  59230. onRotationSphereDragObservable: Observable<{}>;
  59231. /**
  59232. * Fired when a rotation sphere drag is ended
  59233. */
  59234. onRotationSphereDragEndObservable: Observable<{}>;
  59235. /**
  59236. * 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)
  59237. */
  59238. scalePivot: Nullable<Vector3>;
  59239. /**
  59240. * Mesh used as a pivot to rotate the attached node
  59241. */
  59242. private _anchorMesh;
  59243. private _existingMeshScale;
  59244. private _dragMesh;
  59245. private pointerDragBehavior;
  59246. private coloredMaterial;
  59247. private hoverColoredMaterial;
  59248. /**
  59249. * Sets the color of the bounding box gizmo
  59250. * @param color the color to set
  59251. */
  59252. setColor(color: Color3): void;
  59253. /**
  59254. * Creates an BoundingBoxGizmo
  59255. * @param gizmoLayer The utility layer the gizmo will be added to
  59256. * @param color The color of the gizmo
  59257. */
  59258. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  59259. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  59260. private _selectNode;
  59261. /**
  59262. * Updates the bounding box information for the Gizmo
  59263. */
  59264. updateBoundingBox(): void;
  59265. private _updateRotationSpheres;
  59266. private _updateScaleBoxes;
  59267. /**
  59268. * Enables rotation on the specified axis and disables rotation on the others
  59269. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  59270. */
  59271. setEnabledRotationAxis(axis: string): void;
  59272. /**
  59273. * Enables/disables scaling
  59274. * @param enable if scaling should be enabled
  59275. * @param homogeneousScaling defines if scaling should only be homogeneous
  59276. */
  59277. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  59278. private _updateDummy;
  59279. /**
  59280. * Enables a pointer drag behavior on the bounding box of the gizmo
  59281. */
  59282. enableDragBehavior(): void;
  59283. /**
  59284. * Disposes of the gizmo
  59285. */
  59286. dispose(): void;
  59287. /**
  59288. * 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)
  59289. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  59290. * @returns the bounding box mesh with the passed in mesh as a child
  59291. */
  59292. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  59293. /**
  59294. * CustomMeshes are not supported by this gizmo
  59295. * @param mesh The mesh to replace the default mesh of the gizmo
  59296. */
  59297. setCustomMesh(mesh: Mesh): void;
  59298. }
  59299. }
  59300. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  59301. import { Observable } from "babylonjs/Misc/observable";
  59302. import { Nullable } from "babylonjs/types";
  59303. import { Vector3 } from "babylonjs/Maths/math.vector";
  59304. import { Color3 } from "babylonjs/Maths/math.color";
  59305. import { Node } from "babylonjs/node";
  59306. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59307. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59308. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59309. import "babylonjs/Meshes/Builders/linesBuilder";
  59310. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59311. /**
  59312. * Single plane rotation gizmo
  59313. */
  59314. export class PlaneRotationGizmo extends Gizmo {
  59315. /**
  59316. * Drag behavior responsible for the gizmos dragging interactions
  59317. */
  59318. dragBehavior: PointerDragBehavior;
  59319. private _pointerObserver;
  59320. /**
  59321. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  59322. */
  59323. snapDistance: number;
  59324. /**
  59325. * Event that fires each time the gizmo snaps to a new location.
  59326. * * snapDistance is the the change in distance
  59327. */
  59328. onSnapObservable: Observable<{
  59329. snapDistance: number;
  59330. }>;
  59331. private _isEnabled;
  59332. private _parent;
  59333. /**
  59334. * Creates a PlaneRotationGizmo
  59335. * @param gizmoLayer The utility layer the gizmo will be added to
  59336. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  59337. * @param color The color of the gizmo
  59338. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59339. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59340. * @param thickness display gizmo axis thickness
  59341. */
  59342. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  59343. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59344. /**
  59345. * If the gizmo is enabled
  59346. */
  59347. set isEnabled(value: boolean);
  59348. get isEnabled(): boolean;
  59349. /**
  59350. * Disposes of the gizmo
  59351. */
  59352. dispose(): void;
  59353. }
  59354. }
  59355. declare module "babylonjs/Gizmos/rotationGizmo" {
  59356. import { Observable } from "babylonjs/Misc/observable";
  59357. import { Nullable } from "babylonjs/types";
  59358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59359. import { Mesh } from "babylonjs/Meshes/mesh";
  59360. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59361. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  59362. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59363. import { Node } from "babylonjs/node";
  59364. /**
  59365. * Gizmo that enables rotating a mesh along 3 axis
  59366. */
  59367. export class RotationGizmo extends Gizmo {
  59368. /**
  59369. * Internal gizmo used for interactions on the x axis
  59370. */
  59371. xGizmo: PlaneRotationGizmo;
  59372. /**
  59373. * Internal gizmo used for interactions on the y axis
  59374. */
  59375. yGizmo: PlaneRotationGizmo;
  59376. /**
  59377. * Internal gizmo used for interactions on the z axis
  59378. */
  59379. zGizmo: PlaneRotationGizmo;
  59380. /** Fires an event when any of it's sub gizmos are dragged */
  59381. onDragStartObservable: Observable<unknown>;
  59382. /** Fires an event when any of it's sub gizmos are released from dragging */
  59383. onDragEndObservable: Observable<unknown>;
  59384. private _meshAttached;
  59385. private _nodeAttached;
  59386. get attachedMesh(): Nullable<AbstractMesh>;
  59387. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59388. get attachedNode(): Nullable<Node>;
  59389. set attachedNode(node: Nullable<Node>);
  59390. protected _checkBillboardTransform(): void;
  59391. /**
  59392. * True when the mouse pointer is hovering a gizmo mesh
  59393. */
  59394. get isHovered(): boolean;
  59395. /**
  59396. * Creates a RotationGizmo
  59397. * @param gizmoLayer The utility layer the gizmo will be added to
  59398. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59399. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59400. * @param thickness display gizmo axis thickness
  59401. */
  59402. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  59403. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59404. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59405. /**
  59406. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59407. */
  59408. set snapDistance(value: number);
  59409. get snapDistance(): number;
  59410. /**
  59411. * Ratio for the scale of the gizmo (Default: 1)
  59412. */
  59413. set scaleRatio(value: number);
  59414. get scaleRatio(): number;
  59415. /**
  59416. * Disposes of the gizmo
  59417. */
  59418. dispose(): void;
  59419. /**
  59420. * CustomMeshes are not supported by this gizmo
  59421. * @param mesh The mesh to replace the default mesh of the gizmo
  59422. */
  59423. setCustomMesh(mesh: Mesh): void;
  59424. }
  59425. }
  59426. declare module "babylonjs/Gizmos/gizmoManager" {
  59427. import { Observable } from "babylonjs/Misc/observable";
  59428. import { Nullable } from "babylonjs/types";
  59429. import { Scene, IDisposable } from "babylonjs/scene";
  59430. import { Node } from "babylonjs/node";
  59431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59432. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59433. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  59434. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59435. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  59436. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59437. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  59438. /**
  59439. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  59440. */
  59441. export class GizmoManager implements IDisposable {
  59442. private scene;
  59443. /**
  59444. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  59445. */
  59446. gizmos: {
  59447. positionGizmo: Nullable<PositionGizmo>;
  59448. rotationGizmo: Nullable<RotationGizmo>;
  59449. scaleGizmo: Nullable<ScaleGizmo>;
  59450. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  59451. };
  59452. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  59453. clearGizmoOnEmptyPointerEvent: boolean;
  59454. /** Fires an event when the manager is attached to a mesh */
  59455. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  59456. /** Fires an event when the manager is attached to a node */
  59457. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  59458. private _gizmosEnabled;
  59459. private _pointerObserver;
  59460. private _attachedMesh;
  59461. private _attachedNode;
  59462. private _boundingBoxColor;
  59463. private _defaultUtilityLayer;
  59464. private _defaultKeepDepthUtilityLayer;
  59465. private _thickness;
  59466. /**
  59467. * When bounding box gizmo is enabled, this can be used to track drag/end events
  59468. */
  59469. boundingBoxDragBehavior: SixDofDragBehavior;
  59470. /**
  59471. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  59472. */
  59473. attachableMeshes: Nullable<Array<AbstractMesh>>;
  59474. /**
  59475. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  59476. */
  59477. attachableNodes: Nullable<Array<Node>>;
  59478. /**
  59479. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  59480. */
  59481. usePointerToAttachGizmos: boolean;
  59482. /**
  59483. * Utility layer that the bounding box gizmo belongs to
  59484. */
  59485. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  59486. /**
  59487. * Utility layer that all gizmos besides bounding box belong to
  59488. */
  59489. get utilityLayer(): UtilityLayerRenderer;
  59490. /**
  59491. * True when the mouse pointer is hovering a gizmo mesh
  59492. */
  59493. get isHovered(): boolean;
  59494. /**
  59495. * Instatiates a gizmo manager
  59496. * @param scene the scene to overlay the gizmos on top of
  59497. * @param thickness display gizmo axis thickness
  59498. */
  59499. constructor(scene: Scene, thickness?: number);
  59500. /**
  59501. * Attaches a set of gizmos to the specified mesh
  59502. * @param mesh The mesh the gizmo's should be attached to
  59503. */
  59504. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59505. /**
  59506. * Attaches a set of gizmos to the specified node
  59507. * @param node The node the gizmo's should be attached to
  59508. */
  59509. attachToNode(node: Nullable<Node>): void;
  59510. /**
  59511. * If the position gizmo is enabled
  59512. */
  59513. set positionGizmoEnabled(value: boolean);
  59514. get positionGizmoEnabled(): boolean;
  59515. /**
  59516. * If the rotation gizmo is enabled
  59517. */
  59518. set rotationGizmoEnabled(value: boolean);
  59519. get rotationGizmoEnabled(): boolean;
  59520. /**
  59521. * If the scale gizmo is enabled
  59522. */
  59523. set scaleGizmoEnabled(value: boolean);
  59524. get scaleGizmoEnabled(): boolean;
  59525. /**
  59526. * If the boundingBox gizmo is enabled
  59527. */
  59528. set boundingBoxGizmoEnabled(value: boolean);
  59529. get boundingBoxGizmoEnabled(): boolean;
  59530. /**
  59531. * Disposes of the gizmo manager
  59532. */
  59533. dispose(): void;
  59534. }
  59535. }
  59536. declare module "babylonjs/Lights/directionalLight" {
  59537. import { Camera } from "babylonjs/Cameras/camera";
  59538. import { Scene } from "babylonjs/scene";
  59539. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59541. import { Light } from "babylonjs/Lights/light";
  59542. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59543. import { Effect } from "babylonjs/Materials/effect";
  59544. /**
  59545. * A directional light is defined by a direction (what a surprise!).
  59546. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  59547. * 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.
  59548. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59549. */
  59550. export class DirectionalLight extends ShadowLight {
  59551. private _shadowFrustumSize;
  59552. /**
  59553. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  59554. */
  59555. get shadowFrustumSize(): number;
  59556. /**
  59557. * Specifies a fix frustum size for the shadow generation.
  59558. */
  59559. set shadowFrustumSize(value: number);
  59560. private _shadowOrthoScale;
  59561. /**
  59562. * Gets the shadow projection scale against the optimal computed one.
  59563. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59564. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59565. */
  59566. get shadowOrthoScale(): number;
  59567. /**
  59568. * Sets the shadow projection scale against the optimal computed one.
  59569. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59570. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59571. */
  59572. set shadowOrthoScale(value: number);
  59573. /**
  59574. * Automatically compute the projection matrix to best fit (including all the casters)
  59575. * on each frame.
  59576. */
  59577. autoUpdateExtends: boolean;
  59578. /**
  59579. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  59580. * on each frame. autoUpdateExtends must be set to true for this to work
  59581. */
  59582. autoCalcShadowZBounds: boolean;
  59583. private _orthoLeft;
  59584. private _orthoRight;
  59585. private _orthoTop;
  59586. private _orthoBottom;
  59587. /**
  59588. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  59589. * The directional light is emitted from everywhere in the given direction.
  59590. * It can cast shadows.
  59591. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59592. * @param name The friendly name of the light
  59593. * @param direction The direction of the light
  59594. * @param scene The scene the light belongs to
  59595. */
  59596. constructor(name: string, direction: Vector3, scene: Scene);
  59597. /**
  59598. * Returns the string "DirectionalLight".
  59599. * @return The class name
  59600. */
  59601. getClassName(): string;
  59602. /**
  59603. * Returns the integer 1.
  59604. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59605. */
  59606. getTypeID(): number;
  59607. /**
  59608. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  59609. * Returns the DirectionalLight Shadow projection matrix.
  59610. */
  59611. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59612. /**
  59613. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  59614. * Returns the DirectionalLight Shadow projection matrix.
  59615. */
  59616. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  59617. /**
  59618. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  59619. * Returns the DirectionalLight Shadow projection matrix.
  59620. */
  59621. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59622. protected _buildUniformLayout(): void;
  59623. /**
  59624. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  59625. * @param effect The effect to update
  59626. * @param lightIndex The index of the light in the effect to update
  59627. * @returns The directional light
  59628. */
  59629. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  59630. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  59631. /**
  59632. * Gets the minZ used for shadow according to both the scene and the light.
  59633. *
  59634. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59635. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59636. * @param activeCamera The camera we are returning the min for
  59637. * @returns the depth min z
  59638. */
  59639. getDepthMinZ(activeCamera: Camera): number;
  59640. /**
  59641. * Gets the maxZ used for shadow according to both the scene and the light.
  59642. *
  59643. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59644. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59645. * @param activeCamera The camera we are returning the max for
  59646. * @returns the depth max z
  59647. */
  59648. getDepthMaxZ(activeCamera: Camera): number;
  59649. /**
  59650. * Prepares the list of defines specific to the light type.
  59651. * @param defines the list of defines
  59652. * @param lightIndex defines the index of the light for the effect
  59653. */
  59654. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59655. }
  59656. }
  59657. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  59658. import { Mesh } from "babylonjs/Meshes/mesh";
  59659. /**
  59660. * Class containing static functions to help procedurally build meshes
  59661. */
  59662. export class HemisphereBuilder {
  59663. /**
  59664. * Creates a hemisphere mesh
  59665. * @param name defines the name of the mesh
  59666. * @param options defines the options used to create the mesh
  59667. * @param scene defines the hosting scene
  59668. * @returns the hemisphere mesh
  59669. */
  59670. static CreateHemisphere(name: string, options: {
  59671. segments?: number;
  59672. diameter?: number;
  59673. sideOrientation?: number;
  59674. }, scene: any): Mesh;
  59675. }
  59676. }
  59677. declare module "babylonjs/Lights/spotLight" {
  59678. import { Nullable } from "babylonjs/types";
  59679. import { Scene } from "babylonjs/scene";
  59680. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59682. import { Effect } from "babylonjs/Materials/effect";
  59683. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59684. import { Light } from "babylonjs/Lights/light";
  59685. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59686. /**
  59687. * A spot light is defined by a position, a direction, an angle, and an exponent.
  59688. * These values define a cone of light starting from the position, emitting toward the direction.
  59689. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  59690. * and the exponent defines the speed of the decay of the light with distance (reach).
  59691. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59692. */
  59693. export class SpotLight extends ShadowLight {
  59694. private _angle;
  59695. private _innerAngle;
  59696. private _cosHalfAngle;
  59697. private _lightAngleScale;
  59698. private _lightAngleOffset;
  59699. /**
  59700. * Gets the cone angle of the spot light in Radians.
  59701. */
  59702. get angle(): number;
  59703. /**
  59704. * Sets the cone angle of the spot light in Radians.
  59705. */
  59706. set angle(value: number);
  59707. /**
  59708. * Only used in gltf falloff mode, this defines the angle where
  59709. * the directional falloff will start before cutting at angle which could be seen
  59710. * as outer angle.
  59711. */
  59712. get innerAngle(): number;
  59713. /**
  59714. * Only used in gltf falloff mode, this defines the angle where
  59715. * the directional falloff will start before cutting at angle which could be seen
  59716. * as outer angle.
  59717. */
  59718. set innerAngle(value: number);
  59719. private _shadowAngleScale;
  59720. /**
  59721. * Allows scaling the angle of the light for shadow generation only.
  59722. */
  59723. get shadowAngleScale(): number;
  59724. /**
  59725. * Allows scaling the angle of the light for shadow generation only.
  59726. */
  59727. set shadowAngleScale(value: number);
  59728. /**
  59729. * The light decay speed with the distance from the emission spot.
  59730. */
  59731. exponent: number;
  59732. private _projectionTextureMatrix;
  59733. /**
  59734. * Allows reading the projecton texture
  59735. */
  59736. get projectionTextureMatrix(): Matrix;
  59737. protected _projectionTextureLightNear: number;
  59738. /**
  59739. * Gets the near clip of the Spotlight for texture projection.
  59740. */
  59741. get projectionTextureLightNear(): number;
  59742. /**
  59743. * Sets the near clip of the Spotlight for texture projection.
  59744. */
  59745. set projectionTextureLightNear(value: number);
  59746. protected _projectionTextureLightFar: number;
  59747. /**
  59748. * Gets the far clip of the Spotlight for texture projection.
  59749. */
  59750. get projectionTextureLightFar(): number;
  59751. /**
  59752. * Sets the far clip of the Spotlight for texture projection.
  59753. */
  59754. set projectionTextureLightFar(value: number);
  59755. protected _projectionTextureUpDirection: Vector3;
  59756. /**
  59757. * Gets the Up vector of the Spotlight for texture projection.
  59758. */
  59759. get projectionTextureUpDirection(): Vector3;
  59760. /**
  59761. * Sets the Up vector of the Spotlight for texture projection.
  59762. */
  59763. set projectionTextureUpDirection(value: Vector3);
  59764. private _projectionTexture;
  59765. /**
  59766. * Gets the projection texture of the light.
  59767. */
  59768. get projectionTexture(): Nullable<BaseTexture>;
  59769. /**
  59770. * Sets the projection texture of the light.
  59771. */
  59772. set projectionTexture(value: Nullable<BaseTexture>);
  59773. private _projectionTextureViewLightDirty;
  59774. private _projectionTextureProjectionLightDirty;
  59775. private _projectionTextureDirty;
  59776. private _projectionTextureViewTargetVector;
  59777. private _projectionTextureViewLightMatrix;
  59778. private _projectionTextureProjectionLightMatrix;
  59779. private _projectionTextureScalingMatrix;
  59780. /**
  59781. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  59782. * It can cast shadows.
  59783. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59784. * @param name The light friendly name
  59785. * @param position The position of the spot light in the scene
  59786. * @param direction The direction of the light in the scene
  59787. * @param angle The cone angle of the light in Radians
  59788. * @param exponent The light decay speed with the distance from the emission spot
  59789. * @param scene The scene the lights belongs to
  59790. */
  59791. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  59792. /**
  59793. * Returns the string "SpotLight".
  59794. * @returns the class name
  59795. */
  59796. getClassName(): string;
  59797. /**
  59798. * Returns the integer 2.
  59799. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59800. */
  59801. getTypeID(): number;
  59802. /**
  59803. * Overrides the direction setter to recompute the projection texture view light Matrix.
  59804. */
  59805. protected _setDirection(value: Vector3): void;
  59806. /**
  59807. * Overrides the position setter to recompute the projection texture view light Matrix.
  59808. */
  59809. protected _setPosition(value: Vector3): void;
  59810. /**
  59811. * 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.
  59812. * Returns the SpotLight.
  59813. */
  59814. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59815. protected _computeProjectionTextureViewLightMatrix(): void;
  59816. protected _computeProjectionTextureProjectionLightMatrix(): void;
  59817. /**
  59818. * Main function for light texture projection matrix computing.
  59819. */
  59820. protected _computeProjectionTextureMatrix(): void;
  59821. protected _buildUniformLayout(): void;
  59822. private _computeAngleValues;
  59823. /**
  59824. * Sets the passed Effect "effect" with the Light textures.
  59825. * @param effect The effect to update
  59826. * @param lightIndex The index of the light in the effect to update
  59827. * @returns The light
  59828. */
  59829. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  59830. /**
  59831. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  59832. * @param effect The effect to update
  59833. * @param lightIndex The index of the light in the effect to update
  59834. * @returns The spot light
  59835. */
  59836. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  59837. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59838. /**
  59839. * Disposes the light and the associated resources.
  59840. */
  59841. dispose(): void;
  59842. /**
  59843. * Prepares the list of defines specific to the light type.
  59844. * @param defines the list of defines
  59845. * @param lightIndex defines the index of the light for the effect
  59846. */
  59847. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59848. }
  59849. }
  59850. declare module "babylonjs/Gizmos/lightGizmo" {
  59851. import { Nullable } from "babylonjs/types";
  59852. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59853. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59854. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59855. import { Light } from "babylonjs/Lights/light";
  59856. import { Observable } from "babylonjs/Misc/observable";
  59857. /**
  59858. * Gizmo that enables viewing a light
  59859. */
  59860. export class LightGizmo extends Gizmo {
  59861. private _lightMesh;
  59862. private _material;
  59863. private _cachedPosition;
  59864. private _cachedForward;
  59865. private _attachedMeshParent;
  59866. private _pointerObserver;
  59867. /**
  59868. * Event that fires each time the gizmo is clicked
  59869. */
  59870. onClickedObservable: Observable<Light>;
  59871. /**
  59872. * Creates a LightGizmo
  59873. * @param gizmoLayer The utility layer the gizmo will be added to
  59874. */
  59875. constructor(gizmoLayer?: UtilityLayerRenderer);
  59876. private _light;
  59877. /**
  59878. * The light that the gizmo is attached to
  59879. */
  59880. set light(light: Nullable<Light>);
  59881. get light(): Nullable<Light>;
  59882. /**
  59883. * Gets the material used to render the light gizmo
  59884. */
  59885. get material(): StandardMaterial;
  59886. /**
  59887. * @hidden
  59888. * Updates the gizmo to match the attached mesh's position/rotation
  59889. */
  59890. protected _update(): void;
  59891. private static _Scale;
  59892. /**
  59893. * Creates the lines for a light mesh
  59894. */
  59895. private static _CreateLightLines;
  59896. /**
  59897. * Disposes of the light gizmo
  59898. */
  59899. dispose(): void;
  59900. private static _CreateHemisphericLightMesh;
  59901. private static _CreatePointLightMesh;
  59902. private static _CreateSpotLightMesh;
  59903. private static _CreateDirectionalLightMesh;
  59904. }
  59905. }
  59906. declare module "babylonjs/Gizmos/cameraGizmo" {
  59907. import { Nullable } from "babylonjs/types";
  59908. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59909. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59910. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59911. import { Camera } from "babylonjs/Cameras/camera";
  59912. import { Observable } from "babylonjs/Misc/observable";
  59913. /**
  59914. * Gizmo that enables viewing a camera
  59915. */
  59916. export class CameraGizmo extends Gizmo {
  59917. private _cameraMesh;
  59918. private _cameraLinesMesh;
  59919. private _material;
  59920. private _pointerObserver;
  59921. /**
  59922. * Event that fires each time the gizmo is clicked
  59923. */
  59924. onClickedObservable: Observable<Camera>;
  59925. /**
  59926. * Creates a CameraGizmo
  59927. * @param gizmoLayer The utility layer the gizmo will be added to
  59928. */
  59929. constructor(gizmoLayer?: UtilityLayerRenderer);
  59930. private _camera;
  59931. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  59932. get displayFrustum(): boolean;
  59933. set displayFrustum(value: boolean);
  59934. /**
  59935. * The camera that the gizmo is attached to
  59936. */
  59937. set camera(camera: Nullable<Camera>);
  59938. get camera(): Nullable<Camera>;
  59939. /**
  59940. * Gets the material used to render the camera gizmo
  59941. */
  59942. get material(): StandardMaterial;
  59943. /**
  59944. * @hidden
  59945. * Updates the gizmo to match the attached mesh's position/rotation
  59946. */
  59947. protected _update(): void;
  59948. private static _Scale;
  59949. private _invProjection;
  59950. /**
  59951. * Disposes of the camera gizmo
  59952. */
  59953. dispose(): void;
  59954. private static _CreateCameraMesh;
  59955. private static _CreateCameraFrustum;
  59956. }
  59957. }
  59958. declare module "babylonjs/Gizmos/index" {
  59959. export * from "babylonjs/Gizmos/axisDragGizmo";
  59960. export * from "babylonjs/Gizmos/axisScaleGizmo";
  59961. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  59962. export * from "babylonjs/Gizmos/gizmo";
  59963. export * from "babylonjs/Gizmos/gizmoManager";
  59964. export * from "babylonjs/Gizmos/planeRotationGizmo";
  59965. export * from "babylonjs/Gizmos/positionGizmo";
  59966. export * from "babylonjs/Gizmos/rotationGizmo";
  59967. export * from "babylonjs/Gizmos/scaleGizmo";
  59968. export * from "babylonjs/Gizmos/lightGizmo";
  59969. export * from "babylonjs/Gizmos/cameraGizmo";
  59970. export * from "babylonjs/Gizmos/planeDragGizmo";
  59971. }
  59972. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  59973. /** @hidden */
  59974. export var backgroundFragmentDeclaration: {
  59975. name: string;
  59976. shader: string;
  59977. };
  59978. }
  59979. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  59980. /** @hidden */
  59981. export var backgroundUboDeclaration: {
  59982. name: string;
  59983. shader: string;
  59984. };
  59985. }
  59986. declare module "babylonjs/Shaders/background.fragment" {
  59987. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  59988. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  59989. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59990. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59991. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59992. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59993. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59994. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  59995. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  59996. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59997. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  59998. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  59999. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60000. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  60001. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  60002. /** @hidden */
  60003. export var backgroundPixelShader: {
  60004. name: string;
  60005. shader: string;
  60006. };
  60007. }
  60008. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  60009. /** @hidden */
  60010. export var backgroundVertexDeclaration: {
  60011. name: string;
  60012. shader: string;
  60013. };
  60014. }
  60015. declare module "babylonjs/Shaders/background.vertex" {
  60016. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  60017. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  60018. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60019. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60020. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60021. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  60022. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  60023. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60024. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60025. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60026. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60027. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60028. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  60029. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  60030. /** @hidden */
  60031. export var backgroundVertexShader: {
  60032. name: string;
  60033. shader: string;
  60034. };
  60035. }
  60036. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  60037. import { Nullable, int, float } from "babylonjs/types";
  60038. import { Scene } from "babylonjs/scene";
  60039. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60040. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60042. import { Mesh } from "babylonjs/Meshes/mesh";
  60043. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60044. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  60045. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  60046. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60047. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  60048. import { Color3 } from "babylonjs/Maths/math.color";
  60049. import "babylonjs/Shaders/background.fragment";
  60050. import "babylonjs/Shaders/background.vertex";
  60051. /**
  60052. * Background material used to create an efficient environement around your scene.
  60053. */
  60054. export class BackgroundMaterial extends PushMaterial {
  60055. /**
  60056. * Standard reflectance value at parallel view angle.
  60057. */
  60058. static StandardReflectance0: number;
  60059. /**
  60060. * Standard reflectance value at grazing angle.
  60061. */
  60062. static StandardReflectance90: number;
  60063. protected _primaryColor: Color3;
  60064. /**
  60065. * Key light Color (multiply against the environement texture)
  60066. */
  60067. primaryColor: Color3;
  60068. protected __perceptualColor: Nullable<Color3>;
  60069. /**
  60070. * Experimental Internal Use Only.
  60071. *
  60072. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  60073. * This acts as a helper to set the primary color to a more "human friendly" value.
  60074. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  60075. * output color as close as possible from the chosen value.
  60076. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  60077. * part of lighting setup.)
  60078. */
  60079. get _perceptualColor(): Nullable<Color3>;
  60080. set _perceptualColor(value: Nullable<Color3>);
  60081. protected _primaryColorShadowLevel: float;
  60082. /**
  60083. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  60084. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  60085. */
  60086. get primaryColorShadowLevel(): float;
  60087. set primaryColorShadowLevel(value: float);
  60088. protected _primaryColorHighlightLevel: float;
  60089. /**
  60090. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  60091. * The primary color is used at the level chosen to define what the white area would look.
  60092. */
  60093. get primaryColorHighlightLevel(): float;
  60094. set primaryColorHighlightLevel(value: float);
  60095. protected _reflectionTexture: Nullable<BaseTexture>;
  60096. /**
  60097. * Reflection Texture used in the material.
  60098. * Should be author in a specific way for the best result (refer to the documentation).
  60099. */
  60100. reflectionTexture: Nullable<BaseTexture>;
  60101. protected _reflectionBlur: float;
  60102. /**
  60103. * Reflection Texture level of blur.
  60104. *
  60105. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  60106. * texture twice.
  60107. */
  60108. reflectionBlur: float;
  60109. protected _diffuseTexture: Nullable<BaseTexture>;
  60110. /**
  60111. * Diffuse Texture used in the material.
  60112. * Should be author in a specific way for the best result (refer to the documentation).
  60113. */
  60114. diffuseTexture: Nullable<BaseTexture>;
  60115. protected _shadowLights: Nullable<IShadowLight[]>;
  60116. /**
  60117. * Specify the list of lights casting shadow on the material.
  60118. * All scene shadow lights will be included if null.
  60119. */
  60120. shadowLights: Nullable<IShadowLight[]>;
  60121. protected _shadowLevel: float;
  60122. /**
  60123. * Helps adjusting the shadow to a softer level if required.
  60124. * 0 means black shadows and 1 means no shadows.
  60125. */
  60126. shadowLevel: float;
  60127. protected _sceneCenter: Vector3;
  60128. /**
  60129. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  60130. * It is usually zero but might be interesting to modify according to your setup.
  60131. */
  60132. sceneCenter: Vector3;
  60133. protected _opacityFresnel: boolean;
  60134. /**
  60135. * This helps specifying that the material is falling off to the sky box at grazing angle.
  60136. * This helps ensuring a nice transition when the camera goes under the ground.
  60137. */
  60138. opacityFresnel: boolean;
  60139. protected _reflectionFresnel: boolean;
  60140. /**
  60141. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  60142. * This helps adding a mirror texture on the ground.
  60143. */
  60144. reflectionFresnel: boolean;
  60145. protected _reflectionFalloffDistance: number;
  60146. /**
  60147. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  60148. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  60149. */
  60150. reflectionFalloffDistance: number;
  60151. protected _reflectionAmount: number;
  60152. /**
  60153. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  60154. */
  60155. reflectionAmount: number;
  60156. protected _reflectionReflectance0: number;
  60157. /**
  60158. * This specifies the weight of the reflection at grazing angle.
  60159. */
  60160. reflectionReflectance0: number;
  60161. protected _reflectionReflectance90: number;
  60162. /**
  60163. * This specifies the weight of the reflection at a perpendicular point of view.
  60164. */
  60165. reflectionReflectance90: number;
  60166. /**
  60167. * Sets the reflection reflectance fresnel values according to the default standard
  60168. * empirically know to work well :-)
  60169. */
  60170. set reflectionStandardFresnelWeight(value: number);
  60171. protected _useRGBColor: boolean;
  60172. /**
  60173. * Helps to directly use the maps channels instead of their level.
  60174. */
  60175. useRGBColor: boolean;
  60176. protected _enableNoise: boolean;
  60177. /**
  60178. * This helps reducing the banding effect that could occur on the background.
  60179. */
  60180. enableNoise: boolean;
  60181. /**
  60182. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60183. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  60184. * Recommended to be keep at 1.0 except for special cases.
  60185. */
  60186. get fovMultiplier(): number;
  60187. set fovMultiplier(value: number);
  60188. private _fovMultiplier;
  60189. /**
  60190. * Enable the FOV adjustment feature controlled by fovMultiplier.
  60191. */
  60192. useEquirectangularFOV: boolean;
  60193. private _maxSimultaneousLights;
  60194. /**
  60195. * Number of Simultaneous lights allowed on the material.
  60196. */
  60197. maxSimultaneousLights: int;
  60198. private _shadowOnly;
  60199. /**
  60200. * Make the material only render shadows
  60201. */
  60202. shadowOnly: boolean;
  60203. /**
  60204. * Default configuration related to image processing available in the Background Material.
  60205. */
  60206. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60207. /**
  60208. * Keep track of the image processing observer to allow dispose and replace.
  60209. */
  60210. private _imageProcessingObserver;
  60211. /**
  60212. * Attaches a new image processing configuration to the PBR Material.
  60213. * @param configuration (if null the scene configuration will be use)
  60214. */
  60215. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60216. /**
  60217. * Gets the image processing configuration used either in this material.
  60218. */
  60219. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  60220. /**
  60221. * Sets the Default image processing configuration used either in the this material.
  60222. *
  60223. * If sets to null, the scene one is in use.
  60224. */
  60225. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  60226. /**
  60227. * Gets wether the color curves effect is enabled.
  60228. */
  60229. get cameraColorCurvesEnabled(): boolean;
  60230. /**
  60231. * Sets wether the color curves effect is enabled.
  60232. */
  60233. set cameraColorCurvesEnabled(value: boolean);
  60234. /**
  60235. * Gets wether the color grading effect is enabled.
  60236. */
  60237. get cameraColorGradingEnabled(): boolean;
  60238. /**
  60239. * Gets wether the color grading effect is enabled.
  60240. */
  60241. set cameraColorGradingEnabled(value: boolean);
  60242. /**
  60243. * Gets wether tonemapping is enabled or not.
  60244. */
  60245. get cameraToneMappingEnabled(): boolean;
  60246. /**
  60247. * Sets wether tonemapping is enabled or not
  60248. */
  60249. set cameraToneMappingEnabled(value: boolean);
  60250. /**
  60251. * The camera exposure used on this material.
  60252. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60253. * This corresponds to a photographic exposure.
  60254. */
  60255. get cameraExposure(): float;
  60256. /**
  60257. * The camera exposure used on this material.
  60258. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60259. * This corresponds to a photographic exposure.
  60260. */
  60261. set cameraExposure(value: float);
  60262. /**
  60263. * Gets The camera contrast used on this material.
  60264. */
  60265. get cameraContrast(): float;
  60266. /**
  60267. * Sets The camera contrast used on this material.
  60268. */
  60269. set cameraContrast(value: float);
  60270. /**
  60271. * Gets the Color Grading 2D Lookup Texture.
  60272. */
  60273. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60274. /**
  60275. * Sets the Color Grading 2D Lookup Texture.
  60276. */
  60277. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60278. /**
  60279. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60280. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60281. * 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;
  60282. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60283. */
  60284. get cameraColorCurves(): Nullable<ColorCurves>;
  60285. /**
  60286. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60287. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60288. * 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;
  60289. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60290. */
  60291. set cameraColorCurves(value: Nullable<ColorCurves>);
  60292. /**
  60293. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  60294. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  60295. */
  60296. switchToBGR: boolean;
  60297. private _renderTargets;
  60298. private _reflectionControls;
  60299. private _white;
  60300. private _primaryShadowColor;
  60301. private _primaryHighlightColor;
  60302. /**
  60303. * Instantiates a Background Material in the given scene
  60304. * @param name The friendly name of the material
  60305. * @param scene The scene to add the material to
  60306. */
  60307. constructor(name: string, scene: Scene);
  60308. /**
  60309. * Gets a boolean indicating that current material needs to register RTT
  60310. */
  60311. get hasRenderTargetTextures(): boolean;
  60312. /**
  60313. * The entire material has been created in order to prevent overdraw.
  60314. * @returns false
  60315. */
  60316. needAlphaTesting(): boolean;
  60317. /**
  60318. * The entire material has been created in order to prevent overdraw.
  60319. * @returns true if blending is enable
  60320. */
  60321. needAlphaBlending(): boolean;
  60322. /**
  60323. * Checks wether the material is ready to be rendered for a given mesh.
  60324. * @param mesh The mesh to render
  60325. * @param subMesh The submesh to check against
  60326. * @param useInstances Specify wether or not the material is used with instances
  60327. * @returns true if all the dependencies are ready (Textures, Effects...)
  60328. */
  60329. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60330. /**
  60331. * Compute the primary color according to the chosen perceptual color.
  60332. */
  60333. private _computePrimaryColorFromPerceptualColor;
  60334. /**
  60335. * Compute the highlights and shadow colors according to their chosen levels.
  60336. */
  60337. private _computePrimaryColors;
  60338. /**
  60339. * Build the uniform buffer used in the material.
  60340. */
  60341. buildUniformLayout(): void;
  60342. /**
  60343. * Unbind the material.
  60344. */
  60345. unbind(): void;
  60346. /**
  60347. * Bind only the world matrix to the material.
  60348. * @param world The world matrix to bind.
  60349. */
  60350. bindOnlyWorldMatrix(world: Matrix): void;
  60351. /**
  60352. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  60353. * @param world The world matrix to bind.
  60354. * @param subMesh The submesh to bind for.
  60355. */
  60356. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60357. /**
  60358. * Checks to see if a texture is used in the material.
  60359. * @param texture - Base texture to use.
  60360. * @returns - Boolean specifying if a texture is used in the material.
  60361. */
  60362. hasTexture(texture: BaseTexture): boolean;
  60363. /**
  60364. * Dispose the material.
  60365. * @param forceDisposeEffect Force disposal of the associated effect.
  60366. * @param forceDisposeTextures Force disposal of the associated textures.
  60367. */
  60368. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  60369. /**
  60370. * Clones the material.
  60371. * @param name The cloned name.
  60372. * @returns The cloned material.
  60373. */
  60374. clone(name: string): BackgroundMaterial;
  60375. /**
  60376. * Serializes the current material to its JSON representation.
  60377. * @returns The JSON representation.
  60378. */
  60379. serialize(): any;
  60380. /**
  60381. * Gets the class name of the material
  60382. * @returns "BackgroundMaterial"
  60383. */
  60384. getClassName(): string;
  60385. /**
  60386. * Parse a JSON input to create back a background material.
  60387. * @param source The JSON data to parse
  60388. * @param scene The scene to create the parsed material in
  60389. * @param rootUrl The root url of the assets the material depends upon
  60390. * @returns the instantiated BackgroundMaterial.
  60391. */
  60392. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  60393. }
  60394. }
  60395. declare module "babylonjs/Helpers/environmentHelper" {
  60396. import { Observable } from "babylonjs/Misc/observable";
  60397. import { Nullable } from "babylonjs/types";
  60398. import { Scene } from "babylonjs/scene";
  60399. import { Vector3 } from "babylonjs/Maths/math.vector";
  60400. import { Color3 } from "babylonjs/Maths/math.color";
  60401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60402. import { Mesh } from "babylonjs/Meshes/mesh";
  60403. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60404. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  60405. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60406. import "babylonjs/Meshes/Builders/planeBuilder";
  60407. import "babylonjs/Meshes/Builders/boxBuilder";
  60408. /**
  60409. * Represents the different options available during the creation of
  60410. * a Environment helper.
  60411. *
  60412. * This can control the default ground, skybox and image processing setup of your scene.
  60413. */
  60414. export interface IEnvironmentHelperOptions {
  60415. /**
  60416. * Specifies whether or not to create a ground.
  60417. * True by default.
  60418. */
  60419. createGround: boolean;
  60420. /**
  60421. * Specifies the ground size.
  60422. * 15 by default.
  60423. */
  60424. groundSize: number;
  60425. /**
  60426. * The texture used on the ground for the main color.
  60427. * Comes from the BabylonJS CDN by default.
  60428. *
  60429. * Remarks: Can be either a texture or a url.
  60430. */
  60431. groundTexture: string | BaseTexture;
  60432. /**
  60433. * The color mixed in the ground texture by default.
  60434. * BabylonJS clearColor by default.
  60435. */
  60436. groundColor: Color3;
  60437. /**
  60438. * Specifies the ground opacity.
  60439. * 1 by default.
  60440. */
  60441. groundOpacity: number;
  60442. /**
  60443. * Enables the ground to receive shadows.
  60444. * True by default.
  60445. */
  60446. enableGroundShadow: boolean;
  60447. /**
  60448. * Helps preventing the shadow to be fully black on the ground.
  60449. * 0.5 by default.
  60450. */
  60451. groundShadowLevel: number;
  60452. /**
  60453. * Creates a mirror texture attach to the ground.
  60454. * false by default.
  60455. */
  60456. enableGroundMirror: boolean;
  60457. /**
  60458. * Specifies the ground mirror size ratio.
  60459. * 0.3 by default as the default kernel is 64.
  60460. */
  60461. groundMirrorSizeRatio: number;
  60462. /**
  60463. * Specifies the ground mirror blur kernel size.
  60464. * 64 by default.
  60465. */
  60466. groundMirrorBlurKernel: number;
  60467. /**
  60468. * Specifies the ground mirror visibility amount.
  60469. * 1 by default
  60470. */
  60471. groundMirrorAmount: number;
  60472. /**
  60473. * Specifies the ground mirror reflectance weight.
  60474. * This uses the standard weight of the background material to setup the fresnel effect
  60475. * of the mirror.
  60476. * 1 by default.
  60477. */
  60478. groundMirrorFresnelWeight: number;
  60479. /**
  60480. * Specifies the ground mirror Falloff distance.
  60481. * This can helps reducing the size of the reflection.
  60482. * 0 by Default.
  60483. */
  60484. groundMirrorFallOffDistance: number;
  60485. /**
  60486. * Specifies the ground mirror texture type.
  60487. * Unsigned Int by Default.
  60488. */
  60489. groundMirrorTextureType: number;
  60490. /**
  60491. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  60492. * the shown objects.
  60493. */
  60494. groundYBias: number;
  60495. /**
  60496. * Specifies whether or not to create a skybox.
  60497. * True by default.
  60498. */
  60499. createSkybox: boolean;
  60500. /**
  60501. * Specifies the skybox size.
  60502. * 20 by default.
  60503. */
  60504. skyboxSize: number;
  60505. /**
  60506. * The texture used on the skybox for the main color.
  60507. * Comes from the BabylonJS CDN by default.
  60508. *
  60509. * Remarks: Can be either a texture or a url.
  60510. */
  60511. skyboxTexture: string | BaseTexture;
  60512. /**
  60513. * The color mixed in the skybox texture by default.
  60514. * BabylonJS clearColor by default.
  60515. */
  60516. skyboxColor: Color3;
  60517. /**
  60518. * The background rotation around the Y axis of the scene.
  60519. * This helps aligning the key lights of your scene with the background.
  60520. * 0 by default.
  60521. */
  60522. backgroundYRotation: number;
  60523. /**
  60524. * Compute automatically the size of the elements to best fit with the scene.
  60525. */
  60526. sizeAuto: boolean;
  60527. /**
  60528. * Default position of the rootMesh if autoSize is not true.
  60529. */
  60530. rootPosition: Vector3;
  60531. /**
  60532. * Sets up the image processing in the scene.
  60533. * true by default.
  60534. */
  60535. setupImageProcessing: boolean;
  60536. /**
  60537. * The texture used as your environment texture in the scene.
  60538. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  60539. *
  60540. * Remarks: Can be either a texture or a url.
  60541. */
  60542. environmentTexture: string | BaseTexture;
  60543. /**
  60544. * The value of the exposure to apply to the scene.
  60545. * 0.6 by default if setupImageProcessing is true.
  60546. */
  60547. cameraExposure: number;
  60548. /**
  60549. * The value of the contrast to apply to the scene.
  60550. * 1.6 by default if setupImageProcessing is true.
  60551. */
  60552. cameraContrast: number;
  60553. /**
  60554. * Specifies whether or not tonemapping should be enabled in the scene.
  60555. * true by default if setupImageProcessing is true.
  60556. */
  60557. toneMappingEnabled: boolean;
  60558. }
  60559. /**
  60560. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  60561. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  60562. * It also helps with the default setup of your imageProcessing configuration.
  60563. */
  60564. export class EnvironmentHelper {
  60565. /**
  60566. * Default ground texture URL.
  60567. */
  60568. private static _groundTextureCDNUrl;
  60569. /**
  60570. * Default skybox texture URL.
  60571. */
  60572. private static _skyboxTextureCDNUrl;
  60573. /**
  60574. * Default environment texture URL.
  60575. */
  60576. private static _environmentTextureCDNUrl;
  60577. /**
  60578. * Creates the default options for the helper.
  60579. */
  60580. private static _getDefaultOptions;
  60581. private _rootMesh;
  60582. /**
  60583. * Gets the root mesh created by the helper.
  60584. */
  60585. get rootMesh(): Mesh;
  60586. private _skybox;
  60587. /**
  60588. * Gets the skybox created by the helper.
  60589. */
  60590. get skybox(): Nullable<Mesh>;
  60591. private _skyboxTexture;
  60592. /**
  60593. * Gets the skybox texture created by the helper.
  60594. */
  60595. get skyboxTexture(): Nullable<BaseTexture>;
  60596. private _skyboxMaterial;
  60597. /**
  60598. * Gets the skybox material created by the helper.
  60599. */
  60600. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  60601. private _ground;
  60602. /**
  60603. * Gets the ground mesh created by the helper.
  60604. */
  60605. get ground(): Nullable<Mesh>;
  60606. private _groundTexture;
  60607. /**
  60608. * Gets the ground texture created by the helper.
  60609. */
  60610. get groundTexture(): Nullable<BaseTexture>;
  60611. private _groundMirror;
  60612. /**
  60613. * Gets the ground mirror created by the helper.
  60614. */
  60615. get groundMirror(): Nullable<MirrorTexture>;
  60616. /**
  60617. * Gets the ground mirror render list to helps pushing the meshes
  60618. * you wish in the ground reflection.
  60619. */
  60620. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  60621. private _groundMaterial;
  60622. /**
  60623. * Gets the ground material created by the helper.
  60624. */
  60625. get groundMaterial(): Nullable<BackgroundMaterial>;
  60626. /**
  60627. * Stores the creation options.
  60628. */
  60629. private readonly _scene;
  60630. private _options;
  60631. /**
  60632. * This observable will be notified with any error during the creation of the environment,
  60633. * mainly texture creation errors.
  60634. */
  60635. onErrorObservable: Observable<{
  60636. message?: string;
  60637. exception?: any;
  60638. }>;
  60639. /**
  60640. * constructor
  60641. * @param options Defines the options we want to customize the helper
  60642. * @param scene The scene to add the material to
  60643. */
  60644. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  60645. /**
  60646. * Updates the background according to the new options
  60647. * @param options
  60648. */
  60649. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  60650. /**
  60651. * Sets the primary color of all the available elements.
  60652. * @param color the main color to affect to the ground and the background
  60653. */
  60654. setMainColor(color: Color3): void;
  60655. /**
  60656. * Setup the image processing according to the specified options.
  60657. */
  60658. private _setupImageProcessing;
  60659. /**
  60660. * Setup the environment texture according to the specified options.
  60661. */
  60662. private _setupEnvironmentTexture;
  60663. /**
  60664. * Setup the background according to the specified options.
  60665. */
  60666. private _setupBackground;
  60667. /**
  60668. * Get the scene sizes according to the setup.
  60669. */
  60670. private _getSceneSize;
  60671. /**
  60672. * Setup the ground according to the specified options.
  60673. */
  60674. private _setupGround;
  60675. /**
  60676. * Setup the ground material according to the specified options.
  60677. */
  60678. private _setupGroundMaterial;
  60679. /**
  60680. * Setup the ground diffuse texture according to the specified options.
  60681. */
  60682. private _setupGroundDiffuseTexture;
  60683. /**
  60684. * Setup the ground mirror texture according to the specified options.
  60685. */
  60686. private _setupGroundMirrorTexture;
  60687. /**
  60688. * Setup the ground to receive the mirror texture.
  60689. */
  60690. private _setupMirrorInGroundMaterial;
  60691. /**
  60692. * Setup the skybox according to the specified options.
  60693. */
  60694. private _setupSkybox;
  60695. /**
  60696. * Setup the skybox material according to the specified options.
  60697. */
  60698. private _setupSkyboxMaterial;
  60699. /**
  60700. * Setup the skybox reflection texture according to the specified options.
  60701. */
  60702. private _setupSkyboxReflectionTexture;
  60703. private _errorHandler;
  60704. /**
  60705. * Dispose all the elements created by the Helper.
  60706. */
  60707. dispose(): void;
  60708. }
  60709. }
  60710. declare module "babylonjs/Helpers/textureDome" {
  60711. import { Scene } from "babylonjs/scene";
  60712. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60713. import { Mesh } from "babylonjs/Meshes/mesh";
  60714. import { Texture } from "babylonjs/Materials/Textures/texture";
  60715. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60716. import "babylonjs/Meshes/Builders/sphereBuilder";
  60717. import { Nullable } from "babylonjs/types";
  60718. import { Observable } from "babylonjs/Misc/observable";
  60719. /**
  60720. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  60721. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  60722. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  60723. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60724. */
  60725. export abstract class TextureDome<T extends Texture> extends TransformNode {
  60726. protected onError: Nullable<(message?: string, exception?: any) => void>;
  60727. /**
  60728. * Define the source as a Monoscopic panoramic 360/180.
  60729. */
  60730. static readonly MODE_MONOSCOPIC: number;
  60731. /**
  60732. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  60733. */
  60734. static readonly MODE_TOPBOTTOM: number;
  60735. /**
  60736. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  60737. */
  60738. static readonly MODE_SIDEBYSIDE: number;
  60739. private _halfDome;
  60740. private _crossEye;
  60741. protected _useDirectMapping: boolean;
  60742. /**
  60743. * The texture being displayed on the sphere
  60744. */
  60745. protected _texture: T;
  60746. /**
  60747. * Gets the texture being displayed on the sphere
  60748. */
  60749. get texture(): T;
  60750. /**
  60751. * Sets the texture being displayed on the sphere
  60752. */
  60753. set texture(newTexture: T);
  60754. /**
  60755. * The skybox material
  60756. */
  60757. protected _material: BackgroundMaterial;
  60758. /**
  60759. * The surface used for the dome
  60760. */
  60761. protected _mesh: Mesh;
  60762. /**
  60763. * Gets the mesh used for the dome.
  60764. */
  60765. get mesh(): Mesh;
  60766. /**
  60767. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  60768. */
  60769. private _halfDomeMask;
  60770. /**
  60771. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60772. * Also see the options.resolution property.
  60773. */
  60774. get fovMultiplier(): number;
  60775. set fovMultiplier(value: number);
  60776. protected _textureMode: number;
  60777. /**
  60778. * Gets or set the current texture mode for the texture. It can be:
  60779. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60780. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60781. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60782. */
  60783. get textureMode(): number;
  60784. /**
  60785. * Sets the current texture mode for the texture. It can be:
  60786. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60787. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60788. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60789. */
  60790. set textureMode(value: number);
  60791. /**
  60792. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  60793. */
  60794. get halfDome(): boolean;
  60795. /**
  60796. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  60797. */
  60798. set halfDome(enabled: boolean);
  60799. /**
  60800. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  60801. */
  60802. set crossEye(enabled: boolean);
  60803. /**
  60804. * Is it a cross-eye texture?
  60805. */
  60806. get crossEye(): boolean;
  60807. /**
  60808. * The background material of this dome.
  60809. */
  60810. get material(): BackgroundMaterial;
  60811. /**
  60812. * Oberserver used in Stereoscopic VR Mode.
  60813. */
  60814. private _onBeforeCameraRenderObserver;
  60815. /**
  60816. * Observable raised when an error occured while loading the 360 image
  60817. */
  60818. onLoadErrorObservable: Observable<string>;
  60819. /**
  60820. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  60821. * @param name Element's name, child elements will append suffixes for their own names.
  60822. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  60823. * @param options An object containing optional or exposed sub element properties
  60824. */
  60825. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  60826. resolution?: number;
  60827. clickToPlay?: boolean;
  60828. autoPlay?: boolean;
  60829. loop?: boolean;
  60830. size?: number;
  60831. poster?: string;
  60832. faceForward?: boolean;
  60833. useDirectMapping?: boolean;
  60834. halfDomeMode?: boolean;
  60835. crossEyeMode?: boolean;
  60836. generateMipMaps?: boolean;
  60837. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  60838. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  60839. protected _changeTextureMode(value: number): void;
  60840. /**
  60841. * Releases resources associated with this node.
  60842. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  60843. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  60844. */
  60845. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  60846. }
  60847. }
  60848. declare module "babylonjs/Helpers/photoDome" {
  60849. import { Scene } from "babylonjs/scene";
  60850. import { Texture } from "babylonjs/Materials/Textures/texture";
  60851. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60852. /**
  60853. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  60854. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  60855. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  60856. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60857. */
  60858. export class PhotoDome extends TextureDome<Texture> {
  60859. /**
  60860. * Define the image as a Monoscopic panoramic 360 image.
  60861. */
  60862. static readonly MODE_MONOSCOPIC: number;
  60863. /**
  60864. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  60865. */
  60866. static readonly MODE_TOPBOTTOM: number;
  60867. /**
  60868. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  60869. */
  60870. static readonly MODE_SIDEBYSIDE: number;
  60871. /**
  60872. * Gets or sets the texture being displayed on the sphere
  60873. */
  60874. get photoTexture(): Texture;
  60875. /**
  60876. * sets the texture being displayed on the sphere
  60877. */
  60878. set photoTexture(value: Texture);
  60879. /**
  60880. * Gets the current video mode for the video. It can be:
  60881. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60882. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60883. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60884. */
  60885. get imageMode(): number;
  60886. /**
  60887. * Sets the current video mode for the video. It can be:
  60888. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60889. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60890. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60891. */
  60892. set imageMode(value: number);
  60893. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  60894. }
  60895. }
  60896. declare module "babylonjs/Misc/dds" {
  60897. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60898. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60899. import { Nullable } from "babylonjs/types";
  60900. import { Scene } from "babylonjs/scene";
  60901. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60902. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60903. /**
  60904. * Direct draw surface info
  60905. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60906. */
  60907. export interface DDSInfo {
  60908. /**
  60909. * Width of the texture
  60910. */
  60911. width: number;
  60912. /**
  60913. * Width of the texture
  60914. */
  60915. height: number;
  60916. /**
  60917. * Number of Mipmaps for the texture
  60918. * @see https://en.wikipedia.org/wiki/Mipmap
  60919. */
  60920. mipmapCount: number;
  60921. /**
  60922. * If the textures format is a known fourCC format
  60923. * @see https://www.fourcc.org/
  60924. */
  60925. isFourCC: boolean;
  60926. /**
  60927. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60928. */
  60929. isRGB: boolean;
  60930. /**
  60931. * If the texture is a lumincance format
  60932. */
  60933. isLuminance: boolean;
  60934. /**
  60935. * If this is a cube texture
  60936. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60937. */
  60938. isCube: boolean;
  60939. /**
  60940. * If the texture is a compressed format eg. FOURCC_DXT1
  60941. */
  60942. isCompressed: boolean;
  60943. /**
  60944. * The dxgiFormat of the texture
  60945. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60946. */
  60947. dxgiFormat: number;
  60948. /**
  60949. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60950. */
  60951. textureType: number;
  60952. /**
  60953. * Sphericle polynomial created for the dds texture
  60954. */
  60955. sphericalPolynomial?: SphericalPolynomial;
  60956. }
  60957. /**
  60958. * Class used to provide DDS decompression tools
  60959. */
  60960. export class DDSTools {
  60961. /**
  60962. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60963. */
  60964. static StoreLODInAlphaChannel: boolean;
  60965. /**
  60966. * Gets DDS information from an array buffer
  60967. * @param data defines the array buffer view to read data from
  60968. * @returns the DDS information
  60969. */
  60970. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60971. private static _FloatView;
  60972. private static _Int32View;
  60973. private static _ToHalfFloat;
  60974. private static _FromHalfFloat;
  60975. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60976. private static _GetHalfFloatRGBAArrayBuffer;
  60977. private static _GetFloatRGBAArrayBuffer;
  60978. private static _GetFloatAsUIntRGBAArrayBuffer;
  60979. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60980. private static _GetRGBAArrayBuffer;
  60981. private static _ExtractLongWordOrder;
  60982. private static _GetRGBArrayBuffer;
  60983. private static _GetLuminanceArrayBuffer;
  60984. /**
  60985. * Uploads DDS Levels to a Babylon Texture
  60986. * @hidden
  60987. */
  60988. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60989. }
  60990. module "babylonjs/Engines/thinEngine" {
  60991. interface ThinEngine {
  60992. /**
  60993. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60994. * @param rootUrl defines the url where the file to load is located
  60995. * @param scene defines the current scene
  60996. * @param lodScale defines scale to apply to the mip map selection
  60997. * @param lodOffset defines offset to apply to the mip map selection
  60998. * @param onLoad defines an optional callback raised when the texture is loaded
  60999. * @param onError defines an optional callback raised if there is an issue to load the texture
  61000. * @param format defines the format of the data
  61001. * @param forcedExtension defines the extension to use to pick the right loader
  61002. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  61003. * @returns the cube texture as an InternalTexture
  61004. */
  61005. 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;
  61006. }
  61007. }
  61008. }
  61009. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  61010. import { Nullable } from "babylonjs/types";
  61011. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61012. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61013. /**
  61014. * Implementation of the DDS Texture Loader.
  61015. * @hidden
  61016. */
  61017. export class _DDSTextureLoader implements IInternalTextureLoader {
  61018. /**
  61019. * Defines wether the loader supports cascade loading the different faces.
  61020. */
  61021. readonly supportCascades: boolean;
  61022. /**
  61023. * This returns if the loader support the current file information.
  61024. * @param extension defines the file extension of the file being loaded
  61025. * @returns true if the loader can load the specified file
  61026. */
  61027. canLoad(extension: string): boolean;
  61028. /**
  61029. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61030. * @param data contains the texture data
  61031. * @param texture defines the BabylonJS internal texture
  61032. * @param createPolynomials will be true if polynomials have been requested
  61033. * @param onLoad defines the callback to trigger once the texture is ready
  61034. * @param onError defines the callback to trigger in case of error
  61035. */
  61036. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61037. /**
  61038. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61039. * @param data contains the texture data
  61040. * @param texture defines the BabylonJS internal texture
  61041. * @param callback defines the method to call once ready to upload
  61042. */
  61043. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61044. }
  61045. }
  61046. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  61047. import { Nullable } from "babylonjs/types";
  61048. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61049. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61050. /**
  61051. * Implementation of the ENV Texture Loader.
  61052. * @hidden
  61053. */
  61054. export class _ENVTextureLoader implements IInternalTextureLoader {
  61055. /**
  61056. * Defines wether the loader supports cascade loading the different faces.
  61057. */
  61058. readonly supportCascades: boolean;
  61059. /**
  61060. * This returns if the loader support the current file information.
  61061. * @param extension defines the file extension of the file being loaded
  61062. * @returns true if the loader can load the specified file
  61063. */
  61064. canLoad(extension: string): boolean;
  61065. /**
  61066. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61067. * @param data contains the texture data
  61068. * @param texture defines the BabylonJS internal texture
  61069. * @param createPolynomials will be true if polynomials have been requested
  61070. * @param onLoad defines the callback to trigger once the texture is ready
  61071. * @param onError defines the callback to trigger in case of error
  61072. */
  61073. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61074. /**
  61075. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61076. * @param data contains the texture data
  61077. * @param texture defines the BabylonJS internal texture
  61078. * @param callback defines the method to call once ready to upload
  61079. */
  61080. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61081. }
  61082. }
  61083. declare module "babylonjs/Misc/khronosTextureContainer" {
  61084. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61085. /**
  61086. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  61087. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  61088. */
  61089. export class KhronosTextureContainer {
  61090. /** contents of the KTX container file */
  61091. data: ArrayBufferView;
  61092. private static HEADER_LEN;
  61093. private static COMPRESSED_2D;
  61094. private static COMPRESSED_3D;
  61095. private static TEX_2D;
  61096. private static TEX_3D;
  61097. /**
  61098. * Gets the openGL type
  61099. */
  61100. glType: number;
  61101. /**
  61102. * Gets the openGL type size
  61103. */
  61104. glTypeSize: number;
  61105. /**
  61106. * Gets the openGL format
  61107. */
  61108. glFormat: number;
  61109. /**
  61110. * Gets the openGL internal format
  61111. */
  61112. glInternalFormat: number;
  61113. /**
  61114. * Gets the base internal format
  61115. */
  61116. glBaseInternalFormat: number;
  61117. /**
  61118. * Gets image width in pixel
  61119. */
  61120. pixelWidth: number;
  61121. /**
  61122. * Gets image height in pixel
  61123. */
  61124. pixelHeight: number;
  61125. /**
  61126. * Gets image depth in pixels
  61127. */
  61128. pixelDepth: number;
  61129. /**
  61130. * Gets the number of array elements
  61131. */
  61132. numberOfArrayElements: number;
  61133. /**
  61134. * Gets the number of faces
  61135. */
  61136. numberOfFaces: number;
  61137. /**
  61138. * Gets the number of mipmap levels
  61139. */
  61140. numberOfMipmapLevels: number;
  61141. /**
  61142. * Gets the bytes of key value data
  61143. */
  61144. bytesOfKeyValueData: number;
  61145. /**
  61146. * Gets the load type
  61147. */
  61148. loadType: number;
  61149. /**
  61150. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  61151. */
  61152. isInvalid: boolean;
  61153. /**
  61154. * Creates a new KhronosTextureContainer
  61155. * @param data contents of the KTX container file
  61156. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  61157. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  61158. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  61159. */
  61160. constructor(
  61161. /** contents of the KTX container file */
  61162. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  61163. /**
  61164. * Uploads KTX content to a Babylon Texture.
  61165. * It is assumed that the texture has already been created & is currently bound
  61166. * @hidden
  61167. */
  61168. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  61169. private _upload2DCompressedLevels;
  61170. /**
  61171. * Checks if the given data starts with a KTX file identifier.
  61172. * @param data the data to check
  61173. * @returns true if the data is a KTX file or false otherwise
  61174. */
  61175. static IsValid(data: ArrayBufferView): boolean;
  61176. }
  61177. }
  61178. declare module "babylonjs/Misc/workerPool" {
  61179. import { IDisposable } from "babylonjs/scene";
  61180. /**
  61181. * Helper class to push actions to a pool of workers.
  61182. */
  61183. export class WorkerPool implements IDisposable {
  61184. private _workerInfos;
  61185. private _pendingActions;
  61186. /**
  61187. * Constructor
  61188. * @param workers Array of workers to use for actions
  61189. */
  61190. constructor(workers: Array<Worker>);
  61191. /**
  61192. * Terminates all workers and clears any pending actions.
  61193. */
  61194. dispose(): void;
  61195. /**
  61196. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61197. * pended until a worker has completed its action.
  61198. * @param action The action to perform. Call onComplete when the action is complete.
  61199. */
  61200. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61201. private _execute;
  61202. }
  61203. }
  61204. declare module "babylonjs/Misc/khronosTextureContainer2" {
  61205. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61206. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61207. /**
  61208. * Class for loading KTX2 files
  61209. */
  61210. export class KhronosTextureContainer2 {
  61211. private static _WorkerPoolPromise?;
  61212. private static _Initialized;
  61213. private static _Ktx2Decoder;
  61214. /**
  61215. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  61216. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  61217. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  61218. * Urls you can change:
  61219. * URLConfig.jsDecoderModule
  61220. * URLConfig.wasmUASTCToASTC
  61221. * URLConfig.wasmUASTCToBC7
  61222. * URLConfig.jsMSCTranscoder
  61223. * URLConfig.wasmMSCTranscoder
  61224. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  61225. */
  61226. static URLConfig: {
  61227. jsDecoderModule: string;
  61228. wasmUASTCToASTC: null;
  61229. wasmUASTCToBC7: null;
  61230. jsMSCTranscoder: null;
  61231. wasmMSCTranscoder: null;
  61232. };
  61233. /**
  61234. * Default number of workers used to handle data decoding
  61235. */
  61236. static DefaultNumWorkers: number;
  61237. private static GetDefaultNumWorkers;
  61238. private _engine;
  61239. private static _CreateWorkerPool;
  61240. /**
  61241. * Constructor
  61242. * @param engine The engine to use
  61243. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61244. */
  61245. constructor(engine: ThinEngine, numWorkers?: number);
  61246. /** @hidden */
  61247. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  61248. /**
  61249. * Stop all async operations and release resources.
  61250. */
  61251. dispose(): void;
  61252. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  61253. /**
  61254. * Checks if the given data starts with a KTX2 file identifier.
  61255. * @param data the data to check
  61256. * @returns true if the data is a KTX2 file or false otherwise
  61257. */
  61258. static IsValid(data: ArrayBufferView): boolean;
  61259. }
  61260. }
  61261. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  61262. import { Nullable } from "babylonjs/types";
  61263. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61264. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61265. /**
  61266. * Implementation of the KTX Texture Loader.
  61267. * @hidden
  61268. */
  61269. export class _KTXTextureLoader implements IInternalTextureLoader {
  61270. /**
  61271. * Defines wether the loader supports cascade loading the different faces.
  61272. */
  61273. readonly supportCascades: boolean;
  61274. /**
  61275. * This returns if the loader support the current file information.
  61276. * @param extension defines the file extension of the file being loaded
  61277. * @param mimeType defines the optional mime type of the file being loaded
  61278. * @returns true if the loader can load the specified file
  61279. */
  61280. canLoad(extension: string, mimeType?: string): boolean;
  61281. /**
  61282. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61283. * @param data contains the texture data
  61284. * @param texture defines the BabylonJS internal texture
  61285. * @param createPolynomials will be true if polynomials have been requested
  61286. * @param onLoad defines the callback to trigger once the texture is ready
  61287. * @param onError defines the callback to trigger in case of error
  61288. */
  61289. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61290. /**
  61291. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61292. * @param data contains the texture data
  61293. * @param texture defines the BabylonJS internal texture
  61294. * @param callback defines the method to call once ready to upload
  61295. */
  61296. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  61297. }
  61298. }
  61299. declare module "babylonjs/Helpers/sceneHelpers" {
  61300. import { Nullable } from "babylonjs/types";
  61301. import { Mesh } from "babylonjs/Meshes/mesh";
  61302. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61303. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  61304. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  61305. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  61306. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  61307. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  61308. import "babylonjs/Meshes/Builders/boxBuilder";
  61309. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  61310. /** @hidden */
  61311. export var _forceSceneHelpersToBundle: boolean;
  61312. module "babylonjs/scene" {
  61313. interface Scene {
  61314. /**
  61315. * Creates a default light for the scene.
  61316. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  61317. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  61318. */
  61319. createDefaultLight(replace?: boolean): void;
  61320. /**
  61321. * Creates a default camera for the scene.
  61322. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  61323. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61324. * @param replace has default false, when true replaces the active camera in the scene
  61325. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  61326. */
  61327. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61328. /**
  61329. * Creates a default camera and a default light.
  61330. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  61331. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61332. * @param replace has the default false, when true replaces the active camera/light in the scene
  61333. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  61334. */
  61335. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61336. /**
  61337. * Creates a new sky box
  61338. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  61339. * @param environmentTexture defines the texture to use as environment texture
  61340. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  61341. * @param scale defines the overall scale of the skybox
  61342. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  61343. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  61344. * @returns a new mesh holding the sky box
  61345. */
  61346. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  61347. /**
  61348. * Creates a new environment
  61349. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  61350. * @param options defines the options you can use to configure the environment
  61351. * @returns the new EnvironmentHelper
  61352. */
  61353. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  61354. /**
  61355. * Creates a new VREXperienceHelper
  61356. * @see https://doc.babylonjs.com/how_to/webvr_helper
  61357. * @param webVROptions defines the options used to create the new VREXperienceHelper
  61358. * @returns a new VREXperienceHelper
  61359. */
  61360. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  61361. /**
  61362. * Creates a new WebXRDefaultExperience
  61363. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  61364. * @param options experience options
  61365. * @returns a promise for a new WebXRDefaultExperience
  61366. */
  61367. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  61368. }
  61369. }
  61370. }
  61371. declare module "babylonjs/Helpers/videoDome" {
  61372. import { Scene } from "babylonjs/scene";
  61373. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  61374. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61375. /**
  61376. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  61377. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  61378. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  61379. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61380. */
  61381. export class VideoDome extends TextureDome<VideoTexture> {
  61382. /**
  61383. * Define the video source as a Monoscopic panoramic 360 video.
  61384. */
  61385. static readonly MODE_MONOSCOPIC: number;
  61386. /**
  61387. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  61388. */
  61389. static readonly MODE_TOPBOTTOM: number;
  61390. /**
  61391. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  61392. */
  61393. static readonly MODE_SIDEBYSIDE: number;
  61394. /**
  61395. * Get the video texture associated with this video dome
  61396. */
  61397. get videoTexture(): VideoTexture;
  61398. /**
  61399. * Get the video mode of this dome
  61400. */
  61401. get videoMode(): number;
  61402. /**
  61403. * Set the video mode of this dome.
  61404. * @see textureMode
  61405. */
  61406. set videoMode(value: number);
  61407. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  61408. }
  61409. }
  61410. declare module "babylonjs/Helpers/index" {
  61411. export * from "babylonjs/Helpers/environmentHelper";
  61412. export * from "babylonjs/Helpers/photoDome";
  61413. export * from "babylonjs/Helpers/sceneHelpers";
  61414. export * from "babylonjs/Helpers/videoDome";
  61415. }
  61416. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  61417. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61418. import { IDisposable } from "babylonjs/scene";
  61419. import { Engine } from "babylonjs/Engines/engine";
  61420. /**
  61421. * This class can be used to get instrumentation data from a Babylon engine
  61422. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61423. */
  61424. export class EngineInstrumentation implements IDisposable {
  61425. /**
  61426. * Define the instrumented engine.
  61427. */
  61428. engine: Engine;
  61429. private _captureGPUFrameTime;
  61430. private _gpuFrameTimeToken;
  61431. private _gpuFrameTime;
  61432. private _captureShaderCompilationTime;
  61433. private _shaderCompilationTime;
  61434. private _onBeginFrameObserver;
  61435. private _onEndFrameObserver;
  61436. private _onBeforeShaderCompilationObserver;
  61437. private _onAfterShaderCompilationObserver;
  61438. /**
  61439. * Gets the perf counter used for GPU frame time
  61440. */
  61441. get gpuFrameTimeCounter(): PerfCounter;
  61442. /**
  61443. * Gets the GPU frame time capture status
  61444. */
  61445. get captureGPUFrameTime(): boolean;
  61446. /**
  61447. * Enable or disable the GPU frame time capture
  61448. */
  61449. set captureGPUFrameTime(value: boolean);
  61450. /**
  61451. * Gets the perf counter used for shader compilation time
  61452. */
  61453. get shaderCompilationTimeCounter(): PerfCounter;
  61454. /**
  61455. * Gets the shader compilation time capture status
  61456. */
  61457. get captureShaderCompilationTime(): boolean;
  61458. /**
  61459. * Enable or disable the shader compilation time capture
  61460. */
  61461. set captureShaderCompilationTime(value: boolean);
  61462. /**
  61463. * Instantiates a new engine instrumentation.
  61464. * This class can be used to get instrumentation data from a Babylon engine
  61465. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61466. * @param engine Defines the engine to instrument
  61467. */
  61468. constructor(
  61469. /**
  61470. * Define the instrumented engine.
  61471. */
  61472. engine: Engine);
  61473. /**
  61474. * Dispose and release associated resources.
  61475. */
  61476. dispose(): void;
  61477. }
  61478. }
  61479. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  61480. import { Scene, IDisposable } from "babylonjs/scene";
  61481. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61482. /**
  61483. * This class can be used to get instrumentation data from a Babylon engine
  61484. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61485. */
  61486. export class SceneInstrumentation implements IDisposable {
  61487. /**
  61488. * Defines the scene to instrument
  61489. */
  61490. scene: Scene;
  61491. private _captureActiveMeshesEvaluationTime;
  61492. private _activeMeshesEvaluationTime;
  61493. private _captureRenderTargetsRenderTime;
  61494. private _renderTargetsRenderTime;
  61495. private _captureFrameTime;
  61496. private _frameTime;
  61497. private _captureRenderTime;
  61498. private _renderTime;
  61499. private _captureInterFrameTime;
  61500. private _interFrameTime;
  61501. private _captureParticlesRenderTime;
  61502. private _particlesRenderTime;
  61503. private _captureSpritesRenderTime;
  61504. private _spritesRenderTime;
  61505. private _capturePhysicsTime;
  61506. private _physicsTime;
  61507. private _captureAnimationsTime;
  61508. private _animationsTime;
  61509. private _captureCameraRenderTime;
  61510. private _cameraRenderTime;
  61511. private _onBeforeActiveMeshesEvaluationObserver;
  61512. private _onAfterActiveMeshesEvaluationObserver;
  61513. private _onBeforeRenderTargetsRenderObserver;
  61514. private _onAfterRenderTargetsRenderObserver;
  61515. private _onAfterRenderObserver;
  61516. private _onBeforeDrawPhaseObserver;
  61517. private _onAfterDrawPhaseObserver;
  61518. private _onBeforeAnimationsObserver;
  61519. private _onBeforeParticlesRenderingObserver;
  61520. private _onAfterParticlesRenderingObserver;
  61521. private _onBeforeSpritesRenderingObserver;
  61522. private _onAfterSpritesRenderingObserver;
  61523. private _onBeforePhysicsObserver;
  61524. private _onAfterPhysicsObserver;
  61525. private _onAfterAnimationsObserver;
  61526. private _onBeforeCameraRenderObserver;
  61527. private _onAfterCameraRenderObserver;
  61528. /**
  61529. * Gets the perf counter used for active meshes evaluation time
  61530. */
  61531. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  61532. /**
  61533. * Gets the active meshes evaluation time capture status
  61534. */
  61535. get captureActiveMeshesEvaluationTime(): boolean;
  61536. /**
  61537. * Enable or disable the active meshes evaluation time capture
  61538. */
  61539. set captureActiveMeshesEvaluationTime(value: boolean);
  61540. /**
  61541. * Gets the perf counter used for render targets render time
  61542. */
  61543. get renderTargetsRenderTimeCounter(): PerfCounter;
  61544. /**
  61545. * Gets the render targets render time capture status
  61546. */
  61547. get captureRenderTargetsRenderTime(): boolean;
  61548. /**
  61549. * Enable or disable the render targets render time capture
  61550. */
  61551. set captureRenderTargetsRenderTime(value: boolean);
  61552. /**
  61553. * Gets the perf counter used for particles render time
  61554. */
  61555. get particlesRenderTimeCounter(): PerfCounter;
  61556. /**
  61557. * Gets the particles render time capture status
  61558. */
  61559. get captureParticlesRenderTime(): boolean;
  61560. /**
  61561. * Enable or disable the particles render time capture
  61562. */
  61563. set captureParticlesRenderTime(value: boolean);
  61564. /**
  61565. * Gets the perf counter used for sprites render time
  61566. */
  61567. get spritesRenderTimeCounter(): PerfCounter;
  61568. /**
  61569. * Gets the sprites render time capture status
  61570. */
  61571. get captureSpritesRenderTime(): boolean;
  61572. /**
  61573. * Enable or disable the sprites render time capture
  61574. */
  61575. set captureSpritesRenderTime(value: boolean);
  61576. /**
  61577. * Gets the perf counter used for physics time
  61578. */
  61579. get physicsTimeCounter(): PerfCounter;
  61580. /**
  61581. * Gets the physics time capture status
  61582. */
  61583. get capturePhysicsTime(): boolean;
  61584. /**
  61585. * Enable or disable the physics time capture
  61586. */
  61587. set capturePhysicsTime(value: boolean);
  61588. /**
  61589. * Gets the perf counter used for animations time
  61590. */
  61591. get animationsTimeCounter(): PerfCounter;
  61592. /**
  61593. * Gets the animations time capture status
  61594. */
  61595. get captureAnimationsTime(): boolean;
  61596. /**
  61597. * Enable or disable the animations time capture
  61598. */
  61599. set captureAnimationsTime(value: boolean);
  61600. /**
  61601. * Gets the perf counter used for frame time capture
  61602. */
  61603. get frameTimeCounter(): PerfCounter;
  61604. /**
  61605. * Gets the frame time capture status
  61606. */
  61607. get captureFrameTime(): boolean;
  61608. /**
  61609. * Enable or disable the frame time capture
  61610. */
  61611. set captureFrameTime(value: boolean);
  61612. /**
  61613. * Gets the perf counter used for inter-frames time capture
  61614. */
  61615. get interFrameTimeCounter(): PerfCounter;
  61616. /**
  61617. * Gets the inter-frames time capture status
  61618. */
  61619. get captureInterFrameTime(): boolean;
  61620. /**
  61621. * Enable or disable the inter-frames time capture
  61622. */
  61623. set captureInterFrameTime(value: boolean);
  61624. /**
  61625. * Gets the perf counter used for render time capture
  61626. */
  61627. get renderTimeCounter(): PerfCounter;
  61628. /**
  61629. * Gets the render time capture status
  61630. */
  61631. get captureRenderTime(): boolean;
  61632. /**
  61633. * Enable or disable the render time capture
  61634. */
  61635. set captureRenderTime(value: boolean);
  61636. /**
  61637. * Gets the perf counter used for camera render time capture
  61638. */
  61639. get cameraRenderTimeCounter(): PerfCounter;
  61640. /**
  61641. * Gets the camera render time capture status
  61642. */
  61643. get captureCameraRenderTime(): boolean;
  61644. /**
  61645. * Enable or disable the camera render time capture
  61646. */
  61647. set captureCameraRenderTime(value: boolean);
  61648. /**
  61649. * Gets the perf counter used for draw calls
  61650. */
  61651. get drawCallsCounter(): PerfCounter;
  61652. /**
  61653. * Instantiates a new scene instrumentation.
  61654. * This class can be used to get instrumentation data from a Babylon engine
  61655. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61656. * @param scene Defines the scene to instrument
  61657. */
  61658. constructor(
  61659. /**
  61660. * Defines the scene to instrument
  61661. */
  61662. scene: Scene);
  61663. /**
  61664. * Dispose and release associated resources.
  61665. */
  61666. dispose(): void;
  61667. }
  61668. }
  61669. declare module "babylonjs/Instrumentation/index" {
  61670. export * from "babylonjs/Instrumentation/engineInstrumentation";
  61671. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  61672. export * from "babylonjs/Instrumentation/timeToken";
  61673. }
  61674. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  61675. /** @hidden */
  61676. export var glowMapGenerationPixelShader: {
  61677. name: string;
  61678. shader: string;
  61679. };
  61680. }
  61681. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  61682. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61683. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61684. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61685. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61686. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61687. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61688. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61689. /** @hidden */
  61690. export var glowMapGenerationVertexShader: {
  61691. name: string;
  61692. shader: string;
  61693. };
  61694. }
  61695. declare module "babylonjs/Layers/effectLayer" {
  61696. import { Observable } from "babylonjs/Misc/observable";
  61697. import { Nullable } from "babylonjs/types";
  61698. import { Camera } from "babylonjs/Cameras/camera";
  61699. import { Scene } from "babylonjs/scene";
  61700. import { ISize } from "babylonjs/Maths/math.size";
  61701. import { Color4 } from "babylonjs/Maths/math.color";
  61702. import { Engine } from "babylonjs/Engines/engine";
  61703. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61705. import { Mesh } from "babylonjs/Meshes/mesh";
  61706. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61707. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61708. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61709. import { Effect } from "babylonjs/Materials/effect";
  61710. import { Material } from "babylonjs/Materials/material";
  61711. import "babylonjs/Shaders/glowMapGeneration.fragment";
  61712. import "babylonjs/Shaders/glowMapGeneration.vertex";
  61713. /**
  61714. * Effect layer options. This helps customizing the behaviour
  61715. * of the effect layer.
  61716. */
  61717. export interface IEffectLayerOptions {
  61718. /**
  61719. * Multiplication factor apply to the canvas size to compute the render target size
  61720. * used to generated the objects (the smaller the faster).
  61721. */
  61722. mainTextureRatio: number;
  61723. /**
  61724. * Enforces a fixed size texture to ensure effect stability across devices.
  61725. */
  61726. mainTextureFixedSize?: number;
  61727. /**
  61728. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61729. */
  61730. alphaBlendingMode: number;
  61731. /**
  61732. * The camera attached to the layer.
  61733. */
  61734. camera: Nullable<Camera>;
  61735. /**
  61736. * The rendering group to draw the layer in.
  61737. */
  61738. renderingGroupId: number;
  61739. }
  61740. /**
  61741. * The effect layer Helps adding post process effect blended with the main pass.
  61742. *
  61743. * This can be for instance use to generate glow or higlight effects on the scene.
  61744. *
  61745. * The effect layer class can not be used directly and is intented to inherited from to be
  61746. * customized per effects.
  61747. */
  61748. export abstract class EffectLayer {
  61749. private _vertexBuffers;
  61750. private _indexBuffer;
  61751. private _cachedDefines;
  61752. private _effectLayerMapGenerationEffect;
  61753. private _effectLayerOptions;
  61754. private _mergeEffect;
  61755. protected _scene: Scene;
  61756. protected _engine: Engine;
  61757. protected _maxSize: number;
  61758. protected _mainTextureDesiredSize: ISize;
  61759. protected _mainTexture: RenderTargetTexture;
  61760. protected _shouldRender: boolean;
  61761. protected _postProcesses: PostProcess[];
  61762. protected _textures: BaseTexture[];
  61763. protected _emissiveTextureAndColor: {
  61764. texture: Nullable<BaseTexture>;
  61765. color: Color4;
  61766. };
  61767. /**
  61768. * The name of the layer
  61769. */
  61770. name: string;
  61771. /**
  61772. * The clear color of the texture used to generate the glow map.
  61773. */
  61774. neutralColor: Color4;
  61775. /**
  61776. * Specifies whether the highlight layer is enabled or not.
  61777. */
  61778. isEnabled: boolean;
  61779. /**
  61780. * Gets the camera attached to the layer.
  61781. */
  61782. get camera(): Nullable<Camera>;
  61783. /**
  61784. * Gets the rendering group id the layer should render in.
  61785. */
  61786. get renderingGroupId(): number;
  61787. set renderingGroupId(renderingGroupId: number);
  61788. /**
  61789. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  61790. */
  61791. disableBoundingBoxesFromEffectLayer: boolean;
  61792. /**
  61793. * An event triggered when the effect layer has been disposed.
  61794. */
  61795. onDisposeObservable: Observable<EffectLayer>;
  61796. /**
  61797. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  61798. */
  61799. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  61800. /**
  61801. * An event triggered when the generated texture is being merged in the scene.
  61802. */
  61803. onBeforeComposeObservable: Observable<EffectLayer>;
  61804. /**
  61805. * An event triggered when the mesh is rendered into the effect render target.
  61806. */
  61807. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  61808. /**
  61809. * An event triggered after the mesh has been rendered into the effect render target.
  61810. */
  61811. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61812. /**
  61813. * An event triggered when the generated texture has been merged in the scene.
  61814. */
  61815. onAfterComposeObservable: Observable<EffectLayer>;
  61816. /**
  61817. * An event triggered when the efffect layer changes its size.
  61818. */
  61819. onSizeChangedObservable: Observable<EffectLayer>;
  61820. /** @hidden */
  61821. static _SceneComponentInitialization: (scene: Scene) => void;
  61822. /**
  61823. * Instantiates a new effect Layer and references it in the scene.
  61824. * @param name The name of the layer
  61825. * @param scene The scene to use the layer in
  61826. */
  61827. constructor(
  61828. /** The Friendly of the effect in the scene */
  61829. name: string, scene: Scene);
  61830. /**
  61831. * Get the effect name of the layer.
  61832. * @return The effect name
  61833. */
  61834. abstract getEffectName(): string;
  61835. /**
  61836. * Checks for the readiness of the element composing the layer.
  61837. * @param subMesh the mesh to check for
  61838. * @param useInstances specify whether or not to use instances to render the mesh
  61839. * @return true if ready otherwise, false
  61840. */
  61841. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61842. /**
  61843. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61844. * @returns true if the effect requires stencil during the main canvas render pass.
  61845. */
  61846. abstract needStencil(): boolean;
  61847. /**
  61848. * Create the merge effect. This is the shader use to blit the information back
  61849. * to the main canvas at the end of the scene rendering.
  61850. * @returns The effect containing the shader used to merge the effect on the main canvas
  61851. */
  61852. protected abstract _createMergeEffect(): Effect;
  61853. /**
  61854. * Creates the render target textures and post processes used in the effect layer.
  61855. */
  61856. protected abstract _createTextureAndPostProcesses(): void;
  61857. /**
  61858. * Implementation specific of rendering the generating effect on the main canvas.
  61859. * @param effect The effect used to render through
  61860. */
  61861. protected abstract _internalRender(effect: Effect): void;
  61862. /**
  61863. * Sets the required values for both the emissive texture and and the main color.
  61864. */
  61865. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61866. /**
  61867. * Free any resources and references associated to a mesh.
  61868. * Internal use
  61869. * @param mesh The mesh to free.
  61870. */
  61871. abstract _disposeMesh(mesh: Mesh): void;
  61872. /**
  61873. * Serializes this layer (Glow or Highlight for example)
  61874. * @returns a serialized layer object
  61875. */
  61876. abstract serialize?(): any;
  61877. /**
  61878. * Initializes the effect layer with the required options.
  61879. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61880. */
  61881. protected _init(options: Partial<IEffectLayerOptions>): void;
  61882. /**
  61883. * Generates the index buffer of the full screen quad blending to the main canvas.
  61884. */
  61885. private _generateIndexBuffer;
  61886. /**
  61887. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61888. */
  61889. private _generateVertexBuffer;
  61890. /**
  61891. * Sets the main texture desired size which is the closest power of two
  61892. * of the engine canvas size.
  61893. */
  61894. private _setMainTextureSize;
  61895. /**
  61896. * Creates the main texture for the effect layer.
  61897. */
  61898. protected _createMainTexture(): void;
  61899. /**
  61900. * Adds specific effects defines.
  61901. * @param defines The defines to add specifics to.
  61902. */
  61903. protected _addCustomEffectDefines(defines: string[]): void;
  61904. /**
  61905. * Checks for the readiness of the element composing the layer.
  61906. * @param subMesh the mesh to check for
  61907. * @param useInstances specify whether or not to use instances to render the mesh
  61908. * @param emissiveTexture the associated emissive texture used to generate the glow
  61909. * @return true if ready otherwise, false
  61910. */
  61911. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61912. /**
  61913. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61914. */
  61915. render(): void;
  61916. /**
  61917. * Determine if a given mesh will be used in the current effect.
  61918. * @param mesh mesh to test
  61919. * @returns true if the mesh will be used
  61920. */
  61921. hasMesh(mesh: AbstractMesh): boolean;
  61922. /**
  61923. * Returns true if the layer contains information to display, otherwise false.
  61924. * @returns true if the glow layer should be rendered
  61925. */
  61926. shouldRender(): boolean;
  61927. /**
  61928. * Returns true if the mesh should render, otherwise false.
  61929. * @param mesh The mesh to render
  61930. * @returns true if it should render otherwise false
  61931. */
  61932. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61933. /**
  61934. * Returns true if the mesh can be rendered, otherwise false.
  61935. * @param mesh The mesh to render
  61936. * @param material The material used on the mesh
  61937. * @returns true if it can be rendered otherwise false
  61938. */
  61939. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61940. /**
  61941. * Returns true if the mesh should render, otherwise false.
  61942. * @param mesh The mesh to render
  61943. * @returns true if it should render otherwise false
  61944. */
  61945. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61946. /**
  61947. * Renders the submesh passed in parameter to the generation map.
  61948. */
  61949. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61950. /**
  61951. * Defines whether the current material of the mesh should be use to render the effect.
  61952. * @param mesh defines the current mesh to render
  61953. */
  61954. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61955. /**
  61956. * Rebuild the required buffers.
  61957. * @hidden Internal use only.
  61958. */
  61959. _rebuild(): void;
  61960. /**
  61961. * Dispose only the render target textures and post process.
  61962. */
  61963. private _disposeTextureAndPostProcesses;
  61964. /**
  61965. * Dispose the highlight layer and free resources.
  61966. */
  61967. dispose(): void;
  61968. /**
  61969. * Gets the class name of the effect layer
  61970. * @returns the string with the class name of the effect layer
  61971. */
  61972. getClassName(): string;
  61973. /**
  61974. * Creates an effect layer from parsed effect layer data
  61975. * @param parsedEffectLayer defines effect layer data
  61976. * @param scene defines the current scene
  61977. * @param rootUrl defines the root URL containing the effect layer information
  61978. * @returns a parsed effect Layer
  61979. */
  61980. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61981. }
  61982. }
  61983. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61984. import { Scene } from "babylonjs/scene";
  61985. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61986. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61987. import { AbstractScene } from "babylonjs/abstractScene";
  61988. module "babylonjs/abstractScene" {
  61989. interface AbstractScene {
  61990. /**
  61991. * The list of effect layers (highlights/glow) added to the scene
  61992. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61993. * @see https://doc.babylonjs.com/how_to/glow_layer
  61994. */
  61995. effectLayers: Array<EffectLayer>;
  61996. /**
  61997. * Removes the given effect layer from this scene.
  61998. * @param toRemove defines the effect layer to remove
  61999. * @returns the index of the removed effect layer
  62000. */
  62001. removeEffectLayer(toRemove: EffectLayer): number;
  62002. /**
  62003. * Adds the given effect layer to this scene
  62004. * @param newEffectLayer defines the effect layer to add
  62005. */
  62006. addEffectLayer(newEffectLayer: EffectLayer): void;
  62007. }
  62008. }
  62009. /**
  62010. * Defines the layer scene component responsible to manage any effect layers
  62011. * in a given scene.
  62012. */
  62013. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  62014. /**
  62015. * The component name helpfull to identify the component in the list of scene components.
  62016. */
  62017. readonly name: string;
  62018. /**
  62019. * The scene the component belongs to.
  62020. */
  62021. scene: Scene;
  62022. private _engine;
  62023. private _renderEffects;
  62024. private _needStencil;
  62025. private _previousStencilState;
  62026. /**
  62027. * Creates a new instance of the component for the given scene
  62028. * @param scene Defines the scene to register the component in
  62029. */
  62030. constructor(scene: Scene);
  62031. /**
  62032. * Registers the component in a given scene
  62033. */
  62034. register(): void;
  62035. /**
  62036. * Rebuilds the elements related to this component in case of
  62037. * context lost for instance.
  62038. */
  62039. rebuild(): void;
  62040. /**
  62041. * Serializes the component data to the specified json object
  62042. * @param serializationObject The object to serialize to
  62043. */
  62044. serialize(serializationObject: any): void;
  62045. /**
  62046. * Adds all the elements from the container to the scene
  62047. * @param container the container holding the elements
  62048. */
  62049. addFromContainer(container: AbstractScene): void;
  62050. /**
  62051. * Removes all the elements in the container from the scene
  62052. * @param container contains the elements to remove
  62053. * @param dispose if the removed element should be disposed (default: false)
  62054. */
  62055. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62056. /**
  62057. * Disposes the component and the associated ressources.
  62058. */
  62059. dispose(): void;
  62060. private _isReadyForMesh;
  62061. private _renderMainTexture;
  62062. private _setStencil;
  62063. private _setStencilBack;
  62064. private _draw;
  62065. private _drawCamera;
  62066. private _drawRenderingGroup;
  62067. }
  62068. }
  62069. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  62070. /** @hidden */
  62071. export var glowMapMergePixelShader: {
  62072. name: string;
  62073. shader: string;
  62074. };
  62075. }
  62076. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  62077. /** @hidden */
  62078. export var glowMapMergeVertexShader: {
  62079. name: string;
  62080. shader: string;
  62081. };
  62082. }
  62083. declare module "babylonjs/Layers/glowLayer" {
  62084. import { Nullable } from "babylonjs/types";
  62085. import { Camera } from "babylonjs/Cameras/camera";
  62086. import { Scene } from "babylonjs/scene";
  62087. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62089. import { Mesh } from "babylonjs/Meshes/mesh";
  62090. import { Texture } from "babylonjs/Materials/Textures/texture";
  62091. import { Effect } from "babylonjs/Materials/effect";
  62092. import { Material } from "babylonjs/Materials/material";
  62093. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62094. import { Color4 } from "babylonjs/Maths/math.color";
  62095. import "babylonjs/Shaders/glowMapMerge.fragment";
  62096. import "babylonjs/Shaders/glowMapMerge.vertex";
  62097. import "babylonjs/Layers/effectLayerSceneComponent";
  62098. module "babylonjs/abstractScene" {
  62099. interface AbstractScene {
  62100. /**
  62101. * Return a the first highlight layer of the scene with a given name.
  62102. * @param name The name of the highlight layer to look for.
  62103. * @return The highlight layer if found otherwise null.
  62104. */
  62105. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  62106. }
  62107. }
  62108. /**
  62109. * Glow layer options. This helps customizing the behaviour
  62110. * of the glow layer.
  62111. */
  62112. export interface IGlowLayerOptions {
  62113. /**
  62114. * Multiplication factor apply to the canvas size to compute the render target size
  62115. * used to generated the glowing objects (the smaller the faster).
  62116. */
  62117. mainTextureRatio: number;
  62118. /**
  62119. * Enforces a fixed size texture to ensure resize independant blur.
  62120. */
  62121. mainTextureFixedSize?: number;
  62122. /**
  62123. * How big is the kernel of the blur texture.
  62124. */
  62125. blurKernelSize: number;
  62126. /**
  62127. * The camera attached to the layer.
  62128. */
  62129. camera: Nullable<Camera>;
  62130. /**
  62131. * Enable MSAA by chosing the number of samples.
  62132. */
  62133. mainTextureSamples?: number;
  62134. /**
  62135. * The rendering group to draw the layer in.
  62136. */
  62137. renderingGroupId: number;
  62138. }
  62139. /**
  62140. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  62141. *
  62142. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  62143. *
  62144. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  62145. */
  62146. export class GlowLayer extends EffectLayer {
  62147. /**
  62148. * Effect Name of the layer.
  62149. */
  62150. static readonly EffectName: string;
  62151. /**
  62152. * The default blur kernel size used for the glow.
  62153. */
  62154. static DefaultBlurKernelSize: number;
  62155. /**
  62156. * The default texture size ratio used for the glow.
  62157. */
  62158. static DefaultTextureRatio: number;
  62159. /**
  62160. * Sets the kernel size of the blur.
  62161. */
  62162. set blurKernelSize(value: number);
  62163. /**
  62164. * Gets the kernel size of the blur.
  62165. */
  62166. get blurKernelSize(): number;
  62167. /**
  62168. * Sets the glow intensity.
  62169. */
  62170. set intensity(value: number);
  62171. /**
  62172. * Gets the glow intensity.
  62173. */
  62174. get intensity(): number;
  62175. private _options;
  62176. private _intensity;
  62177. private _horizontalBlurPostprocess1;
  62178. private _verticalBlurPostprocess1;
  62179. private _horizontalBlurPostprocess2;
  62180. private _verticalBlurPostprocess2;
  62181. private _blurTexture1;
  62182. private _blurTexture2;
  62183. private _postProcesses1;
  62184. private _postProcesses2;
  62185. private _includedOnlyMeshes;
  62186. private _excludedMeshes;
  62187. private _meshesUsingTheirOwnMaterials;
  62188. /**
  62189. * Callback used to let the user override the color selection on a per mesh basis
  62190. */
  62191. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  62192. /**
  62193. * Callback used to let the user override the texture selection on a per mesh basis
  62194. */
  62195. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  62196. /**
  62197. * Instantiates a new glow Layer and references it to the scene.
  62198. * @param name The name of the layer
  62199. * @param scene The scene to use the layer in
  62200. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  62201. */
  62202. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  62203. /**
  62204. * Get the effect name of the layer.
  62205. * @return The effect name
  62206. */
  62207. getEffectName(): string;
  62208. /**
  62209. * Create the merge effect. This is the shader use to blit the information back
  62210. * to the main canvas at the end of the scene rendering.
  62211. */
  62212. protected _createMergeEffect(): Effect;
  62213. /**
  62214. * Creates the render target textures and post processes used in the glow layer.
  62215. */
  62216. protected _createTextureAndPostProcesses(): void;
  62217. /**
  62218. * Checks for the readiness of the element composing the layer.
  62219. * @param subMesh the mesh to check for
  62220. * @param useInstances specify wether or not to use instances to render the mesh
  62221. * @param emissiveTexture the associated emissive texture used to generate the glow
  62222. * @return true if ready otherwise, false
  62223. */
  62224. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62225. /**
  62226. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62227. */
  62228. needStencil(): boolean;
  62229. /**
  62230. * Returns true if the mesh can be rendered, otherwise false.
  62231. * @param mesh The mesh to render
  62232. * @param material The material used on the mesh
  62233. * @returns true if it can be rendered otherwise false
  62234. */
  62235. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62236. /**
  62237. * Implementation specific of rendering the generating effect on the main canvas.
  62238. * @param effect The effect used to render through
  62239. */
  62240. protected _internalRender(effect: Effect): void;
  62241. /**
  62242. * Sets the required values for both the emissive texture and and the main color.
  62243. */
  62244. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62245. /**
  62246. * Returns true if the mesh should render, otherwise false.
  62247. * @param mesh The mesh to render
  62248. * @returns true if it should render otherwise false
  62249. */
  62250. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62251. /**
  62252. * Adds specific effects defines.
  62253. * @param defines The defines to add specifics to.
  62254. */
  62255. protected _addCustomEffectDefines(defines: string[]): void;
  62256. /**
  62257. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  62258. * @param mesh The mesh to exclude from the glow layer
  62259. */
  62260. addExcludedMesh(mesh: Mesh): void;
  62261. /**
  62262. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  62263. * @param mesh The mesh to remove
  62264. */
  62265. removeExcludedMesh(mesh: Mesh): void;
  62266. /**
  62267. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  62268. * @param mesh The mesh to include in the glow layer
  62269. */
  62270. addIncludedOnlyMesh(mesh: Mesh): void;
  62271. /**
  62272. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  62273. * @param mesh The mesh to remove
  62274. */
  62275. removeIncludedOnlyMesh(mesh: Mesh): void;
  62276. /**
  62277. * Determine if a given mesh will be used in the glow layer
  62278. * @param mesh The mesh to test
  62279. * @returns true if the mesh will be highlighted by the current glow layer
  62280. */
  62281. hasMesh(mesh: AbstractMesh): boolean;
  62282. /**
  62283. * Defines whether the current material of the mesh should be use to render the effect.
  62284. * @param mesh defines the current mesh to render
  62285. */
  62286. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62287. /**
  62288. * Add a mesh to be rendered through its own material and not with emissive only.
  62289. * @param mesh The mesh for which we need to use its material
  62290. */
  62291. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  62292. /**
  62293. * Remove a mesh from being rendered through its own material and not with emissive only.
  62294. * @param mesh The mesh for which we need to not use its material
  62295. */
  62296. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  62297. /**
  62298. * Free any resources and references associated to a mesh.
  62299. * Internal use
  62300. * @param mesh The mesh to free.
  62301. * @hidden
  62302. */
  62303. _disposeMesh(mesh: Mesh): void;
  62304. /**
  62305. * Gets the class name of the effect layer
  62306. * @returns the string with the class name of the effect layer
  62307. */
  62308. getClassName(): string;
  62309. /**
  62310. * Serializes this glow layer
  62311. * @returns a serialized glow layer object
  62312. */
  62313. serialize(): any;
  62314. /**
  62315. * Creates a Glow Layer from parsed glow layer data
  62316. * @param parsedGlowLayer defines glow layer data
  62317. * @param scene defines the current scene
  62318. * @param rootUrl defines the root URL containing the glow layer information
  62319. * @returns a parsed Glow Layer
  62320. */
  62321. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  62322. }
  62323. }
  62324. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  62325. /** @hidden */
  62326. export var glowBlurPostProcessPixelShader: {
  62327. name: string;
  62328. shader: string;
  62329. };
  62330. }
  62331. declare module "babylonjs/Layers/highlightLayer" {
  62332. import { Observable } from "babylonjs/Misc/observable";
  62333. import { Nullable } from "babylonjs/types";
  62334. import { Camera } from "babylonjs/Cameras/camera";
  62335. import { Scene } from "babylonjs/scene";
  62336. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62338. import { Mesh } from "babylonjs/Meshes/mesh";
  62339. import { Effect } from "babylonjs/Materials/effect";
  62340. import { Material } from "babylonjs/Materials/material";
  62341. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62342. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62343. import "babylonjs/Shaders/glowMapMerge.fragment";
  62344. import "babylonjs/Shaders/glowMapMerge.vertex";
  62345. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  62346. module "babylonjs/abstractScene" {
  62347. interface AbstractScene {
  62348. /**
  62349. * Return a the first highlight layer of the scene with a given name.
  62350. * @param name The name of the highlight layer to look for.
  62351. * @return The highlight layer if found otherwise null.
  62352. */
  62353. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  62354. }
  62355. }
  62356. /**
  62357. * Highlight layer options. This helps customizing the behaviour
  62358. * of the highlight layer.
  62359. */
  62360. export interface IHighlightLayerOptions {
  62361. /**
  62362. * Multiplication factor apply to the canvas size to compute the render target size
  62363. * used to generated the glowing objects (the smaller the faster).
  62364. */
  62365. mainTextureRatio: number;
  62366. /**
  62367. * Enforces a fixed size texture to ensure resize independant blur.
  62368. */
  62369. mainTextureFixedSize?: number;
  62370. /**
  62371. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  62372. * of the picture to blur (the smaller the faster).
  62373. */
  62374. blurTextureSizeRatio: number;
  62375. /**
  62376. * How big in texel of the blur texture is the vertical blur.
  62377. */
  62378. blurVerticalSize: number;
  62379. /**
  62380. * How big in texel of the blur texture is the horizontal blur.
  62381. */
  62382. blurHorizontalSize: number;
  62383. /**
  62384. * Alpha blending mode used to apply the blur. Default is combine.
  62385. */
  62386. alphaBlendingMode: number;
  62387. /**
  62388. * The camera attached to the layer.
  62389. */
  62390. camera: Nullable<Camera>;
  62391. /**
  62392. * Should we display highlight as a solid stroke?
  62393. */
  62394. isStroke?: boolean;
  62395. /**
  62396. * The rendering group to draw the layer in.
  62397. */
  62398. renderingGroupId: number;
  62399. }
  62400. /**
  62401. * The highlight layer Helps adding a glow effect around a mesh.
  62402. *
  62403. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  62404. * glowy meshes to your scene.
  62405. *
  62406. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  62407. */
  62408. export class HighlightLayer extends EffectLayer {
  62409. name: string;
  62410. /**
  62411. * Effect Name of the highlight layer.
  62412. */
  62413. static readonly EffectName: string;
  62414. /**
  62415. * The neutral color used during the preparation of the glow effect.
  62416. * This is black by default as the blend operation is a blend operation.
  62417. */
  62418. static NeutralColor: Color4;
  62419. /**
  62420. * Stencil value used for glowing meshes.
  62421. */
  62422. static GlowingMeshStencilReference: number;
  62423. /**
  62424. * Stencil value used for the other meshes in the scene.
  62425. */
  62426. static NormalMeshStencilReference: number;
  62427. /**
  62428. * Specifies whether or not the inner glow is ACTIVE in the layer.
  62429. */
  62430. innerGlow: boolean;
  62431. /**
  62432. * Specifies whether or not the outer glow is ACTIVE in the layer.
  62433. */
  62434. outerGlow: boolean;
  62435. /**
  62436. * Specifies the horizontal size of the blur.
  62437. */
  62438. set blurHorizontalSize(value: number);
  62439. /**
  62440. * Specifies the vertical size of the blur.
  62441. */
  62442. set blurVerticalSize(value: number);
  62443. /**
  62444. * Gets the horizontal size of the blur.
  62445. */
  62446. get blurHorizontalSize(): number;
  62447. /**
  62448. * Gets the vertical size of the blur.
  62449. */
  62450. get blurVerticalSize(): number;
  62451. /**
  62452. * An event triggered when the highlight layer is being blurred.
  62453. */
  62454. onBeforeBlurObservable: Observable<HighlightLayer>;
  62455. /**
  62456. * An event triggered when the highlight layer has been blurred.
  62457. */
  62458. onAfterBlurObservable: Observable<HighlightLayer>;
  62459. private _instanceGlowingMeshStencilReference;
  62460. private _options;
  62461. private _downSamplePostprocess;
  62462. private _horizontalBlurPostprocess;
  62463. private _verticalBlurPostprocess;
  62464. private _blurTexture;
  62465. private _meshes;
  62466. private _excludedMeshes;
  62467. /**
  62468. * Instantiates a new highlight Layer and references it to the scene..
  62469. * @param name The name of the layer
  62470. * @param scene The scene to use the layer in
  62471. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  62472. */
  62473. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  62474. /**
  62475. * Get the effect name of the layer.
  62476. * @return The effect name
  62477. */
  62478. getEffectName(): string;
  62479. /**
  62480. * Create the merge effect. This is the shader use to blit the information back
  62481. * to the main canvas at the end of the scene rendering.
  62482. */
  62483. protected _createMergeEffect(): Effect;
  62484. /**
  62485. * Creates the render target textures and post processes used in the highlight layer.
  62486. */
  62487. protected _createTextureAndPostProcesses(): void;
  62488. /**
  62489. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  62490. */
  62491. needStencil(): boolean;
  62492. /**
  62493. * Checks for the readiness of the element composing the layer.
  62494. * @param subMesh the mesh to check for
  62495. * @param useInstances specify wether or not to use instances to render the mesh
  62496. * @param emissiveTexture the associated emissive texture used to generate the glow
  62497. * @return true if ready otherwise, false
  62498. */
  62499. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62500. /**
  62501. * Implementation specific of rendering the generating effect on the main canvas.
  62502. * @param effect The effect used to render through
  62503. */
  62504. protected _internalRender(effect: Effect): void;
  62505. /**
  62506. * Returns true if the layer contains information to display, otherwise false.
  62507. */
  62508. shouldRender(): boolean;
  62509. /**
  62510. * Returns true if the mesh should render, otherwise false.
  62511. * @param mesh The mesh to render
  62512. * @returns true if it should render otherwise false
  62513. */
  62514. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62515. /**
  62516. * Returns true if the mesh can be rendered, otherwise false.
  62517. * @param mesh The mesh to render
  62518. * @param material The material used on the mesh
  62519. * @returns true if it can be rendered otherwise false
  62520. */
  62521. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62522. /**
  62523. * Adds specific effects defines.
  62524. * @param defines The defines to add specifics to.
  62525. */
  62526. protected _addCustomEffectDefines(defines: string[]): void;
  62527. /**
  62528. * Sets the required values for both the emissive texture and and the main color.
  62529. */
  62530. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62531. /**
  62532. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  62533. * @param mesh The mesh to exclude from the highlight layer
  62534. */
  62535. addExcludedMesh(mesh: Mesh): void;
  62536. /**
  62537. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  62538. * @param mesh The mesh to highlight
  62539. */
  62540. removeExcludedMesh(mesh: Mesh): void;
  62541. /**
  62542. * Determine if a given mesh will be highlighted by the current HighlightLayer
  62543. * @param mesh mesh to test
  62544. * @returns true if the mesh will be highlighted by the current HighlightLayer
  62545. */
  62546. hasMesh(mesh: AbstractMesh): boolean;
  62547. /**
  62548. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  62549. * @param mesh The mesh to highlight
  62550. * @param color The color of the highlight
  62551. * @param glowEmissiveOnly Extract the glow from the emissive texture
  62552. */
  62553. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  62554. /**
  62555. * Remove a mesh from the highlight layer in order to make it stop glowing.
  62556. * @param mesh The mesh to highlight
  62557. */
  62558. removeMesh(mesh: Mesh): void;
  62559. /**
  62560. * Remove all the meshes currently referenced in the highlight layer
  62561. */
  62562. removeAllMeshes(): void;
  62563. /**
  62564. * Force the stencil to the normal expected value for none glowing parts
  62565. */
  62566. private _defaultStencilReference;
  62567. /**
  62568. * Free any resources and references associated to a mesh.
  62569. * Internal use
  62570. * @param mesh The mesh to free.
  62571. * @hidden
  62572. */
  62573. _disposeMesh(mesh: Mesh): void;
  62574. /**
  62575. * Dispose the highlight layer and free resources.
  62576. */
  62577. dispose(): void;
  62578. /**
  62579. * Gets the class name of the effect layer
  62580. * @returns the string with the class name of the effect layer
  62581. */
  62582. getClassName(): string;
  62583. /**
  62584. * Serializes this Highlight layer
  62585. * @returns a serialized Highlight layer object
  62586. */
  62587. serialize(): any;
  62588. /**
  62589. * Creates a Highlight layer from parsed Highlight layer data
  62590. * @param parsedHightlightLayer defines the Highlight layer data
  62591. * @param scene defines the current scene
  62592. * @param rootUrl defines the root URL containing the Highlight layer information
  62593. * @returns a parsed Highlight layer
  62594. */
  62595. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  62596. }
  62597. }
  62598. declare module "babylonjs/Layers/layerSceneComponent" {
  62599. import { Scene } from "babylonjs/scene";
  62600. import { ISceneComponent } from "babylonjs/sceneComponent";
  62601. import { Layer } from "babylonjs/Layers/layer";
  62602. import { AbstractScene } from "babylonjs/abstractScene";
  62603. module "babylonjs/abstractScene" {
  62604. interface AbstractScene {
  62605. /**
  62606. * The list of layers (background and foreground) of the scene
  62607. */
  62608. layers: Array<Layer>;
  62609. }
  62610. }
  62611. /**
  62612. * Defines the layer scene component responsible to manage any layers
  62613. * in a given scene.
  62614. */
  62615. export class LayerSceneComponent implements ISceneComponent {
  62616. /**
  62617. * The component name helpfull to identify the component in the list of scene components.
  62618. */
  62619. readonly name: string;
  62620. /**
  62621. * The scene the component belongs to.
  62622. */
  62623. scene: Scene;
  62624. private _engine;
  62625. /**
  62626. * Creates a new instance of the component for the given scene
  62627. * @param scene Defines the scene to register the component in
  62628. */
  62629. constructor(scene: Scene);
  62630. /**
  62631. * Registers the component in a given scene
  62632. */
  62633. register(): void;
  62634. /**
  62635. * Rebuilds the elements related to this component in case of
  62636. * context lost for instance.
  62637. */
  62638. rebuild(): void;
  62639. /**
  62640. * Disposes the component and the associated ressources.
  62641. */
  62642. dispose(): void;
  62643. private _draw;
  62644. private _drawCameraPredicate;
  62645. private _drawCameraBackground;
  62646. private _drawCameraForeground;
  62647. private _drawRenderTargetPredicate;
  62648. private _drawRenderTargetBackground;
  62649. private _drawRenderTargetForeground;
  62650. /**
  62651. * Adds all the elements from the container to the scene
  62652. * @param container the container holding the elements
  62653. */
  62654. addFromContainer(container: AbstractScene): void;
  62655. /**
  62656. * Removes all the elements in the container from the scene
  62657. * @param container contains the elements to remove
  62658. * @param dispose if the removed element should be disposed (default: false)
  62659. */
  62660. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62661. }
  62662. }
  62663. declare module "babylonjs/Shaders/layer.fragment" {
  62664. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62665. /** @hidden */
  62666. export var layerPixelShader: {
  62667. name: string;
  62668. shader: string;
  62669. };
  62670. }
  62671. declare module "babylonjs/Shaders/layer.vertex" {
  62672. /** @hidden */
  62673. export var layerVertexShader: {
  62674. name: string;
  62675. shader: string;
  62676. };
  62677. }
  62678. declare module "babylonjs/Layers/layer" {
  62679. import { Observable } from "babylonjs/Misc/observable";
  62680. import { Nullable } from "babylonjs/types";
  62681. import { Scene } from "babylonjs/scene";
  62682. import { Vector2 } from "babylonjs/Maths/math.vector";
  62683. import { Color4 } from "babylonjs/Maths/math.color";
  62684. import { Texture } from "babylonjs/Materials/Textures/texture";
  62685. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62686. import "babylonjs/Shaders/layer.fragment";
  62687. import "babylonjs/Shaders/layer.vertex";
  62688. /**
  62689. * This represents a full screen 2d layer.
  62690. * This can be useful to display a picture in the background of your scene for instance.
  62691. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62692. */
  62693. export class Layer {
  62694. /**
  62695. * Define the name of the layer.
  62696. */
  62697. name: string;
  62698. /**
  62699. * Define the texture the layer should display.
  62700. */
  62701. texture: Nullable<Texture>;
  62702. /**
  62703. * Is the layer in background or foreground.
  62704. */
  62705. isBackground: boolean;
  62706. /**
  62707. * Define the color of the layer (instead of texture).
  62708. */
  62709. color: Color4;
  62710. /**
  62711. * Define the scale of the layer in order to zoom in out of the texture.
  62712. */
  62713. scale: Vector2;
  62714. /**
  62715. * Define an offset for the layer in order to shift the texture.
  62716. */
  62717. offset: Vector2;
  62718. /**
  62719. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62720. */
  62721. alphaBlendingMode: number;
  62722. /**
  62723. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  62724. * Alpha test will not mix with the background color in case of transparency.
  62725. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  62726. */
  62727. alphaTest: boolean;
  62728. /**
  62729. * Define a mask to restrict the layer to only some of the scene cameras.
  62730. */
  62731. layerMask: number;
  62732. /**
  62733. * Define the list of render target the layer is visible into.
  62734. */
  62735. renderTargetTextures: RenderTargetTexture[];
  62736. /**
  62737. * Define if the layer is only used in renderTarget or if it also
  62738. * renders in the main frame buffer of the canvas.
  62739. */
  62740. renderOnlyInRenderTargetTextures: boolean;
  62741. private _scene;
  62742. private _vertexBuffers;
  62743. private _indexBuffer;
  62744. private _effect;
  62745. private _previousDefines;
  62746. /**
  62747. * An event triggered when the layer is disposed.
  62748. */
  62749. onDisposeObservable: Observable<Layer>;
  62750. private _onDisposeObserver;
  62751. /**
  62752. * Back compatibility with callback before the onDisposeObservable existed.
  62753. * The set callback will be triggered when the layer has been disposed.
  62754. */
  62755. set onDispose(callback: () => void);
  62756. /**
  62757. * An event triggered before rendering the scene
  62758. */
  62759. onBeforeRenderObservable: Observable<Layer>;
  62760. private _onBeforeRenderObserver;
  62761. /**
  62762. * Back compatibility with callback before the onBeforeRenderObservable existed.
  62763. * The set callback will be triggered just before rendering the layer.
  62764. */
  62765. set onBeforeRender(callback: () => void);
  62766. /**
  62767. * An event triggered after rendering the scene
  62768. */
  62769. onAfterRenderObservable: Observable<Layer>;
  62770. private _onAfterRenderObserver;
  62771. /**
  62772. * Back compatibility with callback before the onAfterRenderObservable existed.
  62773. * The set callback will be triggered just after rendering the layer.
  62774. */
  62775. set onAfterRender(callback: () => void);
  62776. /**
  62777. * Instantiates a new layer.
  62778. * This represents a full screen 2d layer.
  62779. * This can be useful to display a picture in the background of your scene for instance.
  62780. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62781. * @param name Define the name of the layer in the scene
  62782. * @param imgUrl Define the url of the texture to display in the layer
  62783. * @param scene Define the scene the layer belongs to
  62784. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  62785. * @param color Defines a color for the layer
  62786. */
  62787. constructor(
  62788. /**
  62789. * Define the name of the layer.
  62790. */
  62791. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  62792. private _createIndexBuffer;
  62793. /** @hidden */
  62794. _rebuild(): void;
  62795. /**
  62796. * Renders the layer in the scene.
  62797. */
  62798. render(): void;
  62799. /**
  62800. * Disposes and releases the associated ressources.
  62801. */
  62802. dispose(): void;
  62803. }
  62804. }
  62805. declare module "babylonjs/Layers/index" {
  62806. export * from "babylonjs/Layers/effectLayer";
  62807. export * from "babylonjs/Layers/effectLayerSceneComponent";
  62808. export * from "babylonjs/Layers/glowLayer";
  62809. export * from "babylonjs/Layers/highlightLayer";
  62810. export * from "babylonjs/Layers/layer";
  62811. export * from "babylonjs/Layers/layerSceneComponent";
  62812. }
  62813. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62814. /** @hidden */
  62815. export var lensFlarePixelShader: {
  62816. name: string;
  62817. shader: string;
  62818. };
  62819. }
  62820. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62821. /** @hidden */
  62822. export var lensFlareVertexShader: {
  62823. name: string;
  62824. shader: string;
  62825. };
  62826. }
  62827. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62828. import { Scene } from "babylonjs/scene";
  62829. import { Vector3 } from "babylonjs/Maths/math.vector";
  62830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62831. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62832. import "babylonjs/Shaders/lensFlare.fragment";
  62833. import "babylonjs/Shaders/lensFlare.vertex";
  62834. import { Viewport } from "babylonjs/Maths/math.viewport";
  62835. /**
  62836. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62837. * It is usually composed of several `lensFlare`.
  62838. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62839. */
  62840. export class LensFlareSystem {
  62841. /**
  62842. * Define the name of the lens flare system
  62843. */
  62844. name: string;
  62845. /**
  62846. * List of lens flares used in this system.
  62847. */
  62848. lensFlares: LensFlare[];
  62849. /**
  62850. * Define a limit from the border the lens flare can be visible.
  62851. */
  62852. borderLimit: number;
  62853. /**
  62854. * Define a viewport border we do not want to see the lens flare in.
  62855. */
  62856. viewportBorder: number;
  62857. /**
  62858. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62859. */
  62860. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62861. /**
  62862. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62863. */
  62864. layerMask: number;
  62865. /**
  62866. * Define the id of the lens flare system in the scene.
  62867. * (equal to name by default)
  62868. */
  62869. id: string;
  62870. private _scene;
  62871. private _emitter;
  62872. private _vertexBuffers;
  62873. private _indexBuffer;
  62874. private _effect;
  62875. private _positionX;
  62876. private _positionY;
  62877. private _isEnabled;
  62878. /** @hidden */
  62879. static _SceneComponentInitialization: (scene: Scene) => void;
  62880. /**
  62881. * Instantiates a lens flare system.
  62882. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62883. * It is usually composed of several `lensFlare`.
  62884. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62885. * @param name Define the name of the lens flare system in the scene
  62886. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62887. * @param scene Define the scene the lens flare system belongs to
  62888. */
  62889. constructor(
  62890. /**
  62891. * Define the name of the lens flare system
  62892. */
  62893. name: string, emitter: any, scene: Scene);
  62894. /**
  62895. * Define if the lens flare system is enabled.
  62896. */
  62897. get isEnabled(): boolean;
  62898. set isEnabled(value: boolean);
  62899. /**
  62900. * Get the scene the effects belongs to.
  62901. * @returns the scene holding the lens flare system
  62902. */
  62903. getScene(): Scene;
  62904. /**
  62905. * Get the emitter of the lens flare system.
  62906. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62907. * @returns the emitter of the lens flare system
  62908. */
  62909. getEmitter(): any;
  62910. /**
  62911. * Set the emitter of the lens flare system.
  62912. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62913. * @param newEmitter Define the new emitter of the system
  62914. */
  62915. setEmitter(newEmitter: any): void;
  62916. /**
  62917. * Get the lens flare system emitter position.
  62918. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62919. * @returns the position
  62920. */
  62921. getEmitterPosition(): Vector3;
  62922. /**
  62923. * @hidden
  62924. */
  62925. computeEffectivePosition(globalViewport: Viewport): boolean;
  62926. /** @hidden */
  62927. _isVisible(): boolean;
  62928. /**
  62929. * @hidden
  62930. */
  62931. render(): boolean;
  62932. /**
  62933. * Dispose and release the lens flare with its associated resources.
  62934. */
  62935. dispose(): void;
  62936. /**
  62937. * Parse a lens flare system from a JSON repressentation
  62938. * @param parsedLensFlareSystem Define the JSON to parse
  62939. * @param scene Define the scene the parsed system should be instantiated in
  62940. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62941. * @returns the parsed system
  62942. */
  62943. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62944. /**
  62945. * Serialize the current Lens Flare System into a JSON representation.
  62946. * @returns the serialized JSON
  62947. */
  62948. serialize(): any;
  62949. }
  62950. }
  62951. declare module "babylonjs/LensFlares/lensFlare" {
  62952. import { Nullable } from "babylonjs/types";
  62953. import { Color3 } from "babylonjs/Maths/math.color";
  62954. import { Texture } from "babylonjs/Materials/Textures/texture";
  62955. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62956. /**
  62957. * This represents one of the lens effect in a `lensFlareSystem`.
  62958. * It controls one of the indiviual texture used in the effect.
  62959. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62960. */
  62961. export class LensFlare {
  62962. /**
  62963. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62964. */
  62965. size: number;
  62966. /**
  62967. * 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.
  62968. */
  62969. position: number;
  62970. /**
  62971. * Define the lens color.
  62972. */
  62973. color: Color3;
  62974. /**
  62975. * Define the lens texture.
  62976. */
  62977. texture: Nullable<Texture>;
  62978. /**
  62979. * Define the alpha mode to render this particular lens.
  62980. */
  62981. alphaMode: number;
  62982. private _system;
  62983. /**
  62984. * Creates a new Lens Flare.
  62985. * This represents one of the lens effect in a `lensFlareSystem`.
  62986. * It controls one of the indiviual texture used in the effect.
  62987. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62988. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62989. * @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.
  62990. * @param color Define the lens color
  62991. * @param imgUrl Define the lens texture url
  62992. * @param system Define the `lensFlareSystem` this flare is part of
  62993. * @returns The newly created Lens Flare
  62994. */
  62995. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62996. /**
  62997. * Instantiates a new Lens Flare.
  62998. * This represents one of the lens effect in a `lensFlareSystem`.
  62999. * It controls one of the indiviual texture used in the effect.
  63000. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63001. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  63002. * @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.
  63003. * @param color Define the lens color
  63004. * @param imgUrl Define the lens texture url
  63005. * @param system Define the `lensFlareSystem` this flare is part of
  63006. */
  63007. constructor(
  63008. /**
  63009. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63010. */
  63011. size: number,
  63012. /**
  63013. * 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.
  63014. */
  63015. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  63016. /**
  63017. * Dispose and release the lens flare with its associated resources.
  63018. */
  63019. dispose(): void;
  63020. }
  63021. }
  63022. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  63023. import { Nullable } from "babylonjs/types";
  63024. import { Scene } from "babylonjs/scene";
  63025. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63026. import { AbstractScene } from "babylonjs/abstractScene";
  63027. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63028. module "babylonjs/abstractScene" {
  63029. interface AbstractScene {
  63030. /**
  63031. * The list of lens flare system added to the scene
  63032. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63033. */
  63034. lensFlareSystems: Array<LensFlareSystem>;
  63035. /**
  63036. * Removes the given lens flare system from this scene.
  63037. * @param toRemove The lens flare system to remove
  63038. * @returns The index of the removed lens flare system
  63039. */
  63040. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  63041. /**
  63042. * Adds the given lens flare system to this scene
  63043. * @param newLensFlareSystem The lens flare system to add
  63044. */
  63045. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  63046. /**
  63047. * Gets a lens flare system using its name
  63048. * @param name defines the name to look for
  63049. * @returns the lens flare system or null if not found
  63050. */
  63051. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  63052. /**
  63053. * Gets a lens flare system using its id
  63054. * @param id defines the id to look for
  63055. * @returns the lens flare system or null if not found
  63056. */
  63057. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63058. }
  63059. }
  63060. /**
  63061. * Defines the lens flare scene component responsible to manage any lens flares
  63062. * in a given scene.
  63063. */
  63064. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63065. /**
  63066. * The component name helpfull to identify the component in the list of scene components.
  63067. */
  63068. readonly name: string;
  63069. /**
  63070. * The scene the component belongs to.
  63071. */
  63072. scene: Scene;
  63073. /**
  63074. * Creates a new instance of the component for the given scene
  63075. * @param scene Defines the scene to register the component in
  63076. */
  63077. constructor(scene: Scene);
  63078. /**
  63079. * Registers the component in a given scene
  63080. */
  63081. register(): void;
  63082. /**
  63083. * Rebuilds the elements related to this component in case of
  63084. * context lost for instance.
  63085. */
  63086. rebuild(): void;
  63087. /**
  63088. * Adds all the elements from the container to the scene
  63089. * @param container the container holding the elements
  63090. */
  63091. addFromContainer(container: AbstractScene): void;
  63092. /**
  63093. * Removes all the elements in the container from the scene
  63094. * @param container contains the elements to remove
  63095. * @param dispose if the removed element should be disposed (default: false)
  63096. */
  63097. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63098. /**
  63099. * Serializes the component data to the specified json object
  63100. * @param serializationObject The object to serialize to
  63101. */
  63102. serialize(serializationObject: any): void;
  63103. /**
  63104. * Disposes the component and the associated ressources.
  63105. */
  63106. dispose(): void;
  63107. private _draw;
  63108. }
  63109. }
  63110. declare module "babylonjs/LensFlares/index" {
  63111. export * from "babylonjs/LensFlares/lensFlare";
  63112. export * from "babylonjs/LensFlares/lensFlareSystem";
  63113. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  63114. }
  63115. declare module "babylonjs/Shaders/depth.fragment" {
  63116. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63117. /** @hidden */
  63118. export var depthPixelShader: {
  63119. name: string;
  63120. shader: string;
  63121. };
  63122. }
  63123. declare module "babylonjs/Shaders/depth.vertex" {
  63124. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63125. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63126. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63127. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63128. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63129. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63130. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63131. /** @hidden */
  63132. export var depthVertexShader: {
  63133. name: string;
  63134. shader: string;
  63135. };
  63136. }
  63137. declare module "babylonjs/Rendering/depthRenderer" {
  63138. import { Nullable } from "babylonjs/types";
  63139. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63140. import { Scene } from "babylonjs/scene";
  63141. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63142. import { Camera } from "babylonjs/Cameras/camera";
  63143. import "babylonjs/Shaders/depth.fragment";
  63144. import "babylonjs/Shaders/depth.vertex";
  63145. /**
  63146. * This represents a depth renderer in Babylon.
  63147. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63148. */
  63149. export class DepthRenderer {
  63150. private _scene;
  63151. private _depthMap;
  63152. private _effect;
  63153. private readonly _storeNonLinearDepth;
  63154. private readonly _clearColor;
  63155. /** Get if the depth renderer is using packed depth or not */
  63156. readonly isPacked: boolean;
  63157. private _cachedDefines;
  63158. private _camera;
  63159. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  63160. enabled: boolean;
  63161. /**
  63162. * Specifiess that the depth renderer will only be used within
  63163. * the camera it is created for.
  63164. * This can help forcing its rendering during the camera processing.
  63165. */
  63166. useOnlyInActiveCamera: boolean;
  63167. /** @hidden */
  63168. static _SceneComponentInitialization: (scene: Scene) => void;
  63169. /**
  63170. * Instantiates a depth renderer
  63171. * @param scene The scene the renderer belongs to
  63172. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63173. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63174. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63175. */
  63176. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63177. /**
  63178. * Creates the depth rendering effect and checks if the effect is ready.
  63179. * @param subMesh The submesh to be used to render the depth map of
  63180. * @param useInstances If multiple world instances should be used
  63181. * @returns if the depth renderer is ready to render the depth map
  63182. */
  63183. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63184. /**
  63185. * Gets the texture which the depth map will be written to.
  63186. * @returns The depth map texture
  63187. */
  63188. getDepthMap(): RenderTargetTexture;
  63189. /**
  63190. * Disposes of the depth renderer.
  63191. */
  63192. dispose(): void;
  63193. }
  63194. }
  63195. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  63196. /** @hidden */
  63197. export var minmaxReduxPixelShader: {
  63198. name: string;
  63199. shader: string;
  63200. };
  63201. }
  63202. declare module "babylonjs/Misc/minMaxReducer" {
  63203. import { Nullable } from "babylonjs/types";
  63204. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63205. import { Camera } from "babylonjs/Cameras/camera";
  63206. import { Observer } from "babylonjs/Misc/observable";
  63207. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63208. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  63209. import { Observable } from "babylonjs/Misc/observable";
  63210. import "babylonjs/Shaders/minmaxRedux.fragment";
  63211. /**
  63212. * This class computes a min/max reduction from a texture: it means it computes the minimum
  63213. * and maximum values from all values of the texture.
  63214. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  63215. * The source values are read from the red channel of the texture.
  63216. */
  63217. export class MinMaxReducer {
  63218. /**
  63219. * Observable triggered when the computation has been performed
  63220. */
  63221. onAfterReductionPerformed: Observable<{
  63222. min: number;
  63223. max: number;
  63224. }>;
  63225. protected _camera: Camera;
  63226. protected _sourceTexture: Nullable<RenderTargetTexture>;
  63227. protected _reductionSteps: Nullable<Array<PostProcess>>;
  63228. protected _postProcessManager: PostProcessManager;
  63229. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  63230. protected _forceFullscreenViewport: boolean;
  63231. /**
  63232. * Creates a min/max reducer
  63233. * @param camera The camera to use for the post processes
  63234. */
  63235. constructor(camera: Camera);
  63236. /**
  63237. * Gets the texture used to read the values from.
  63238. */
  63239. get sourceTexture(): Nullable<RenderTargetTexture>;
  63240. /**
  63241. * Sets the source texture to read the values from.
  63242. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  63243. * because in such textures '1' value must not be taken into account to compute the maximum
  63244. * as this value is used to clear the texture.
  63245. * Note that the computation is not activated by calling this function, you must call activate() for that!
  63246. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  63247. * @param depthRedux Indicates if the texture is a depth texture or not
  63248. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  63249. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63250. */
  63251. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63252. /**
  63253. * Defines the refresh rate of the computation.
  63254. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63255. */
  63256. get refreshRate(): number;
  63257. set refreshRate(value: number);
  63258. protected _activated: boolean;
  63259. /**
  63260. * Gets the activation status of the reducer
  63261. */
  63262. get activated(): boolean;
  63263. /**
  63264. * Activates the reduction computation.
  63265. * When activated, the observers registered in onAfterReductionPerformed are
  63266. * called after the compuation is performed
  63267. */
  63268. activate(): void;
  63269. /**
  63270. * Deactivates the reduction computation.
  63271. */
  63272. deactivate(): void;
  63273. /**
  63274. * Disposes the min/max reducer
  63275. * @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.
  63276. */
  63277. dispose(disposeAll?: boolean): void;
  63278. }
  63279. }
  63280. declare module "babylonjs/Misc/depthReducer" {
  63281. import { Nullable } from "babylonjs/types";
  63282. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63283. import { Camera } from "babylonjs/Cameras/camera";
  63284. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63285. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  63286. /**
  63287. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  63288. */
  63289. export class DepthReducer extends MinMaxReducer {
  63290. private _depthRenderer;
  63291. private _depthRendererId;
  63292. /**
  63293. * Gets the depth renderer used for the computation.
  63294. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  63295. */
  63296. get depthRenderer(): Nullable<DepthRenderer>;
  63297. /**
  63298. * Creates a depth reducer
  63299. * @param camera The camera used to render the depth texture
  63300. */
  63301. constructor(camera: Camera);
  63302. /**
  63303. * Sets the depth renderer to use to generate the depth map
  63304. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  63305. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  63306. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63307. */
  63308. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  63309. /** @hidden */
  63310. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63311. /**
  63312. * Activates the reduction computation.
  63313. * When activated, the observers registered in onAfterReductionPerformed are
  63314. * called after the compuation is performed
  63315. */
  63316. activate(): void;
  63317. /**
  63318. * Deactivates the reduction computation.
  63319. */
  63320. deactivate(): void;
  63321. /**
  63322. * Disposes the depth reducer
  63323. * @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.
  63324. */
  63325. dispose(disposeAll?: boolean): void;
  63326. }
  63327. }
  63328. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  63329. import { Nullable } from "babylonjs/types";
  63330. import { Scene } from "babylonjs/scene";
  63331. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63332. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63334. import { Effect } from "babylonjs/Materials/effect";
  63335. import "babylonjs/Shaders/shadowMap.fragment";
  63336. import "babylonjs/Shaders/shadowMap.vertex";
  63337. import "babylonjs/Shaders/depthBoxBlur.fragment";
  63338. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  63339. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63340. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63341. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63342. /**
  63343. * A CSM implementation allowing casting shadows on large scenes.
  63344. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63345. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  63346. */
  63347. export class CascadedShadowGenerator extends ShadowGenerator {
  63348. private static readonly frustumCornersNDCSpace;
  63349. /**
  63350. * Name of the CSM class
  63351. */
  63352. static CLASSNAME: string;
  63353. /**
  63354. * Defines the default number of cascades used by the CSM.
  63355. */
  63356. static readonly DEFAULT_CASCADES_COUNT: number;
  63357. /**
  63358. * Defines the minimum number of cascades used by the CSM.
  63359. */
  63360. static readonly MIN_CASCADES_COUNT: number;
  63361. /**
  63362. * Defines the maximum number of cascades used by the CSM.
  63363. */
  63364. static readonly MAX_CASCADES_COUNT: number;
  63365. protected _validateFilter(filter: number): number;
  63366. /**
  63367. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  63368. */
  63369. penumbraDarkness: number;
  63370. private _numCascades;
  63371. /**
  63372. * Gets or set the number of cascades used by the CSM.
  63373. */
  63374. get numCascades(): number;
  63375. set numCascades(value: number);
  63376. /**
  63377. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  63378. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  63379. */
  63380. stabilizeCascades: boolean;
  63381. private _freezeShadowCastersBoundingInfo;
  63382. private _freezeShadowCastersBoundingInfoObservable;
  63383. /**
  63384. * Enables or disables the shadow casters bounding info computation.
  63385. * If your shadow casters don't move, you can disable this feature.
  63386. * If it is enabled, the bounding box computation is done every frame.
  63387. */
  63388. get freezeShadowCastersBoundingInfo(): boolean;
  63389. set freezeShadowCastersBoundingInfo(freeze: boolean);
  63390. private _scbiMin;
  63391. private _scbiMax;
  63392. protected _computeShadowCastersBoundingInfo(): void;
  63393. protected _shadowCastersBoundingInfo: BoundingInfo;
  63394. /**
  63395. * Gets or sets the shadow casters bounding info.
  63396. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  63397. * so that the system won't overwrite the bounds you provide
  63398. */
  63399. get shadowCastersBoundingInfo(): BoundingInfo;
  63400. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  63401. protected _breaksAreDirty: boolean;
  63402. protected _minDistance: number;
  63403. protected _maxDistance: number;
  63404. /**
  63405. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  63406. *
  63407. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  63408. * If you don't know these values, simply leave them to their defaults and don't call this function.
  63409. * @param min minimal distance for the breaks (default to 0.)
  63410. * @param max maximal distance for the breaks (default to 1.)
  63411. */
  63412. setMinMaxDistance(min: number, max: number): void;
  63413. /** Gets the minimal distance used in the cascade break computation */
  63414. get minDistance(): number;
  63415. /** Gets the maximal distance used in the cascade break computation */
  63416. get maxDistance(): number;
  63417. /**
  63418. * Gets the class name of that object
  63419. * @returns "CascadedShadowGenerator"
  63420. */
  63421. getClassName(): string;
  63422. private _cascadeMinExtents;
  63423. private _cascadeMaxExtents;
  63424. /**
  63425. * Gets a cascade minimum extents
  63426. * @param cascadeIndex index of the cascade
  63427. * @returns the minimum cascade extents
  63428. */
  63429. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  63430. /**
  63431. * Gets a cascade maximum extents
  63432. * @param cascadeIndex index of the cascade
  63433. * @returns the maximum cascade extents
  63434. */
  63435. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  63436. private _cascades;
  63437. private _currentLayer;
  63438. private _viewSpaceFrustumsZ;
  63439. private _viewMatrices;
  63440. private _projectionMatrices;
  63441. private _transformMatrices;
  63442. private _transformMatricesAsArray;
  63443. private _frustumLengths;
  63444. private _lightSizeUVCorrection;
  63445. private _depthCorrection;
  63446. private _frustumCornersWorldSpace;
  63447. private _frustumCenter;
  63448. private _shadowCameraPos;
  63449. private _shadowMaxZ;
  63450. /**
  63451. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  63452. * It defaults to camera.maxZ
  63453. */
  63454. get shadowMaxZ(): number;
  63455. /**
  63456. * Sets the shadow max z distance.
  63457. */
  63458. set shadowMaxZ(value: number);
  63459. protected _debug: boolean;
  63460. /**
  63461. * Gets or sets the debug flag.
  63462. * When enabled, the cascades are materialized by different colors on the screen.
  63463. */
  63464. get debug(): boolean;
  63465. set debug(dbg: boolean);
  63466. private _depthClamp;
  63467. /**
  63468. * Gets or sets the depth clamping value.
  63469. *
  63470. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  63471. * to account for the shadow casters far away.
  63472. *
  63473. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  63474. */
  63475. get depthClamp(): boolean;
  63476. set depthClamp(value: boolean);
  63477. private _cascadeBlendPercentage;
  63478. /**
  63479. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  63480. * It defaults to 0.1 (10% blending).
  63481. */
  63482. get cascadeBlendPercentage(): number;
  63483. set cascadeBlendPercentage(value: number);
  63484. private _lambda;
  63485. /**
  63486. * Gets or set the lambda parameter.
  63487. * This parameter is used to split the camera frustum and create the cascades.
  63488. * 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.
  63489. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  63490. */
  63491. get lambda(): number;
  63492. set lambda(value: number);
  63493. /**
  63494. * Gets the view matrix corresponding to a given cascade
  63495. * @param cascadeNum cascade to retrieve the view matrix from
  63496. * @returns the cascade view matrix
  63497. */
  63498. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  63499. /**
  63500. * Gets the projection matrix corresponding to a given cascade
  63501. * @param cascadeNum cascade to retrieve the projection matrix from
  63502. * @returns the cascade projection matrix
  63503. */
  63504. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  63505. /**
  63506. * Gets the transformation matrix corresponding to a given cascade
  63507. * @param cascadeNum cascade to retrieve the transformation matrix from
  63508. * @returns the cascade transformation matrix
  63509. */
  63510. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  63511. private _depthRenderer;
  63512. /**
  63513. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  63514. *
  63515. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  63516. *
  63517. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  63518. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  63519. * @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
  63520. */
  63521. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  63522. private _depthReducer;
  63523. private _autoCalcDepthBounds;
  63524. /**
  63525. * Gets or sets the autoCalcDepthBounds property.
  63526. *
  63527. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  63528. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  63529. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  63530. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  63531. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  63532. */
  63533. get autoCalcDepthBounds(): boolean;
  63534. set autoCalcDepthBounds(value: boolean);
  63535. /**
  63536. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  63537. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63538. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  63539. * for setting the refresh rate on the renderer yourself!
  63540. */
  63541. get autoCalcDepthBoundsRefreshRate(): number;
  63542. set autoCalcDepthBoundsRefreshRate(value: number);
  63543. /**
  63544. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  63545. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  63546. * you change the camera near/far planes!
  63547. */
  63548. splitFrustum(): void;
  63549. private _splitFrustum;
  63550. private _computeMatrices;
  63551. private _computeFrustumInWorldSpace;
  63552. private _computeCascadeFrustum;
  63553. /**
  63554. * Support test.
  63555. */
  63556. static get IsSupported(): boolean;
  63557. /** @hidden */
  63558. static _SceneComponentInitialization: (scene: Scene) => void;
  63559. /**
  63560. * Creates a Cascaded Shadow Generator object.
  63561. * A ShadowGenerator is the required tool to use the shadows.
  63562. * Each directional light casting shadows needs to use its own ShadowGenerator.
  63563. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63564. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  63565. * @param light The directional light object generating the shadows.
  63566. * @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.
  63567. */
  63568. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  63569. protected _initializeGenerator(): void;
  63570. protected _createTargetRenderTexture(): void;
  63571. protected _initializeShadowMap(): void;
  63572. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  63573. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  63574. /**
  63575. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  63576. * @param defines Defines of the material we want to update
  63577. * @param lightIndex Index of the light in the enabled light list of the material
  63578. */
  63579. prepareDefines(defines: any, lightIndex: number): void;
  63580. /**
  63581. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  63582. * defined in the generator but impacting the effect).
  63583. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  63584. * @param effect The effect we are binfing the information for
  63585. */
  63586. bindShadowLight(lightIndex: string, effect: Effect): void;
  63587. /**
  63588. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  63589. * (eq to view projection * shadow projection matrices)
  63590. * @returns The transform matrix used to create the shadow map
  63591. */
  63592. getTransformMatrix(): Matrix;
  63593. /**
  63594. * Disposes the ShadowGenerator.
  63595. * Returns nothing.
  63596. */
  63597. dispose(): void;
  63598. /**
  63599. * Serializes the shadow generator setup to a json object.
  63600. * @returns The serialized JSON object
  63601. */
  63602. serialize(): any;
  63603. /**
  63604. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  63605. * @param parsedShadowGenerator The JSON object to parse
  63606. * @param scene The scene to create the shadow map for
  63607. * @returns The parsed shadow generator
  63608. */
  63609. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  63610. }
  63611. }
  63612. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  63613. import { Scene } from "babylonjs/scene";
  63614. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63615. import { AbstractScene } from "babylonjs/abstractScene";
  63616. /**
  63617. * Defines the shadow generator component responsible to manage any shadow generators
  63618. * in a given scene.
  63619. */
  63620. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  63621. /**
  63622. * The component name helpfull to identify the component in the list of scene components.
  63623. */
  63624. readonly name: string;
  63625. /**
  63626. * The scene the component belongs to.
  63627. */
  63628. scene: Scene;
  63629. /**
  63630. * Creates a new instance of the component for the given scene
  63631. * @param scene Defines the scene to register the component in
  63632. */
  63633. constructor(scene: Scene);
  63634. /**
  63635. * Registers the component in a given scene
  63636. */
  63637. register(): void;
  63638. /**
  63639. * Rebuilds the elements related to this component in case of
  63640. * context lost for instance.
  63641. */
  63642. rebuild(): void;
  63643. /**
  63644. * Serializes the component data to the specified json object
  63645. * @param serializationObject The object to serialize to
  63646. */
  63647. serialize(serializationObject: any): void;
  63648. /**
  63649. * Adds all the elements from the container to the scene
  63650. * @param container the container holding the elements
  63651. */
  63652. addFromContainer(container: AbstractScene): void;
  63653. /**
  63654. * Removes all the elements in the container from the scene
  63655. * @param container contains the elements to remove
  63656. * @param dispose if the removed element should be disposed (default: false)
  63657. */
  63658. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63659. /**
  63660. * Rebuilds the elements related to this component in case of
  63661. * context lost for instance.
  63662. */
  63663. dispose(): void;
  63664. private _gatherRenderTargets;
  63665. }
  63666. }
  63667. declare module "babylonjs/Lights/Shadows/index" {
  63668. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  63669. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  63670. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  63671. }
  63672. declare module "babylonjs/Lights/pointLight" {
  63673. import { Scene } from "babylonjs/scene";
  63674. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63676. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63677. import { Effect } from "babylonjs/Materials/effect";
  63678. /**
  63679. * A point light is a light defined by an unique point in world space.
  63680. * The light is emitted in every direction from this point.
  63681. * A good example of a point light is a standard light bulb.
  63682. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63683. */
  63684. export class PointLight extends ShadowLight {
  63685. private _shadowAngle;
  63686. /**
  63687. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63688. * This specifies what angle the shadow will use to be created.
  63689. *
  63690. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63691. */
  63692. get shadowAngle(): number;
  63693. /**
  63694. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63695. * This specifies what angle the shadow will use to be created.
  63696. *
  63697. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63698. */
  63699. set shadowAngle(value: number);
  63700. /**
  63701. * Gets the direction if it has been set.
  63702. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63703. */
  63704. get direction(): Vector3;
  63705. /**
  63706. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63707. */
  63708. set direction(value: Vector3);
  63709. /**
  63710. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  63711. * A PointLight emits the light in every direction.
  63712. * It can cast shadows.
  63713. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  63714. * ```javascript
  63715. * var pointLight = new PointLight("pl", camera.position, scene);
  63716. * ```
  63717. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63718. * @param name The light friendly name
  63719. * @param position The position of the point light in the scene
  63720. * @param scene The scene the lights belongs to
  63721. */
  63722. constructor(name: string, position: Vector3, scene: Scene);
  63723. /**
  63724. * Returns the string "PointLight"
  63725. * @returns the class name
  63726. */
  63727. getClassName(): string;
  63728. /**
  63729. * Returns the integer 0.
  63730. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63731. */
  63732. getTypeID(): number;
  63733. /**
  63734. * Specifies wether or not the shadowmap should be a cube texture.
  63735. * @returns true if the shadowmap needs to be a cube texture.
  63736. */
  63737. needCube(): boolean;
  63738. /**
  63739. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  63740. * @param faceIndex The index of the face we are computed the direction to generate shadow
  63741. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  63742. */
  63743. getShadowDirection(faceIndex?: number): Vector3;
  63744. /**
  63745. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  63746. * - fov = PI / 2
  63747. * - aspect ratio : 1.0
  63748. * - z-near and far equal to the active camera minZ and maxZ.
  63749. * Returns the PointLight.
  63750. */
  63751. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63752. protected _buildUniformLayout(): void;
  63753. /**
  63754. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  63755. * @param effect The effect to update
  63756. * @param lightIndex The index of the light in the effect to update
  63757. * @returns The point light
  63758. */
  63759. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  63760. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63761. /**
  63762. * Prepares the list of defines specific to the light type.
  63763. * @param defines the list of defines
  63764. * @param lightIndex defines the index of the light for the effect
  63765. */
  63766. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63767. }
  63768. }
  63769. declare module "babylonjs/Lights/index" {
  63770. export * from "babylonjs/Lights/light";
  63771. export * from "babylonjs/Lights/shadowLight";
  63772. export * from "babylonjs/Lights/Shadows/index";
  63773. export * from "babylonjs/Lights/directionalLight";
  63774. export * from "babylonjs/Lights/hemisphericLight";
  63775. export * from "babylonjs/Lights/pointLight";
  63776. export * from "babylonjs/Lights/spotLight";
  63777. }
  63778. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  63779. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63780. /**
  63781. * Header information of HDR texture files.
  63782. */
  63783. export interface HDRInfo {
  63784. /**
  63785. * The height of the texture in pixels.
  63786. */
  63787. height: number;
  63788. /**
  63789. * The width of the texture in pixels.
  63790. */
  63791. width: number;
  63792. /**
  63793. * The index of the beginning of the data in the binary file.
  63794. */
  63795. dataPosition: number;
  63796. }
  63797. /**
  63798. * This groups tools to convert HDR texture to native colors array.
  63799. */
  63800. export class HDRTools {
  63801. private static Ldexp;
  63802. private static Rgbe2float;
  63803. private static readStringLine;
  63804. /**
  63805. * Reads header information from an RGBE texture stored in a native array.
  63806. * More information on this format are available here:
  63807. * https://en.wikipedia.org/wiki/RGBE_image_format
  63808. *
  63809. * @param uint8array The binary file stored in native array.
  63810. * @return The header information.
  63811. */
  63812. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63813. /**
  63814. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63815. * This RGBE texture needs to store the information as a panorama.
  63816. *
  63817. * More information on this format are available here:
  63818. * https://en.wikipedia.org/wiki/RGBE_image_format
  63819. *
  63820. * @param buffer The binary file stored in an array buffer.
  63821. * @param size The expected size of the extracted cubemap.
  63822. * @return The Cube Map information.
  63823. */
  63824. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63825. /**
  63826. * Returns the pixels data extracted from an RGBE texture.
  63827. * This pixels will be stored left to right up to down in the R G B order in one array.
  63828. *
  63829. * More information on this format are available here:
  63830. * https://en.wikipedia.org/wiki/RGBE_image_format
  63831. *
  63832. * @param uint8array The binary file stored in an array buffer.
  63833. * @param hdrInfo The header information of the file.
  63834. * @return The pixels data in RGB right to left up to down order.
  63835. */
  63836. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63837. private static RGBE_ReadPixels_RLE;
  63838. private static RGBE_ReadPixels_NOT_RLE;
  63839. }
  63840. }
  63841. declare module "babylonjs/Materials/effectRenderer" {
  63842. import { Nullable } from "babylonjs/types";
  63843. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63844. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63845. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63846. import { Viewport } from "babylonjs/Maths/math.viewport";
  63847. import { Observable } from "babylonjs/Misc/observable";
  63848. import { Effect } from "babylonjs/Materials/effect";
  63849. import "babylonjs/Shaders/postprocess.vertex";
  63850. /**
  63851. * Effect Render Options
  63852. */
  63853. export interface IEffectRendererOptions {
  63854. /**
  63855. * Defines the vertices positions.
  63856. */
  63857. positions?: number[];
  63858. /**
  63859. * Defines the indices.
  63860. */
  63861. indices?: number[];
  63862. }
  63863. /**
  63864. * Helper class to render one or more effects.
  63865. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63866. */
  63867. export class EffectRenderer {
  63868. private engine;
  63869. private static _DefaultOptions;
  63870. private _vertexBuffers;
  63871. private _indexBuffer;
  63872. private _fullscreenViewport;
  63873. /**
  63874. * Creates an effect renderer
  63875. * @param engine the engine to use for rendering
  63876. * @param options defines the options of the effect renderer
  63877. */
  63878. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63879. /**
  63880. * Sets the current viewport in normalized coordinates 0-1
  63881. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63882. */
  63883. setViewport(viewport?: Viewport): void;
  63884. /**
  63885. * Binds the embedded attributes buffer to the effect.
  63886. * @param effect Defines the effect to bind the attributes for
  63887. */
  63888. bindBuffers(effect: Effect): void;
  63889. /**
  63890. * Sets the current effect wrapper to use during draw.
  63891. * The effect needs to be ready before calling this api.
  63892. * This also sets the default full screen position attribute.
  63893. * @param effectWrapper Defines the effect to draw with
  63894. */
  63895. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63896. /**
  63897. * Restores engine states
  63898. */
  63899. restoreStates(): void;
  63900. /**
  63901. * Draws a full screen quad.
  63902. */
  63903. draw(): void;
  63904. private isRenderTargetTexture;
  63905. /**
  63906. * renders one or more effects to a specified texture
  63907. * @param effectWrapper the effect to renderer
  63908. * @param outputTexture texture to draw to, if null it will render to the screen.
  63909. */
  63910. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63911. /**
  63912. * Disposes of the effect renderer
  63913. */
  63914. dispose(): void;
  63915. }
  63916. /**
  63917. * Options to create an EffectWrapper
  63918. */
  63919. interface EffectWrapperCreationOptions {
  63920. /**
  63921. * Engine to use to create the effect
  63922. */
  63923. engine: ThinEngine;
  63924. /**
  63925. * Fragment shader for the effect
  63926. */
  63927. fragmentShader: string;
  63928. /**
  63929. * Use the shader store instead of direct source code
  63930. */
  63931. useShaderStore?: boolean;
  63932. /**
  63933. * Vertex shader for the effect
  63934. */
  63935. vertexShader?: string;
  63936. /**
  63937. * Attributes to use in the shader
  63938. */
  63939. attributeNames?: Array<string>;
  63940. /**
  63941. * Uniforms to use in the shader
  63942. */
  63943. uniformNames?: Array<string>;
  63944. /**
  63945. * Texture sampler names to use in the shader
  63946. */
  63947. samplerNames?: Array<string>;
  63948. /**
  63949. * Defines to use in the shader
  63950. */
  63951. defines?: Array<string>;
  63952. /**
  63953. * Callback when effect is compiled
  63954. */
  63955. onCompiled?: Nullable<(effect: Effect) => void>;
  63956. /**
  63957. * The friendly name of the effect displayed in Spector.
  63958. */
  63959. name?: string;
  63960. }
  63961. /**
  63962. * Wraps an effect to be used for rendering
  63963. */
  63964. export class EffectWrapper {
  63965. /**
  63966. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63967. */
  63968. onApplyObservable: Observable<{}>;
  63969. /**
  63970. * The underlying effect
  63971. */
  63972. effect: Effect;
  63973. /**
  63974. * Creates an effect to be renderer
  63975. * @param creationOptions options to create the effect
  63976. */
  63977. constructor(creationOptions: EffectWrapperCreationOptions);
  63978. /**
  63979. * Disposes of the effect wrapper
  63980. */
  63981. dispose(): void;
  63982. }
  63983. }
  63984. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63985. /** @hidden */
  63986. export var hdrFilteringVertexShader: {
  63987. name: string;
  63988. shader: string;
  63989. };
  63990. }
  63991. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63992. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63993. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63994. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63995. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63996. /** @hidden */
  63997. export var hdrFilteringPixelShader: {
  63998. name: string;
  63999. shader: string;
  64000. };
  64001. }
  64002. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  64003. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64004. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64005. import { Nullable } from "babylonjs/types";
  64006. import "babylonjs/Shaders/hdrFiltering.vertex";
  64007. import "babylonjs/Shaders/hdrFiltering.fragment";
  64008. /**
  64009. * Options for texture filtering
  64010. */
  64011. interface IHDRFilteringOptions {
  64012. /**
  64013. * Scales pixel intensity for the input HDR map.
  64014. */
  64015. hdrScale?: number;
  64016. /**
  64017. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  64018. */
  64019. quality?: number;
  64020. }
  64021. /**
  64022. * Filters HDR maps to get correct renderings of PBR reflections
  64023. */
  64024. export class HDRFiltering {
  64025. private _engine;
  64026. private _effectRenderer;
  64027. private _effectWrapper;
  64028. private _lodGenerationOffset;
  64029. private _lodGenerationScale;
  64030. /**
  64031. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  64032. * you care about baking speed.
  64033. */
  64034. quality: number;
  64035. /**
  64036. * Scales pixel intensity for the input HDR map.
  64037. */
  64038. hdrScale: number;
  64039. /**
  64040. * Instantiates HDR filter for reflection maps
  64041. *
  64042. * @param engine Thin engine
  64043. * @param options Options
  64044. */
  64045. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64046. private _createRenderTarget;
  64047. private _prefilterInternal;
  64048. private _createEffect;
  64049. /**
  64050. * Get a value indicating if the filter is ready to be used
  64051. * @param texture Texture to filter
  64052. * @returns true if the filter is ready
  64053. */
  64054. isReady(texture: BaseTexture): boolean;
  64055. /**
  64056. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64057. * Prefiltering will be invoked at the end of next rendering pass.
  64058. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64059. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64060. * @param texture Texture to filter
  64061. * @param onFinished Callback when filtering is done
  64062. * @return Promise called when prefiltering is done
  64063. */
  64064. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  64065. }
  64066. }
  64067. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  64068. import { Nullable } from "babylonjs/types";
  64069. import { Scene } from "babylonjs/scene";
  64070. import { Matrix, Vector3 } 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. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  64075. /**
  64076. * This represents a texture coming from an HDR input.
  64077. *
  64078. * The only supported format is currently panorama picture stored in RGBE format.
  64079. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64080. */
  64081. export class HDRCubeTexture extends BaseTexture {
  64082. private static _facesMapping;
  64083. private _generateHarmonics;
  64084. private _noMipmap;
  64085. private _prefilterOnLoad;
  64086. private _textureMatrix;
  64087. private _size;
  64088. private _onLoad;
  64089. private _onError;
  64090. /**
  64091. * The texture URL.
  64092. */
  64093. url: string;
  64094. protected _isBlocking: boolean;
  64095. /**
  64096. * Sets wether or not the texture is blocking during loading.
  64097. */
  64098. set isBlocking(value: boolean);
  64099. /**
  64100. * Gets wether or not the texture is blocking during loading.
  64101. */
  64102. get isBlocking(): boolean;
  64103. protected _rotationY: number;
  64104. /**
  64105. * Sets texture matrix rotation angle around Y axis in radians.
  64106. */
  64107. set rotationY(value: number);
  64108. /**
  64109. * Gets texture matrix rotation angle around Y axis radians.
  64110. */
  64111. get rotationY(): number;
  64112. /**
  64113. * Gets or sets the center of the bounding box associated with the cube texture
  64114. * It must define where the camera used to render the texture was set
  64115. */
  64116. boundingBoxPosition: Vector3;
  64117. private _boundingBoxSize;
  64118. /**
  64119. * Gets or sets the size of the bounding box associated with the cube texture
  64120. * When defined, the cubemap will switch to local mode
  64121. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64122. * @example https://www.babylonjs-playground.com/#RNASML
  64123. */
  64124. set boundingBoxSize(value: Vector3);
  64125. get boundingBoxSize(): Vector3;
  64126. /**
  64127. * Instantiates an HDRTexture from the following parameters.
  64128. *
  64129. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64130. * @param sceneOrEngine The scene or engine the texture will be used in
  64131. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64132. * @param noMipmap Forces to not generate the mipmap if true
  64133. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64134. * @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)
  64135. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64136. */
  64137. 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>);
  64138. /**
  64139. * Get the current class name of the texture useful for serialization or dynamic coding.
  64140. * @returns "HDRCubeTexture"
  64141. */
  64142. getClassName(): string;
  64143. /**
  64144. * Occurs when the file is raw .hdr file.
  64145. */
  64146. private loadTexture;
  64147. clone(): HDRCubeTexture;
  64148. delayLoad(): void;
  64149. /**
  64150. * Get the texture reflection matrix used to rotate/transform the reflection.
  64151. * @returns the reflection matrix
  64152. */
  64153. getReflectionTextureMatrix(): Matrix;
  64154. /**
  64155. * Set the texture reflection matrix used to rotate/transform the reflection.
  64156. * @param value Define the reflection matrix to set
  64157. */
  64158. setReflectionTextureMatrix(value: Matrix): void;
  64159. /**
  64160. * Parses a JSON representation of an HDR Texture in order to create the texture
  64161. * @param parsedTexture Define the JSON representation
  64162. * @param scene Define the scene the texture should be created in
  64163. * @param rootUrl Define the root url in case we need to load relative dependencies
  64164. * @returns the newly created texture after parsing
  64165. */
  64166. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64167. serialize(): any;
  64168. }
  64169. }
  64170. declare module "babylonjs/Physics/physicsEngine" {
  64171. import { Nullable } from "babylonjs/types";
  64172. import { Vector3 } from "babylonjs/Maths/math.vector";
  64173. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64174. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  64175. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  64176. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64177. /**
  64178. * Class used to control physics engine
  64179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64180. */
  64181. export class PhysicsEngine implements IPhysicsEngine {
  64182. private _physicsPlugin;
  64183. /**
  64184. * Global value used to control the smallest number supported by the simulation
  64185. */
  64186. static Epsilon: number;
  64187. private _impostors;
  64188. private _joints;
  64189. private _subTimeStep;
  64190. /**
  64191. * Gets the gravity vector used by the simulation
  64192. */
  64193. gravity: Vector3;
  64194. /**
  64195. * Factory used to create the default physics plugin.
  64196. * @returns The default physics plugin
  64197. */
  64198. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64199. /**
  64200. * Creates a new Physics Engine
  64201. * @param gravity defines the gravity vector used by the simulation
  64202. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64203. */
  64204. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64205. /**
  64206. * Sets the gravity vector used by the simulation
  64207. * @param gravity defines the gravity vector to use
  64208. */
  64209. setGravity(gravity: Vector3): void;
  64210. /**
  64211. * Set the time step of the physics engine.
  64212. * Default is 1/60.
  64213. * To slow it down, enter 1/600 for example.
  64214. * To speed it up, 1/30
  64215. * @param newTimeStep defines the new timestep to apply to this world.
  64216. */
  64217. setTimeStep(newTimeStep?: number): void;
  64218. /**
  64219. * Get the time step of the physics engine.
  64220. * @returns the current time step
  64221. */
  64222. getTimeStep(): number;
  64223. /**
  64224. * Set the sub time step of the physics engine.
  64225. * Default is 0 meaning there is no sub steps
  64226. * To increase physics resolution precision, set a small value (like 1 ms)
  64227. * @param subTimeStep defines the new sub timestep used for physics resolution.
  64228. */
  64229. setSubTimeStep(subTimeStep?: number): void;
  64230. /**
  64231. * Get the sub time step of the physics engine.
  64232. * @returns the current sub time step
  64233. */
  64234. getSubTimeStep(): number;
  64235. /**
  64236. * Release all resources
  64237. */
  64238. dispose(): void;
  64239. /**
  64240. * Gets the name of the current physics plugin
  64241. * @returns the name of the plugin
  64242. */
  64243. getPhysicsPluginName(): string;
  64244. /**
  64245. * Adding a new impostor for the impostor tracking.
  64246. * This will be done by the impostor itself.
  64247. * @param impostor the impostor to add
  64248. */
  64249. addImpostor(impostor: PhysicsImpostor): void;
  64250. /**
  64251. * Remove an impostor from the engine.
  64252. * This impostor and its mesh will not longer be updated by the physics engine.
  64253. * @param impostor the impostor to remove
  64254. */
  64255. removeImpostor(impostor: PhysicsImpostor): void;
  64256. /**
  64257. * Add a joint to the physics engine
  64258. * @param mainImpostor defines the main impostor to which the joint is added.
  64259. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  64260. * @param joint defines the joint that will connect both impostors.
  64261. */
  64262. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64263. /**
  64264. * Removes a joint from the simulation
  64265. * @param mainImpostor defines the impostor used with the joint
  64266. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  64267. * @param joint defines the joint to remove
  64268. */
  64269. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64270. /**
  64271. * Called by the scene. No need to call it.
  64272. * @param delta defines the timespam between frames
  64273. */
  64274. _step(delta: number): void;
  64275. /**
  64276. * Gets the current plugin used to run the simulation
  64277. * @returns current plugin
  64278. */
  64279. getPhysicsPlugin(): IPhysicsEnginePlugin;
  64280. /**
  64281. * Gets the list of physic impostors
  64282. * @returns an array of PhysicsImpostor
  64283. */
  64284. getImpostors(): Array<PhysicsImpostor>;
  64285. /**
  64286. * Gets the impostor for a physics enabled object
  64287. * @param object defines the object impersonated by the impostor
  64288. * @returns the PhysicsImpostor or null if not found
  64289. */
  64290. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  64291. /**
  64292. * Gets the impostor for a physics body object
  64293. * @param body defines physics body used by the impostor
  64294. * @returns the PhysicsImpostor or null if not found
  64295. */
  64296. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  64297. /**
  64298. * Does a raycast in the physics world
  64299. * @param from when should the ray start?
  64300. * @param to when should the ray end?
  64301. * @returns PhysicsRaycastResult
  64302. */
  64303. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64304. }
  64305. }
  64306. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  64307. import { Nullable } from "babylonjs/types";
  64308. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64310. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64311. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64312. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64313. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64314. /** @hidden */
  64315. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  64316. private _useDeltaForWorldStep;
  64317. world: any;
  64318. name: string;
  64319. private _physicsMaterials;
  64320. private _fixedTimeStep;
  64321. private _cannonRaycastResult;
  64322. private _raycastResult;
  64323. private _physicsBodysToRemoveAfterStep;
  64324. private _firstFrame;
  64325. BJSCANNON: any;
  64326. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  64327. setGravity(gravity: Vector3): void;
  64328. setTimeStep(timeStep: number): void;
  64329. getTimeStep(): number;
  64330. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64331. private _removeMarkedPhysicsBodiesFromWorld;
  64332. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64333. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64334. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64335. private _processChildMeshes;
  64336. removePhysicsBody(impostor: PhysicsImpostor): void;
  64337. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64338. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64339. private _addMaterial;
  64340. private _checkWithEpsilon;
  64341. private _createShape;
  64342. private _createHeightmap;
  64343. private _minus90X;
  64344. private _plus90X;
  64345. private _tmpPosition;
  64346. private _tmpDeltaPosition;
  64347. private _tmpUnityRotation;
  64348. private _updatePhysicsBodyTransformation;
  64349. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64350. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64351. isSupported(): boolean;
  64352. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64353. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64354. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64355. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64356. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64357. getBodyMass(impostor: PhysicsImpostor): number;
  64358. getBodyFriction(impostor: PhysicsImpostor): number;
  64359. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64360. getBodyRestitution(impostor: PhysicsImpostor): number;
  64361. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64362. sleepBody(impostor: PhysicsImpostor): void;
  64363. wakeUpBody(impostor: PhysicsImpostor): void;
  64364. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  64365. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64366. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64367. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64368. getRadius(impostor: PhysicsImpostor): number;
  64369. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64370. dispose(): void;
  64371. private _extendNamespace;
  64372. /**
  64373. * Does a raycast in the physics world
  64374. * @param from when should the ray start?
  64375. * @param to when should the ray end?
  64376. * @returns PhysicsRaycastResult
  64377. */
  64378. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64379. }
  64380. }
  64381. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  64382. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64383. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64384. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64386. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64387. import { Nullable } from "babylonjs/types";
  64388. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64389. /** @hidden */
  64390. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  64391. private _useDeltaForWorldStep;
  64392. world: any;
  64393. name: string;
  64394. BJSOIMO: any;
  64395. private _raycastResult;
  64396. private _fixedTimeStep;
  64397. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  64398. setGravity(gravity: Vector3): void;
  64399. setTimeStep(timeStep: number): void;
  64400. getTimeStep(): number;
  64401. private _tmpImpostorsArray;
  64402. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64403. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64404. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64405. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64406. private _tmpPositionVector;
  64407. removePhysicsBody(impostor: PhysicsImpostor): void;
  64408. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64409. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64410. isSupported(): boolean;
  64411. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64412. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64413. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64414. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64415. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64416. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64417. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64418. getBodyMass(impostor: PhysicsImpostor): number;
  64419. getBodyFriction(impostor: PhysicsImpostor): number;
  64420. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64421. getBodyRestitution(impostor: PhysicsImpostor): number;
  64422. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64423. sleepBody(impostor: PhysicsImpostor): void;
  64424. wakeUpBody(impostor: PhysicsImpostor): void;
  64425. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64426. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  64427. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  64428. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64429. getRadius(impostor: PhysicsImpostor): number;
  64430. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64431. dispose(): void;
  64432. /**
  64433. * Does a raycast in the physics world
  64434. * @param from when should the ray start?
  64435. * @param to when should the ray end?
  64436. * @returns PhysicsRaycastResult
  64437. */
  64438. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64439. }
  64440. }
  64441. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  64442. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  64443. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64444. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64445. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64446. import { Nullable } from "babylonjs/types";
  64447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64448. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64449. /**
  64450. * AmmoJS Physics plugin
  64451. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64452. * @see https://github.com/kripken/ammo.js/
  64453. */
  64454. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  64455. private _useDeltaForWorldStep;
  64456. /**
  64457. * Reference to the Ammo library
  64458. */
  64459. bjsAMMO: any;
  64460. /**
  64461. * Created ammoJS world which physics bodies are added to
  64462. */
  64463. world: any;
  64464. /**
  64465. * Name of the plugin
  64466. */
  64467. name: string;
  64468. private _timeStep;
  64469. private _fixedTimeStep;
  64470. private _maxSteps;
  64471. private _tmpQuaternion;
  64472. private _tmpAmmoTransform;
  64473. private _tmpAmmoQuaternion;
  64474. private _tmpAmmoConcreteContactResultCallback;
  64475. private _collisionConfiguration;
  64476. private _dispatcher;
  64477. private _overlappingPairCache;
  64478. private _solver;
  64479. private _softBodySolver;
  64480. private _tmpAmmoVectorA;
  64481. private _tmpAmmoVectorB;
  64482. private _tmpAmmoVectorC;
  64483. private _tmpAmmoVectorD;
  64484. private _tmpContactCallbackResult;
  64485. private _tmpAmmoVectorRCA;
  64486. private _tmpAmmoVectorRCB;
  64487. private _raycastResult;
  64488. private _tmpContactPoint;
  64489. private static readonly DISABLE_COLLISION_FLAG;
  64490. private static readonly KINEMATIC_FLAG;
  64491. private static readonly DISABLE_DEACTIVATION_FLAG;
  64492. /**
  64493. * Initializes the ammoJS plugin
  64494. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  64495. * @param ammoInjection can be used to inject your own ammo reference
  64496. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  64497. */
  64498. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  64499. /**
  64500. * Sets the gravity of the physics world (m/(s^2))
  64501. * @param gravity Gravity to set
  64502. */
  64503. setGravity(gravity: Vector3): void;
  64504. /**
  64505. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  64506. * @param timeStep timestep to use in seconds
  64507. */
  64508. setTimeStep(timeStep: number): void;
  64509. /**
  64510. * 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)
  64511. * @param fixedTimeStep fixedTimeStep to use in seconds
  64512. */
  64513. setFixedTimeStep(fixedTimeStep: number): void;
  64514. /**
  64515. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  64516. * @param maxSteps the maximum number of steps by the physics engine per frame
  64517. */
  64518. setMaxSteps(maxSteps: number): void;
  64519. /**
  64520. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  64521. * @returns the current timestep in seconds
  64522. */
  64523. getTimeStep(): number;
  64524. /**
  64525. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  64526. */
  64527. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  64528. private _isImpostorInContact;
  64529. private _isImpostorPairInContact;
  64530. private _stepSimulation;
  64531. /**
  64532. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  64533. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  64534. * After the step the babylon meshes are set to the position of the physics imposters
  64535. * @param delta amount of time to step forward
  64536. * @param impostors array of imposters to update before/after the step
  64537. */
  64538. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64539. /**
  64540. * Update babylon mesh to match physics world object
  64541. * @param impostor imposter to match
  64542. */
  64543. private _afterSoftStep;
  64544. /**
  64545. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64546. * @param impostor imposter to match
  64547. */
  64548. private _ropeStep;
  64549. /**
  64550. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64551. * @param impostor imposter to match
  64552. */
  64553. private _softbodyOrClothStep;
  64554. private _tmpMatrix;
  64555. /**
  64556. * Applies an impulse on the imposter
  64557. * @param impostor imposter to apply impulse to
  64558. * @param force amount of force to be applied to the imposter
  64559. * @param contactPoint the location to apply the impulse on the imposter
  64560. */
  64561. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64562. /**
  64563. * Applies a force on the imposter
  64564. * @param impostor imposter to apply force
  64565. * @param force amount of force to be applied to the imposter
  64566. * @param contactPoint the location to apply the force on the imposter
  64567. */
  64568. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64569. /**
  64570. * Creates a physics body using the plugin
  64571. * @param impostor the imposter to create the physics body on
  64572. */
  64573. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64574. /**
  64575. * Removes the physics body from the imposter and disposes of the body's memory
  64576. * @param impostor imposter to remove the physics body from
  64577. */
  64578. removePhysicsBody(impostor: PhysicsImpostor): void;
  64579. /**
  64580. * Generates a joint
  64581. * @param impostorJoint the imposter joint to create the joint with
  64582. */
  64583. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64584. /**
  64585. * Removes a joint
  64586. * @param impostorJoint the imposter joint to remove the joint from
  64587. */
  64588. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64589. private _addMeshVerts;
  64590. /**
  64591. * Initialise the soft body vertices to match its object's (mesh) vertices
  64592. * Softbody vertices (nodes) are in world space and to match this
  64593. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  64594. * @param impostor to create the softbody for
  64595. */
  64596. private _softVertexData;
  64597. /**
  64598. * Create an impostor's soft body
  64599. * @param impostor to create the softbody for
  64600. */
  64601. private _createSoftbody;
  64602. /**
  64603. * Create cloth for an impostor
  64604. * @param impostor to create the softbody for
  64605. */
  64606. private _createCloth;
  64607. /**
  64608. * Create rope for an impostor
  64609. * @param impostor to create the softbody for
  64610. */
  64611. private _createRope;
  64612. /**
  64613. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  64614. * @param impostor to create the custom physics shape for
  64615. */
  64616. private _createCustom;
  64617. private _addHullVerts;
  64618. private _createShape;
  64619. /**
  64620. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  64621. * @param impostor imposter containing the physics body and babylon object
  64622. */
  64623. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64624. /**
  64625. * Sets the babylon object's position/rotation from the physics body's position/rotation
  64626. * @param impostor imposter containing the physics body and babylon object
  64627. * @param newPosition new position
  64628. * @param newRotation new rotation
  64629. */
  64630. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64631. /**
  64632. * If this plugin is supported
  64633. * @returns true if its supported
  64634. */
  64635. isSupported(): boolean;
  64636. /**
  64637. * Sets the linear velocity of the physics body
  64638. * @param impostor imposter to set the velocity on
  64639. * @param velocity velocity to set
  64640. */
  64641. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64642. /**
  64643. * Sets the angular velocity of the physics body
  64644. * @param impostor imposter to set the velocity on
  64645. * @param velocity velocity to set
  64646. */
  64647. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64648. /**
  64649. * gets the linear velocity
  64650. * @param impostor imposter to get linear velocity from
  64651. * @returns linear velocity
  64652. */
  64653. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64654. /**
  64655. * gets the angular velocity
  64656. * @param impostor imposter to get angular velocity from
  64657. * @returns angular velocity
  64658. */
  64659. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64660. /**
  64661. * Sets the mass of physics body
  64662. * @param impostor imposter to set the mass on
  64663. * @param mass mass to set
  64664. */
  64665. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64666. /**
  64667. * Gets the mass of the physics body
  64668. * @param impostor imposter to get the mass from
  64669. * @returns mass
  64670. */
  64671. getBodyMass(impostor: PhysicsImpostor): number;
  64672. /**
  64673. * Gets friction of the impostor
  64674. * @param impostor impostor to get friction from
  64675. * @returns friction value
  64676. */
  64677. getBodyFriction(impostor: PhysicsImpostor): number;
  64678. /**
  64679. * Sets friction of the impostor
  64680. * @param impostor impostor to set friction on
  64681. * @param friction friction value
  64682. */
  64683. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64684. /**
  64685. * Gets restitution of the impostor
  64686. * @param impostor impostor to get restitution from
  64687. * @returns restitution value
  64688. */
  64689. getBodyRestitution(impostor: PhysicsImpostor): number;
  64690. /**
  64691. * Sets resitution of the impostor
  64692. * @param impostor impostor to set resitution on
  64693. * @param restitution resitution value
  64694. */
  64695. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64696. /**
  64697. * Gets pressure inside the impostor
  64698. * @param impostor impostor to get pressure from
  64699. * @returns pressure value
  64700. */
  64701. getBodyPressure(impostor: PhysicsImpostor): number;
  64702. /**
  64703. * Sets pressure inside a soft body impostor
  64704. * Cloth and rope must remain 0 pressure
  64705. * @param impostor impostor to set pressure on
  64706. * @param pressure pressure value
  64707. */
  64708. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  64709. /**
  64710. * Gets stiffness of the impostor
  64711. * @param impostor impostor to get stiffness from
  64712. * @returns pressure value
  64713. */
  64714. getBodyStiffness(impostor: PhysicsImpostor): number;
  64715. /**
  64716. * Sets stiffness of the impostor
  64717. * @param impostor impostor to set stiffness on
  64718. * @param stiffness stiffness value from 0 to 1
  64719. */
  64720. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  64721. /**
  64722. * Gets velocityIterations of the impostor
  64723. * @param impostor impostor to get velocity iterations from
  64724. * @returns velocityIterations value
  64725. */
  64726. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  64727. /**
  64728. * Sets velocityIterations of the impostor
  64729. * @param impostor impostor to set velocity iterations on
  64730. * @param velocityIterations velocityIterations value
  64731. */
  64732. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64733. /**
  64734. * Gets positionIterations of the impostor
  64735. * @param impostor impostor to get position iterations from
  64736. * @returns positionIterations value
  64737. */
  64738. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64739. /**
  64740. * Sets positionIterations of the impostor
  64741. * @param impostor impostor to set position on
  64742. * @param positionIterations positionIterations value
  64743. */
  64744. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  64745. /**
  64746. * Append an anchor to a cloth object
  64747. * @param impostor is the cloth impostor to add anchor to
  64748. * @param otherImpostor is the rigid impostor to anchor to
  64749. * @param width ratio across width from 0 to 1
  64750. * @param height ratio up height from 0 to 1
  64751. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  64752. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64753. */
  64754. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64755. /**
  64756. * Append an hook to a rope object
  64757. * @param impostor is the rope impostor to add hook to
  64758. * @param otherImpostor is the rigid impostor to hook to
  64759. * @param length ratio along the rope from 0 to 1
  64760. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  64761. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64762. */
  64763. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64764. /**
  64765. * Sleeps the physics body and stops it from being active
  64766. * @param impostor impostor to sleep
  64767. */
  64768. sleepBody(impostor: PhysicsImpostor): void;
  64769. /**
  64770. * Activates the physics body
  64771. * @param impostor impostor to activate
  64772. */
  64773. wakeUpBody(impostor: PhysicsImpostor): void;
  64774. /**
  64775. * Updates the distance parameters of the joint
  64776. * @param joint joint to update
  64777. * @param maxDistance maximum distance of the joint
  64778. * @param minDistance minimum distance of the joint
  64779. */
  64780. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64781. /**
  64782. * Sets a motor on the joint
  64783. * @param joint joint to set motor on
  64784. * @param speed speed of the motor
  64785. * @param maxForce maximum force of the motor
  64786. * @param motorIndex index of the motor
  64787. */
  64788. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64789. /**
  64790. * Sets the motors limit
  64791. * @param joint joint to set limit on
  64792. * @param upperLimit upper limit
  64793. * @param lowerLimit lower limit
  64794. */
  64795. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64796. /**
  64797. * Syncs the position and rotation of a mesh with the impostor
  64798. * @param mesh mesh to sync
  64799. * @param impostor impostor to update the mesh with
  64800. */
  64801. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64802. /**
  64803. * Gets the radius of the impostor
  64804. * @param impostor impostor to get radius from
  64805. * @returns the radius
  64806. */
  64807. getRadius(impostor: PhysicsImpostor): number;
  64808. /**
  64809. * Gets the box size of the impostor
  64810. * @param impostor impostor to get box size from
  64811. * @param result the resulting box size
  64812. */
  64813. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64814. /**
  64815. * Disposes of the impostor
  64816. */
  64817. dispose(): void;
  64818. /**
  64819. * Does a raycast in the physics world
  64820. * @param from when should the ray start?
  64821. * @param to when should the ray end?
  64822. * @returns PhysicsRaycastResult
  64823. */
  64824. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64825. }
  64826. }
  64827. declare module "babylonjs/Probes/reflectionProbe" {
  64828. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64829. import { Vector3 } from "babylonjs/Maths/math.vector";
  64830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64831. import { Nullable } from "babylonjs/types";
  64832. import { Scene } from "babylonjs/scene";
  64833. module "babylonjs/abstractScene" {
  64834. interface AbstractScene {
  64835. /**
  64836. * The list of reflection probes added to the scene
  64837. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64838. */
  64839. reflectionProbes: Array<ReflectionProbe>;
  64840. /**
  64841. * Removes the given reflection probe from this scene.
  64842. * @param toRemove The reflection probe to remove
  64843. * @returns The index of the removed reflection probe
  64844. */
  64845. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64846. /**
  64847. * Adds the given reflection probe to this scene.
  64848. * @param newReflectionProbe The reflection probe to add
  64849. */
  64850. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64851. }
  64852. }
  64853. /**
  64854. * Class used to generate realtime reflection / refraction cube textures
  64855. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64856. */
  64857. export class ReflectionProbe {
  64858. /** defines the name of the probe */
  64859. name: string;
  64860. private _scene;
  64861. private _renderTargetTexture;
  64862. private _projectionMatrix;
  64863. private _viewMatrix;
  64864. private _target;
  64865. private _add;
  64866. private _attachedMesh;
  64867. private _invertYAxis;
  64868. /** Gets or sets probe position (center of the cube map) */
  64869. position: Vector3;
  64870. /**
  64871. * Creates a new reflection probe
  64872. * @param name defines the name of the probe
  64873. * @param size defines the texture resolution (for each face)
  64874. * @param scene defines the hosting scene
  64875. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64876. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64877. */
  64878. constructor(
  64879. /** defines the name of the probe */
  64880. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64881. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64882. get samples(): number;
  64883. set samples(value: number);
  64884. /** Gets or sets the refresh rate to use (on every frame by default) */
  64885. get refreshRate(): number;
  64886. set refreshRate(value: number);
  64887. /**
  64888. * Gets the hosting scene
  64889. * @returns a Scene
  64890. */
  64891. getScene(): Scene;
  64892. /** Gets the internal CubeTexture used to render to */
  64893. get cubeTexture(): RenderTargetTexture;
  64894. /** Gets the list of meshes to render */
  64895. get renderList(): Nullable<AbstractMesh[]>;
  64896. /**
  64897. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64898. * @param mesh defines the mesh to attach to
  64899. */
  64900. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64901. /**
  64902. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64903. * @param renderingGroupId The rendering group id corresponding to its index
  64904. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64905. */
  64906. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64907. /**
  64908. * Clean all associated resources
  64909. */
  64910. dispose(): void;
  64911. /**
  64912. * Converts the reflection probe information to a readable string for debug purpose.
  64913. * @param fullDetails Supports for multiple levels of logging within scene loading
  64914. * @returns the human readable reflection probe info
  64915. */
  64916. toString(fullDetails?: boolean): string;
  64917. /**
  64918. * Get the class name of the relfection probe.
  64919. * @returns "ReflectionProbe"
  64920. */
  64921. getClassName(): string;
  64922. /**
  64923. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64924. * @returns The JSON representation of the texture
  64925. */
  64926. serialize(): any;
  64927. /**
  64928. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64929. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64930. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64931. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64932. * @returns The parsed reflection probe if successful
  64933. */
  64934. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64935. }
  64936. }
  64937. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64938. /** @hidden */
  64939. export var _BabylonLoaderRegistered: boolean;
  64940. /**
  64941. * Helps setting up some configuration for the babylon file loader.
  64942. */
  64943. export class BabylonFileLoaderConfiguration {
  64944. /**
  64945. * The loader does not allow injecting custom physix engine into the plugins.
  64946. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64947. * So you could set this variable to your engine import to make it work.
  64948. */
  64949. static LoaderInjectedPhysicsEngine: any;
  64950. }
  64951. }
  64952. declare module "babylonjs/Loading/Plugins/index" {
  64953. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64954. }
  64955. declare module "babylonjs/Loading/index" {
  64956. export * from "babylonjs/Loading/loadingScreen";
  64957. export * from "babylonjs/Loading/Plugins/index";
  64958. export * from "babylonjs/Loading/sceneLoader";
  64959. export * from "babylonjs/Loading/sceneLoaderFlags";
  64960. }
  64961. declare module "babylonjs/Materials/Background/index" {
  64962. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64963. }
  64964. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64965. import { Scene } from "babylonjs/scene";
  64966. import { Color3 } from "babylonjs/Maths/math.color";
  64967. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64968. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64969. /**
  64970. * The Physically based simple base material of BJS.
  64971. *
  64972. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64973. * It is used as the base class for both the specGloss and metalRough conventions.
  64974. */
  64975. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64976. /**
  64977. * Number of Simultaneous lights allowed on the material.
  64978. */
  64979. maxSimultaneousLights: number;
  64980. /**
  64981. * If sets to true, disables all the lights affecting the material.
  64982. */
  64983. disableLighting: boolean;
  64984. /**
  64985. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64986. */
  64987. environmentTexture: BaseTexture;
  64988. /**
  64989. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64990. */
  64991. invertNormalMapX: boolean;
  64992. /**
  64993. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64994. */
  64995. invertNormalMapY: boolean;
  64996. /**
  64997. * Normal map used in the model.
  64998. */
  64999. normalTexture: BaseTexture;
  65000. /**
  65001. * Emissivie color used to self-illuminate the model.
  65002. */
  65003. emissiveColor: Color3;
  65004. /**
  65005. * Emissivie texture used to self-illuminate the model.
  65006. */
  65007. emissiveTexture: BaseTexture;
  65008. /**
  65009. * Occlusion Channel Strenght.
  65010. */
  65011. occlusionStrength: number;
  65012. /**
  65013. * Occlusion Texture of the material (adding extra occlusion effects).
  65014. */
  65015. occlusionTexture: BaseTexture;
  65016. /**
  65017. * Defines the alpha limits in alpha test mode.
  65018. */
  65019. alphaCutOff: number;
  65020. /**
  65021. * Gets the current double sided mode.
  65022. */
  65023. get doubleSided(): boolean;
  65024. /**
  65025. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  65026. */
  65027. set doubleSided(value: boolean);
  65028. /**
  65029. * Stores the pre-calculated light information of a mesh in a texture.
  65030. */
  65031. lightmapTexture: BaseTexture;
  65032. /**
  65033. * If true, the light map contains occlusion information instead of lighting info.
  65034. */
  65035. useLightmapAsShadowmap: boolean;
  65036. /**
  65037. * Instantiates a new PBRMaterial instance.
  65038. *
  65039. * @param name The material name
  65040. * @param scene The scene the material will be use in.
  65041. */
  65042. constructor(name: string, scene: Scene);
  65043. getClassName(): string;
  65044. }
  65045. }
  65046. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  65047. import { Scene } from "babylonjs/scene";
  65048. import { Color3 } from "babylonjs/Maths/math.color";
  65049. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65050. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65051. /**
  65052. * The PBR material of BJS following the metal roughness convention.
  65053. *
  65054. * This fits to the PBR convention in the GLTF definition:
  65055. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65056. */
  65057. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65058. /**
  65059. * The base color has two different interpretations depending on the value of metalness.
  65060. * When the material is a metal, the base color is the specific measured reflectance value
  65061. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65062. * of the material.
  65063. */
  65064. baseColor: Color3;
  65065. /**
  65066. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65067. * well as opacity information in the alpha channel.
  65068. */
  65069. baseTexture: BaseTexture;
  65070. /**
  65071. * Specifies the metallic scalar value of the material.
  65072. * Can also be used to scale the metalness values of the metallic texture.
  65073. */
  65074. metallic: number;
  65075. /**
  65076. * Specifies the roughness scalar value of the material.
  65077. * Can also be used to scale the roughness values of the metallic texture.
  65078. */
  65079. roughness: number;
  65080. /**
  65081. * Texture containing both the metallic value in the B channel and the
  65082. * roughness value in the G channel to keep better precision.
  65083. */
  65084. metallicRoughnessTexture: BaseTexture;
  65085. /**
  65086. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65087. *
  65088. * @param name The material name
  65089. * @param scene The scene the material will be use in.
  65090. */
  65091. constructor(name: string, scene: Scene);
  65092. /**
  65093. * Return the currrent class name of the material.
  65094. */
  65095. getClassName(): string;
  65096. /**
  65097. * Makes a duplicate of the current material.
  65098. * @param name - name to use for the new material.
  65099. */
  65100. clone(name: string): PBRMetallicRoughnessMaterial;
  65101. /**
  65102. * Serialize the material to a parsable JSON object.
  65103. */
  65104. serialize(): any;
  65105. /**
  65106. * Parses a JSON object correponding to the serialize function.
  65107. */
  65108. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65109. }
  65110. }
  65111. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  65112. import { Scene } from "babylonjs/scene";
  65113. import { Color3 } from "babylonjs/Maths/math.color";
  65114. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65115. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65116. /**
  65117. * The PBR material of BJS following the specular glossiness convention.
  65118. *
  65119. * This fits to the PBR convention in the GLTF definition:
  65120. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65121. */
  65122. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65123. /**
  65124. * Specifies the diffuse color of the material.
  65125. */
  65126. diffuseColor: Color3;
  65127. /**
  65128. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65129. * channel.
  65130. */
  65131. diffuseTexture: BaseTexture;
  65132. /**
  65133. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65134. */
  65135. specularColor: Color3;
  65136. /**
  65137. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65138. */
  65139. glossiness: number;
  65140. /**
  65141. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65142. */
  65143. specularGlossinessTexture: BaseTexture;
  65144. /**
  65145. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65146. *
  65147. * @param name The material name
  65148. * @param scene The scene the material will be use in.
  65149. */
  65150. constructor(name: string, scene: Scene);
  65151. /**
  65152. * Return the currrent class name of the material.
  65153. */
  65154. getClassName(): string;
  65155. /**
  65156. * Makes a duplicate of the current material.
  65157. * @param name - name to use for the new material.
  65158. */
  65159. clone(name: string): PBRSpecularGlossinessMaterial;
  65160. /**
  65161. * Serialize the material to a parsable JSON object.
  65162. */
  65163. serialize(): any;
  65164. /**
  65165. * Parses a JSON object correponding to the serialize function.
  65166. */
  65167. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65168. }
  65169. }
  65170. declare module "babylonjs/Materials/PBR/index" {
  65171. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65172. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65173. export * from "babylonjs/Materials/PBR/pbrMaterial";
  65174. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  65175. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  65176. }
  65177. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  65178. import { Nullable } from "babylonjs/types";
  65179. import { Scene } from "babylonjs/scene";
  65180. import { Matrix } from "babylonjs/Maths/math.vector";
  65181. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65182. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65183. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65184. /**
  65185. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65186. * It can help converting any input color in a desired output one. This can then be used to create effects
  65187. * from sepia, black and white to sixties or futuristic rendering...
  65188. *
  65189. * The only supported format is currently 3dl.
  65190. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65191. */
  65192. export class ColorGradingTexture extends BaseTexture {
  65193. /**
  65194. * The texture URL.
  65195. */
  65196. url: string;
  65197. /**
  65198. * Empty line regex stored for GC.
  65199. */
  65200. private static _noneEmptyLineRegex;
  65201. private _textureMatrix;
  65202. private _onLoad;
  65203. /**
  65204. * Instantiates a ColorGradingTexture from the following parameters.
  65205. *
  65206. * @param url The location of the color gradind data (currently only supporting 3dl)
  65207. * @param sceneOrEngine The scene or engine the texture will be used in
  65208. * @param onLoad defines a callback triggered when the texture has been loaded
  65209. */
  65210. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65211. /**
  65212. * Fires the onload event from the constructor if requested.
  65213. */
  65214. private _triggerOnLoad;
  65215. /**
  65216. * Returns the texture matrix used in most of the material.
  65217. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65218. */
  65219. getTextureMatrix(): Matrix;
  65220. /**
  65221. * Occurs when the file being loaded is a .3dl LUT file.
  65222. */
  65223. private load3dlTexture;
  65224. /**
  65225. * Starts the loading process of the texture.
  65226. */
  65227. private loadTexture;
  65228. /**
  65229. * Clones the color gradind texture.
  65230. */
  65231. clone(): ColorGradingTexture;
  65232. /**
  65233. * Called during delayed load for textures.
  65234. */
  65235. delayLoad(): void;
  65236. /**
  65237. * Parses a color grading texture serialized by Babylon.
  65238. * @param parsedTexture The texture information being parsedTexture
  65239. * @param scene The scene to load the texture in
  65240. * @param rootUrl The root url of the data assets to load
  65241. * @return A color gradind texture
  65242. */
  65243. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65244. /**
  65245. * Serializes the LUT texture to json format.
  65246. */
  65247. serialize(): any;
  65248. }
  65249. }
  65250. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  65251. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65252. import { Scene } from "babylonjs/scene";
  65253. import { Nullable } from "babylonjs/types";
  65254. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65255. /**
  65256. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  65257. */
  65258. export class EquiRectangularCubeTexture extends BaseTexture {
  65259. /** The six faces of the cube. */
  65260. private static _FacesMapping;
  65261. private _noMipmap;
  65262. private _onLoad;
  65263. private _onError;
  65264. /** The size of the cubemap. */
  65265. private _size;
  65266. /** The buffer of the image. */
  65267. private _buffer;
  65268. /** The width of the input image. */
  65269. private _width;
  65270. /** The height of the input image. */
  65271. private _height;
  65272. /** The URL to the image. */
  65273. url: string;
  65274. /**
  65275. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  65276. * @param url The location of the image
  65277. * @param scene The scene the texture will be used in
  65278. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65279. * @param noMipmap Forces to not generate the mipmap if true
  65280. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65281. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65282. * @param onLoad — defines a callback called when texture is loaded
  65283. * @param onError — defines a callback called if there is an error
  65284. */
  65285. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  65286. /**
  65287. * Load the image data, by putting the image on a canvas and extracting its buffer.
  65288. */
  65289. private loadImage;
  65290. /**
  65291. * Convert the image buffer into a cubemap and create a CubeTexture.
  65292. */
  65293. private loadTexture;
  65294. /**
  65295. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  65296. * @param buffer The ArrayBuffer that should be converted.
  65297. * @returns The buffer as Float32Array.
  65298. */
  65299. private getFloat32ArrayFromArrayBuffer;
  65300. /**
  65301. * Get the current class name of the texture useful for serialization or dynamic coding.
  65302. * @returns "EquiRectangularCubeTexture"
  65303. */
  65304. getClassName(): string;
  65305. /**
  65306. * Create a clone of the current EquiRectangularCubeTexture and return it.
  65307. * @returns A clone of the current EquiRectangularCubeTexture.
  65308. */
  65309. clone(): EquiRectangularCubeTexture;
  65310. }
  65311. }
  65312. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  65313. import { Nullable } from "babylonjs/types";
  65314. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65315. import { Matrix } from "babylonjs/Maths/math.vector";
  65316. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  65317. import "babylonjs/Engines/Extensions/engine.videoTexture";
  65318. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65319. import { Scene } from "babylonjs/scene";
  65320. /**
  65321. * Defines the options related to the creation of an HtmlElementTexture
  65322. */
  65323. export interface IHtmlElementTextureOptions {
  65324. /**
  65325. * Defines wether mip maps should be created or not.
  65326. */
  65327. generateMipMaps?: boolean;
  65328. /**
  65329. * Defines the sampling mode of the texture.
  65330. */
  65331. samplingMode?: number;
  65332. /**
  65333. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  65334. */
  65335. engine: Nullable<ThinEngine>;
  65336. /**
  65337. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  65338. */
  65339. scene: Nullable<Scene>;
  65340. }
  65341. /**
  65342. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  65343. * To be as efficient as possible depending on your constraints nothing aside the first upload
  65344. * is automatically managed.
  65345. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  65346. * in your application.
  65347. *
  65348. * As the update is not automatic, you need to call them manually.
  65349. */
  65350. export class HtmlElementTexture extends BaseTexture {
  65351. /**
  65352. * The texture URL.
  65353. */
  65354. element: HTMLVideoElement | HTMLCanvasElement;
  65355. private static readonly DefaultOptions;
  65356. private _textureMatrix;
  65357. private _isVideo;
  65358. private _generateMipMaps;
  65359. private _samplingMode;
  65360. /**
  65361. * Instantiates a HtmlElementTexture from the following parameters.
  65362. *
  65363. * @param name Defines the name of the texture
  65364. * @param element Defines the video or canvas the texture is filled with
  65365. * @param options Defines the other none mandatory texture creation options
  65366. */
  65367. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  65368. private _createInternalTexture;
  65369. /**
  65370. * Returns the texture matrix used in most of the material.
  65371. */
  65372. getTextureMatrix(): Matrix;
  65373. /**
  65374. * Updates the content of the texture.
  65375. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  65376. */
  65377. update(invertY?: Nullable<boolean>): void;
  65378. }
  65379. }
  65380. declare module "babylonjs/Misc/tga" {
  65381. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65382. /**
  65383. * Based on jsTGALoader - Javascript loader for TGA file
  65384. * By Vincent Thibault
  65385. * @see http://blog.robrowser.com/javascript-tga-loader.html
  65386. */
  65387. export class TGATools {
  65388. private static _TYPE_INDEXED;
  65389. private static _TYPE_RGB;
  65390. private static _TYPE_GREY;
  65391. private static _TYPE_RLE_INDEXED;
  65392. private static _TYPE_RLE_RGB;
  65393. private static _TYPE_RLE_GREY;
  65394. private static _ORIGIN_MASK;
  65395. private static _ORIGIN_SHIFT;
  65396. private static _ORIGIN_BL;
  65397. private static _ORIGIN_BR;
  65398. private static _ORIGIN_UL;
  65399. private static _ORIGIN_UR;
  65400. /**
  65401. * Gets the header of a TGA file
  65402. * @param data defines the TGA data
  65403. * @returns the header
  65404. */
  65405. static GetTGAHeader(data: Uint8Array): any;
  65406. /**
  65407. * Uploads TGA content to a Babylon Texture
  65408. * @hidden
  65409. */
  65410. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  65411. /** @hidden */
  65412. 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;
  65413. /** @hidden */
  65414. 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;
  65415. /** @hidden */
  65416. 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;
  65417. /** @hidden */
  65418. 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;
  65419. /** @hidden */
  65420. 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;
  65421. /** @hidden */
  65422. 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;
  65423. }
  65424. }
  65425. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  65426. import { Nullable } from "babylonjs/types";
  65427. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65428. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65429. /**
  65430. * Implementation of the TGA Texture Loader.
  65431. * @hidden
  65432. */
  65433. export class _TGATextureLoader implements IInternalTextureLoader {
  65434. /**
  65435. * Defines wether the loader supports cascade loading the different faces.
  65436. */
  65437. readonly supportCascades: boolean;
  65438. /**
  65439. * This returns if the loader support the current file information.
  65440. * @param extension defines the file extension of the file being loaded
  65441. * @returns true if the loader can load the specified file
  65442. */
  65443. canLoad(extension: string): boolean;
  65444. /**
  65445. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65446. * @param data contains the texture data
  65447. * @param texture defines the BabylonJS internal texture
  65448. * @param createPolynomials will be true if polynomials have been requested
  65449. * @param onLoad defines the callback to trigger once the texture is ready
  65450. * @param onError defines the callback to trigger in case of error
  65451. */
  65452. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65453. /**
  65454. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65455. * @param data contains the texture data
  65456. * @param texture defines the BabylonJS internal texture
  65457. * @param callback defines the method to call once ready to upload
  65458. */
  65459. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65460. }
  65461. }
  65462. declare module "babylonjs/Misc/basis" {
  65463. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65464. /**
  65465. * Info about the .basis files
  65466. */
  65467. class BasisFileInfo {
  65468. /**
  65469. * If the file has alpha
  65470. */
  65471. hasAlpha: boolean;
  65472. /**
  65473. * Info about each image of the basis file
  65474. */
  65475. images: Array<{
  65476. levels: Array<{
  65477. width: number;
  65478. height: number;
  65479. transcodedPixels: ArrayBufferView;
  65480. }>;
  65481. }>;
  65482. }
  65483. /**
  65484. * Result of transcoding a basis file
  65485. */
  65486. class TranscodeResult {
  65487. /**
  65488. * Info about the .basis file
  65489. */
  65490. fileInfo: BasisFileInfo;
  65491. /**
  65492. * Format to use when loading the file
  65493. */
  65494. format: number;
  65495. }
  65496. /**
  65497. * Configuration options for the Basis transcoder
  65498. */
  65499. export class BasisTranscodeConfiguration {
  65500. /**
  65501. * Supported compression formats used to determine the supported output format of the transcoder
  65502. */
  65503. supportedCompressionFormats?: {
  65504. /**
  65505. * etc1 compression format
  65506. */
  65507. etc1?: boolean;
  65508. /**
  65509. * s3tc compression format
  65510. */
  65511. s3tc?: boolean;
  65512. /**
  65513. * pvrtc compression format
  65514. */
  65515. pvrtc?: boolean;
  65516. /**
  65517. * etc2 compression format
  65518. */
  65519. etc2?: boolean;
  65520. };
  65521. /**
  65522. * If mipmap levels should be loaded for transcoded images (Default: true)
  65523. */
  65524. loadMipmapLevels?: boolean;
  65525. /**
  65526. * Index of a single image to load (Default: all images)
  65527. */
  65528. loadSingleImage?: number;
  65529. }
  65530. /**
  65531. * Used to load .Basis files
  65532. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  65533. */
  65534. export class BasisTools {
  65535. private static _IgnoreSupportedFormats;
  65536. /**
  65537. * URL to use when loading the basis transcoder
  65538. */
  65539. static JSModuleURL: string;
  65540. /**
  65541. * URL to use when loading the wasm module for the transcoder
  65542. */
  65543. static WasmModuleURL: string;
  65544. /**
  65545. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  65546. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  65547. * @returns internal format corresponding to the Basis format
  65548. */
  65549. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  65550. private static _WorkerPromise;
  65551. private static _Worker;
  65552. private static _actionId;
  65553. private static _CreateWorkerAsync;
  65554. /**
  65555. * Transcodes a loaded image file to compressed pixel data
  65556. * @param data image data to transcode
  65557. * @param config configuration options for the transcoding
  65558. * @returns a promise resulting in the transcoded image
  65559. */
  65560. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  65561. /**
  65562. * Loads a texture from the transcode result
  65563. * @param texture texture load to
  65564. * @param transcodeResult the result of transcoding the basis file to load from
  65565. */
  65566. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  65567. }
  65568. }
  65569. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  65570. import { Nullable } from "babylonjs/types";
  65571. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65572. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65573. /**
  65574. * Loader for .basis file format
  65575. */
  65576. export class _BasisTextureLoader implements IInternalTextureLoader {
  65577. /**
  65578. * Defines whether the loader supports cascade loading the different faces.
  65579. */
  65580. readonly supportCascades: boolean;
  65581. /**
  65582. * This returns if the loader support the current file information.
  65583. * @param extension defines the file extension of the file being loaded
  65584. * @returns true if the loader can load the specified file
  65585. */
  65586. canLoad(extension: string): boolean;
  65587. /**
  65588. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65589. * @param data contains the texture data
  65590. * @param texture defines the BabylonJS internal texture
  65591. * @param createPolynomials will be true if polynomials have been requested
  65592. * @param onLoad defines the callback to trigger once the texture is ready
  65593. * @param onError defines the callback to trigger in case of error
  65594. */
  65595. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65596. /**
  65597. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65598. * @param data contains the texture data
  65599. * @param texture defines the BabylonJS internal texture
  65600. * @param callback defines the method to call once ready to upload
  65601. */
  65602. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65603. }
  65604. }
  65605. declare module "babylonjs/Materials/Textures/Loaders/index" {
  65606. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  65607. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  65608. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  65609. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  65610. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  65611. }
  65612. declare module "babylonjs/Materials/Textures/Packer/frame" {
  65613. import { Vector2 } from "babylonjs/Maths/math.vector";
  65614. /**
  65615. * Defines the basic options interface of a TexturePacker Frame
  65616. */
  65617. export interface ITexturePackerFrame {
  65618. /**
  65619. * The frame ID
  65620. */
  65621. id: number;
  65622. /**
  65623. * The frames Scale
  65624. */
  65625. scale: Vector2;
  65626. /**
  65627. * The Frames offset
  65628. */
  65629. offset: Vector2;
  65630. }
  65631. /**
  65632. * This is a support class for frame Data on texture packer sets.
  65633. */
  65634. export class TexturePackerFrame implements ITexturePackerFrame {
  65635. /**
  65636. * The frame ID
  65637. */
  65638. id: number;
  65639. /**
  65640. * The frames Scale
  65641. */
  65642. scale: Vector2;
  65643. /**
  65644. * The Frames offset
  65645. */
  65646. offset: Vector2;
  65647. /**
  65648. * Initializes a texture package frame.
  65649. * @param id The numerical frame identifier
  65650. * @param scale Scalar Vector2 for UV frame
  65651. * @param offset Vector2 for the frame position in UV units.
  65652. * @returns TexturePackerFrame
  65653. */
  65654. constructor(id: number, scale: Vector2, offset: Vector2);
  65655. }
  65656. }
  65657. declare module "babylonjs/Materials/Textures/Packer/packer" {
  65658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65659. import { Scene } from "babylonjs/scene";
  65660. import { Nullable } from "babylonjs/types";
  65661. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  65662. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  65663. /**
  65664. * Defines the basic options interface of a TexturePacker
  65665. */
  65666. export interface ITexturePackerOptions {
  65667. /**
  65668. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  65669. */
  65670. map?: string[];
  65671. /**
  65672. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65673. */
  65674. uvsIn?: string;
  65675. /**
  65676. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65677. */
  65678. uvsOut?: string;
  65679. /**
  65680. * number representing the layout style. Defaults to LAYOUT_STRIP
  65681. */
  65682. layout?: number;
  65683. /**
  65684. * number of columns if using custom column count layout(2). This defaults to 4.
  65685. */
  65686. colnum?: number;
  65687. /**
  65688. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  65689. */
  65690. updateInputMeshes?: boolean;
  65691. /**
  65692. * boolean flag to dispose all the source textures. Defaults to true.
  65693. */
  65694. disposeSources?: boolean;
  65695. /**
  65696. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  65697. */
  65698. fillBlanks?: boolean;
  65699. /**
  65700. * string value representing the context fill style color. Defaults to 'black'.
  65701. */
  65702. customFillColor?: string;
  65703. /**
  65704. * Width and Height Value of each Frame in the TexturePacker Sets
  65705. */
  65706. frameSize?: number;
  65707. /**
  65708. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  65709. */
  65710. paddingRatio?: number;
  65711. /**
  65712. * Number that declares the fill method for the padding gutter.
  65713. */
  65714. paddingMode?: number;
  65715. /**
  65716. * If in SUBUV_COLOR padding mode what color to use.
  65717. */
  65718. paddingColor?: Color3 | Color4;
  65719. }
  65720. /**
  65721. * Defines the basic interface of a TexturePacker JSON File
  65722. */
  65723. export interface ITexturePackerJSON {
  65724. /**
  65725. * The frame ID
  65726. */
  65727. name: string;
  65728. /**
  65729. * The base64 channel data
  65730. */
  65731. sets: any;
  65732. /**
  65733. * The options of the Packer
  65734. */
  65735. options: ITexturePackerOptions;
  65736. /**
  65737. * The frame data of the Packer
  65738. */
  65739. frames: Array<number>;
  65740. }
  65741. /**
  65742. * This is a support class that generates a series of packed texture sets.
  65743. * @see https://doc.babylonjs.com/babylon101/materials
  65744. */
  65745. export class TexturePacker {
  65746. /** Packer Layout Constant 0 */
  65747. static readonly LAYOUT_STRIP: number;
  65748. /** Packer Layout Constant 1 */
  65749. static readonly LAYOUT_POWER2: number;
  65750. /** Packer Layout Constant 2 */
  65751. static readonly LAYOUT_COLNUM: number;
  65752. /** Packer Layout Constant 0 */
  65753. static readonly SUBUV_WRAP: number;
  65754. /** Packer Layout Constant 1 */
  65755. static readonly SUBUV_EXTEND: number;
  65756. /** Packer Layout Constant 2 */
  65757. static readonly SUBUV_COLOR: number;
  65758. /** The Name of the Texture Package */
  65759. name: string;
  65760. /** The scene scope of the TexturePacker */
  65761. scene: Scene;
  65762. /** The Meshes to target */
  65763. meshes: AbstractMesh[];
  65764. /** Arguments passed with the Constructor */
  65765. options: ITexturePackerOptions;
  65766. /** The promise that is started upon initialization */
  65767. promise: Nullable<Promise<TexturePacker | string>>;
  65768. /** The Container object for the channel sets that are generated */
  65769. sets: object;
  65770. /** The Container array for the frames that are generated */
  65771. frames: TexturePackerFrame[];
  65772. /** The expected number of textures the system is parsing. */
  65773. private _expecting;
  65774. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  65775. private _paddingValue;
  65776. /**
  65777. * Initializes a texture package series from an array of meshes or a single mesh.
  65778. * @param name The name of the package
  65779. * @param meshes The target meshes to compose the package from
  65780. * @param options The arguments that texture packer should follow while building.
  65781. * @param scene The scene which the textures are scoped to.
  65782. * @returns TexturePacker
  65783. */
  65784. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  65785. /**
  65786. * Starts the package process
  65787. * @param resolve The promises resolution function
  65788. * @returns TexturePacker
  65789. */
  65790. private _createFrames;
  65791. /**
  65792. * Calculates the Size of the Channel Sets
  65793. * @returns Vector2
  65794. */
  65795. private _calculateSize;
  65796. /**
  65797. * Calculates the UV data for the frames.
  65798. * @param baseSize the base frameSize
  65799. * @param padding the base frame padding
  65800. * @param dtSize size of the Dynamic Texture for that channel
  65801. * @param dtUnits is 1/dtSize
  65802. * @param update flag to update the input meshes
  65803. */
  65804. private _calculateMeshUVFrames;
  65805. /**
  65806. * Calculates the frames Offset.
  65807. * @param index of the frame
  65808. * @returns Vector2
  65809. */
  65810. private _getFrameOffset;
  65811. /**
  65812. * Updates a Mesh to the frame data
  65813. * @param mesh that is the target
  65814. * @param frameID or the frame index
  65815. */
  65816. private _updateMeshUV;
  65817. /**
  65818. * Updates a Meshes materials to use the texture packer channels
  65819. * @param m is the mesh to target
  65820. * @param force all channels on the packer to be set.
  65821. */
  65822. private _updateTextureReferences;
  65823. /**
  65824. * Public method to set a Mesh to a frame
  65825. * @param m that is the target
  65826. * @param frameID or the frame index
  65827. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65828. */
  65829. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65830. /**
  65831. * Starts the async promise to compile the texture packer.
  65832. * @returns Promise<void>
  65833. */
  65834. processAsync(): Promise<void>;
  65835. /**
  65836. * Disposes all textures associated with this packer
  65837. */
  65838. dispose(): void;
  65839. /**
  65840. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65841. * @param imageType is the image type to use.
  65842. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65843. */
  65844. download(imageType?: string, quality?: number): void;
  65845. /**
  65846. * Public method to load a texturePacker JSON file.
  65847. * @param data of the JSON file in string format.
  65848. */
  65849. updateFromJSON(data: string): void;
  65850. }
  65851. }
  65852. declare module "babylonjs/Materials/Textures/Packer/index" {
  65853. export * from "babylonjs/Materials/Textures/Packer/packer";
  65854. export * from "babylonjs/Materials/Textures/Packer/frame";
  65855. }
  65856. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65857. import { Scene } from "babylonjs/scene";
  65858. import { Texture } from "babylonjs/Materials/Textures/texture";
  65859. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65860. /**
  65861. * 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.
  65862. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65863. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65864. */
  65865. export class CustomProceduralTexture extends ProceduralTexture {
  65866. private _animate;
  65867. private _time;
  65868. private _config;
  65869. private _texturePath;
  65870. /**
  65871. * Instantiates a new Custom Procedural Texture.
  65872. * 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.
  65873. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65874. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65875. * @param name Define the name of the texture
  65876. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65877. * @param size Define the size of the texture to create
  65878. * @param scene Define the scene the texture belongs to
  65879. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65880. * @param generateMipMaps Define if the texture should creates mip maps or not
  65881. */
  65882. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65883. private _loadJson;
  65884. /**
  65885. * Is the texture ready to be used ? (rendered at least once)
  65886. * @returns true if ready, otherwise, false.
  65887. */
  65888. isReady(): boolean;
  65889. /**
  65890. * Render the texture to its associated render target.
  65891. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65892. */
  65893. render(useCameraPostProcess?: boolean): void;
  65894. /**
  65895. * Update the list of dependant textures samplers in the shader.
  65896. */
  65897. updateTextures(): void;
  65898. /**
  65899. * Update the uniform values of the procedural texture in the shader.
  65900. */
  65901. updateShaderUniforms(): void;
  65902. /**
  65903. * Define if the texture animates or not.
  65904. */
  65905. get animate(): boolean;
  65906. set animate(value: boolean);
  65907. }
  65908. }
  65909. declare module "babylonjs/Shaders/noise.fragment" {
  65910. /** @hidden */
  65911. export var noisePixelShader: {
  65912. name: string;
  65913. shader: string;
  65914. };
  65915. }
  65916. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65917. import { Nullable } from "babylonjs/types";
  65918. import { Scene } from "babylonjs/scene";
  65919. import { Texture } from "babylonjs/Materials/Textures/texture";
  65920. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65921. import "babylonjs/Shaders/noise.fragment";
  65922. /**
  65923. * Class used to generate noise procedural textures
  65924. */
  65925. export class NoiseProceduralTexture extends ProceduralTexture {
  65926. /** Gets or sets the start time (default is 0) */
  65927. time: number;
  65928. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65929. brightness: number;
  65930. /** Defines the number of octaves to process */
  65931. octaves: number;
  65932. /** Defines the level of persistence (0.8 by default) */
  65933. persistence: number;
  65934. /** Gets or sets animation speed factor (default is 1) */
  65935. animationSpeedFactor: number;
  65936. /**
  65937. * Creates a new NoiseProceduralTexture
  65938. * @param name defines the name fo the texture
  65939. * @param size defines the size of the texture (default is 256)
  65940. * @param scene defines the hosting scene
  65941. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65942. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65943. */
  65944. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65945. private _updateShaderUniforms;
  65946. protected _getDefines(): string;
  65947. /** Generate the current state of the procedural texture */
  65948. render(useCameraPostProcess?: boolean): void;
  65949. /**
  65950. * Serializes this noise procedural texture
  65951. * @returns a serialized noise procedural texture object
  65952. */
  65953. serialize(): any;
  65954. /**
  65955. * Clone the texture.
  65956. * @returns the cloned texture
  65957. */
  65958. clone(): NoiseProceduralTexture;
  65959. /**
  65960. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65961. * @param parsedTexture defines parsed texture data
  65962. * @param scene defines the current scene
  65963. * @param rootUrl defines the root URL containing noise procedural texture information
  65964. * @returns a parsed NoiseProceduralTexture
  65965. */
  65966. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65967. }
  65968. }
  65969. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65970. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65971. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65972. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65973. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65974. }
  65975. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65976. import { Nullable } from "babylonjs/types";
  65977. import { Scene } from "babylonjs/scene";
  65978. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65979. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65980. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65981. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65982. /**
  65983. * Raw cube texture where the raw buffers are passed in
  65984. */
  65985. export class RawCubeTexture extends CubeTexture {
  65986. /**
  65987. * Creates a cube texture where the raw buffers are passed in.
  65988. * @param scene defines the scene the texture is attached to
  65989. * @param data defines the array of data to use to create each face
  65990. * @param size defines the size of the textures
  65991. * @param format defines the format of the data
  65992. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65993. * @param generateMipMaps defines if the engine should generate the mip levels
  65994. * @param invertY defines if data must be stored with Y axis inverted
  65995. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65996. * @param compression defines the compression used (null by default)
  65997. */
  65998. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65999. /**
  66000. * Updates the raw cube texture.
  66001. * @param data defines the data to store
  66002. * @param format defines the data format
  66003. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66004. * @param invertY defines if data must be stored with Y axis inverted
  66005. * @param compression defines the compression used (null by default)
  66006. * @param level defines which level of the texture to update
  66007. */
  66008. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  66009. /**
  66010. * Updates a raw cube texture with RGBD encoded data.
  66011. * @param data defines the array of data [mipmap][face] to use to create each face
  66012. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  66013. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66014. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66015. * @returns a promsie that resolves when the operation is complete
  66016. */
  66017. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  66018. /**
  66019. * Clones the raw cube texture.
  66020. * @return a new cube texture
  66021. */
  66022. clone(): CubeTexture;
  66023. /** @hidden */
  66024. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  66025. }
  66026. }
  66027. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  66028. import { Scene } from "babylonjs/scene";
  66029. import { Texture } from "babylonjs/Materials/Textures/texture";
  66030. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66031. /**
  66032. * Class used to store 2D array textures containing user data
  66033. */
  66034. export class RawTexture2DArray extends Texture {
  66035. /** Gets or sets the texture format to use */
  66036. format: number;
  66037. /**
  66038. * Create a new RawTexture2DArray
  66039. * @param data defines the data of the texture
  66040. * @param width defines the width of the texture
  66041. * @param height defines the height of the texture
  66042. * @param depth defines the number of layers of the texture
  66043. * @param format defines the texture format to use
  66044. * @param scene defines the hosting scene
  66045. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66046. * @param invertY defines if texture must be stored with Y axis inverted
  66047. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66048. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66049. */
  66050. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66051. /** Gets or sets the texture format to use */
  66052. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66053. /**
  66054. * Update the texture with new data
  66055. * @param data defines the data to store in the texture
  66056. */
  66057. update(data: ArrayBufferView): void;
  66058. }
  66059. }
  66060. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  66061. import { Scene } from "babylonjs/scene";
  66062. import { Texture } from "babylonjs/Materials/Textures/texture";
  66063. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66064. /**
  66065. * Class used to store 3D textures containing user data
  66066. */
  66067. export class RawTexture3D extends Texture {
  66068. /** Gets or sets the texture format to use */
  66069. format: number;
  66070. /**
  66071. * Create a new RawTexture3D
  66072. * @param data defines the data of the texture
  66073. * @param width defines the width of the texture
  66074. * @param height defines the height of the texture
  66075. * @param depth defines the depth of the texture
  66076. * @param format defines the texture format to use
  66077. * @param scene defines the hosting scene
  66078. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66079. * @param invertY defines if texture must be stored with Y axis inverted
  66080. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66081. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66082. */
  66083. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66084. /** Gets or sets the texture format to use */
  66085. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66086. /**
  66087. * Update the texture with new data
  66088. * @param data defines the data to store in the texture
  66089. */
  66090. update(data: ArrayBufferView): void;
  66091. }
  66092. }
  66093. declare module "babylonjs/Materials/Textures/refractionTexture" {
  66094. import { Scene } from "babylonjs/scene";
  66095. import { Plane } from "babylonjs/Maths/math.plane";
  66096. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66097. /**
  66098. * Creates a refraction texture used by refraction channel of the standard material.
  66099. * It is like a mirror but to see through a material.
  66100. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66101. */
  66102. export class RefractionTexture extends RenderTargetTexture {
  66103. /**
  66104. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66105. * 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.
  66106. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66107. */
  66108. refractionPlane: Plane;
  66109. /**
  66110. * Define how deep under the surface we should see.
  66111. */
  66112. depth: number;
  66113. /**
  66114. * Creates a refraction texture used by refraction channel of the standard material.
  66115. * It is like a mirror but to see through a material.
  66116. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66117. * @param name Define the texture name
  66118. * @param size Define the size of the underlying texture
  66119. * @param scene Define the scene the refraction belongs to
  66120. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66121. */
  66122. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66123. /**
  66124. * Clone the refraction texture.
  66125. * @returns the cloned texture
  66126. */
  66127. clone(): RefractionTexture;
  66128. /**
  66129. * Serialize the texture to a JSON representation you could use in Parse later on
  66130. * @returns the serialized JSON representation
  66131. */
  66132. serialize(): any;
  66133. }
  66134. }
  66135. declare module "babylonjs/Materials/Textures/index" {
  66136. export * from "babylonjs/Materials/Textures/baseTexture";
  66137. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  66138. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  66139. export * from "babylonjs/Materials/Textures/cubeTexture";
  66140. export * from "babylonjs/Materials/Textures/dynamicTexture";
  66141. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66142. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  66143. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  66144. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  66145. export * from "babylonjs/Materials/Textures/internalTexture";
  66146. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  66147. export * from "babylonjs/Materials/Textures/Loaders/index";
  66148. export * from "babylonjs/Materials/Textures/mirrorTexture";
  66149. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  66150. export * from "babylonjs/Materials/Textures/Packer/index";
  66151. export * from "babylonjs/Materials/Textures/Procedurals/index";
  66152. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  66153. export * from "babylonjs/Materials/Textures/rawTexture";
  66154. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  66155. export * from "babylonjs/Materials/Textures/rawTexture3D";
  66156. export * from "babylonjs/Materials/Textures/refractionTexture";
  66157. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  66158. export * from "babylonjs/Materials/Textures/texture";
  66159. export * from "babylonjs/Materials/Textures/videoTexture";
  66160. }
  66161. declare module "babylonjs/Materials/Node/Enums/index" {
  66162. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  66163. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  66164. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  66165. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  66166. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  66167. }
  66168. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  66169. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66170. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66172. import { Mesh } from "babylonjs/Meshes/mesh";
  66173. import { Effect } from "babylonjs/Materials/effect";
  66174. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66175. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66176. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66177. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66178. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66179. /**
  66180. * Block used to add support for vertex skinning (bones)
  66181. */
  66182. export class BonesBlock extends NodeMaterialBlock {
  66183. /**
  66184. * Creates a new BonesBlock
  66185. * @param name defines the block name
  66186. */
  66187. constructor(name: string);
  66188. /**
  66189. * Initialize the block and prepare the context for build
  66190. * @param state defines the state that will be used for the build
  66191. */
  66192. initialize(state: NodeMaterialBuildState): void;
  66193. /**
  66194. * Gets the current class name
  66195. * @returns the class name
  66196. */
  66197. getClassName(): string;
  66198. /**
  66199. * Gets the matrix indices input component
  66200. */
  66201. get matricesIndices(): NodeMaterialConnectionPoint;
  66202. /**
  66203. * Gets the matrix weights input component
  66204. */
  66205. get matricesWeights(): NodeMaterialConnectionPoint;
  66206. /**
  66207. * Gets the extra matrix indices input component
  66208. */
  66209. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66210. /**
  66211. * Gets the extra matrix weights input component
  66212. */
  66213. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66214. /**
  66215. * Gets the world input component
  66216. */
  66217. get world(): NodeMaterialConnectionPoint;
  66218. /**
  66219. * Gets the output component
  66220. */
  66221. get output(): NodeMaterialConnectionPoint;
  66222. autoConfigure(material: NodeMaterial): void;
  66223. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66224. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66225. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66226. protected _buildBlock(state: NodeMaterialBuildState): this;
  66227. }
  66228. }
  66229. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  66230. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66231. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66232. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66233. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66234. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66235. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66236. /**
  66237. * Block used to add support for instances
  66238. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66239. */
  66240. export class InstancesBlock extends NodeMaterialBlock {
  66241. /**
  66242. * Creates a new InstancesBlock
  66243. * @param name defines the block name
  66244. */
  66245. constructor(name: string);
  66246. /**
  66247. * Gets the current class name
  66248. * @returns the class name
  66249. */
  66250. getClassName(): string;
  66251. /**
  66252. * Gets the first world row input component
  66253. */
  66254. get world0(): NodeMaterialConnectionPoint;
  66255. /**
  66256. * Gets the second world row input component
  66257. */
  66258. get world1(): NodeMaterialConnectionPoint;
  66259. /**
  66260. * Gets the third world row input component
  66261. */
  66262. get world2(): NodeMaterialConnectionPoint;
  66263. /**
  66264. * Gets the forth world row input component
  66265. */
  66266. get world3(): NodeMaterialConnectionPoint;
  66267. /**
  66268. * Gets the world input component
  66269. */
  66270. get world(): NodeMaterialConnectionPoint;
  66271. /**
  66272. * Gets the output component
  66273. */
  66274. get output(): NodeMaterialConnectionPoint;
  66275. /**
  66276. * Gets the isntanceID component
  66277. */
  66278. get instanceID(): NodeMaterialConnectionPoint;
  66279. autoConfigure(material: NodeMaterial): void;
  66280. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66281. protected _buildBlock(state: NodeMaterialBuildState): this;
  66282. }
  66283. }
  66284. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  66285. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66286. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66287. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66289. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66290. import { Effect } from "babylonjs/Materials/effect";
  66291. import { Mesh } from "babylonjs/Meshes/mesh";
  66292. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66293. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66294. /**
  66295. * Block used to add morph targets support to vertex shader
  66296. */
  66297. export class MorphTargetsBlock extends NodeMaterialBlock {
  66298. private _repeatableContentAnchor;
  66299. /**
  66300. * Create a new MorphTargetsBlock
  66301. * @param name defines the block name
  66302. */
  66303. constructor(name: string);
  66304. /**
  66305. * Gets the current class name
  66306. * @returns the class name
  66307. */
  66308. getClassName(): string;
  66309. /**
  66310. * Gets the position input component
  66311. */
  66312. get position(): NodeMaterialConnectionPoint;
  66313. /**
  66314. * Gets the normal input component
  66315. */
  66316. get normal(): NodeMaterialConnectionPoint;
  66317. /**
  66318. * Gets the tangent input component
  66319. */
  66320. get tangent(): NodeMaterialConnectionPoint;
  66321. /**
  66322. * Gets the tangent input component
  66323. */
  66324. get uv(): NodeMaterialConnectionPoint;
  66325. /**
  66326. * Gets the position output component
  66327. */
  66328. get positionOutput(): NodeMaterialConnectionPoint;
  66329. /**
  66330. * Gets the normal output component
  66331. */
  66332. get normalOutput(): NodeMaterialConnectionPoint;
  66333. /**
  66334. * Gets the tangent output component
  66335. */
  66336. get tangentOutput(): NodeMaterialConnectionPoint;
  66337. /**
  66338. * Gets the tangent output component
  66339. */
  66340. get uvOutput(): NodeMaterialConnectionPoint;
  66341. initialize(state: NodeMaterialBuildState): void;
  66342. autoConfigure(material: NodeMaterial): void;
  66343. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66344. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66345. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  66346. protected _buildBlock(state: NodeMaterialBuildState): this;
  66347. }
  66348. }
  66349. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  66350. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66351. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66352. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66353. import { Nullable } from "babylonjs/types";
  66354. import { Scene } from "babylonjs/scene";
  66355. import { Effect } from "babylonjs/Materials/effect";
  66356. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66357. import { Mesh } from "babylonjs/Meshes/mesh";
  66358. import { Light } from "babylonjs/Lights/light";
  66359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66360. /**
  66361. * Block used to get data information from a light
  66362. */
  66363. export class LightInformationBlock extends NodeMaterialBlock {
  66364. private _lightDataUniformName;
  66365. private _lightColorUniformName;
  66366. private _lightTypeDefineName;
  66367. /**
  66368. * Gets or sets the light associated with this block
  66369. */
  66370. light: Nullable<Light>;
  66371. /**
  66372. * Creates a new LightInformationBlock
  66373. * @param name defines the block name
  66374. */
  66375. constructor(name: string);
  66376. /**
  66377. * Gets the current class name
  66378. * @returns the class name
  66379. */
  66380. getClassName(): string;
  66381. /**
  66382. * Gets the world position input component
  66383. */
  66384. get worldPosition(): NodeMaterialConnectionPoint;
  66385. /**
  66386. * Gets the direction output component
  66387. */
  66388. get direction(): NodeMaterialConnectionPoint;
  66389. /**
  66390. * Gets the direction output component
  66391. */
  66392. get color(): NodeMaterialConnectionPoint;
  66393. /**
  66394. * Gets the direction output component
  66395. */
  66396. get intensity(): NodeMaterialConnectionPoint;
  66397. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66398. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66399. protected _buildBlock(state: NodeMaterialBuildState): this;
  66400. serialize(): any;
  66401. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66402. }
  66403. }
  66404. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  66405. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  66406. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  66407. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  66408. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  66409. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  66410. }
  66411. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  66412. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66413. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66414. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66416. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66417. import { Effect } from "babylonjs/Materials/effect";
  66418. import { Mesh } from "babylonjs/Meshes/mesh";
  66419. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66420. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  66421. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  66422. /**
  66423. * Block used to add image processing support to fragment shader
  66424. */
  66425. export class ImageProcessingBlock extends NodeMaterialBlock {
  66426. /**
  66427. * Create a new ImageProcessingBlock
  66428. * @param name defines the block name
  66429. */
  66430. constructor(name: string);
  66431. /**
  66432. * Gets the current class name
  66433. * @returns the class name
  66434. */
  66435. getClassName(): string;
  66436. /**
  66437. * Gets the color input component
  66438. */
  66439. get color(): NodeMaterialConnectionPoint;
  66440. /**
  66441. * Gets the output component
  66442. */
  66443. get output(): NodeMaterialConnectionPoint;
  66444. /**
  66445. * Initialize the block and prepare the context for build
  66446. * @param state defines the state that will be used for the build
  66447. */
  66448. initialize(state: NodeMaterialBuildState): void;
  66449. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  66450. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66451. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66452. protected _buildBlock(state: NodeMaterialBuildState): this;
  66453. }
  66454. }
  66455. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  66456. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66457. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66458. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66459. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66461. import { Effect } from "babylonjs/Materials/effect";
  66462. import { Mesh } from "babylonjs/Meshes/mesh";
  66463. import { Scene } from "babylonjs/scene";
  66464. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  66465. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  66466. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  66467. /**
  66468. * Block used to pertub normals based on a normal map
  66469. */
  66470. export class PerturbNormalBlock extends NodeMaterialBlock {
  66471. private _tangentSpaceParameterName;
  66472. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66473. invertX: boolean;
  66474. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  66475. invertY: boolean;
  66476. /**
  66477. * Create a new PerturbNormalBlock
  66478. * @param name defines the block name
  66479. */
  66480. constructor(name: string);
  66481. /**
  66482. * Gets the current class name
  66483. * @returns the class name
  66484. */
  66485. getClassName(): string;
  66486. /**
  66487. * Gets the world position input component
  66488. */
  66489. get worldPosition(): NodeMaterialConnectionPoint;
  66490. /**
  66491. * Gets the world normal input component
  66492. */
  66493. get worldNormal(): NodeMaterialConnectionPoint;
  66494. /**
  66495. * Gets the world tangent input component
  66496. */
  66497. get worldTangent(): NodeMaterialConnectionPoint;
  66498. /**
  66499. * Gets the uv input component
  66500. */
  66501. get uv(): NodeMaterialConnectionPoint;
  66502. /**
  66503. * Gets the normal map color input component
  66504. */
  66505. get normalMapColor(): NodeMaterialConnectionPoint;
  66506. /**
  66507. * Gets the strength input component
  66508. */
  66509. get strength(): NodeMaterialConnectionPoint;
  66510. /**
  66511. * Gets the output component
  66512. */
  66513. get output(): NodeMaterialConnectionPoint;
  66514. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66515. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66516. autoConfigure(material: NodeMaterial): void;
  66517. protected _buildBlock(state: NodeMaterialBuildState): this;
  66518. protected _dumpPropertiesCode(): string;
  66519. serialize(): any;
  66520. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66521. }
  66522. }
  66523. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  66524. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66525. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66526. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66527. /**
  66528. * Block used to discard a pixel if a value is smaller than a cutoff
  66529. */
  66530. export class DiscardBlock extends NodeMaterialBlock {
  66531. /**
  66532. * Create a new DiscardBlock
  66533. * @param name defines the block name
  66534. */
  66535. constructor(name: string);
  66536. /**
  66537. * Gets the current class name
  66538. * @returns the class name
  66539. */
  66540. getClassName(): string;
  66541. /**
  66542. * Gets the color input component
  66543. */
  66544. get value(): NodeMaterialConnectionPoint;
  66545. /**
  66546. * Gets the cutoff input component
  66547. */
  66548. get cutoff(): NodeMaterialConnectionPoint;
  66549. protected _buildBlock(state: NodeMaterialBuildState): this;
  66550. }
  66551. }
  66552. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  66553. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66554. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66555. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66556. /**
  66557. * Block used to test if the fragment shader is front facing
  66558. */
  66559. export class FrontFacingBlock extends NodeMaterialBlock {
  66560. /**
  66561. * Creates a new FrontFacingBlock
  66562. * @param name defines the block name
  66563. */
  66564. constructor(name: string);
  66565. /**
  66566. * Gets the current class name
  66567. * @returns the class name
  66568. */
  66569. getClassName(): string;
  66570. /**
  66571. * Gets the output component
  66572. */
  66573. get output(): NodeMaterialConnectionPoint;
  66574. protected _buildBlock(state: NodeMaterialBuildState): this;
  66575. }
  66576. }
  66577. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  66578. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66579. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66580. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66581. /**
  66582. * Block used to get the derivative value on x and y of a given input
  66583. */
  66584. export class DerivativeBlock extends NodeMaterialBlock {
  66585. /**
  66586. * Create a new DerivativeBlock
  66587. * @param name defines the block name
  66588. */
  66589. constructor(name: string);
  66590. /**
  66591. * Gets the current class name
  66592. * @returns the class name
  66593. */
  66594. getClassName(): string;
  66595. /**
  66596. * Gets the input component
  66597. */
  66598. get input(): NodeMaterialConnectionPoint;
  66599. /**
  66600. * Gets the derivative output on x
  66601. */
  66602. get dx(): NodeMaterialConnectionPoint;
  66603. /**
  66604. * Gets the derivative output on y
  66605. */
  66606. get dy(): NodeMaterialConnectionPoint;
  66607. protected _buildBlock(state: NodeMaterialBuildState): this;
  66608. }
  66609. }
  66610. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  66611. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66612. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66613. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66614. /**
  66615. * Block used to make gl_FragCoord available
  66616. */
  66617. export class FragCoordBlock extends NodeMaterialBlock {
  66618. /**
  66619. * Creates a new FragCoordBlock
  66620. * @param name defines the block name
  66621. */
  66622. constructor(name: string);
  66623. /**
  66624. * Gets the current class name
  66625. * @returns the class name
  66626. */
  66627. getClassName(): string;
  66628. /**
  66629. * Gets the xy component
  66630. */
  66631. get xy(): NodeMaterialConnectionPoint;
  66632. /**
  66633. * Gets the xyz component
  66634. */
  66635. get xyz(): NodeMaterialConnectionPoint;
  66636. /**
  66637. * Gets the xyzw component
  66638. */
  66639. get xyzw(): NodeMaterialConnectionPoint;
  66640. /**
  66641. * Gets the x component
  66642. */
  66643. get x(): NodeMaterialConnectionPoint;
  66644. /**
  66645. * Gets the y component
  66646. */
  66647. get y(): NodeMaterialConnectionPoint;
  66648. /**
  66649. * Gets the z component
  66650. */
  66651. get z(): NodeMaterialConnectionPoint;
  66652. /**
  66653. * Gets the w component
  66654. */
  66655. get output(): NodeMaterialConnectionPoint;
  66656. protected writeOutputs(state: NodeMaterialBuildState): string;
  66657. protected _buildBlock(state: NodeMaterialBuildState): this;
  66658. }
  66659. }
  66660. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  66661. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66662. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66663. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66664. import { Effect } from "babylonjs/Materials/effect";
  66665. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66666. import { Mesh } from "babylonjs/Meshes/mesh";
  66667. /**
  66668. * Block used to get the screen sizes
  66669. */
  66670. export class ScreenSizeBlock extends NodeMaterialBlock {
  66671. private _varName;
  66672. private _scene;
  66673. /**
  66674. * Creates a new ScreenSizeBlock
  66675. * @param name defines the block name
  66676. */
  66677. constructor(name: string);
  66678. /**
  66679. * Gets the current class name
  66680. * @returns the class name
  66681. */
  66682. getClassName(): string;
  66683. /**
  66684. * Gets the xy component
  66685. */
  66686. get xy(): NodeMaterialConnectionPoint;
  66687. /**
  66688. * Gets the x component
  66689. */
  66690. get x(): NodeMaterialConnectionPoint;
  66691. /**
  66692. * Gets the y component
  66693. */
  66694. get y(): NodeMaterialConnectionPoint;
  66695. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66696. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  66697. protected _buildBlock(state: NodeMaterialBuildState): this;
  66698. }
  66699. }
  66700. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  66701. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  66702. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  66703. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  66704. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  66705. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  66706. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  66707. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  66708. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  66709. }
  66710. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  66711. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66712. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66713. import { Mesh } from "babylonjs/Meshes/mesh";
  66714. import { Effect } from "babylonjs/Materials/effect";
  66715. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66717. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66718. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66719. /**
  66720. * Block used to add support for scene fog
  66721. */
  66722. export class FogBlock extends NodeMaterialBlock {
  66723. private _fogDistanceName;
  66724. private _fogParameters;
  66725. /**
  66726. * Create a new FogBlock
  66727. * @param name defines the block name
  66728. */
  66729. constructor(name: string);
  66730. /**
  66731. * Gets the current class name
  66732. * @returns the class name
  66733. */
  66734. getClassName(): string;
  66735. /**
  66736. * Gets the world position input component
  66737. */
  66738. get worldPosition(): NodeMaterialConnectionPoint;
  66739. /**
  66740. * Gets the view input component
  66741. */
  66742. get view(): NodeMaterialConnectionPoint;
  66743. /**
  66744. * Gets the color input component
  66745. */
  66746. get input(): NodeMaterialConnectionPoint;
  66747. /**
  66748. * Gets the fog color input component
  66749. */
  66750. get fogColor(): NodeMaterialConnectionPoint;
  66751. /**
  66752. * Gets the output component
  66753. */
  66754. get output(): NodeMaterialConnectionPoint;
  66755. autoConfigure(material: NodeMaterial): void;
  66756. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66757. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66758. protected _buildBlock(state: NodeMaterialBuildState): this;
  66759. }
  66760. }
  66761. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  66762. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66763. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66764. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66766. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66767. import { Effect } from "babylonjs/Materials/effect";
  66768. import { Mesh } from "babylonjs/Meshes/mesh";
  66769. import { Light } from "babylonjs/Lights/light";
  66770. import { Nullable } from "babylonjs/types";
  66771. import { Scene } from "babylonjs/scene";
  66772. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  66773. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  66774. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  66775. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66776. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  66777. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  66778. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  66779. /**
  66780. * Block used to add light in the fragment shader
  66781. */
  66782. export class LightBlock extends NodeMaterialBlock {
  66783. private _lightId;
  66784. /**
  66785. * Gets or sets the light associated with this block
  66786. */
  66787. light: Nullable<Light>;
  66788. /**
  66789. * Create a new LightBlock
  66790. * @param name defines the block name
  66791. */
  66792. constructor(name: string);
  66793. /**
  66794. * Gets the current class name
  66795. * @returns the class name
  66796. */
  66797. getClassName(): string;
  66798. /**
  66799. * Gets the world position input component
  66800. */
  66801. get worldPosition(): NodeMaterialConnectionPoint;
  66802. /**
  66803. * Gets the world normal input component
  66804. */
  66805. get worldNormal(): NodeMaterialConnectionPoint;
  66806. /**
  66807. * Gets the camera (or eye) position component
  66808. */
  66809. get cameraPosition(): NodeMaterialConnectionPoint;
  66810. /**
  66811. * Gets the glossiness component
  66812. */
  66813. get glossiness(): NodeMaterialConnectionPoint;
  66814. /**
  66815. * Gets the glossinness power component
  66816. */
  66817. get glossPower(): NodeMaterialConnectionPoint;
  66818. /**
  66819. * Gets the diffuse color component
  66820. */
  66821. get diffuseColor(): NodeMaterialConnectionPoint;
  66822. /**
  66823. * Gets the specular color component
  66824. */
  66825. get specularColor(): NodeMaterialConnectionPoint;
  66826. /**
  66827. * Gets the view matrix component
  66828. */
  66829. get view(): NodeMaterialConnectionPoint;
  66830. /**
  66831. * Gets the diffuse output component
  66832. */
  66833. get diffuseOutput(): NodeMaterialConnectionPoint;
  66834. /**
  66835. * Gets the specular output component
  66836. */
  66837. get specularOutput(): NodeMaterialConnectionPoint;
  66838. /**
  66839. * Gets the shadow output component
  66840. */
  66841. get shadow(): NodeMaterialConnectionPoint;
  66842. autoConfigure(material: NodeMaterial): void;
  66843. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66844. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66845. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66846. private _injectVertexCode;
  66847. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66848. serialize(): any;
  66849. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66850. }
  66851. }
  66852. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66853. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66854. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66855. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66856. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66857. /**
  66858. * Block used to read a reflection texture from a sampler
  66859. */
  66860. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66861. /**
  66862. * Create a new ReflectionTextureBlock
  66863. * @param name defines the block name
  66864. */
  66865. constructor(name: string);
  66866. /**
  66867. * Gets the current class name
  66868. * @returns the class name
  66869. */
  66870. getClassName(): string;
  66871. /**
  66872. * Gets the world position input component
  66873. */
  66874. get position(): NodeMaterialConnectionPoint;
  66875. /**
  66876. * Gets the world position input component
  66877. */
  66878. get worldPosition(): NodeMaterialConnectionPoint;
  66879. /**
  66880. * Gets the world normal input component
  66881. */
  66882. get worldNormal(): NodeMaterialConnectionPoint;
  66883. /**
  66884. * Gets the world input component
  66885. */
  66886. get world(): NodeMaterialConnectionPoint;
  66887. /**
  66888. * Gets the camera (or eye) position component
  66889. */
  66890. get cameraPosition(): NodeMaterialConnectionPoint;
  66891. /**
  66892. * Gets the view input component
  66893. */
  66894. get view(): NodeMaterialConnectionPoint;
  66895. /**
  66896. * Gets the rgb output component
  66897. */
  66898. get rgb(): NodeMaterialConnectionPoint;
  66899. /**
  66900. * Gets the rgba output component
  66901. */
  66902. get rgba(): NodeMaterialConnectionPoint;
  66903. /**
  66904. * Gets the r output component
  66905. */
  66906. get r(): NodeMaterialConnectionPoint;
  66907. /**
  66908. * Gets the g output component
  66909. */
  66910. get g(): NodeMaterialConnectionPoint;
  66911. /**
  66912. * Gets the b output component
  66913. */
  66914. get b(): NodeMaterialConnectionPoint;
  66915. /**
  66916. * Gets the a output component
  66917. */
  66918. get a(): NodeMaterialConnectionPoint;
  66919. autoConfigure(material: NodeMaterial): void;
  66920. protected _buildBlock(state: NodeMaterialBuildState): this;
  66921. }
  66922. }
  66923. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66924. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66925. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66926. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66927. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66928. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66929. }
  66930. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66931. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66932. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66933. }
  66934. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66935. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66936. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66937. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66938. /**
  66939. * Block used to add 2 vectors
  66940. */
  66941. export class AddBlock extends NodeMaterialBlock {
  66942. /**
  66943. * Creates a new AddBlock
  66944. * @param name defines the block name
  66945. */
  66946. constructor(name: string);
  66947. /**
  66948. * Gets the current class name
  66949. * @returns the class name
  66950. */
  66951. getClassName(): string;
  66952. /**
  66953. * Gets the left operand input component
  66954. */
  66955. get left(): NodeMaterialConnectionPoint;
  66956. /**
  66957. * Gets the right operand input component
  66958. */
  66959. get right(): NodeMaterialConnectionPoint;
  66960. /**
  66961. * Gets the output component
  66962. */
  66963. get output(): NodeMaterialConnectionPoint;
  66964. protected _buildBlock(state: NodeMaterialBuildState): this;
  66965. }
  66966. }
  66967. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66968. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66969. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66970. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66971. /**
  66972. * Block used to scale a vector by a float
  66973. */
  66974. export class ScaleBlock extends NodeMaterialBlock {
  66975. /**
  66976. * Creates a new ScaleBlock
  66977. * @param name defines the block name
  66978. */
  66979. constructor(name: string);
  66980. /**
  66981. * Gets the current class name
  66982. * @returns the class name
  66983. */
  66984. getClassName(): string;
  66985. /**
  66986. * Gets the input component
  66987. */
  66988. get input(): NodeMaterialConnectionPoint;
  66989. /**
  66990. * Gets the factor input component
  66991. */
  66992. get factor(): NodeMaterialConnectionPoint;
  66993. /**
  66994. * Gets the output component
  66995. */
  66996. get output(): NodeMaterialConnectionPoint;
  66997. protected _buildBlock(state: NodeMaterialBuildState): this;
  66998. }
  66999. }
  67000. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  67001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67002. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67003. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67004. import { Scene } from "babylonjs/scene";
  67005. /**
  67006. * Block used to clamp a float
  67007. */
  67008. export class ClampBlock extends NodeMaterialBlock {
  67009. /** Gets or sets the minimum range */
  67010. minimum: number;
  67011. /** Gets or sets the maximum range */
  67012. maximum: number;
  67013. /**
  67014. * Creates a new ClampBlock
  67015. * @param name defines the block name
  67016. */
  67017. constructor(name: string);
  67018. /**
  67019. * Gets the current class name
  67020. * @returns the class name
  67021. */
  67022. getClassName(): string;
  67023. /**
  67024. * Gets the value input component
  67025. */
  67026. get value(): NodeMaterialConnectionPoint;
  67027. /**
  67028. * Gets the output component
  67029. */
  67030. get output(): NodeMaterialConnectionPoint;
  67031. protected _buildBlock(state: NodeMaterialBuildState): this;
  67032. protected _dumpPropertiesCode(): string;
  67033. serialize(): any;
  67034. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67035. }
  67036. }
  67037. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  67038. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67039. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67040. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67041. /**
  67042. * Block used to apply a cross product between 2 vectors
  67043. */
  67044. export class CrossBlock extends NodeMaterialBlock {
  67045. /**
  67046. * Creates a new CrossBlock
  67047. * @param name defines the block name
  67048. */
  67049. constructor(name: string);
  67050. /**
  67051. * Gets the current class name
  67052. * @returns the class name
  67053. */
  67054. getClassName(): string;
  67055. /**
  67056. * Gets the left operand input component
  67057. */
  67058. get left(): NodeMaterialConnectionPoint;
  67059. /**
  67060. * Gets the right operand input component
  67061. */
  67062. get right(): NodeMaterialConnectionPoint;
  67063. /**
  67064. * Gets the output component
  67065. */
  67066. get output(): NodeMaterialConnectionPoint;
  67067. protected _buildBlock(state: NodeMaterialBuildState): this;
  67068. }
  67069. }
  67070. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  67071. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67072. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67073. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67074. /**
  67075. * Block used to apply a dot product between 2 vectors
  67076. */
  67077. export class DotBlock extends NodeMaterialBlock {
  67078. /**
  67079. * Creates a new DotBlock
  67080. * @param name defines the block name
  67081. */
  67082. constructor(name: string);
  67083. /**
  67084. * Gets the current class name
  67085. * @returns the class name
  67086. */
  67087. getClassName(): string;
  67088. /**
  67089. * Gets the left operand input component
  67090. */
  67091. get left(): NodeMaterialConnectionPoint;
  67092. /**
  67093. * Gets the right operand input component
  67094. */
  67095. get right(): NodeMaterialConnectionPoint;
  67096. /**
  67097. * Gets the output component
  67098. */
  67099. get output(): NodeMaterialConnectionPoint;
  67100. protected _buildBlock(state: NodeMaterialBuildState): this;
  67101. }
  67102. }
  67103. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  67104. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67105. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67106. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67107. /**
  67108. * Block used to normalize a vector
  67109. */
  67110. export class NormalizeBlock extends NodeMaterialBlock {
  67111. /**
  67112. * Creates a new NormalizeBlock
  67113. * @param name defines the block name
  67114. */
  67115. constructor(name: string);
  67116. /**
  67117. * Gets the current class name
  67118. * @returns the class name
  67119. */
  67120. getClassName(): string;
  67121. /**
  67122. * Gets the input component
  67123. */
  67124. get input(): NodeMaterialConnectionPoint;
  67125. /**
  67126. * Gets the output component
  67127. */
  67128. get output(): NodeMaterialConnectionPoint;
  67129. protected _buildBlock(state: NodeMaterialBuildState): this;
  67130. }
  67131. }
  67132. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  67133. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67134. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67135. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67136. /**
  67137. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67138. */
  67139. export class ColorMergerBlock extends NodeMaterialBlock {
  67140. /**
  67141. * Create a new ColorMergerBlock
  67142. * @param name defines the block name
  67143. */
  67144. constructor(name: string);
  67145. /**
  67146. * Gets the current class name
  67147. * @returns the class name
  67148. */
  67149. getClassName(): string;
  67150. /**
  67151. * Gets the rgb component (input)
  67152. */
  67153. get rgbIn(): NodeMaterialConnectionPoint;
  67154. /**
  67155. * Gets the r component (input)
  67156. */
  67157. get r(): NodeMaterialConnectionPoint;
  67158. /**
  67159. * Gets the g component (input)
  67160. */
  67161. get g(): NodeMaterialConnectionPoint;
  67162. /**
  67163. * Gets the b component (input)
  67164. */
  67165. get b(): NodeMaterialConnectionPoint;
  67166. /**
  67167. * Gets the a component (input)
  67168. */
  67169. get a(): NodeMaterialConnectionPoint;
  67170. /**
  67171. * Gets the rgba component (output)
  67172. */
  67173. get rgba(): NodeMaterialConnectionPoint;
  67174. /**
  67175. * Gets the rgb component (output)
  67176. */
  67177. get rgbOut(): NodeMaterialConnectionPoint;
  67178. /**
  67179. * Gets the rgb component (output)
  67180. * @deprecated Please use rgbOut instead.
  67181. */
  67182. get rgb(): NodeMaterialConnectionPoint;
  67183. protected _buildBlock(state: NodeMaterialBuildState): this;
  67184. }
  67185. }
  67186. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  67187. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67188. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67189. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67190. /**
  67191. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67192. */
  67193. export class VectorSplitterBlock extends NodeMaterialBlock {
  67194. /**
  67195. * Create a new VectorSplitterBlock
  67196. * @param name defines the block name
  67197. */
  67198. constructor(name: string);
  67199. /**
  67200. * Gets the current class name
  67201. * @returns the class name
  67202. */
  67203. getClassName(): string;
  67204. /**
  67205. * Gets the xyzw component (input)
  67206. */
  67207. get xyzw(): NodeMaterialConnectionPoint;
  67208. /**
  67209. * Gets the xyz component (input)
  67210. */
  67211. get xyzIn(): NodeMaterialConnectionPoint;
  67212. /**
  67213. * Gets the xy component (input)
  67214. */
  67215. get xyIn(): NodeMaterialConnectionPoint;
  67216. /**
  67217. * Gets the xyz component (output)
  67218. */
  67219. get xyzOut(): NodeMaterialConnectionPoint;
  67220. /**
  67221. * Gets the xy component (output)
  67222. */
  67223. get xyOut(): NodeMaterialConnectionPoint;
  67224. /**
  67225. * Gets the x component (output)
  67226. */
  67227. get x(): NodeMaterialConnectionPoint;
  67228. /**
  67229. * Gets the y component (output)
  67230. */
  67231. get y(): NodeMaterialConnectionPoint;
  67232. /**
  67233. * Gets the z component (output)
  67234. */
  67235. get z(): NodeMaterialConnectionPoint;
  67236. /**
  67237. * Gets the w component (output)
  67238. */
  67239. get w(): NodeMaterialConnectionPoint;
  67240. protected _inputRename(name: string): string;
  67241. protected _outputRename(name: string): string;
  67242. protected _buildBlock(state: NodeMaterialBuildState): this;
  67243. }
  67244. }
  67245. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  67246. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67247. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67248. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67249. /**
  67250. * Block used to lerp between 2 values
  67251. */
  67252. export class LerpBlock extends NodeMaterialBlock {
  67253. /**
  67254. * Creates a new LerpBlock
  67255. * @param name defines the block name
  67256. */
  67257. constructor(name: string);
  67258. /**
  67259. * Gets the current class name
  67260. * @returns the class name
  67261. */
  67262. getClassName(): string;
  67263. /**
  67264. * Gets the left operand input component
  67265. */
  67266. get left(): NodeMaterialConnectionPoint;
  67267. /**
  67268. * Gets the right operand input component
  67269. */
  67270. get right(): NodeMaterialConnectionPoint;
  67271. /**
  67272. * Gets the gradient operand input component
  67273. */
  67274. get gradient(): NodeMaterialConnectionPoint;
  67275. /**
  67276. * Gets the output component
  67277. */
  67278. get output(): NodeMaterialConnectionPoint;
  67279. protected _buildBlock(state: NodeMaterialBuildState): this;
  67280. }
  67281. }
  67282. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  67283. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67284. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67285. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67286. /**
  67287. * Block used to divide 2 vectors
  67288. */
  67289. export class DivideBlock extends NodeMaterialBlock {
  67290. /**
  67291. * Creates a new DivideBlock
  67292. * @param name defines the block name
  67293. */
  67294. constructor(name: string);
  67295. /**
  67296. * Gets the current class name
  67297. * @returns the class name
  67298. */
  67299. getClassName(): string;
  67300. /**
  67301. * Gets the left operand input component
  67302. */
  67303. get left(): NodeMaterialConnectionPoint;
  67304. /**
  67305. * Gets the right operand input component
  67306. */
  67307. get right(): NodeMaterialConnectionPoint;
  67308. /**
  67309. * Gets the output component
  67310. */
  67311. get output(): NodeMaterialConnectionPoint;
  67312. protected _buildBlock(state: NodeMaterialBuildState): this;
  67313. }
  67314. }
  67315. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  67316. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67317. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67318. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67319. /**
  67320. * Block used to subtract 2 vectors
  67321. */
  67322. export class SubtractBlock extends NodeMaterialBlock {
  67323. /**
  67324. * Creates a new SubtractBlock
  67325. * @param name defines the block name
  67326. */
  67327. constructor(name: string);
  67328. /**
  67329. * Gets the current class name
  67330. * @returns the class name
  67331. */
  67332. getClassName(): string;
  67333. /**
  67334. * Gets the left operand input component
  67335. */
  67336. get left(): NodeMaterialConnectionPoint;
  67337. /**
  67338. * Gets the right operand input component
  67339. */
  67340. get right(): NodeMaterialConnectionPoint;
  67341. /**
  67342. * Gets the output component
  67343. */
  67344. get output(): NodeMaterialConnectionPoint;
  67345. protected _buildBlock(state: NodeMaterialBuildState): this;
  67346. }
  67347. }
  67348. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  67349. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67350. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67351. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67352. /**
  67353. * Block used to step a value
  67354. */
  67355. export class StepBlock extends NodeMaterialBlock {
  67356. /**
  67357. * Creates a new StepBlock
  67358. * @param name defines the block name
  67359. */
  67360. constructor(name: string);
  67361. /**
  67362. * Gets the current class name
  67363. * @returns the class name
  67364. */
  67365. getClassName(): string;
  67366. /**
  67367. * Gets the value operand input component
  67368. */
  67369. get value(): NodeMaterialConnectionPoint;
  67370. /**
  67371. * Gets the edge operand input component
  67372. */
  67373. get edge(): NodeMaterialConnectionPoint;
  67374. /**
  67375. * Gets the output component
  67376. */
  67377. get output(): NodeMaterialConnectionPoint;
  67378. protected _buildBlock(state: NodeMaterialBuildState): this;
  67379. }
  67380. }
  67381. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  67382. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67383. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67384. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67385. /**
  67386. * Block used to get the opposite (1 - x) of a value
  67387. */
  67388. export class OneMinusBlock extends NodeMaterialBlock {
  67389. /**
  67390. * Creates a new OneMinusBlock
  67391. * @param name defines the block name
  67392. */
  67393. constructor(name: string);
  67394. /**
  67395. * Gets the current class name
  67396. * @returns the class name
  67397. */
  67398. getClassName(): string;
  67399. /**
  67400. * Gets the input component
  67401. */
  67402. get input(): NodeMaterialConnectionPoint;
  67403. /**
  67404. * Gets the output component
  67405. */
  67406. get output(): NodeMaterialConnectionPoint;
  67407. protected _buildBlock(state: NodeMaterialBuildState): this;
  67408. }
  67409. }
  67410. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  67411. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67412. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67413. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67414. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67415. /**
  67416. * Block used to get the view direction
  67417. */
  67418. export class ViewDirectionBlock extends NodeMaterialBlock {
  67419. /**
  67420. * Creates a new ViewDirectionBlock
  67421. * @param name defines the block name
  67422. */
  67423. constructor(name: string);
  67424. /**
  67425. * Gets the current class name
  67426. * @returns the class name
  67427. */
  67428. getClassName(): string;
  67429. /**
  67430. * Gets the world position component
  67431. */
  67432. get worldPosition(): NodeMaterialConnectionPoint;
  67433. /**
  67434. * Gets the camera position component
  67435. */
  67436. get cameraPosition(): NodeMaterialConnectionPoint;
  67437. /**
  67438. * Gets the output component
  67439. */
  67440. get output(): NodeMaterialConnectionPoint;
  67441. autoConfigure(material: NodeMaterial): void;
  67442. protected _buildBlock(state: NodeMaterialBuildState): this;
  67443. }
  67444. }
  67445. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  67446. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67447. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67448. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67449. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67450. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  67451. /**
  67452. * Block used to compute fresnel value
  67453. */
  67454. export class FresnelBlock extends NodeMaterialBlock {
  67455. /**
  67456. * Create a new FresnelBlock
  67457. * @param name defines the block name
  67458. */
  67459. constructor(name: string);
  67460. /**
  67461. * Gets the current class name
  67462. * @returns the class name
  67463. */
  67464. getClassName(): string;
  67465. /**
  67466. * Gets the world normal input component
  67467. */
  67468. get worldNormal(): NodeMaterialConnectionPoint;
  67469. /**
  67470. * Gets the view direction input component
  67471. */
  67472. get viewDirection(): NodeMaterialConnectionPoint;
  67473. /**
  67474. * Gets the bias input component
  67475. */
  67476. get bias(): NodeMaterialConnectionPoint;
  67477. /**
  67478. * Gets the camera (or eye) position component
  67479. */
  67480. get power(): NodeMaterialConnectionPoint;
  67481. /**
  67482. * Gets the fresnel output component
  67483. */
  67484. get fresnel(): NodeMaterialConnectionPoint;
  67485. autoConfigure(material: NodeMaterial): void;
  67486. protected _buildBlock(state: NodeMaterialBuildState): this;
  67487. }
  67488. }
  67489. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  67490. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67491. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67492. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67493. /**
  67494. * Block used to get the max of 2 values
  67495. */
  67496. export class MaxBlock extends NodeMaterialBlock {
  67497. /**
  67498. * Creates a new MaxBlock
  67499. * @param name defines the block name
  67500. */
  67501. constructor(name: string);
  67502. /**
  67503. * Gets the current class name
  67504. * @returns the class name
  67505. */
  67506. getClassName(): string;
  67507. /**
  67508. * Gets the left operand input component
  67509. */
  67510. get left(): NodeMaterialConnectionPoint;
  67511. /**
  67512. * Gets the right operand input component
  67513. */
  67514. get right(): NodeMaterialConnectionPoint;
  67515. /**
  67516. * Gets the output component
  67517. */
  67518. get output(): NodeMaterialConnectionPoint;
  67519. protected _buildBlock(state: NodeMaterialBuildState): this;
  67520. }
  67521. }
  67522. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  67523. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67525. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67526. /**
  67527. * Block used to get the min of 2 values
  67528. */
  67529. export class MinBlock extends NodeMaterialBlock {
  67530. /**
  67531. * Creates a new MinBlock
  67532. * @param name defines the block name
  67533. */
  67534. constructor(name: string);
  67535. /**
  67536. * Gets the current class name
  67537. * @returns the class name
  67538. */
  67539. getClassName(): string;
  67540. /**
  67541. * Gets the left operand input component
  67542. */
  67543. get left(): NodeMaterialConnectionPoint;
  67544. /**
  67545. * Gets the right operand input component
  67546. */
  67547. get right(): NodeMaterialConnectionPoint;
  67548. /**
  67549. * Gets the output component
  67550. */
  67551. get output(): NodeMaterialConnectionPoint;
  67552. protected _buildBlock(state: NodeMaterialBuildState): this;
  67553. }
  67554. }
  67555. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  67556. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67557. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67558. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67559. /**
  67560. * Block used to get the distance between 2 values
  67561. */
  67562. export class DistanceBlock extends NodeMaterialBlock {
  67563. /**
  67564. * Creates a new DistanceBlock
  67565. * @param name defines the block name
  67566. */
  67567. constructor(name: string);
  67568. /**
  67569. * Gets the current class name
  67570. * @returns the class name
  67571. */
  67572. getClassName(): string;
  67573. /**
  67574. * Gets the left operand input component
  67575. */
  67576. get left(): NodeMaterialConnectionPoint;
  67577. /**
  67578. * Gets the right operand input component
  67579. */
  67580. get right(): NodeMaterialConnectionPoint;
  67581. /**
  67582. * Gets the output component
  67583. */
  67584. get output(): NodeMaterialConnectionPoint;
  67585. protected _buildBlock(state: NodeMaterialBuildState): this;
  67586. }
  67587. }
  67588. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  67589. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67590. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67591. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67592. /**
  67593. * Block used to get the length of a vector
  67594. */
  67595. export class LengthBlock extends NodeMaterialBlock {
  67596. /**
  67597. * Creates a new LengthBlock
  67598. * @param name defines the block name
  67599. */
  67600. constructor(name: string);
  67601. /**
  67602. * Gets the current class name
  67603. * @returns the class name
  67604. */
  67605. getClassName(): string;
  67606. /**
  67607. * Gets the value input component
  67608. */
  67609. get value(): NodeMaterialConnectionPoint;
  67610. /**
  67611. * Gets the output component
  67612. */
  67613. get output(): NodeMaterialConnectionPoint;
  67614. protected _buildBlock(state: NodeMaterialBuildState): this;
  67615. }
  67616. }
  67617. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  67618. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67619. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67620. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67621. /**
  67622. * Block used to get negative version of a value (i.e. x * -1)
  67623. */
  67624. export class NegateBlock extends NodeMaterialBlock {
  67625. /**
  67626. * Creates a new NegateBlock
  67627. * @param name defines the block name
  67628. */
  67629. constructor(name: string);
  67630. /**
  67631. * Gets the current class name
  67632. * @returns the class name
  67633. */
  67634. getClassName(): string;
  67635. /**
  67636. * Gets the value input component
  67637. */
  67638. get value(): NodeMaterialConnectionPoint;
  67639. /**
  67640. * Gets the output component
  67641. */
  67642. get output(): NodeMaterialConnectionPoint;
  67643. protected _buildBlock(state: NodeMaterialBuildState): this;
  67644. }
  67645. }
  67646. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  67647. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67648. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67649. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67650. /**
  67651. * Block used to get the value of the first parameter raised to the power of the second
  67652. */
  67653. export class PowBlock extends NodeMaterialBlock {
  67654. /**
  67655. * Creates a new PowBlock
  67656. * @param name defines the block name
  67657. */
  67658. constructor(name: string);
  67659. /**
  67660. * Gets the current class name
  67661. * @returns the class name
  67662. */
  67663. getClassName(): string;
  67664. /**
  67665. * Gets the value operand input component
  67666. */
  67667. get value(): NodeMaterialConnectionPoint;
  67668. /**
  67669. * Gets the power operand input component
  67670. */
  67671. get power(): NodeMaterialConnectionPoint;
  67672. /**
  67673. * Gets the output component
  67674. */
  67675. get output(): NodeMaterialConnectionPoint;
  67676. protected _buildBlock(state: NodeMaterialBuildState): this;
  67677. }
  67678. }
  67679. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  67680. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67681. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67682. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67683. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67684. /**
  67685. * Block used to get a random number
  67686. */
  67687. export class RandomNumberBlock extends NodeMaterialBlock {
  67688. /**
  67689. * Creates a new RandomNumberBlock
  67690. * @param name defines the block name
  67691. */
  67692. constructor(name: string);
  67693. /**
  67694. * Gets the current class name
  67695. * @returns the class name
  67696. */
  67697. getClassName(): string;
  67698. /**
  67699. * Gets the seed input component
  67700. */
  67701. get seed(): NodeMaterialConnectionPoint;
  67702. /**
  67703. * Gets the output component
  67704. */
  67705. get output(): NodeMaterialConnectionPoint;
  67706. protected _buildBlock(state: NodeMaterialBuildState): this;
  67707. }
  67708. }
  67709. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  67710. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67711. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67712. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67713. /**
  67714. * Block used to compute arc tangent of 2 values
  67715. */
  67716. export class ArcTan2Block extends NodeMaterialBlock {
  67717. /**
  67718. * Creates a new ArcTan2Block
  67719. * @param name defines the block name
  67720. */
  67721. constructor(name: string);
  67722. /**
  67723. * Gets the current class name
  67724. * @returns the class name
  67725. */
  67726. getClassName(): string;
  67727. /**
  67728. * Gets the x operand input component
  67729. */
  67730. get x(): NodeMaterialConnectionPoint;
  67731. /**
  67732. * Gets the y operand input component
  67733. */
  67734. get y(): NodeMaterialConnectionPoint;
  67735. /**
  67736. * Gets the output component
  67737. */
  67738. get output(): NodeMaterialConnectionPoint;
  67739. protected _buildBlock(state: NodeMaterialBuildState): this;
  67740. }
  67741. }
  67742. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  67743. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67744. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67745. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67746. /**
  67747. * Block used to smooth step a value
  67748. */
  67749. export class SmoothStepBlock extends NodeMaterialBlock {
  67750. /**
  67751. * Creates a new SmoothStepBlock
  67752. * @param name defines the block name
  67753. */
  67754. constructor(name: string);
  67755. /**
  67756. * Gets the current class name
  67757. * @returns the class name
  67758. */
  67759. getClassName(): string;
  67760. /**
  67761. * Gets the value operand input component
  67762. */
  67763. get value(): NodeMaterialConnectionPoint;
  67764. /**
  67765. * Gets the first edge operand input component
  67766. */
  67767. get edge0(): NodeMaterialConnectionPoint;
  67768. /**
  67769. * Gets the second edge operand input component
  67770. */
  67771. get edge1(): NodeMaterialConnectionPoint;
  67772. /**
  67773. * Gets the output component
  67774. */
  67775. get output(): NodeMaterialConnectionPoint;
  67776. protected _buildBlock(state: NodeMaterialBuildState): this;
  67777. }
  67778. }
  67779. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67780. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67781. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67782. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67783. /**
  67784. * Block used to get the reciprocal (1 / x) of a value
  67785. */
  67786. export class ReciprocalBlock extends NodeMaterialBlock {
  67787. /**
  67788. * Creates a new ReciprocalBlock
  67789. * @param name defines the block name
  67790. */
  67791. constructor(name: string);
  67792. /**
  67793. * Gets the current class name
  67794. * @returns the class name
  67795. */
  67796. getClassName(): string;
  67797. /**
  67798. * Gets the input component
  67799. */
  67800. get input(): NodeMaterialConnectionPoint;
  67801. /**
  67802. * Gets the output component
  67803. */
  67804. get output(): NodeMaterialConnectionPoint;
  67805. protected _buildBlock(state: NodeMaterialBuildState): this;
  67806. }
  67807. }
  67808. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67811. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67812. /**
  67813. * Block used to replace a color by another one
  67814. */
  67815. export class ReplaceColorBlock extends NodeMaterialBlock {
  67816. /**
  67817. * Creates a new ReplaceColorBlock
  67818. * @param name defines the block name
  67819. */
  67820. constructor(name: string);
  67821. /**
  67822. * Gets the current class name
  67823. * @returns the class name
  67824. */
  67825. getClassName(): string;
  67826. /**
  67827. * Gets the value input component
  67828. */
  67829. get value(): NodeMaterialConnectionPoint;
  67830. /**
  67831. * Gets the reference input component
  67832. */
  67833. get reference(): NodeMaterialConnectionPoint;
  67834. /**
  67835. * Gets the distance input component
  67836. */
  67837. get distance(): NodeMaterialConnectionPoint;
  67838. /**
  67839. * Gets the replacement input component
  67840. */
  67841. get replacement(): NodeMaterialConnectionPoint;
  67842. /**
  67843. * Gets the output component
  67844. */
  67845. get output(): NodeMaterialConnectionPoint;
  67846. protected _buildBlock(state: NodeMaterialBuildState): this;
  67847. }
  67848. }
  67849. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67850. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67851. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67852. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67853. /**
  67854. * Block used to posterize a value
  67855. * @see https://en.wikipedia.org/wiki/Posterization
  67856. */
  67857. export class PosterizeBlock extends NodeMaterialBlock {
  67858. /**
  67859. * Creates a new PosterizeBlock
  67860. * @param name defines the block name
  67861. */
  67862. constructor(name: string);
  67863. /**
  67864. * Gets the current class name
  67865. * @returns the class name
  67866. */
  67867. getClassName(): string;
  67868. /**
  67869. * Gets the value input component
  67870. */
  67871. get value(): NodeMaterialConnectionPoint;
  67872. /**
  67873. * Gets the steps input component
  67874. */
  67875. get steps(): NodeMaterialConnectionPoint;
  67876. /**
  67877. * Gets the output component
  67878. */
  67879. get output(): NodeMaterialConnectionPoint;
  67880. protected _buildBlock(state: NodeMaterialBuildState): this;
  67881. }
  67882. }
  67883. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67884. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67885. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67886. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67887. import { Scene } from "babylonjs/scene";
  67888. /**
  67889. * Operations supported by the Wave block
  67890. */
  67891. export enum WaveBlockKind {
  67892. /** SawTooth */
  67893. SawTooth = 0,
  67894. /** Square */
  67895. Square = 1,
  67896. /** Triangle */
  67897. Triangle = 2
  67898. }
  67899. /**
  67900. * Block used to apply wave operation to floats
  67901. */
  67902. export class WaveBlock extends NodeMaterialBlock {
  67903. /**
  67904. * Gets or sets the kibnd of wave to be applied by the block
  67905. */
  67906. kind: WaveBlockKind;
  67907. /**
  67908. * Creates a new WaveBlock
  67909. * @param name defines the block name
  67910. */
  67911. constructor(name: string);
  67912. /**
  67913. * Gets the current class name
  67914. * @returns the class name
  67915. */
  67916. getClassName(): string;
  67917. /**
  67918. * Gets the input component
  67919. */
  67920. get input(): NodeMaterialConnectionPoint;
  67921. /**
  67922. * Gets the output component
  67923. */
  67924. get output(): NodeMaterialConnectionPoint;
  67925. protected _buildBlock(state: NodeMaterialBuildState): this;
  67926. serialize(): any;
  67927. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67928. }
  67929. }
  67930. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67931. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67932. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67933. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67934. import { Color3 } from "babylonjs/Maths/math.color";
  67935. import { Scene } from "babylonjs/scene";
  67936. import { Observable } from "babylonjs/Misc/observable";
  67937. /**
  67938. * Class used to store a color step for the GradientBlock
  67939. */
  67940. export class GradientBlockColorStep {
  67941. private _step;
  67942. /**
  67943. * Gets value indicating which step this color is associated with (between 0 and 1)
  67944. */
  67945. get step(): number;
  67946. /**
  67947. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67948. */
  67949. set step(val: number);
  67950. private _color;
  67951. /**
  67952. * Gets the color associated with this step
  67953. */
  67954. get color(): Color3;
  67955. /**
  67956. * Sets the color associated with this step
  67957. */
  67958. set color(val: Color3);
  67959. /**
  67960. * Creates a new GradientBlockColorStep
  67961. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67962. * @param color defines the color associated with this step
  67963. */
  67964. constructor(step: number, color: Color3);
  67965. }
  67966. /**
  67967. * Block used to return a color from a gradient based on an input value between 0 and 1
  67968. */
  67969. export class GradientBlock extends NodeMaterialBlock {
  67970. /**
  67971. * Gets or sets the list of color steps
  67972. */
  67973. colorSteps: GradientBlockColorStep[];
  67974. /** Gets an observable raised when the value is changed */
  67975. onValueChangedObservable: Observable<GradientBlock>;
  67976. /** calls observable when the value is changed*/
  67977. colorStepsUpdated(): void;
  67978. /**
  67979. * Creates a new GradientBlock
  67980. * @param name defines the block name
  67981. */
  67982. constructor(name: string);
  67983. /**
  67984. * Gets the current class name
  67985. * @returns the class name
  67986. */
  67987. getClassName(): string;
  67988. /**
  67989. * Gets the gradient input component
  67990. */
  67991. get gradient(): NodeMaterialConnectionPoint;
  67992. /**
  67993. * Gets the output component
  67994. */
  67995. get output(): NodeMaterialConnectionPoint;
  67996. private _writeColorConstant;
  67997. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67998. serialize(): any;
  67999. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68000. protected _dumpPropertiesCode(): string;
  68001. }
  68002. }
  68003. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  68004. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68005. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68006. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68007. /**
  68008. * Block used to normalize lerp between 2 values
  68009. */
  68010. export class NLerpBlock extends NodeMaterialBlock {
  68011. /**
  68012. * Creates a new NLerpBlock
  68013. * @param name defines the block name
  68014. */
  68015. constructor(name: string);
  68016. /**
  68017. * Gets the current class name
  68018. * @returns the class name
  68019. */
  68020. getClassName(): string;
  68021. /**
  68022. * Gets the left operand input component
  68023. */
  68024. get left(): NodeMaterialConnectionPoint;
  68025. /**
  68026. * Gets the right operand input component
  68027. */
  68028. get right(): NodeMaterialConnectionPoint;
  68029. /**
  68030. * Gets the gradient operand input component
  68031. */
  68032. get gradient(): NodeMaterialConnectionPoint;
  68033. /**
  68034. * Gets the output component
  68035. */
  68036. get output(): NodeMaterialConnectionPoint;
  68037. protected _buildBlock(state: NodeMaterialBuildState): this;
  68038. }
  68039. }
  68040. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  68041. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68042. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68043. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68044. import { Scene } from "babylonjs/scene";
  68045. /**
  68046. * block used to Generate a Worley Noise 3D Noise Pattern
  68047. */
  68048. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68049. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68050. manhattanDistance: boolean;
  68051. /**
  68052. * Creates a new WorleyNoise3DBlock
  68053. * @param name defines the block name
  68054. */
  68055. constructor(name: string);
  68056. /**
  68057. * Gets the current class name
  68058. * @returns the class name
  68059. */
  68060. getClassName(): string;
  68061. /**
  68062. * Gets the seed input component
  68063. */
  68064. get seed(): NodeMaterialConnectionPoint;
  68065. /**
  68066. * Gets the jitter input component
  68067. */
  68068. get jitter(): NodeMaterialConnectionPoint;
  68069. /**
  68070. * Gets the output component
  68071. */
  68072. get output(): NodeMaterialConnectionPoint;
  68073. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68074. /**
  68075. * Exposes the properties to the UI?
  68076. */
  68077. protected _dumpPropertiesCode(): string;
  68078. /**
  68079. * Exposes the properties to the Seralize?
  68080. */
  68081. serialize(): any;
  68082. /**
  68083. * Exposes the properties to the deseralize?
  68084. */
  68085. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68086. }
  68087. }
  68088. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  68089. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68090. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68091. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68092. /**
  68093. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68094. */
  68095. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68096. /**
  68097. * Creates a new SimplexPerlin3DBlock
  68098. * @param name defines the block name
  68099. */
  68100. constructor(name: string);
  68101. /**
  68102. * Gets the current class name
  68103. * @returns the class name
  68104. */
  68105. getClassName(): string;
  68106. /**
  68107. * Gets the seed operand input component
  68108. */
  68109. get seed(): NodeMaterialConnectionPoint;
  68110. /**
  68111. * Gets the output component
  68112. */
  68113. get output(): NodeMaterialConnectionPoint;
  68114. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68115. }
  68116. }
  68117. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  68118. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68119. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68120. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68121. /**
  68122. * Block used to blend normals
  68123. */
  68124. export class NormalBlendBlock extends NodeMaterialBlock {
  68125. /**
  68126. * Creates a new NormalBlendBlock
  68127. * @param name defines the block name
  68128. */
  68129. constructor(name: string);
  68130. /**
  68131. * Gets the current class name
  68132. * @returns the class name
  68133. */
  68134. getClassName(): string;
  68135. /**
  68136. * Gets the first input component
  68137. */
  68138. get normalMap0(): NodeMaterialConnectionPoint;
  68139. /**
  68140. * Gets the second input component
  68141. */
  68142. get normalMap1(): NodeMaterialConnectionPoint;
  68143. /**
  68144. * Gets the output component
  68145. */
  68146. get output(): NodeMaterialConnectionPoint;
  68147. protected _buildBlock(state: NodeMaterialBuildState): this;
  68148. }
  68149. }
  68150. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  68151. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68152. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68153. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68154. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68155. /**
  68156. * Block used to rotate a 2d vector by a given angle
  68157. */
  68158. export class Rotate2dBlock extends NodeMaterialBlock {
  68159. /**
  68160. * Creates a new Rotate2dBlock
  68161. * @param name defines the block name
  68162. */
  68163. constructor(name: string);
  68164. /**
  68165. * Gets the current class name
  68166. * @returns the class name
  68167. */
  68168. getClassName(): string;
  68169. /**
  68170. * Gets the input vector
  68171. */
  68172. get input(): NodeMaterialConnectionPoint;
  68173. /**
  68174. * Gets the input angle
  68175. */
  68176. get angle(): NodeMaterialConnectionPoint;
  68177. /**
  68178. * Gets the output component
  68179. */
  68180. get output(): NodeMaterialConnectionPoint;
  68181. autoConfigure(material: NodeMaterial): void;
  68182. protected _buildBlock(state: NodeMaterialBuildState): this;
  68183. }
  68184. }
  68185. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  68186. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68187. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68188. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68189. /**
  68190. * Block used to get the reflected vector from a direction and a normal
  68191. */
  68192. export class ReflectBlock extends NodeMaterialBlock {
  68193. /**
  68194. * Creates a new ReflectBlock
  68195. * @param name defines the block name
  68196. */
  68197. constructor(name: string);
  68198. /**
  68199. * Gets the current class name
  68200. * @returns the class name
  68201. */
  68202. getClassName(): string;
  68203. /**
  68204. * Gets the incident component
  68205. */
  68206. get incident(): NodeMaterialConnectionPoint;
  68207. /**
  68208. * Gets the normal component
  68209. */
  68210. get normal(): NodeMaterialConnectionPoint;
  68211. /**
  68212. * Gets the output component
  68213. */
  68214. get output(): NodeMaterialConnectionPoint;
  68215. protected _buildBlock(state: NodeMaterialBuildState): this;
  68216. }
  68217. }
  68218. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  68219. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68220. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68221. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68222. /**
  68223. * Block used to get the refracted vector from a direction and a normal
  68224. */
  68225. export class RefractBlock extends NodeMaterialBlock {
  68226. /**
  68227. * Creates a new RefractBlock
  68228. * @param name defines the block name
  68229. */
  68230. constructor(name: string);
  68231. /**
  68232. * Gets the current class name
  68233. * @returns the class name
  68234. */
  68235. getClassName(): string;
  68236. /**
  68237. * Gets the incident component
  68238. */
  68239. get incident(): NodeMaterialConnectionPoint;
  68240. /**
  68241. * Gets the normal component
  68242. */
  68243. get normal(): NodeMaterialConnectionPoint;
  68244. /**
  68245. * Gets the index of refraction component
  68246. */
  68247. get ior(): NodeMaterialConnectionPoint;
  68248. /**
  68249. * Gets the output component
  68250. */
  68251. get output(): NodeMaterialConnectionPoint;
  68252. protected _buildBlock(state: NodeMaterialBuildState): this;
  68253. }
  68254. }
  68255. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  68256. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68257. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68258. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68259. /**
  68260. * Block used to desaturate a color
  68261. */
  68262. export class DesaturateBlock extends NodeMaterialBlock {
  68263. /**
  68264. * Creates a new DesaturateBlock
  68265. * @param name defines the block name
  68266. */
  68267. constructor(name: string);
  68268. /**
  68269. * Gets the current class name
  68270. * @returns the class name
  68271. */
  68272. getClassName(): string;
  68273. /**
  68274. * Gets the color operand input component
  68275. */
  68276. get color(): NodeMaterialConnectionPoint;
  68277. /**
  68278. * Gets the level operand input component
  68279. */
  68280. get level(): NodeMaterialConnectionPoint;
  68281. /**
  68282. * Gets the output component
  68283. */
  68284. get output(): NodeMaterialConnectionPoint;
  68285. protected _buildBlock(state: NodeMaterialBuildState): this;
  68286. }
  68287. }
  68288. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  68289. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68290. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68291. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68292. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68293. import { Nullable } from "babylonjs/types";
  68294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68295. import { Scene } from "babylonjs/scene";
  68296. /**
  68297. * Block used to implement the ambient occlusion module of the PBR material
  68298. */
  68299. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  68300. /**
  68301. * Create a new AmbientOcclusionBlock
  68302. * @param name defines the block name
  68303. */
  68304. constructor(name: string);
  68305. /**
  68306. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  68307. */
  68308. useAmbientInGrayScale: boolean;
  68309. /**
  68310. * Initialize the block and prepare the context for build
  68311. * @param state defines the state that will be used for the build
  68312. */
  68313. initialize(state: NodeMaterialBuildState): void;
  68314. /**
  68315. * Gets the current class name
  68316. * @returns the class name
  68317. */
  68318. getClassName(): string;
  68319. /**
  68320. * Gets the texture input component
  68321. */
  68322. get texture(): NodeMaterialConnectionPoint;
  68323. /**
  68324. * Gets the texture intensity component
  68325. */
  68326. get intensity(): NodeMaterialConnectionPoint;
  68327. /**
  68328. * Gets the direct light intensity input component
  68329. */
  68330. get directLightIntensity(): NodeMaterialConnectionPoint;
  68331. /**
  68332. * Gets the ambient occlusion object output component
  68333. */
  68334. get ambientOcc(): NodeMaterialConnectionPoint;
  68335. /**
  68336. * Gets the main code of the block (fragment side)
  68337. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  68338. * @returns the shader code
  68339. */
  68340. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  68341. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68342. protected _buildBlock(state: NodeMaterialBuildState): this;
  68343. protected _dumpPropertiesCode(): string;
  68344. serialize(): any;
  68345. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68346. }
  68347. }
  68348. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  68349. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68350. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68351. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68352. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  68353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68354. import { Nullable } from "babylonjs/types";
  68355. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68356. import { Mesh } from "babylonjs/Meshes/mesh";
  68357. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68358. import { Effect } from "babylonjs/Materials/effect";
  68359. import { Scene } from "babylonjs/scene";
  68360. /**
  68361. * Block used to implement the reflection module of the PBR material
  68362. */
  68363. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68364. /** @hidden */
  68365. _defineLODReflectionAlpha: string;
  68366. /** @hidden */
  68367. _defineLinearSpecularReflection: string;
  68368. private _vEnvironmentIrradianceName;
  68369. /** @hidden */
  68370. _vReflectionMicrosurfaceInfosName: string;
  68371. /** @hidden */
  68372. _vReflectionInfosName: string;
  68373. /** @hidden */
  68374. _vReflectionFilteringInfoName: string;
  68375. private _scene;
  68376. /**
  68377. * The three properties below are set by the main PBR block prior to calling methods of this class.
  68378. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68379. * It's less burden on the user side in the editor part.
  68380. */
  68381. /** @hidden */
  68382. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68383. /** @hidden */
  68384. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68385. /** @hidden */
  68386. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68387. /**
  68388. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68389. * diffuse part of the IBL.
  68390. */
  68391. useSphericalHarmonics: boolean;
  68392. /**
  68393. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68394. */
  68395. forceIrradianceInFragment: boolean;
  68396. /**
  68397. * Create a new ReflectionBlock
  68398. * @param name defines the block name
  68399. */
  68400. constructor(name: string);
  68401. /**
  68402. * Gets the current class name
  68403. * @returns the class name
  68404. */
  68405. getClassName(): string;
  68406. /**
  68407. * Gets the position input component
  68408. */
  68409. get position(): NodeMaterialConnectionPoint;
  68410. /**
  68411. * Gets the world position input component
  68412. */
  68413. get worldPosition(): NodeMaterialConnectionPoint;
  68414. /**
  68415. * Gets the world normal input component
  68416. */
  68417. get worldNormal(): NodeMaterialConnectionPoint;
  68418. /**
  68419. * Gets the world input component
  68420. */
  68421. get world(): NodeMaterialConnectionPoint;
  68422. /**
  68423. * Gets the camera (or eye) position component
  68424. */
  68425. get cameraPosition(): NodeMaterialConnectionPoint;
  68426. /**
  68427. * Gets the view input component
  68428. */
  68429. get view(): NodeMaterialConnectionPoint;
  68430. /**
  68431. * Gets the color input component
  68432. */
  68433. get color(): NodeMaterialConnectionPoint;
  68434. /**
  68435. * Gets the reflection object output component
  68436. */
  68437. get reflection(): NodeMaterialConnectionPoint;
  68438. /**
  68439. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68440. */
  68441. get hasTexture(): boolean;
  68442. /**
  68443. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68444. */
  68445. get reflectionColor(): string;
  68446. protected _getTexture(): Nullable<BaseTexture>;
  68447. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68448. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68449. /**
  68450. * Gets the code to inject in the vertex shader
  68451. * @param state current state of the node material building
  68452. * @returns the shader code
  68453. */
  68454. handleVertexSide(state: NodeMaterialBuildState): string;
  68455. /**
  68456. * Gets the main code of the block (fragment side)
  68457. * @param state current state of the node material building
  68458. * @param normalVarName name of the existing variable corresponding to the normal
  68459. * @returns the shader code
  68460. */
  68461. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68462. protected _buildBlock(state: NodeMaterialBuildState): this;
  68463. protected _dumpPropertiesCode(): string;
  68464. serialize(): any;
  68465. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68466. }
  68467. }
  68468. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  68469. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68470. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68471. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68472. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68474. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68475. import { Scene } from "babylonjs/scene";
  68476. import { Nullable } from "babylonjs/types";
  68477. /**
  68478. * Block used to implement the sheen module of the PBR material
  68479. */
  68480. export class SheenBlock extends NodeMaterialBlock {
  68481. /**
  68482. * Create a new SheenBlock
  68483. * @param name defines the block name
  68484. */
  68485. constructor(name: string);
  68486. /**
  68487. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68488. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68489. * making it easier to setup and tweak the effect
  68490. */
  68491. albedoScaling: boolean;
  68492. /**
  68493. * Defines if the sheen is linked to the sheen color.
  68494. */
  68495. linkSheenWithAlbedo: boolean;
  68496. /**
  68497. * Initialize the block and prepare the context for build
  68498. * @param state defines the state that will be used for the build
  68499. */
  68500. initialize(state: NodeMaterialBuildState): void;
  68501. /**
  68502. * Gets the current class name
  68503. * @returns the class name
  68504. */
  68505. getClassName(): string;
  68506. /**
  68507. * Gets the intensity input component
  68508. */
  68509. get intensity(): NodeMaterialConnectionPoint;
  68510. /**
  68511. * Gets the color input component
  68512. */
  68513. get color(): NodeMaterialConnectionPoint;
  68514. /**
  68515. * Gets the roughness input component
  68516. */
  68517. get roughness(): NodeMaterialConnectionPoint;
  68518. /**
  68519. * Gets the sheen object output component
  68520. */
  68521. get sheen(): NodeMaterialConnectionPoint;
  68522. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68523. /**
  68524. * Gets the main code of the block (fragment side)
  68525. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68526. * @returns the shader code
  68527. */
  68528. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68529. protected _buildBlock(state: NodeMaterialBuildState): this;
  68530. protected _dumpPropertiesCode(): string;
  68531. serialize(): any;
  68532. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68533. }
  68534. }
  68535. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  68536. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68537. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68541. import { Scene } from "babylonjs/scene";
  68542. import { Nullable } from "babylonjs/types";
  68543. import { Mesh } from "babylonjs/Meshes/mesh";
  68544. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68545. import { Effect } from "babylonjs/Materials/effect";
  68546. /**
  68547. * Block used to implement the reflectivity module of the PBR material
  68548. */
  68549. export class ReflectivityBlock extends NodeMaterialBlock {
  68550. private _metallicReflectanceColor;
  68551. private _metallicF0Factor;
  68552. /** @hidden */
  68553. _vMetallicReflectanceFactorsName: string;
  68554. /**
  68555. * The property below is set by the main PBR block prior to calling methods of this class.
  68556. */
  68557. /** @hidden */
  68558. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  68559. /**
  68560. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  68561. */
  68562. useAmbientOcclusionFromMetallicTextureRed: boolean;
  68563. /**
  68564. * Specifies if the metallic texture contains the metallness information in its blue channel.
  68565. */
  68566. useMetallnessFromMetallicTextureBlue: boolean;
  68567. /**
  68568. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  68569. */
  68570. useRoughnessFromMetallicTextureAlpha: boolean;
  68571. /**
  68572. * Specifies if the metallic texture contains the roughness information in its green channel.
  68573. */
  68574. useRoughnessFromMetallicTextureGreen: boolean;
  68575. /**
  68576. * Create a new ReflectivityBlock
  68577. * @param name defines the block name
  68578. */
  68579. constructor(name: string);
  68580. /**
  68581. * Initialize the block and prepare the context for build
  68582. * @param state defines the state that will be used for the build
  68583. */
  68584. initialize(state: NodeMaterialBuildState): void;
  68585. /**
  68586. * Gets the current class name
  68587. * @returns the class name
  68588. */
  68589. getClassName(): string;
  68590. /**
  68591. * Gets the metallic input component
  68592. */
  68593. get metallic(): NodeMaterialConnectionPoint;
  68594. /**
  68595. * Gets the roughness input component
  68596. */
  68597. get roughness(): NodeMaterialConnectionPoint;
  68598. /**
  68599. * Gets the texture input component
  68600. */
  68601. get texture(): NodeMaterialConnectionPoint;
  68602. /**
  68603. * Gets the reflectivity object output component
  68604. */
  68605. get reflectivity(): NodeMaterialConnectionPoint;
  68606. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68607. /**
  68608. * Gets the main code of the block (fragment side)
  68609. * @param state current state of the node material building
  68610. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  68611. * @returns the shader code
  68612. */
  68613. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  68614. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68615. protected _buildBlock(state: NodeMaterialBuildState): this;
  68616. protected _dumpPropertiesCode(): string;
  68617. serialize(): any;
  68618. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68619. }
  68620. }
  68621. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  68622. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68623. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68624. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68625. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68627. /**
  68628. * Block used to implement the anisotropy module of the PBR material
  68629. */
  68630. export class AnisotropyBlock extends NodeMaterialBlock {
  68631. /**
  68632. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68633. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68634. * It's less burden on the user side in the editor part.
  68635. */
  68636. /** @hidden */
  68637. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68638. /** @hidden */
  68639. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68640. /**
  68641. * Create a new AnisotropyBlock
  68642. * @param name defines the block name
  68643. */
  68644. constructor(name: string);
  68645. /**
  68646. * Initialize the block and prepare the context for build
  68647. * @param state defines the state that will be used for the build
  68648. */
  68649. initialize(state: NodeMaterialBuildState): void;
  68650. /**
  68651. * Gets the current class name
  68652. * @returns the class name
  68653. */
  68654. getClassName(): string;
  68655. /**
  68656. * Gets the intensity input component
  68657. */
  68658. get intensity(): NodeMaterialConnectionPoint;
  68659. /**
  68660. * Gets the direction input component
  68661. */
  68662. get direction(): NodeMaterialConnectionPoint;
  68663. /**
  68664. * Gets the texture input component
  68665. */
  68666. get texture(): NodeMaterialConnectionPoint;
  68667. /**
  68668. * Gets the uv input component
  68669. */
  68670. get uv(): NodeMaterialConnectionPoint;
  68671. /**
  68672. * Gets the worldTangent input component
  68673. */
  68674. get worldTangent(): NodeMaterialConnectionPoint;
  68675. /**
  68676. * Gets the anisotropy object output component
  68677. */
  68678. get anisotropy(): NodeMaterialConnectionPoint;
  68679. private _generateTBNSpace;
  68680. /**
  68681. * Gets the main code of the block (fragment side)
  68682. * @param state current state of the node material building
  68683. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68684. * @returns the shader code
  68685. */
  68686. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68687. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68688. protected _buildBlock(state: NodeMaterialBuildState): this;
  68689. }
  68690. }
  68691. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  68692. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68693. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68694. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68695. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68697. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68698. import { Nullable } from "babylonjs/types";
  68699. import { Mesh } from "babylonjs/Meshes/mesh";
  68700. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68701. import { Effect } from "babylonjs/Materials/effect";
  68702. /**
  68703. * Block used to implement the clear coat module of the PBR material
  68704. */
  68705. export class ClearCoatBlock extends NodeMaterialBlock {
  68706. private _scene;
  68707. /**
  68708. * Create a new ClearCoatBlock
  68709. * @param name defines the block name
  68710. */
  68711. constructor(name: string);
  68712. /**
  68713. * Initialize the block and prepare the context for build
  68714. * @param state defines the state that will be used for the build
  68715. */
  68716. initialize(state: NodeMaterialBuildState): void;
  68717. /**
  68718. * Gets the current class name
  68719. * @returns the class name
  68720. */
  68721. getClassName(): string;
  68722. /**
  68723. * Gets the intensity input component
  68724. */
  68725. get intensity(): NodeMaterialConnectionPoint;
  68726. /**
  68727. * Gets the roughness input component
  68728. */
  68729. get roughness(): NodeMaterialConnectionPoint;
  68730. /**
  68731. * Gets the ior input component
  68732. */
  68733. get ior(): NodeMaterialConnectionPoint;
  68734. /**
  68735. * Gets the texture input component
  68736. */
  68737. get texture(): NodeMaterialConnectionPoint;
  68738. /**
  68739. * Gets the bump texture input component
  68740. */
  68741. get bumpTexture(): NodeMaterialConnectionPoint;
  68742. /**
  68743. * Gets the uv input component
  68744. */
  68745. get uv(): NodeMaterialConnectionPoint;
  68746. /**
  68747. * Gets the tint color input component
  68748. */
  68749. get tintColor(): NodeMaterialConnectionPoint;
  68750. /**
  68751. * Gets the tint "at distance" input component
  68752. */
  68753. get tintAtDistance(): NodeMaterialConnectionPoint;
  68754. /**
  68755. * Gets the tint thickness input component
  68756. */
  68757. get tintThickness(): NodeMaterialConnectionPoint;
  68758. /**
  68759. * Gets the world tangent input component
  68760. */
  68761. get worldTangent(): NodeMaterialConnectionPoint;
  68762. /**
  68763. * Gets the clear coat object output component
  68764. */
  68765. get clearcoat(): NodeMaterialConnectionPoint;
  68766. autoConfigure(material: NodeMaterial): void;
  68767. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68768. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68769. private _generateTBNSpace;
  68770. /**
  68771. * Gets the main code of the block (fragment side)
  68772. * @param state current state of the node material building
  68773. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68774. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68775. * @param worldPosVarName name of the variable holding the world position
  68776. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68777. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68778. * @param worldNormalVarName name of the variable holding the world normal
  68779. * @returns the shader code
  68780. */
  68781. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68782. protected _buildBlock(state: NodeMaterialBuildState): this;
  68783. }
  68784. }
  68785. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68786. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68787. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68788. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68789. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68791. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68792. import { Nullable } from "babylonjs/types";
  68793. /**
  68794. * Block used to implement the sub surface module of the PBR material
  68795. */
  68796. export class SubSurfaceBlock extends NodeMaterialBlock {
  68797. /**
  68798. * Create a new SubSurfaceBlock
  68799. * @param name defines the block name
  68800. */
  68801. constructor(name: string);
  68802. /**
  68803. * Stores the intensity of the different subsurface effects in the thickness texture.
  68804. * * the green channel is the translucency intensity.
  68805. * * the blue channel is the scattering intensity.
  68806. * * the alpha channel is the refraction intensity.
  68807. */
  68808. useMaskFromThicknessTexture: boolean;
  68809. /**
  68810. * Initialize the block and prepare the context for build
  68811. * @param state defines the state that will be used for the build
  68812. */
  68813. initialize(state: NodeMaterialBuildState): void;
  68814. /**
  68815. * Gets the current class name
  68816. * @returns the class name
  68817. */
  68818. getClassName(): string;
  68819. /**
  68820. * Gets the min thickness input component
  68821. */
  68822. get minThickness(): NodeMaterialConnectionPoint;
  68823. /**
  68824. * Gets the max thickness input component
  68825. */
  68826. get maxThickness(): NodeMaterialConnectionPoint;
  68827. /**
  68828. * Gets the thickness texture component
  68829. */
  68830. get thicknessTexture(): NodeMaterialConnectionPoint;
  68831. /**
  68832. * Gets the tint color input component
  68833. */
  68834. get tintColor(): NodeMaterialConnectionPoint;
  68835. /**
  68836. * Gets the translucency intensity input component
  68837. */
  68838. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68839. /**
  68840. * Gets the translucency diffusion distance input component
  68841. */
  68842. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68843. /**
  68844. * Gets the refraction object parameters
  68845. */
  68846. get refraction(): NodeMaterialConnectionPoint;
  68847. /**
  68848. * Gets the sub surface object output component
  68849. */
  68850. get subsurface(): NodeMaterialConnectionPoint;
  68851. autoConfigure(material: NodeMaterial): void;
  68852. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68853. /**
  68854. * Gets the main code of the block (fragment side)
  68855. * @param state current state of the node material building
  68856. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68857. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68858. * @param worldPosVarName name of the variable holding the world position
  68859. * @returns the shader code
  68860. */
  68861. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68862. protected _buildBlock(state: NodeMaterialBuildState): this;
  68863. }
  68864. }
  68865. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68866. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68867. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68868. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68869. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68870. import { Light } from "babylonjs/Lights/light";
  68871. import { Nullable } from "babylonjs/types";
  68872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68873. import { Effect } from "babylonjs/Materials/effect";
  68874. import { Mesh } from "babylonjs/Meshes/mesh";
  68875. import { Scene } from "babylonjs/scene";
  68876. /**
  68877. * Block used to implement the PBR metallic/roughness model
  68878. */
  68879. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68880. /**
  68881. * Gets or sets the light associated with this block
  68882. */
  68883. light: Nullable<Light>;
  68884. private _lightId;
  68885. private _scene;
  68886. private _environmentBRDFTexture;
  68887. private _environmentBrdfSamplerName;
  68888. private _vNormalWName;
  68889. private _invertNormalName;
  68890. /**
  68891. * Create a new ReflectionBlock
  68892. * @param name defines the block name
  68893. */
  68894. constructor(name: string);
  68895. /**
  68896. * Intensity of the direct lights e.g. the four lights available in your scene.
  68897. * This impacts both the direct diffuse and specular highlights.
  68898. */
  68899. directIntensity: number;
  68900. /**
  68901. * Intensity of the environment e.g. how much the environment will light the object
  68902. * either through harmonics for rough material or through the refelction for shiny ones.
  68903. */
  68904. environmentIntensity: number;
  68905. /**
  68906. * This is a special control allowing the reduction of the specular highlights coming from the
  68907. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68908. */
  68909. specularIntensity: number;
  68910. /**
  68911. * Defines the falloff type used in this material.
  68912. * It by default is Physical.
  68913. */
  68914. lightFalloff: number;
  68915. /**
  68916. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68917. */
  68918. useAlphaFromAlbedoTexture: boolean;
  68919. /**
  68920. * Specifies that alpha test should be used
  68921. */
  68922. useAlphaTest: boolean;
  68923. /**
  68924. * Defines the alpha limits in alpha test mode.
  68925. */
  68926. alphaTestCutoff: number;
  68927. /**
  68928. * Specifies that alpha blending should be used
  68929. */
  68930. useAlphaBlending: boolean;
  68931. /**
  68932. * Defines if the alpha value should be determined via the rgb values.
  68933. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68934. */
  68935. opacityRGB: boolean;
  68936. /**
  68937. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68938. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68939. */
  68940. useRadianceOverAlpha: boolean;
  68941. /**
  68942. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68943. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68944. */
  68945. useSpecularOverAlpha: boolean;
  68946. /**
  68947. * Enables specular anti aliasing in the PBR shader.
  68948. * It will both interacts on the Geometry for analytical and IBL lighting.
  68949. * It also prefilter the roughness map based on the bump values.
  68950. */
  68951. enableSpecularAntiAliasing: boolean;
  68952. /**
  68953. * Enables realtime filtering on the texture.
  68954. */
  68955. realTimeFiltering: boolean;
  68956. /**
  68957. * Quality switch for realtime filtering
  68958. */
  68959. realTimeFilteringQuality: number;
  68960. /**
  68961. * Defines if the material uses energy conservation.
  68962. */
  68963. useEnergyConservation: boolean;
  68964. /**
  68965. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68966. * too much the area relying on ambient texture to define their ambient occlusion.
  68967. */
  68968. useRadianceOcclusion: boolean;
  68969. /**
  68970. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68971. * makes the reflect vector face the model (under horizon).
  68972. */
  68973. useHorizonOcclusion: boolean;
  68974. /**
  68975. * If set to true, no lighting calculations will be applied.
  68976. */
  68977. unlit: boolean;
  68978. /**
  68979. * Force normal to face away from face.
  68980. */
  68981. forceNormalForward: boolean;
  68982. /**
  68983. * Defines the material debug mode.
  68984. * It helps seeing only some components of the material while troubleshooting.
  68985. */
  68986. debugMode: number;
  68987. /**
  68988. * Specify from where on screen the debug mode should start.
  68989. * The value goes from -1 (full screen) to 1 (not visible)
  68990. * It helps with side by side comparison against the final render
  68991. * This defaults to 0
  68992. */
  68993. debugLimit: number;
  68994. /**
  68995. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68996. * You can use the factor to better multiply the final value.
  68997. */
  68998. debugFactor: number;
  68999. /**
  69000. * Initialize the block and prepare the context for build
  69001. * @param state defines the state that will be used for the build
  69002. */
  69003. initialize(state: NodeMaterialBuildState): void;
  69004. /**
  69005. * Gets the current class name
  69006. * @returns the class name
  69007. */
  69008. getClassName(): string;
  69009. /**
  69010. * Gets the world position input component
  69011. */
  69012. get worldPosition(): NodeMaterialConnectionPoint;
  69013. /**
  69014. * Gets the world normal input component
  69015. */
  69016. get worldNormal(): NodeMaterialConnectionPoint;
  69017. /**
  69018. * Gets the perturbed normal input component
  69019. */
  69020. get perturbedNormal(): NodeMaterialConnectionPoint;
  69021. /**
  69022. * Gets the camera position input component
  69023. */
  69024. get cameraPosition(): NodeMaterialConnectionPoint;
  69025. /**
  69026. * Gets the base color input component
  69027. */
  69028. get baseColor(): NodeMaterialConnectionPoint;
  69029. /**
  69030. * Gets the opacity texture input component
  69031. */
  69032. get opacityTexture(): NodeMaterialConnectionPoint;
  69033. /**
  69034. * Gets the ambient color input component
  69035. */
  69036. get ambientColor(): NodeMaterialConnectionPoint;
  69037. /**
  69038. * Gets the reflectivity object parameters
  69039. */
  69040. get reflectivity(): NodeMaterialConnectionPoint;
  69041. /**
  69042. * Gets the ambient occlusion object parameters
  69043. */
  69044. get ambientOcc(): NodeMaterialConnectionPoint;
  69045. /**
  69046. * Gets the reflection object parameters
  69047. */
  69048. get reflection(): NodeMaterialConnectionPoint;
  69049. /**
  69050. * Gets the sheen object parameters
  69051. */
  69052. get sheen(): NodeMaterialConnectionPoint;
  69053. /**
  69054. * Gets the clear coat object parameters
  69055. */
  69056. get clearcoat(): NodeMaterialConnectionPoint;
  69057. /**
  69058. * Gets the sub surface object parameters
  69059. */
  69060. get subsurface(): NodeMaterialConnectionPoint;
  69061. /**
  69062. * Gets the anisotropy object parameters
  69063. */
  69064. get anisotropy(): NodeMaterialConnectionPoint;
  69065. /**
  69066. * Gets the view matrix parameter
  69067. */
  69068. get view(): NodeMaterialConnectionPoint;
  69069. /**
  69070. * Gets the ambient output component
  69071. */
  69072. get ambient(): NodeMaterialConnectionPoint;
  69073. /**
  69074. * Gets the diffuse output component
  69075. */
  69076. get diffuse(): NodeMaterialConnectionPoint;
  69077. /**
  69078. * Gets the specular output component
  69079. */
  69080. get specular(): NodeMaterialConnectionPoint;
  69081. /**
  69082. * Gets the sheen output component
  69083. */
  69084. get sheenDir(): NodeMaterialConnectionPoint;
  69085. /**
  69086. * Gets the clear coat output component
  69087. */
  69088. get clearcoatDir(): NodeMaterialConnectionPoint;
  69089. /**
  69090. * Gets the indirect diffuse output component
  69091. */
  69092. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69093. /**
  69094. * Gets the indirect specular output component
  69095. */
  69096. get specularIndirect(): NodeMaterialConnectionPoint;
  69097. /**
  69098. * Gets the indirect sheen output component
  69099. */
  69100. get sheenIndirect(): NodeMaterialConnectionPoint;
  69101. /**
  69102. * Gets the indirect clear coat output component
  69103. */
  69104. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69105. /**
  69106. * Gets the refraction output component
  69107. */
  69108. get refraction(): NodeMaterialConnectionPoint;
  69109. /**
  69110. * Gets the global lighting output component
  69111. */
  69112. get lighting(): NodeMaterialConnectionPoint;
  69113. /**
  69114. * Gets the shadow output component
  69115. */
  69116. get shadow(): NodeMaterialConnectionPoint;
  69117. /**
  69118. * Gets the alpha output component
  69119. */
  69120. get alpha(): NodeMaterialConnectionPoint;
  69121. autoConfigure(material: NodeMaterial): void;
  69122. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69123. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69124. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69125. private _injectVertexCode;
  69126. /**
  69127. * Gets the code corresponding to the albedo/opacity module
  69128. * @returns the shader code
  69129. */
  69130. getAlbedoOpacityCode(): string;
  69131. protected _buildBlock(state: NodeMaterialBuildState): this;
  69132. protected _dumpPropertiesCode(): string;
  69133. serialize(): any;
  69134. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69135. }
  69136. }
  69137. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  69138. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  69139. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  69140. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  69141. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  69142. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  69143. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69144. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  69145. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  69146. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  69147. }
  69148. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  69149. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  69150. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  69151. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  69152. }
  69153. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  69154. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69155. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69156. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69157. /**
  69158. * Block used to compute value of one parameter modulo another
  69159. */
  69160. export class ModBlock extends NodeMaterialBlock {
  69161. /**
  69162. * Creates a new ModBlock
  69163. * @param name defines the block name
  69164. */
  69165. constructor(name: string);
  69166. /**
  69167. * Gets the current class name
  69168. * @returns the class name
  69169. */
  69170. getClassName(): string;
  69171. /**
  69172. * Gets the left operand input component
  69173. */
  69174. get left(): NodeMaterialConnectionPoint;
  69175. /**
  69176. * Gets the right operand input component
  69177. */
  69178. get right(): NodeMaterialConnectionPoint;
  69179. /**
  69180. * Gets the output component
  69181. */
  69182. get output(): NodeMaterialConnectionPoint;
  69183. protected _buildBlock(state: NodeMaterialBuildState): this;
  69184. }
  69185. }
  69186. declare module "babylonjs/Materials/Node/Blocks/index" {
  69187. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  69188. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  69189. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  69190. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  69191. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  69192. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  69193. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  69194. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  69195. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  69196. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  69197. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  69198. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  69199. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  69200. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  69201. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  69202. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  69203. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  69204. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  69205. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  69206. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  69207. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  69208. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  69209. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  69210. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  69211. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  69212. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  69213. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  69214. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  69215. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  69216. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  69217. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  69218. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  69219. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  69220. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  69221. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  69222. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  69223. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  69224. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  69225. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  69226. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  69227. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  69228. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  69229. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  69230. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  69231. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  69232. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  69233. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  69234. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  69235. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  69236. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  69237. }
  69238. declare module "babylonjs/Materials/Node/Optimizers/index" {
  69239. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  69240. }
  69241. declare module "babylonjs/Materials/Node/index" {
  69242. export * from "babylonjs/Materials/Node/Enums/index";
  69243. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69244. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  69245. export * from "babylonjs/Materials/Node/nodeMaterial";
  69246. export * from "babylonjs/Materials/Node/Blocks/index";
  69247. export * from "babylonjs/Materials/Node/Optimizers/index";
  69248. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  69249. }
  69250. declare module "babylonjs/Materials/index" {
  69251. export * from "babylonjs/Materials/Background/index";
  69252. export * from "babylonjs/Materials/colorCurves";
  69253. export * from "babylonjs/Materials/iEffectFallbacks";
  69254. export * from "babylonjs/Materials/effectFallbacks";
  69255. export * from "babylonjs/Materials/effect";
  69256. export * from "babylonjs/Materials/fresnelParameters";
  69257. export * from "babylonjs/Materials/imageProcessingConfiguration";
  69258. export * from "babylonjs/Materials/material";
  69259. export * from "babylonjs/Materials/materialDefines";
  69260. export * from "babylonjs/Materials/thinMaterialHelper";
  69261. export * from "babylonjs/Materials/materialHelper";
  69262. export * from "babylonjs/Materials/multiMaterial";
  69263. export * from "babylonjs/Materials/PBR/index";
  69264. export * from "babylonjs/Materials/pushMaterial";
  69265. export * from "babylonjs/Materials/shaderMaterial";
  69266. export * from "babylonjs/Materials/standardMaterial";
  69267. export * from "babylonjs/Materials/Textures/index";
  69268. export * from "babylonjs/Materials/uniformBuffer";
  69269. export * from "babylonjs/Materials/materialFlags";
  69270. export * from "babylonjs/Materials/Node/index";
  69271. export * from "babylonjs/Materials/effectRenderer";
  69272. export * from "babylonjs/Materials/shadowDepthWrapper";
  69273. }
  69274. declare module "babylonjs/Maths/index" {
  69275. export * from "babylonjs/Maths/math.scalar";
  69276. export * from "babylonjs/Maths/math";
  69277. export * from "babylonjs/Maths/sphericalPolynomial";
  69278. }
  69279. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  69280. import { IDisposable } from "babylonjs/scene";
  69281. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69282. /**
  69283. * Configuration for Draco compression
  69284. */
  69285. export interface IDracoCompressionConfiguration {
  69286. /**
  69287. * Configuration for the decoder.
  69288. */
  69289. decoder: {
  69290. /**
  69291. * The url to the WebAssembly module.
  69292. */
  69293. wasmUrl?: string;
  69294. /**
  69295. * The url to the WebAssembly binary.
  69296. */
  69297. wasmBinaryUrl?: string;
  69298. /**
  69299. * The url to the fallback JavaScript module.
  69300. */
  69301. fallbackUrl?: string;
  69302. };
  69303. }
  69304. /**
  69305. * Draco compression (https://google.github.io/draco/)
  69306. *
  69307. * This class wraps the Draco module.
  69308. *
  69309. * **Encoder**
  69310. *
  69311. * The encoder is not currently implemented.
  69312. *
  69313. * **Decoder**
  69314. *
  69315. * 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.
  69316. *
  69317. * To update the configuration, use the following code:
  69318. * ```javascript
  69319. * DracoCompression.Configuration = {
  69320. * decoder: {
  69321. * wasmUrl: "<url to the WebAssembly library>",
  69322. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69323. * fallbackUrl: "<url to the fallback JavaScript library>",
  69324. * }
  69325. * };
  69326. * ```
  69327. *
  69328. * 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.
  69329. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69330. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69331. *
  69332. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69333. * ```javascript
  69334. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69335. * ```
  69336. *
  69337. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69338. */
  69339. export class DracoCompression implements IDisposable {
  69340. private _workerPoolPromise?;
  69341. private _decoderModulePromise?;
  69342. /**
  69343. * The configuration. Defaults to the following urls:
  69344. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69345. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69346. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69347. */
  69348. static Configuration: IDracoCompressionConfiguration;
  69349. /**
  69350. * Returns true if the decoder configuration is available.
  69351. */
  69352. static get DecoderAvailable(): boolean;
  69353. /**
  69354. * Default number of workers to create when creating the draco compression object.
  69355. */
  69356. static DefaultNumWorkers: number;
  69357. private static GetDefaultNumWorkers;
  69358. private static _Default;
  69359. /**
  69360. * Default instance for the draco compression object.
  69361. */
  69362. static get Default(): DracoCompression;
  69363. /**
  69364. * Constructor
  69365. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69366. */
  69367. constructor(numWorkers?: number);
  69368. /**
  69369. * Stop all async operations and release resources.
  69370. */
  69371. dispose(): void;
  69372. /**
  69373. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69374. * @returns a promise that resolves when ready
  69375. */
  69376. whenReadyAsync(): Promise<void>;
  69377. /**
  69378. * Decode Draco compressed mesh data to vertex data.
  69379. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69380. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69381. * @returns A promise that resolves with the decoded vertex data
  69382. */
  69383. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69384. [kind: string]: number;
  69385. }): Promise<VertexData>;
  69386. }
  69387. }
  69388. declare module "babylonjs/Meshes/Compression/index" {
  69389. export * from "babylonjs/Meshes/Compression/dracoCompression";
  69390. }
  69391. declare module "babylonjs/Meshes/csg" {
  69392. import { Nullable } from "babylonjs/types";
  69393. import { Scene } from "babylonjs/scene";
  69394. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  69395. import { Mesh } from "babylonjs/Meshes/mesh";
  69396. import { Material } from "babylonjs/Materials/material";
  69397. /**
  69398. * Class for building Constructive Solid Geometry
  69399. */
  69400. export class CSG {
  69401. private polygons;
  69402. /**
  69403. * The world matrix
  69404. */
  69405. matrix: Matrix;
  69406. /**
  69407. * Stores the position
  69408. */
  69409. position: Vector3;
  69410. /**
  69411. * Stores the rotation
  69412. */
  69413. rotation: Vector3;
  69414. /**
  69415. * Stores the rotation quaternion
  69416. */
  69417. rotationQuaternion: Nullable<Quaternion>;
  69418. /**
  69419. * Stores the scaling vector
  69420. */
  69421. scaling: Vector3;
  69422. /**
  69423. * Convert the Mesh to CSG
  69424. * @param mesh The Mesh to convert to CSG
  69425. * @returns A new CSG from the Mesh
  69426. */
  69427. static FromMesh(mesh: Mesh): CSG;
  69428. /**
  69429. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69430. * @param polygons Polygons used to construct a CSG solid
  69431. */
  69432. private static FromPolygons;
  69433. /**
  69434. * Clones, or makes a deep copy, of the CSG
  69435. * @returns A new CSG
  69436. */
  69437. clone(): CSG;
  69438. /**
  69439. * Unions this CSG with another CSG
  69440. * @param csg The CSG to union against this CSG
  69441. * @returns The unioned CSG
  69442. */
  69443. union(csg: CSG): CSG;
  69444. /**
  69445. * Unions this CSG with another CSG in place
  69446. * @param csg The CSG to union against this CSG
  69447. */
  69448. unionInPlace(csg: CSG): void;
  69449. /**
  69450. * Subtracts this CSG with another CSG
  69451. * @param csg The CSG to subtract against this CSG
  69452. * @returns A new CSG
  69453. */
  69454. subtract(csg: CSG): CSG;
  69455. /**
  69456. * Subtracts this CSG with another CSG in place
  69457. * @param csg The CSG to subtact against this CSG
  69458. */
  69459. subtractInPlace(csg: CSG): void;
  69460. /**
  69461. * Intersect this CSG with another CSG
  69462. * @param csg The CSG to intersect against this CSG
  69463. * @returns A new CSG
  69464. */
  69465. intersect(csg: CSG): CSG;
  69466. /**
  69467. * Intersects this CSG with another CSG in place
  69468. * @param csg The CSG to intersect against this CSG
  69469. */
  69470. intersectInPlace(csg: CSG): void;
  69471. /**
  69472. * Return a new CSG solid with solid and empty space switched. This solid is
  69473. * not modified.
  69474. * @returns A new CSG solid with solid and empty space switched
  69475. */
  69476. inverse(): CSG;
  69477. /**
  69478. * Inverses the CSG in place
  69479. */
  69480. inverseInPlace(): void;
  69481. /**
  69482. * This is used to keep meshes transformations so they can be restored
  69483. * when we build back a Babylon Mesh
  69484. * NB : All CSG operations are performed in world coordinates
  69485. * @param csg The CSG to copy the transform attributes from
  69486. * @returns This CSG
  69487. */
  69488. copyTransformAttributes(csg: CSG): CSG;
  69489. /**
  69490. * Build Raw mesh from CSG
  69491. * Coordinates here are in world space
  69492. * @param name The name of the mesh geometry
  69493. * @param scene The Scene
  69494. * @param keepSubMeshes Specifies if the submeshes should be kept
  69495. * @returns A new Mesh
  69496. */
  69497. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69498. /**
  69499. * Build Mesh from CSG taking material and transforms into account
  69500. * @param name The name of the Mesh
  69501. * @param material The material of the Mesh
  69502. * @param scene The Scene
  69503. * @param keepSubMeshes Specifies if submeshes should be kept
  69504. * @returns The new Mesh
  69505. */
  69506. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69507. }
  69508. }
  69509. declare module "babylonjs/Meshes/trailMesh" {
  69510. import { Mesh } from "babylonjs/Meshes/mesh";
  69511. import { Scene } from "babylonjs/scene";
  69512. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69513. /**
  69514. * Class used to create a trail following a mesh
  69515. */
  69516. export class TrailMesh extends Mesh {
  69517. private _generator;
  69518. private _autoStart;
  69519. private _running;
  69520. private _diameter;
  69521. private _length;
  69522. private _sectionPolygonPointsCount;
  69523. private _sectionVectors;
  69524. private _sectionNormalVectors;
  69525. private _beforeRenderObserver;
  69526. /**
  69527. * @constructor
  69528. * @param name The value used by scene.getMeshByName() to do a lookup.
  69529. * @param generator The mesh or transform node to generate a trail.
  69530. * @param scene The scene to add this mesh to.
  69531. * @param diameter Diameter of trailing mesh. Default is 1.
  69532. * @param length Length of trailing mesh. Default is 60.
  69533. * @param autoStart Automatically start trailing mesh. Default true.
  69534. */
  69535. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69536. /**
  69537. * "TrailMesh"
  69538. * @returns "TrailMesh"
  69539. */
  69540. getClassName(): string;
  69541. private _createMesh;
  69542. /**
  69543. * Start trailing mesh.
  69544. */
  69545. start(): void;
  69546. /**
  69547. * Stop trailing mesh.
  69548. */
  69549. stop(): void;
  69550. /**
  69551. * Update trailing mesh geometry.
  69552. */
  69553. update(): void;
  69554. /**
  69555. * Returns a new TrailMesh object.
  69556. * @param name is a string, the name given to the new mesh
  69557. * @param newGenerator use new generator object for cloned trail mesh
  69558. * @returns a new mesh
  69559. */
  69560. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69561. /**
  69562. * Serializes this trail mesh
  69563. * @param serializationObject object to write serialization to
  69564. */
  69565. serialize(serializationObject: any): void;
  69566. /**
  69567. * Parses a serialized trail mesh
  69568. * @param parsedMesh the serialized mesh
  69569. * @param scene the scene to create the trail mesh in
  69570. * @returns the created trail mesh
  69571. */
  69572. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69573. }
  69574. }
  69575. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  69576. import { Nullable } from "babylonjs/types";
  69577. import { Scene } from "babylonjs/scene";
  69578. import { Vector4 } from "babylonjs/Maths/math.vector";
  69579. import { Color4 } from "babylonjs/Maths/math.color";
  69580. import { Mesh } from "babylonjs/Meshes/mesh";
  69581. /**
  69582. * Class containing static functions to help procedurally build meshes
  69583. */
  69584. export class TiledBoxBuilder {
  69585. /**
  69586. * Creates a box mesh
  69587. * 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)
  69588. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69590. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69592. * @param name defines the name of the mesh
  69593. * @param options defines the options used to create the mesh
  69594. * @param scene defines the hosting scene
  69595. * @returns the box mesh
  69596. */
  69597. static CreateTiledBox(name: string, options: {
  69598. pattern?: number;
  69599. width?: number;
  69600. height?: number;
  69601. depth?: number;
  69602. tileSize?: number;
  69603. tileWidth?: number;
  69604. tileHeight?: number;
  69605. alignHorizontal?: number;
  69606. alignVertical?: number;
  69607. faceUV?: Vector4[];
  69608. faceColors?: Color4[];
  69609. sideOrientation?: number;
  69610. updatable?: boolean;
  69611. }, scene?: Nullable<Scene>): Mesh;
  69612. }
  69613. }
  69614. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  69615. import { Vector4 } from "babylonjs/Maths/math.vector";
  69616. import { Mesh } from "babylonjs/Meshes/mesh";
  69617. /**
  69618. * Class containing static functions to help procedurally build meshes
  69619. */
  69620. export class TorusKnotBuilder {
  69621. /**
  69622. * Creates a torus knot mesh
  69623. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69624. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69625. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69626. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69628. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69630. * @param name defines the name of the mesh
  69631. * @param options defines the options used to create the mesh
  69632. * @param scene defines the hosting scene
  69633. * @returns the torus knot mesh
  69634. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69635. */
  69636. static CreateTorusKnot(name: string, options: {
  69637. radius?: number;
  69638. tube?: number;
  69639. radialSegments?: number;
  69640. tubularSegments?: number;
  69641. p?: number;
  69642. q?: number;
  69643. updatable?: boolean;
  69644. sideOrientation?: number;
  69645. frontUVs?: Vector4;
  69646. backUVs?: Vector4;
  69647. }, scene: any): Mesh;
  69648. }
  69649. }
  69650. declare module "babylonjs/Meshes/polygonMesh" {
  69651. import { Scene } from "babylonjs/scene";
  69652. import { Vector2 } from "babylonjs/Maths/math.vector";
  69653. import { Mesh } from "babylonjs/Meshes/mesh";
  69654. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69655. import { Path2 } from "babylonjs/Maths/math.path";
  69656. /**
  69657. * Polygon
  69658. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69659. */
  69660. export class Polygon {
  69661. /**
  69662. * Creates a rectangle
  69663. * @param xmin bottom X coord
  69664. * @param ymin bottom Y coord
  69665. * @param xmax top X coord
  69666. * @param ymax top Y coord
  69667. * @returns points that make the resulting rectation
  69668. */
  69669. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69670. /**
  69671. * Creates a circle
  69672. * @param radius radius of circle
  69673. * @param cx scale in x
  69674. * @param cy scale in y
  69675. * @param numberOfSides number of sides that make up the circle
  69676. * @returns points that make the resulting circle
  69677. */
  69678. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69679. /**
  69680. * Creates a polygon from input string
  69681. * @param input Input polygon data
  69682. * @returns the parsed points
  69683. */
  69684. static Parse(input: string): Vector2[];
  69685. /**
  69686. * Starts building a polygon from x and y coordinates
  69687. * @param x x coordinate
  69688. * @param y y coordinate
  69689. * @returns the started path2
  69690. */
  69691. static StartingAt(x: number, y: number): Path2;
  69692. }
  69693. /**
  69694. * Builds a polygon
  69695. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69696. */
  69697. export class PolygonMeshBuilder {
  69698. private _points;
  69699. private _outlinepoints;
  69700. private _holes;
  69701. private _name;
  69702. private _scene;
  69703. private _epoints;
  69704. private _eholes;
  69705. private _addToepoint;
  69706. /**
  69707. * Babylon reference to the earcut plugin.
  69708. */
  69709. bjsEarcut: any;
  69710. /**
  69711. * Creates a PolygonMeshBuilder
  69712. * @param name name of the builder
  69713. * @param contours Path of the polygon
  69714. * @param scene scene to add to when creating the mesh
  69715. * @param earcutInjection can be used to inject your own earcut reference
  69716. */
  69717. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69718. /**
  69719. * Adds a whole within the polygon
  69720. * @param hole Array of points defining the hole
  69721. * @returns this
  69722. */
  69723. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69724. /**
  69725. * Creates the polygon
  69726. * @param updatable If the mesh should be updatable
  69727. * @param depth The depth of the mesh created
  69728. * @returns the created mesh
  69729. */
  69730. build(updatable?: boolean, depth?: number): Mesh;
  69731. /**
  69732. * Creates the polygon
  69733. * @param depth The depth of the mesh created
  69734. * @returns the created VertexData
  69735. */
  69736. buildVertexData(depth?: number): VertexData;
  69737. /**
  69738. * Adds a side to the polygon
  69739. * @param positions points that make the polygon
  69740. * @param normals normals of the polygon
  69741. * @param uvs uvs of the polygon
  69742. * @param indices indices of the polygon
  69743. * @param bounds bounds of the polygon
  69744. * @param points points of the polygon
  69745. * @param depth depth of the polygon
  69746. * @param flip flip of the polygon
  69747. */
  69748. private addSide;
  69749. }
  69750. }
  69751. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69752. import { Scene } from "babylonjs/scene";
  69753. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69754. import { Color4 } from "babylonjs/Maths/math.color";
  69755. import { Mesh } from "babylonjs/Meshes/mesh";
  69756. import { Nullable } from "babylonjs/types";
  69757. /**
  69758. * Class containing static functions to help procedurally build meshes
  69759. */
  69760. export class PolygonBuilder {
  69761. /**
  69762. * Creates a polygon mesh
  69763. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69764. * * 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
  69765. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69768. * * Remember you can only change the shape positions, not their number when updating a polygon
  69769. * @param name defines the name of the mesh
  69770. * @param options defines the options used to create the mesh
  69771. * @param scene defines the hosting scene
  69772. * @param earcutInjection can be used to inject your own earcut reference
  69773. * @returns the polygon mesh
  69774. */
  69775. static CreatePolygon(name: string, options: {
  69776. shape: Vector3[];
  69777. holes?: Vector3[][];
  69778. depth?: number;
  69779. faceUV?: Vector4[];
  69780. faceColors?: Color4[];
  69781. updatable?: boolean;
  69782. sideOrientation?: number;
  69783. frontUVs?: Vector4;
  69784. backUVs?: Vector4;
  69785. wrap?: boolean;
  69786. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69787. /**
  69788. * Creates an extruded polygon mesh, with depth in the Y direction.
  69789. * * 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)
  69790. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69791. * @param name defines the name of the mesh
  69792. * @param options defines the options used to create the mesh
  69793. * @param scene defines the hosting scene
  69794. * @param earcutInjection can be used to inject your own earcut reference
  69795. * @returns the polygon mesh
  69796. */
  69797. static ExtrudePolygon(name: string, options: {
  69798. shape: Vector3[];
  69799. holes?: Vector3[][];
  69800. depth?: number;
  69801. faceUV?: Vector4[];
  69802. faceColors?: Color4[];
  69803. updatable?: boolean;
  69804. sideOrientation?: number;
  69805. frontUVs?: Vector4;
  69806. backUVs?: Vector4;
  69807. wrap?: boolean;
  69808. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69809. }
  69810. }
  69811. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69812. import { Scene } from "babylonjs/scene";
  69813. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69814. import { Mesh } from "babylonjs/Meshes/mesh";
  69815. import { Nullable } from "babylonjs/types";
  69816. /**
  69817. * Class containing static functions to help procedurally build meshes
  69818. */
  69819. export class LatheBuilder {
  69820. /**
  69821. * Creates lathe mesh.
  69822. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69823. * * 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
  69824. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69825. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69826. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69827. * * 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
  69828. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69829. * * 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
  69830. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69831. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69832. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69834. * @param name defines the name of the mesh
  69835. * @param options defines the options used to create the mesh
  69836. * @param scene defines the hosting scene
  69837. * @returns the lathe mesh
  69838. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69839. */
  69840. static CreateLathe(name: string, options: {
  69841. shape: Vector3[];
  69842. radius?: number;
  69843. tessellation?: number;
  69844. clip?: number;
  69845. arc?: number;
  69846. closed?: boolean;
  69847. updatable?: boolean;
  69848. sideOrientation?: number;
  69849. frontUVs?: Vector4;
  69850. backUVs?: Vector4;
  69851. cap?: number;
  69852. invertUV?: boolean;
  69853. }, scene?: Nullable<Scene>): Mesh;
  69854. }
  69855. }
  69856. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69857. import { Nullable } from "babylonjs/types";
  69858. import { Scene } from "babylonjs/scene";
  69859. import { Vector4 } from "babylonjs/Maths/math.vector";
  69860. import { Mesh } from "babylonjs/Meshes/mesh";
  69861. /**
  69862. * Class containing static functions to help procedurally build meshes
  69863. */
  69864. export class TiledPlaneBuilder {
  69865. /**
  69866. * Creates a tiled plane mesh
  69867. * * The parameter `pattern` will, depending on value, do nothing or
  69868. * * * flip (reflect about central vertical) alternate tiles across and up
  69869. * * * flip every tile on alternate rows
  69870. * * * rotate (180 degs) alternate tiles across and up
  69871. * * * rotate every tile on alternate rows
  69872. * * * flip and rotate alternate tiles across and up
  69873. * * * flip and rotate every tile on alternate rows
  69874. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69875. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69876. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69877. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69878. * * 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)
  69879. * * 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)
  69880. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69881. * @param name defines the name of the mesh
  69882. * @param options defines the options used to create the mesh
  69883. * @param scene defines the hosting scene
  69884. * @returns the box mesh
  69885. */
  69886. static CreateTiledPlane(name: string, options: {
  69887. pattern?: number;
  69888. tileSize?: number;
  69889. tileWidth?: number;
  69890. tileHeight?: number;
  69891. size?: number;
  69892. width?: number;
  69893. height?: number;
  69894. alignHorizontal?: number;
  69895. alignVertical?: number;
  69896. sideOrientation?: number;
  69897. frontUVs?: Vector4;
  69898. backUVs?: Vector4;
  69899. updatable?: boolean;
  69900. }, scene?: Nullable<Scene>): Mesh;
  69901. }
  69902. }
  69903. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69904. import { Nullable } from "babylonjs/types";
  69905. import { Scene } from "babylonjs/scene";
  69906. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69907. import { Mesh } from "babylonjs/Meshes/mesh";
  69908. /**
  69909. * Class containing static functions to help procedurally build meshes
  69910. */
  69911. export class TubeBuilder {
  69912. /**
  69913. * Creates a tube mesh.
  69914. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69915. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69916. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69917. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69918. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69919. * * 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)
  69920. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69921. * * 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
  69922. * * 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
  69923. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69924. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69925. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69927. * @param name defines the name of the mesh
  69928. * @param options defines the options used to create the mesh
  69929. * @param scene defines the hosting scene
  69930. * @returns the tube mesh
  69931. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69932. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69933. */
  69934. static CreateTube(name: string, options: {
  69935. path: Vector3[];
  69936. radius?: number;
  69937. tessellation?: number;
  69938. radiusFunction?: {
  69939. (i: number, distance: number): number;
  69940. };
  69941. cap?: number;
  69942. arc?: number;
  69943. updatable?: boolean;
  69944. sideOrientation?: number;
  69945. frontUVs?: Vector4;
  69946. backUVs?: Vector4;
  69947. instance?: Mesh;
  69948. invertUV?: boolean;
  69949. }, scene?: Nullable<Scene>): Mesh;
  69950. }
  69951. }
  69952. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69953. import { Scene } from "babylonjs/scene";
  69954. import { Vector4 } from "babylonjs/Maths/math.vector";
  69955. import { Mesh } from "babylonjs/Meshes/mesh";
  69956. import { Nullable } from "babylonjs/types";
  69957. /**
  69958. * Class containing static functions to help procedurally build meshes
  69959. */
  69960. export class IcoSphereBuilder {
  69961. /**
  69962. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69963. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69964. * * 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`)
  69965. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69966. * * 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
  69967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69968. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69970. * @param name defines the name of the mesh
  69971. * @param options defines the options used to create the mesh
  69972. * @param scene defines the hosting scene
  69973. * @returns the icosahedron mesh
  69974. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69975. */
  69976. static CreateIcoSphere(name: string, options: {
  69977. radius?: number;
  69978. radiusX?: number;
  69979. radiusY?: number;
  69980. radiusZ?: number;
  69981. flat?: boolean;
  69982. subdivisions?: number;
  69983. sideOrientation?: number;
  69984. frontUVs?: Vector4;
  69985. backUVs?: Vector4;
  69986. updatable?: boolean;
  69987. }, scene?: Nullable<Scene>): Mesh;
  69988. }
  69989. }
  69990. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69991. import { Vector3 } from "babylonjs/Maths/math.vector";
  69992. import { Mesh } from "babylonjs/Meshes/mesh";
  69993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69994. /**
  69995. * Class containing static functions to help procedurally build meshes
  69996. */
  69997. export class DecalBuilder {
  69998. /**
  69999. * Creates a decal mesh.
  70000. * 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
  70001. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70002. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70003. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70004. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70005. * @param name defines the name of the mesh
  70006. * @param sourceMesh defines the mesh where the decal must be applied
  70007. * @param options defines the options used to create the mesh
  70008. * @param scene defines the hosting scene
  70009. * @returns the decal mesh
  70010. * @see https://doc.babylonjs.com/how_to/decals
  70011. */
  70012. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70013. position?: Vector3;
  70014. normal?: Vector3;
  70015. size?: Vector3;
  70016. angle?: number;
  70017. }): Mesh;
  70018. }
  70019. }
  70020. declare module "babylonjs/Meshes/meshBuilder" {
  70021. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  70022. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  70023. import { Nullable } from "babylonjs/types";
  70024. import { Scene } from "babylonjs/scene";
  70025. import { Mesh } from "babylonjs/Meshes/mesh";
  70026. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  70027. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  70028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70029. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70030. import { Plane } from "babylonjs/Maths/math.plane";
  70031. /**
  70032. * Class containing static functions to help procedurally build meshes
  70033. */
  70034. export class MeshBuilder {
  70035. /**
  70036. * Creates a box mesh
  70037. * * The parameter `size` sets the size (float) of each box side (default 1)
  70038. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70039. * * 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)
  70040. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70042. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70044. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70045. * @param name defines the name of the mesh
  70046. * @param options defines the options used to create the mesh
  70047. * @param scene defines the hosting scene
  70048. * @returns the box mesh
  70049. */
  70050. static CreateBox(name: string, options: {
  70051. size?: number;
  70052. width?: number;
  70053. height?: number;
  70054. depth?: number;
  70055. faceUV?: Vector4[];
  70056. faceColors?: Color4[];
  70057. sideOrientation?: number;
  70058. frontUVs?: Vector4;
  70059. backUVs?: Vector4;
  70060. wrap?: boolean;
  70061. topBaseAt?: number;
  70062. bottomBaseAt?: number;
  70063. updatable?: boolean;
  70064. }, scene?: Nullable<Scene>): Mesh;
  70065. /**
  70066. * Creates a tiled box mesh
  70067. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70069. * @param name defines the name of the mesh
  70070. * @param options defines the options used to create the mesh
  70071. * @param scene defines the hosting scene
  70072. * @returns the tiled box mesh
  70073. */
  70074. static CreateTiledBox(name: string, options: {
  70075. pattern?: number;
  70076. size?: number;
  70077. width?: number;
  70078. height?: number;
  70079. depth: number;
  70080. tileSize?: number;
  70081. tileWidth?: number;
  70082. tileHeight?: number;
  70083. faceUV?: Vector4[];
  70084. faceColors?: Color4[];
  70085. alignHorizontal?: number;
  70086. alignVertical?: number;
  70087. sideOrientation?: number;
  70088. updatable?: boolean;
  70089. }, scene?: Nullable<Scene>): Mesh;
  70090. /**
  70091. * Creates a sphere mesh
  70092. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70093. * * 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`)
  70094. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70095. * * 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
  70096. * * 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)
  70097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70098. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70100. * @param name defines the name of the mesh
  70101. * @param options defines the options used to create the mesh
  70102. * @param scene defines the hosting scene
  70103. * @returns the sphere mesh
  70104. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70105. */
  70106. static CreateSphere(name: string, options: {
  70107. segments?: number;
  70108. diameter?: number;
  70109. diameterX?: number;
  70110. diameterY?: number;
  70111. diameterZ?: number;
  70112. arc?: number;
  70113. slice?: number;
  70114. sideOrientation?: number;
  70115. frontUVs?: Vector4;
  70116. backUVs?: Vector4;
  70117. updatable?: boolean;
  70118. }, scene?: Nullable<Scene>): Mesh;
  70119. /**
  70120. * Creates a plane polygonal mesh. By default, this is a disc
  70121. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70122. * * 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
  70123. * * 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
  70124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70125. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70127. * @param name defines the name of the mesh
  70128. * @param options defines the options used to create the mesh
  70129. * @param scene defines the hosting scene
  70130. * @returns the plane polygonal mesh
  70131. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70132. */
  70133. static CreateDisc(name: string, options: {
  70134. radius?: number;
  70135. tessellation?: number;
  70136. arc?: number;
  70137. updatable?: boolean;
  70138. sideOrientation?: number;
  70139. frontUVs?: Vector4;
  70140. backUVs?: Vector4;
  70141. }, scene?: Nullable<Scene>): Mesh;
  70142. /**
  70143. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70144. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70145. * * 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`)
  70146. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70147. * * 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
  70148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70151. * @param name defines the name of the mesh
  70152. * @param options defines the options used to create the mesh
  70153. * @param scene defines the hosting scene
  70154. * @returns the icosahedron mesh
  70155. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70156. */
  70157. static CreateIcoSphere(name: string, options: {
  70158. radius?: number;
  70159. radiusX?: number;
  70160. radiusY?: number;
  70161. radiusZ?: number;
  70162. flat?: boolean;
  70163. subdivisions?: number;
  70164. sideOrientation?: number;
  70165. frontUVs?: Vector4;
  70166. backUVs?: Vector4;
  70167. updatable?: boolean;
  70168. }, scene?: Nullable<Scene>): Mesh;
  70169. /**
  70170. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70171. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70172. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70173. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70174. * * 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
  70175. * * 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
  70176. * * 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
  70177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70178. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70179. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70180. * * 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
  70181. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70182. * * 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
  70183. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70185. * @param name defines the name of the mesh
  70186. * @param options defines the options used to create the mesh
  70187. * @param scene defines the hosting scene
  70188. * @returns the ribbon mesh
  70189. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70190. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70191. */
  70192. static CreateRibbon(name: string, options: {
  70193. pathArray: Vector3[][];
  70194. closeArray?: boolean;
  70195. closePath?: boolean;
  70196. offset?: number;
  70197. updatable?: boolean;
  70198. sideOrientation?: number;
  70199. frontUVs?: Vector4;
  70200. backUVs?: Vector4;
  70201. instance?: Mesh;
  70202. invertUV?: boolean;
  70203. uvs?: Vector2[];
  70204. colors?: Color4[];
  70205. }, scene?: Nullable<Scene>): Mesh;
  70206. /**
  70207. * Creates a cylinder or a cone mesh
  70208. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70209. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70210. * * 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.
  70211. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70212. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70213. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70214. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70215. * * 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).
  70216. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70217. * * 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).
  70218. * * 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
  70219. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70220. * * 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
  70221. * * 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.
  70222. * * If `enclose` is false, a ring surface is one element.
  70223. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70224. * * 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
  70225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70228. * @param name defines the name of the mesh
  70229. * @param options defines the options used to create the mesh
  70230. * @param scene defines the hosting scene
  70231. * @returns the cylinder mesh
  70232. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70233. */
  70234. static CreateCylinder(name: string, options: {
  70235. height?: number;
  70236. diameterTop?: number;
  70237. diameterBottom?: number;
  70238. diameter?: number;
  70239. tessellation?: number;
  70240. subdivisions?: number;
  70241. arc?: number;
  70242. faceColors?: Color4[];
  70243. faceUV?: Vector4[];
  70244. updatable?: boolean;
  70245. hasRings?: boolean;
  70246. enclose?: boolean;
  70247. cap?: number;
  70248. sideOrientation?: number;
  70249. frontUVs?: Vector4;
  70250. backUVs?: Vector4;
  70251. }, scene?: Nullable<Scene>): Mesh;
  70252. /**
  70253. * Creates a torus mesh
  70254. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70255. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70256. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70258. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70260. * @param name defines the name of the mesh
  70261. * @param options defines the options used to create the mesh
  70262. * @param scene defines the hosting scene
  70263. * @returns the torus mesh
  70264. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70265. */
  70266. static CreateTorus(name: string, options: {
  70267. diameter?: number;
  70268. thickness?: number;
  70269. tessellation?: number;
  70270. updatable?: boolean;
  70271. sideOrientation?: number;
  70272. frontUVs?: Vector4;
  70273. backUVs?: Vector4;
  70274. }, scene?: Nullable<Scene>): Mesh;
  70275. /**
  70276. * Creates a torus knot mesh
  70277. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70278. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70279. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70280. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70282. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70284. * @param name defines the name of the mesh
  70285. * @param options defines the options used to create the mesh
  70286. * @param scene defines the hosting scene
  70287. * @returns the torus knot mesh
  70288. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70289. */
  70290. static CreateTorusKnot(name: string, options: {
  70291. radius?: number;
  70292. tube?: number;
  70293. radialSegments?: number;
  70294. tubularSegments?: number;
  70295. p?: number;
  70296. q?: number;
  70297. updatable?: boolean;
  70298. sideOrientation?: number;
  70299. frontUVs?: Vector4;
  70300. backUVs?: Vector4;
  70301. }, scene?: Nullable<Scene>): Mesh;
  70302. /**
  70303. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70304. * * 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
  70305. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70306. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70307. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70308. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70309. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70310. * * 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
  70311. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70313. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70314. * @param name defines the name of the new line system
  70315. * @param options defines the options used to create the line system
  70316. * @param scene defines the hosting scene
  70317. * @returns a new line system mesh
  70318. */
  70319. static CreateLineSystem(name: string, options: {
  70320. lines: Vector3[][];
  70321. updatable?: boolean;
  70322. instance?: Nullable<LinesMesh>;
  70323. colors?: Nullable<Color4[][]>;
  70324. useVertexAlpha?: boolean;
  70325. }, scene: Nullable<Scene>): LinesMesh;
  70326. /**
  70327. * Creates a line mesh
  70328. * 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
  70329. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70330. * * The parameter `points` is an array successive Vector3
  70331. * * 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
  70332. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70333. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70334. * * When updating an instance, remember that only point positions can change, not the number of points
  70335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70336. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70337. * @param name defines the name of the new line system
  70338. * @param options defines the options used to create the line system
  70339. * @param scene defines the hosting scene
  70340. * @returns a new line mesh
  70341. */
  70342. static CreateLines(name: string, options: {
  70343. points: Vector3[];
  70344. updatable?: boolean;
  70345. instance?: Nullable<LinesMesh>;
  70346. colors?: Color4[];
  70347. useVertexAlpha?: boolean;
  70348. }, scene?: Nullable<Scene>): LinesMesh;
  70349. /**
  70350. * Creates a dashed line mesh
  70351. * * 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
  70352. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70353. * * The parameter `points` is an array successive Vector3
  70354. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70355. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70356. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70357. * * 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
  70358. * * When updating an instance, remember that only point positions can change, not the number of points
  70359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70360. * @param name defines the name of the mesh
  70361. * @param options defines the options used to create the mesh
  70362. * @param scene defines the hosting scene
  70363. * @returns the dashed line mesh
  70364. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70365. */
  70366. static CreateDashedLines(name: string, options: {
  70367. points: Vector3[];
  70368. dashSize?: number;
  70369. gapSize?: number;
  70370. dashNb?: number;
  70371. updatable?: boolean;
  70372. instance?: LinesMesh;
  70373. }, scene?: Nullable<Scene>): LinesMesh;
  70374. /**
  70375. * 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.
  70376. * * 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.
  70377. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70378. * * 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.
  70379. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70380. * * 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
  70381. * * 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
  70382. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70384. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70385. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70387. * @param name defines the name of the mesh
  70388. * @param options defines the options used to create the mesh
  70389. * @param scene defines the hosting scene
  70390. * @returns the extruded shape mesh
  70391. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70392. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70393. */
  70394. static ExtrudeShape(name: string, options: {
  70395. shape: Vector3[];
  70396. path: Vector3[];
  70397. scale?: number;
  70398. rotation?: number;
  70399. cap?: number;
  70400. updatable?: boolean;
  70401. sideOrientation?: number;
  70402. frontUVs?: Vector4;
  70403. backUVs?: Vector4;
  70404. instance?: Mesh;
  70405. invertUV?: boolean;
  70406. }, scene?: Nullable<Scene>): Mesh;
  70407. /**
  70408. * Creates an custom extruded shape mesh.
  70409. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70410. * * 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.
  70411. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70412. * * 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
  70413. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70414. * * 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
  70415. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70416. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70417. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70418. * * 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
  70419. * * 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
  70420. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70422. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70423. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70425. * @param name defines the name of the mesh
  70426. * @param options defines the options used to create the mesh
  70427. * @param scene defines the hosting scene
  70428. * @returns the custom extruded shape mesh
  70429. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70430. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70431. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70432. */
  70433. static ExtrudeShapeCustom(name: string, options: {
  70434. shape: Vector3[];
  70435. path: Vector3[];
  70436. scaleFunction?: any;
  70437. rotationFunction?: any;
  70438. ribbonCloseArray?: boolean;
  70439. ribbonClosePath?: boolean;
  70440. cap?: number;
  70441. updatable?: boolean;
  70442. sideOrientation?: number;
  70443. frontUVs?: Vector4;
  70444. backUVs?: Vector4;
  70445. instance?: Mesh;
  70446. invertUV?: boolean;
  70447. }, scene?: Nullable<Scene>): Mesh;
  70448. /**
  70449. * Creates lathe mesh.
  70450. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70451. * * 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
  70452. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70453. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70454. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70455. * * 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
  70456. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70457. * * 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
  70458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70459. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70460. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70462. * @param name defines the name of the mesh
  70463. * @param options defines the options used to create the mesh
  70464. * @param scene defines the hosting scene
  70465. * @returns the lathe mesh
  70466. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70467. */
  70468. static CreateLathe(name: string, options: {
  70469. shape: Vector3[];
  70470. radius?: number;
  70471. tessellation?: number;
  70472. clip?: number;
  70473. arc?: number;
  70474. closed?: boolean;
  70475. updatable?: boolean;
  70476. sideOrientation?: number;
  70477. frontUVs?: Vector4;
  70478. backUVs?: Vector4;
  70479. cap?: number;
  70480. invertUV?: boolean;
  70481. }, scene?: Nullable<Scene>): Mesh;
  70482. /**
  70483. * Creates a tiled plane mesh
  70484. * * You can set a limited pattern arrangement with the tiles
  70485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70488. * @param name defines the name of the mesh
  70489. * @param options defines the options used to create the mesh
  70490. * @param scene defines the hosting scene
  70491. * @returns the plane mesh
  70492. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70493. */
  70494. static CreateTiledPlane(name: string, options: {
  70495. pattern?: number;
  70496. tileSize?: number;
  70497. tileWidth?: number;
  70498. tileHeight?: number;
  70499. size?: number;
  70500. width?: number;
  70501. height?: number;
  70502. alignHorizontal?: number;
  70503. alignVertical?: number;
  70504. sideOrientation?: number;
  70505. frontUVs?: Vector4;
  70506. backUVs?: Vector4;
  70507. updatable?: boolean;
  70508. }, scene?: Nullable<Scene>): Mesh;
  70509. /**
  70510. * Creates a plane mesh
  70511. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70512. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70513. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70515. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70517. * @param name defines the name of the mesh
  70518. * @param options defines the options used to create the mesh
  70519. * @param scene defines the hosting scene
  70520. * @returns the plane mesh
  70521. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70522. */
  70523. static CreatePlane(name: string, options: {
  70524. size?: number;
  70525. width?: number;
  70526. height?: number;
  70527. sideOrientation?: number;
  70528. frontUVs?: Vector4;
  70529. backUVs?: Vector4;
  70530. updatable?: boolean;
  70531. sourcePlane?: Plane;
  70532. }, scene?: Nullable<Scene>): Mesh;
  70533. /**
  70534. * Creates a ground mesh
  70535. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70536. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70538. * @param name defines the name of the mesh
  70539. * @param options defines the options used to create the mesh
  70540. * @param scene defines the hosting scene
  70541. * @returns the ground mesh
  70542. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70543. */
  70544. static CreateGround(name: string, options: {
  70545. width?: number;
  70546. height?: number;
  70547. subdivisions?: number;
  70548. subdivisionsX?: number;
  70549. subdivisionsY?: number;
  70550. updatable?: boolean;
  70551. }, scene?: Nullable<Scene>): Mesh;
  70552. /**
  70553. * Creates a tiled ground mesh
  70554. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70555. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70556. * * 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
  70557. * * 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
  70558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70559. * @param name defines the name of the mesh
  70560. * @param options defines the options used to create the mesh
  70561. * @param scene defines the hosting scene
  70562. * @returns the tiled ground mesh
  70563. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70564. */
  70565. static CreateTiledGround(name: string, options: {
  70566. xmin: number;
  70567. zmin: number;
  70568. xmax: number;
  70569. zmax: number;
  70570. subdivisions?: {
  70571. w: number;
  70572. h: number;
  70573. };
  70574. precision?: {
  70575. w: number;
  70576. h: number;
  70577. };
  70578. updatable?: boolean;
  70579. }, scene?: Nullable<Scene>): Mesh;
  70580. /**
  70581. * Creates a ground mesh from a height map
  70582. * * The parameter `url` sets the URL of the height map image resource.
  70583. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70584. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70585. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70586. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70587. * * 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.
  70588. * * 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).
  70589. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70591. * @param name defines the name of the mesh
  70592. * @param url defines the url to the height map
  70593. * @param options defines the options used to create the mesh
  70594. * @param scene defines the hosting scene
  70595. * @returns the ground mesh
  70596. * @see https://doc.babylonjs.com/babylon101/height_map
  70597. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70598. */
  70599. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70600. width?: number;
  70601. height?: number;
  70602. subdivisions?: number;
  70603. minHeight?: number;
  70604. maxHeight?: number;
  70605. colorFilter?: Color3;
  70606. alphaFilter?: number;
  70607. updatable?: boolean;
  70608. onReady?: (mesh: GroundMesh) => void;
  70609. }, scene?: Nullable<Scene>): GroundMesh;
  70610. /**
  70611. * Creates a polygon mesh
  70612. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70613. * * 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
  70614. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70617. * * Remember you can only change the shape positions, not their number when updating a polygon
  70618. * @param name defines the name of the mesh
  70619. * @param options defines the options used to create the mesh
  70620. * @param scene defines the hosting scene
  70621. * @param earcutInjection can be used to inject your own earcut reference
  70622. * @returns the polygon mesh
  70623. */
  70624. static CreatePolygon(name: string, options: {
  70625. shape: Vector3[];
  70626. holes?: Vector3[][];
  70627. depth?: number;
  70628. faceUV?: Vector4[];
  70629. faceColors?: Color4[];
  70630. updatable?: boolean;
  70631. sideOrientation?: number;
  70632. frontUVs?: Vector4;
  70633. backUVs?: Vector4;
  70634. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70635. /**
  70636. * Creates an extruded polygon mesh, with depth in the Y direction.
  70637. * * 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)
  70638. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70639. * @param name defines the name of the mesh
  70640. * @param options defines the options used to create the mesh
  70641. * @param scene defines the hosting scene
  70642. * @param earcutInjection can be used to inject your own earcut reference
  70643. * @returns the polygon mesh
  70644. */
  70645. static ExtrudePolygon(name: string, options: {
  70646. shape: Vector3[];
  70647. holes?: Vector3[][];
  70648. depth?: number;
  70649. faceUV?: Vector4[];
  70650. faceColors?: Color4[];
  70651. updatable?: boolean;
  70652. sideOrientation?: number;
  70653. frontUVs?: Vector4;
  70654. backUVs?: Vector4;
  70655. wrap?: boolean;
  70656. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70657. /**
  70658. * Creates a tube mesh.
  70659. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70660. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70661. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70662. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70663. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70664. * * 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)
  70665. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70666. * * 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
  70667. * * 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
  70668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70670. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70672. * @param name defines the name of the mesh
  70673. * @param options defines the options used to create the mesh
  70674. * @param scene defines the hosting scene
  70675. * @returns the tube mesh
  70676. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70677. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70678. */
  70679. static CreateTube(name: string, options: {
  70680. path: Vector3[];
  70681. radius?: number;
  70682. tessellation?: number;
  70683. radiusFunction?: {
  70684. (i: number, distance: number): number;
  70685. };
  70686. cap?: number;
  70687. arc?: number;
  70688. updatable?: boolean;
  70689. sideOrientation?: number;
  70690. frontUVs?: Vector4;
  70691. backUVs?: Vector4;
  70692. instance?: Mesh;
  70693. invertUV?: boolean;
  70694. }, scene?: Nullable<Scene>): Mesh;
  70695. /**
  70696. * Creates a polyhedron mesh
  70697. * * 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
  70698. * * The parameter `size` (positive float, default 1) sets the polygon size
  70699. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70700. * * 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`
  70701. * * 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
  70702. * * 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)`)
  70703. * * 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
  70704. * * 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
  70705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70706. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70708. * @param name defines the name of the mesh
  70709. * @param options defines the options used to create the mesh
  70710. * @param scene defines the hosting scene
  70711. * @returns the polyhedron mesh
  70712. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70713. */
  70714. static CreatePolyhedron(name: string, options: {
  70715. type?: number;
  70716. size?: number;
  70717. sizeX?: number;
  70718. sizeY?: number;
  70719. sizeZ?: number;
  70720. custom?: any;
  70721. faceUV?: Vector4[];
  70722. faceColors?: Color4[];
  70723. flat?: boolean;
  70724. updatable?: boolean;
  70725. sideOrientation?: number;
  70726. frontUVs?: Vector4;
  70727. backUVs?: Vector4;
  70728. }, scene?: Nullable<Scene>): Mesh;
  70729. /**
  70730. * Creates a decal mesh.
  70731. * 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
  70732. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70733. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70734. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70735. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70736. * @param name defines the name of the mesh
  70737. * @param sourceMesh defines the mesh where the decal must be applied
  70738. * @param options defines the options used to create the mesh
  70739. * @param scene defines the hosting scene
  70740. * @returns the decal mesh
  70741. * @see https://doc.babylonjs.com/how_to/decals
  70742. */
  70743. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70744. position?: Vector3;
  70745. normal?: Vector3;
  70746. size?: Vector3;
  70747. angle?: number;
  70748. }): Mesh;
  70749. /**
  70750. * Creates a Capsule Mesh
  70751. * @param name defines the name of the mesh.
  70752. * @param options the constructors options used to shape the mesh.
  70753. * @param scene defines the scene the mesh is scoped to.
  70754. * @returns the capsule mesh
  70755. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70756. */
  70757. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70758. }
  70759. }
  70760. declare module "babylonjs/Meshes/meshSimplification" {
  70761. import { Mesh } from "babylonjs/Meshes/mesh";
  70762. /**
  70763. * A simplifier interface for future simplification implementations
  70764. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70765. */
  70766. export interface ISimplifier {
  70767. /**
  70768. * Simplification of a given mesh according to the given settings.
  70769. * Since this requires computation, it is assumed that the function runs async.
  70770. * @param settings The settings of the simplification, including quality and distance
  70771. * @param successCallback A callback that will be called after the mesh was simplified.
  70772. * @param errorCallback in case of an error, this callback will be called. optional.
  70773. */
  70774. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70775. }
  70776. /**
  70777. * Expected simplification settings.
  70778. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70779. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70780. */
  70781. export interface ISimplificationSettings {
  70782. /**
  70783. * Gets or sets the expected quality
  70784. */
  70785. quality: number;
  70786. /**
  70787. * Gets or sets the distance when this optimized version should be used
  70788. */
  70789. distance: number;
  70790. /**
  70791. * Gets an already optimized mesh
  70792. */
  70793. optimizeMesh?: boolean;
  70794. }
  70795. /**
  70796. * Class used to specify simplification options
  70797. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70798. */
  70799. export class SimplificationSettings implements ISimplificationSettings {
  70800. /** expected quality */
  70801. quality: number;
  70802. /** distance when this optimized version should be used */
  70803. distance: number;
  70804. /** already optimized mesh */
  70805. optimizeMesh?: boolean | undefined;
  70806. /**
  70807. * Creates a SimplificationSettings
  70808. * @param quality expected quality
  70809. * @param distance distance when this optimized version should be used
  70810. * @param optimizeMesh already optimized mesh
  70811. */
  70812. constructor(
  70813. /** expected quality */
  70814. quality: number,
  70815. /** distance when this optimized version should be used */
  70816. distance: number,
  70817. /** already optimized mesh */
  70818. optimizeMesh?: boolean | undefined);
  70819. }
  70820. /**
  70821. * Interface used to define a simplification task
  70822. */
  70823. export interface ISimplificationTask {
  70824. /**
  70825. * Array of settings
  70826. */
  70827. settings: Array<ISimplificationSettings>;
  70828. /**
  70829. * Simplification type
  70830. */
  70831. simplificationType: SimplificationType;
  70832. /**
  70833. * Mesh to simplify
  70834. */
  70835. mesh: Mesh;
  70836. /**
  70837. * Callback called on success
  70838. */
  70839. successCallback?: () => void;
  70840. /**
  70841. * Defines if parallel processing can be used
  70842. */
  70843. parallelProcessing: boolean;
  70844. }
  70845. /**
  70846. * Queue used to order the simplification tasks
  70847. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70848. */
  70849. export class SimplificationQueue {
  70850. private _simplificationArray;
  70851. /**
  70852. * Gets a boolean indicating that the process is still running
  70853. */
  70854. running: boolean;
  70855. /**
  70856. * Creates a new queue
  70857. */
  70858. constructor();
  70859. /**
  70860. * Adds a new simplification task
  70861. * @param task defines a task to add
  70862. */
  70863. addTask(task: ISimplificationTask): void;
  70864. /**
  70865. * Execute next task
  70866. */
  70867. executeNext(): void;
  70868. /**
  70869. * Execute a simplification task
  70870. * @param task defines the task to run
  70871. */
  70872. runSimplification(task: ISimplificationTask): void;
  70873. private getSimplifier;
  70874. }
  70875. /**
  70876. * The implemented types of simplification
  70877. * At the moment only Quadratic Error Decimation is implemented
  70878. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70879. */
  70880. export enum SimplificationType {
  70881. /** Quadratic error decimation */
  70882. QUADRATIC = 0
  70883. }
  70884. /**
  70885. * An implementation of the Quadratic Error simplification algorithm.
  70886. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70887. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70888. * @author RaananW
  70889. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70890. */
  70891. export class QuadraticErrorSimplification implements ISimplifier {
  70892. private _mesh;
  70893. private triangles;
  70894. private vertices;
  70895. private references;
  70896. private _reconstructedMesh;
  70897. /** Gets or sets the number pf sync interations */
  70898. syncIterations: number;
  70899. /** Gets or sets the aggressiveness of the simplifier */
  70900. aggressiveness: number;
  70901. /** Gets or sets the number of allowed iterations for decimation */
  70902. decimationIterations: number;
  70903. /** Gets or sets the espilon to use for bounding box computation */
  70904. boundingBoxEpsilon: number;
  70905. /**
  70906. * Creates a new QuadraticErrorSimplification
  70907. * @param _mesh defines the target mesh
  70908. */
  70909. constructor(_mesh: Mesh);
  70910. /**
  70911. * Simplification of a given mesh according to the given settings.
  70912. * Since this requires computation, it is assumed that the function runs async.
  70913. * @param settings The settings of the simplification, including quality and distance
  70914. * @param successCallback A callback that will be called after the mesh was simplified.
  70915. */
  70916. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70917. private runDecimation;
  70918. private initWithMesh;
  70919. private init;
  70920. private reconstructMesh;
  70921. private initDecimatedMesh;
  70922. private isFlipped;
  70923. private updateTriangles;
  70924. private identifyBorder;
  70925. private updateMesh;
  70926. private vertexError;
  70927. private calculateError;
  70928. }
  70929. }
  70930. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70931. import { Scene } from "babylonjs/scene";
  70932. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70933. import { ISceneComponent } from "babylonjs/sceneComponent";
  70934. module "babylonjs/scene" {
  70935. interface Scene {
  70936. /** @hidden (Backing field) */
  70937. _simplificationQueue: SimplificationQueue;
  70938. /**
  70939. * Gets or sets the simplification queue attached to the scene
  70940. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70941. */
  70942. simplificationQueue: SimplificationQueue;
  70943. }
  70944. }
  70945. module "babylonjs/Meshes/mesh" {
  70946. interface Mesh {
  70947. /**
  70948. * Simplify the mesh according to the given array of settings.
  70949. * Function will return immediately and will simplify async
  70950. * @param settings a collection of simplification settings
  70951. * @param parallelProcessing should all levels calculate parallel or one after the other
  70952. * @param simplificationType the type of simplification to run
  70953. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70954. * @returns the current mesh
  70955. */
  70956. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70957. }
  70958. }
  70959. /**
  70960. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70961. * created in a scene
  70962. */
  70963. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70964. /**
  70965. * The component name helpfull to identify the component in the list of scene components.
  70966. */
  70967. readonly name: string;
  70968. /**
  70969. * The scene the component belongs to.
  70970. */
  70971. scene: Scene;
  70972. /**
  70973. * Creates a new instance of the component for the given scene
  70974. * @param scene Defines the scene to register the component in
  70975. */
  70976. constructor(scene: Scene);
  70977. /**
  70978. * Registers the component in a given scene
  70979. */
  70980. register(): void;
  70981. /**
  70982. * Rebuilds the elements related to this component in case of
  70983. * context lost for instance.
  70984. */
  70985. rebuild(): void;
  70986. /**
  70987. * Disposes the component and the associated ressources
  70988. */
  70989. dispose(): void;
  70990. private _beforeCameraUpdate;
  70991. }
  70992. }
  70993. declare module "babylonjs/Meshes/Builders/index" {
  70994. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70995. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70996. export * from "babylonjs/Meshes/Builders/discBuilder";
  70997. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70998. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70999. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  71000. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  71001. export * from "babylonjs/Meshes/Builders/torusBuilder";
  71002. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  71003. export * from "babylonjs/Meshes/Builders/linesBuilder";
  71004. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  71005. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  71006. export * from "babylonjs/Meshes/Builders/latheBuilder";
  71007. export * from "babylonjs/Meshes/Builders/planeBuilder";
  71008. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  71009. export * from "babylonjs/Meshes/Builders/groundBuilder";
  71010. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  71011. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  71012. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71013. export * from "babylonjs/Meshes/Builders/decalBuilder";
  71014. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71015. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  71016. }
  71017. declare module "babylonjs/Meshes/thinInstanceMesh" {
  71018. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  71019. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  71020. import { Matrix } from "babylonjs/Maths/math.vector";
  71021. module "babylonjs/Meshes/mesh" {
  71022. interface Mesh {
  71023. /**
  71024. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71025. */
  71026. thinInstanceEnablePicking: boolean;
  71027. /**
  71028. * Creates a new thin instance
  71029. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71030. * @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
  71031. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71032. */
  71033. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71034. /**
  71035. * Adds the transformation (matrix) of the current mesh as a thin instance
  71036. * @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
  71037. * @returns the thin instance index number
  71038. */
  71039. thinInstanceAddSelf(refresh: boolean): number;
  71040. /**
  71041. * Registers a custom attribute to be used with thin instances
  71042. * @param kind name of the attribute
  71043. * @param stride size in floats of the attribute
  71044. */
  71045. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71046. /**
  71047. * Sets the matrix of a thin instance
  71048. * @param index index of the thin instance
  71049. * @param matrix matrix to set
  71050. * @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
  71051. */
  71052. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71053. /**
  71054. * Sets the value of a custom attribute for a thin instance
  71055. * @param kind name of the attribute
  71056. * @param index index of the thin instance
  71057. * @param value value to set
  71058. * @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
  71059. */
  71060. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71061. /**
  71062. * 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.
  71063. */
  71064. thinInstanceCount: number;
  71065. /**
  71066. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71067. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71068. * @param buffer buffer to set
  71069. * @param stride size in floats of each value of the buffer
  71070. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71071. */
  71072. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71073. /**
  71074. * Gets the list of world matrices
  71075. * @return an array containing all the world matrices from the thin instances
  71076. */
  71077. thinInstanceGetWorldMatrices(): Matrix[];
  71078. /**
  71079. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71080. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71081. */
  71082. thinInstanceBufferUpdated(kind: string): void;
  71083. /**
  71084. * Applies a partial update to a buffer directly on the GPU
  71085. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  71086. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71087. * @param data the data to set in the GPU buffer
  71088. * @param offset the offset in the GPU buffer where to update the data
  71089. */
  71090. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71091. /**
  71092. * Refreshes the bounding info, taking into account all the thin instances defined
  71093. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71094. */
  71095. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71096. /** @hidden */
  71097. _thinInstanceInitializeUserStorage(): void;
  71098. /** @hidden */
  71099. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71100. /** @hidden */
  71101. _userThinInstanceBuffersStorage: {
  71102. data: {
  71103. [key: string]: Float32Array;
  71104. };
  71105. sizes: {
  71106. [key: string]: number;
  71107. };
  71108. vertexBuffers: {
  71109. [key: string]: Nullable<VertexBuffer>;
  71110. };
  71111. strides: {
  71112. [key: string]: number;
  71113. };
  71114. };
  71115. }
  71116. }
  71117. }
  71118. declare module "babylonjs/Meshes/index" {
  71119. export * from "babylonjs/Meshes/abstractMesh";
  71120. export * from "babylonjs/Meshes/buffer";
  71121. export * from "babylonjs/Meshes/Compression/index";
  71122. export * from "babylonjs/Meshes/csg";
  71123. export * from "babylonjs/Meshes/geometry";
  71124. export * from "babylonjs/Meshes/groundMesh";
  71125. export * from "babylonjs/Meshes/trailMesh";
  71126. export * from "babylonjs/Meshes/instancedMesh";
  71127. export * from "babylonjs/Meshes/linesMesh";
  71128. export * from "babylonjs/Meshes/mesh";
  71129. export * from "babylonjs/Meshes/mesh.vertexData";
  71130. export * from "babylonjs/Meshes/meshBuilder";
  71131. export * from "babylonjs/Meshes/meshSimplification";
  71132. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  71133. export * from "babylonjs/Meshes/polygonMesh";
  71134. export * from "babylonjs/Meshes/subMesh";
  71135. export * from "babylonjs/Meshes/meshLODLevel";
  71136. export * from "babylonjs/Meshes/transformNode";
  71137. export * from "babylonjs/Meshes/Builders/index";
  71138. export * from "babylonjs/Meshes/dataBuffer";
  71139. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  71140. import "babylonjs/Meshes/thinInstanceMesh";
  71141. export * from "babylonjs/Meshes/thinInstanceMesh";
  71142. }
  71143. declare module "babylonjs/Morph/index" {
  71144. export * from "babylonjs/Morph/morphTarget";
  71145. export * from "babylonjs/Morph/morphTargetManager";
  71146. }
  71147. declare module "babylonjs/Navigation/INavigationEngine" {
  71148. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71149. import { Vector3 } from "babylonjs/Maths/math";
  71150. import { Mesh } from "babylonjs/Meshes/mesh";
  71151. import { Scene } from "babylonjs/scene";
  71152. /**
  71153. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71154. */
  71155. export interface INavigationEnginePlugin {
  71156. /**
  71157. * plugin name
  71158. */
  71159. name: string;
  71160. /**
  71161. * Creates a navigation mesh
  71162. * @param meshes array of all the geometry used to compute the navigatio mesh
  71163. * @param parameters bunch of parameters used to filter geometry
  71164. */
  71165. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71166. /**
  71167. * Create a navigation mesh debug mesh
  71168. * @param scene is where the mesh will be added
  71169. * @returns debug display mesh
  71170. */
  71171. createDebugNavMesh(scene: Scene): Mesh;
  71172. /**
  71173. * Get a navigation mesh constrained position, closest to the parameter position
  71174. * @param position world position
  71175. * @returns the closest point to position constrained by the navigation mesh
  71176. */
  71177. getClosestPoint(position: Vector3): Vector3;
  71178. /**
  71179. * Get a navigation mesh constrained position, closest to the parameter position
  71180. * @param position world position
  71181. * @param result output the closest point to position constrained by the navigation mesh
  71182. */
  71183. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71184. /**
  71185. * Get a navigation mesh constrained position, within a particular radius
  71186. * @param position world position
  71187. * @param maxRadius the maximum distance to the constrained world position
  71188. * @returns the closest point to position constrained by the navigation mesh
  71189. */
  71190. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71191. /**
  71192. * Get a navigation mesh constrained position, within a particular radius
  71193. * @param position world position
  71194. * @param maxRadius the maximum distance to the constrained world position
  71195. * @param result output the closest point to position constrained by the navigation mesh
  71196. */
  71197. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71198. /**
  71199. * Compute the final position from a segment made of destination-position
  71200. * @param position world position
  71201. * @param destination world position
  71202. * @returns the resulting point along the navmesh
  71203. */
  71204. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71205. /**
  71206. * Compute the final position from a segment made of destination-position
  71207. * @param position world position
  71208. * @param destination world position
  71209. * @param result output the resulting point along the navmesh
  71210. */
  71211. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71212. /**
  71213. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71214. * @param start world position
  71215. * @param end world position
  71216. * @returns array containing world position composing the path
  71217. */
  71218. computePath(start: Vector3, end: Vector3): Vector3[];
  71219. /**
  71220. * If this plugin is supported
  71221. * @returns true if plugin is supported
  71222. */
  71223. isSupported(): boolean;
  71224. /**
  71225. * Create a new Crowd so you can add agents
  71226. * @param maxAgents the maximum agent count in the crowd
  71227. * @param maxAgentRadius the maximum radius an agent can have
  71228. * @param scene to attach the crowd to
  71229. * @returns the crowd you can add agents to
  71230. */
  71231. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71232. /**
  71233. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71234. * The queries will try to find a solution within those bounds
  71235. * default is (1,1,1)
  71236. * @param extent x,y,z value that define the extent around the queries point of reference
  71237. */
  71238. setDefaultQueryExtent(extent: Vector3): void;
  71239. /**
  71240. * Get the Bounding box extent specified by setDefaultQueryExtent
  71241. * @returns the box extent values
  71242. */
  71243. getDefaultQueryExtent(): Vector3;
  71244. /**
  71245. * build the navmesh from a previously saved state using getNavmeshData
  71246. * @param data the Uint8Array returned by getNavmeshData
  71247. */
  71248. buildFromNavmeshData(data: Uint8Array): void;
  71249. /**
  71250. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71251. * @returns data the Uint8Array that can be saved and reused
  71252. */
  71253. getNavmeshData(): Uint8Array;
  71254. /**
  71255. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71256. * @param result output the box extent values
  71257. */
  71258. getDefaultQueryExtentToRef(result: Vector3): void;
  71259. /**
  71260. * Release all resources
  71261. */
  71262. dispose(): void;
  71263. }
  71264. /**
  71265. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71266. */
  71267. export interface ICrowd {
  71268. /**
  71269. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71270. * You can attach anything to that node. The node position is updated in the scene update tick.
  71271. * @param pos world position that will be constrained by the navigation mesh
  71272. * @param parameters agent parameters
  71273. * @param transform hooked to the agent that will be update by the scene
  71274. * @returns agent index
  71275. */
  71276. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71277. /**
  71278. * Returns the agent position in world space
  71279. * @param index agent index returned by addAgent
  71280. * @returns world space position
  71281. */
  71282. getAgentPosition(index: number): Vector3;
  71283. /**
  71284. * Gets the agent position result in world space
  71285. * @param index agent index returned by addAgent
  71286. * @param result output world space position
  71287. */
  71288. getAgentPositionToRef(index: number, result: Vector3): void;
  71289. /**
  71290. * Gets the agent velocity in world space
  71291. * @param index agent index returned by addAgent
  71292. * @returns world space velocity
  71293. */
  71294. getAgentVelocity(index: number): Vector3;
  71295. /**
  71296. * Gets the agent velocity result in world space
  71297. * @param index agent index returned by addAgent
  71298. * @param result output world space velocity
  71299. */
  71300. getAgentVelocityToRef(index: number, result: Vector3): void;
  71301. /**
  71302. * remove a particular agent previously created
  71303. * @param index agent index returned by addAgent
  71304. */
  71305. removeAgent(index: number): void;
  71306. /**
  71307. * get the list of all agents attached to this crowd
  71308. * @returns list of agent indices
  71309. */
  71310. getAgents(): number[];
  71311. /**
  71312. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71313. * @param deltaTime in seconds
  71314. */
  71315. update(deltaTime: number): void;
  71316. /**
  71317. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71318. * @param index agent index returned by addAgent
  71319. * @param destination targeted world position
  71320. */
  71321. agentGoto(index: number, destination: Vector3): void;
  71322. /**
  71323. * Teleport the agent to a new position
  71324. * @param index agent index returned by addAgent
  71325. * @param destination targeted world position
  71326. */
  71327. agentTeleport(index: number, destination: Vector3): void;
  71328. /**
  71329. * Update agent parameters
  71330. * @param index agent index returned by addAgent
  71331. * @param parameters agent parameters
  71332. */
  71333. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71334. /**
  71335. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71336. * The queries will try to find a solution within those bounds
  71337. * default is (1,1,1)
  71338. * @param extent x,y,z value that define the extent around the queries point of reference
  71339. */
  71340. setDefaultQueryExtent(extent: Vector3): void;
  71341. /**
  71342. * Get the Bounding box extent specified by setDefaultQueryExtent
  71343. * @returns the box extent values
  71344. */
  71345. getDefaultQueryExtent(): Vector3;
  71346. /**
  71347. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71348. * @param result output the box extent values
  71349. */
  71350. getDefaultQueryExtentToRef(result: Vector3): void;
  71351. /**
  71352. * Release all resources
  71353. */
  71354. dispose(): void;
  71355. }
  71356. /**
  71357. * Configures an agent
  71358. */
  71359. export interface IAgentParameters {
  71360. /**
  71361. * Agent radius. [Limit: >= 0]
  71362. */
  71363. radius: number;
  71364. /**
  71365. * Agent height. [Limit: > 0]
  71366. */
  71367. height: number;
  71368. /**
  71369. * Maximum allowed acceleration. [Limit: >= 0]
  71370. */
  71371. maxAcceleration: number;
  71372. /**
  71373. * Maximum allowed speed. [Limit: >= 0]
  71374. */
  71375. maxSpeed: number;
  71376. /**
  71377. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71378. */
  71379. collisionQueryRange: number;
  71380. /**
  71381. * The path visibility optimization range. [Limit: > 0]
  71382. */
  71383. pathOptimizationRange: number;
  71384. /**
  71385. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71386. */
  71387. separationWeight: number;
  71388. }
  71389. /**
  71390. * Configures the navigation mesh creation
  71391. */
  71392. export interface INavMeshParameters {
  71393. /**
  71394. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71395. */
  71396. cs: number;
  71397. /**
  71398. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71399. */
  71400. ch: number;
  71401. /**
  71402. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71403. */
  71404. walkableSlopeAngle: number;
  71405. /**
  71406. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71407. * be considered walkable. [Limit: >= 3] [Units: vx]
  71408. */
  71409. walkableHeight: number;
  71410. /**
  71411. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71412. */
  71413. walkableClimb: number;
  71414. /**
  71415. * The distance to erode/shrink the walkable area of the heightfield away from
  71416. * obstructions. [Limit: >=0] [Units: vx]
  71417. */
  71418. walkableRadius: number;
  71419. /**
  71420. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71421. */
  71422. maxEdgeLen: number;
  71423. /**
  71424. * The maximum distance a simplfied contour's border edges should deviate
  71425. * the original raw contour. [Limit: >=0] [Units: vx]
  71426. */
  71427. maxSimplificationError: number;
  71428. /**
  71429. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71430. */
  71431. minRegionArea: number;
  71432. /**
  71433. * Any regions with a span count smaller than this value will, if possible,
  71434. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71435. */
  71436. mergeRegionArea: number;
  71437. /**
  71438. * The maximum number of vertices allowed for polygons generated during the
  71439. * contour to polygon conversion process. [Limit: >= 3]
  71440. */
  71441. maxVertsPerPoly: number;
  71442. /**
  71443. * Sets the sampling distance to use when generating the detail mesh.
  71444. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71445. */
  71446. detailSampleDist: number;
  71447. /**
  71448. * The maximum distance the detail mesh surface should deviate from heightfield
  71449. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71450. */
  71451. detailSampleMaxError: number;
  71452. }
  71453. }
  71454. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  71455. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  71456. import { Mesh } from "babylonjs/Meshes/mesh";
  71457. import { Scene } from "babylonjs/scene";
  71458. import { Vector3 } from "babylonjs/Maths/math";
  71459. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71460. /**
  71461. * RecastJS navigation plugin
  71462. */
  71463. export class RecastJSPlugin implements INavigationEnginePlugin {
  71464. /**
  71465. * Reference to the Recast library
  71466. */
  71467. bjsRECAST: any;
  71468. /**
  71469. * plugin name
  71470. */
  71471. name: string;
  71472. /**
  71473. * the first navmesh created. We might extend this to support multiple navmeshes
  71474. */
  71475. navMesh: any;
  71476. /**
  71477. * Initializes the recastJS plugin
  71478. * @param recastInjection can be used to inject your own recast reference
  71479. */
  71480. constructor(recastInjection?: any);
  71481. /**
  71482. * Creates a navigation mesh
  71483. * @param meshes array of all the geometry used to compute the navigatio mesh
  71484. * @param parameters bunch of parameters used to filter geometry
  71485. */
  71486. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71487. /**
  71488. * Create a navigation mesh debug mesh
  71489. * @param scene is where the mesh will be added
  71490. * @returns debug display mesh
  71491. */
  71492. createDebugNavMesh(scene: Scene): Mesh;
  71493. /**
  71494. * Get a navigation mesh constrained position, closest to the parameter position
  71495. * @param position world position
  71496. * @returns the closest point to position constrained by the navigation mesh
  71497. */
  71498. getClosestPoint(position: Vector3): Vector3;
  71499. /**
  71500. * Get a navigation mesh constrained position, closest to the parameter position
  71501. * @param position world position
  71502. * @param result output the closest point to position constrained by the navigation mesh
  71503. */
  71504. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71505. /**
  71506. * Get a navigation mesh constrained position, within a particular radius
  71507. * @param position world position
  71508. * @param maxRadius the maximum distance to the constrained world position
  71509. * @returns the closest point to position constrained by the navigation mesh
  71510. */
  71511. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71512. /**
  71513. * Get a navigation mesh constrained position, within a particular radius
  71514. * @param position world position
  71515. * @param maxRadius the maximum distance to the constrained world position
  71516. * @param result output the closest point to position constrained by the navigation mesh
  71517. */
  71518. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71519. /**
  71520. * Compute the final position from a segment made of destination-position
  71521. * @param position world position
  71522. * @param destination world position
  71523. * @returns the resulting point along the navmesh
  71524. */
  71525. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71526. /**
  71527. * Compute the final position from a segment made of destination-position
  71528. * @param position world position
  71529. * @param destination world position
  71530. * @param result output the resulting point along the navmesh
  71531. */
  71532. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71533. /**
  71534. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71535. * @param start world position
  71536. * @param end world position
  71537. * @returns array containing world position composing the path
  71538. */
  71539. computePath(start: Vector3, end: Vector3): Vector3[];
  71540. /**
  71541. * Create a new Crowd so you can add agents
  71542. * @param maxAgents the maximum agent count in the crowd
  71543. * @param maxAgentRadius the maximum radius an agent can have
  71544. * @param scene to attach the crowd to
  71545. * @returns the crowd you can add agents to
  71546. */
  71547. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71548. /**
  71549. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71550. * The queries will try to find a solution within those bounds
  71551. * default is (1,1,1)
  71552. * @param extent x,y,z value that define the extent around the queries point of reference
  71553. */
  71554. setDefaultQueryExtent(extent: Vector3): void;
  71555. /**
  71556. * Get the Bounding box extent specified by setDefaultQueryExtent
  71557. * @returns the box extent values
  71558. */
  71559. getDefaultQueryExtent(): Vector3;
  71560. /**
  71561. * build the navmesh from a previously saved state using getNavmeshData
  71562. * @param data the Uint8Array returned by getNavmeshData
  71563. */
  71564. buildFromNavmeshData(data: Uint8Array): void;
  71565. /**
  71566. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71567. * @returns data the Uint8Array that can be saved and reused
  71568. */
  71569. getNavmeshData(): Uint8Array;
  71570. /**
  71571. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71572. * @param result output the box extent values
  71573. */
  71574. getDefaultQueryExtentToRef(result: Vector3): void;
  71575. /**
  71576. * Disposes
  71577. */
  71578. dispose(): void;
  71579. /**
  71580. * If this plugin is supported
  71581. * @returns true if plugin is supported
  71582. */
  71583. isSupported(): boolean;
  71584. }
  71585. /**
  71586. * Recast detour crowd implementation
  71587. */
  71588. export class RecastJSCrowd implements ICrowd {
  71589. /**
  71590. * Recast/detour plugin
  71591. */
  71592. bjsRECASTPlugin: RecastJSPlugin;
  71593. /**
  71594. * Link to the detour crowd
  71595. */
  71596. recastCrowd: any;
  71597. /**
  71598. * One transform per agent
  71599. */
  71600. transforms: TransformNode[];
  71601. /**
  71602. * All agents created
  71603. */
  71604. agents: number[];
  71605. /**
  71606. * Link to the scene is kept to unregister the crowd from the scene
  71607. */
  71608. private _scene;
  71609. /**
  71610. * Observer for crowd updates
  71611. */
  71612. private _onBeforeAnimationsObserver;
  71613. /**
  71614. * Constructor
  71615. * @param plugin recastJS plugin
  71616. * @param maxAgents the maximum agent count in the crowd
  71617. * @param maxAgentRadius the maximum radius an agent can have
  71618. * @param scene to attach the crowd to
  71619. * @returns the crowd you can add agents to
  71620. */
  71621. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71622. /**
  71623. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71624. * You can attach anything to that node. The node position is updated in the scene update tick.
  71625. * @param pos world position that will be constrained by the navigation mesh
  71626. * @param parameters agent parameters
  71627. * @param transform hooked to the agent that will be update by the scene
  71628. * @returns agent index
  71629. */
  71630. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71631. /**
  71632. * Returns the agent position in world space
  71633. * @param index agent index returned by addAgent
  71634. * @returns world space position
  71635. */
  71636. getAgentPosition(index: number): Vector3;
  71637. /**
  71638. * Returns the agent position result in world space
  71639. * @param index agent index returned by addAgent
  71640. * @param result output world space position
  71641. */
  71642. getAgentPositionToRef(index: number, result: Vector3): void;
  71643. /**
  71644. * Returns the agent velocity in world space
  71645. * @param index agent index returned by addAgent
  71646. * @returns world space velocity
  71647. */
  71648. getAgentVelocity(index: number): Vector3;
  71649. /**
  71650. * Returns the agent velocity result in world space
  71651. * @param index agent index returned by addAgent
  71652. * @param result output world space velocity
  71653. */
  71654. getAgentVelocityToRef(index: number, result: Vector3): void;
  71655. /**
  71656. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71657. * @param index agent index returned by addAgent
  71658. * @param destination targeted world position
  71659. */
  71660. agentGoto(index: number, destination: Vector3): void;
  71661. /**
  71662. * Teleport the agent to a new position
  71663. * @param index agent index returned by addAgent
  71664. * @param destination targeted world position
  71665. */
  71666. agentTeleport(index: number, destination: Vector3): void;
  71667. /**
  71668. * Update agent parameters
  71669. * @param index agent index returned by addAgent
  71670. * @param parameters agent parameters
  71671. */
  71672. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71673. /**
  71674. * remove a particular agent previously created
  71675. * @param index agent index returned by addAgent
  71676. */
  71677. removeAgent(index: number): void;
  71678. /**
  71679. * get the list of all agents attached to this crowd
  71680. * @returns list of agent indices
  71681. */
  71682. getAgents(): number[];
  71683. /**
  71684. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71685. * @param deltaTime in seconds
  71686. */
  71687. update(deltaTime: number): void;
  71688. /**
  71689. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71690. * The queries will try to find a solution within those bounds
  71691. * default is (1,1,1)
  71692. * @param extent x,y,z value that define the extent around the queries point of reference
  71693. */
  71694. setDefaultQueryExtent(extent: Vector3): void;
  71695. /**
  71696. * Get the Bounding box extent specified by setDefaultQueryExtent
  71697. * @returns the box extent values
  71698. */
  71699. getDefaultQueryExtent(): Vector3;
  71700. /**
  71701. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71702. * @param result output the box extent values
  71703. */
  71704. getDefaultQueryExtentToRef(result: Vector3): void;
  71705. /**
  71706. * Release all resources
  71707. */
  71708. dispose(): void;
  71709. }
  71710. }
  71711. declare module "babylonjs/Navigation/Plugins/index" {
  71712. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  71713. }
  71714. declare module "babylonjs/Navigation/index" {
  71715. export * from "babylonjs/Navigation/INavigationEngine";
  71716. export * from "babylonjs/Navigation/Plugins/index";
  71717. }
  71718. declare module "babylonjs/Offline/database" {
  71719. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  71720. /**
  71721. * Class used to enable access to IndexedDB
  71722. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71723. */
  71724. export class Database implements IOfflineProvider {
  71725. private _callbackManifestChecked;
  71726. private _currentSceneUrl;
  71727. private _db;
  71728. private _enableSceneOffline;
  71729. private _enableTexturesOffline;
  71730. private _manifestVersionFound;
  71731. private _mustUpdateRessources;
  71732. private _hasReachedQuota;
  71733. private _isSupported;
  71734. private _idbFactory;
  71735. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71736. private static IsUASupportingBlobStorage;
  71737. /**
  71738. * Gets a boolean indicating if Database storate is enabled (off by default)
  71739. */
  71740. static IDBStorageEnabled: boolean;
  71741. /**
  71742. * Gets a boolean indicating if scene must be saved in the database
  71743. */
  71744. get enableSceneOffline(): boolean;
  71745. /**
  71746. * Gets a boolean indicating if textures must be saved in the database
  71747. */
  71748. get enableTexturesOffline(): boolean;
  71749. /**
  71750. * Creates a new Database
  71751. * @param urlToScene defines the url to load the scene
  71752. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71753. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71754. */
  71755. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71756. private static _ParseURL;
  71757. private static _ReturnFullUrlLocation;
  71758. private _checkManifestFile;
  71759. /**
  71760. * Open the database and make it available
  71761. * @param successCallback defines the callback to call on success
  71762. * @param errorCallback defines the callback to call on error
  71763. */
  71764. open(successCallback: () => void, errorCallback: () => void): void;
  71765. /**
  71766. * Loads an image from the database
  71767. * @param url defines the url to load from
  71768. * @param image defines the target DOM image
  71769. */
  71770. loadImage(url: string, image: HTMLImageElement): void;
  71771. private _loadImageFromDBAsync;
  71772. private _saveImageIntoDBAsync;
  71773. private _checkVersionFromDB;
  71774. private _loadVersionFromDBAsync;
  71775. private _saveVersionIntoDBAsync;
  71776. /**
  71777. * Loads a file from database
  71778. * @param url defines the URL to load from
  71779. * @param sceneLoaded defines a callback to call on success
  71780. * @param progressCallBack defines a callback to call when progress changed
  71781. * @param errorCallback defines a callback to call on error
  71782. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71783. */
  71784. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71785. private _loadFileAsync;
  71786. private _saveFileAsync;
  71787. /**
  71788. * Validates if xhr data is correct
  71789. * @param xhr defines the request to validate
  71790. * @param dataType defines the expected data type
  71791. * @returns true if data is correct
  71792. */
  71793. private static _ValidateXHRData;
  71794. }
  71795. }
  71796. declare module "babylonjs/Offline/index" {
  71797. export * from "babylonjs/Offline/database";
  71798. export * from "babylonjs/Offline/IOfflineProvider";
  71799. }
  71800. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71801. /** @hidden */
  71802. export var gpuUpdateParticlesPixelShader: {
  71803. name: string;
  71804. shader: string;
  71805. };
  71806. }
  71807. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71808. /** @hidden */
  71809. export var gpuUpdateParticlesVertexShader: {
  71810. name: string;
  71811. shader: string;
  71812. };
  71813. }
  71814. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71815. /** @hidden */
  71816. export var clipPlaneFragmentDeclaration2: {
  71817. name: string;
  71818. shader: string;
  71819. };
  71820. }
  71821. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71822. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71823. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71824. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71825. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71826. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71827. /** @hidden */
  71828. export var gpuRenderParticlesPixelShader: {
  71829. name: string;
  71830. shader: string;
  71831. };
  71832. }
  71833. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71834. /** @hidden */
  71835. export var clipPlaneVertexDeclaration2: {
  71836. name: string;
  71837. shader: string;
  71838. };
  71839. }
  71840. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71841. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71842. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71843. /** @hidden */
  71844. export var gpuRenderParticlesVertexShader: {
  71845. name: string;
  71846. shader: string;
  71847. };
  71848. }
  71849. declare module "babylonjs/Particles/gpuParticleSystem" {
  71850. import { Nullable } from "babylonjs/types";
  71851. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71852. import { Observable } from "babylonjs/Misc/observable";
  71853. import { Matrix } from "babylonjs/Maths/math.vector";
  71854. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71855. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71856. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71857. import { IDisposable } from "babylonjs/scene";
  71858. import { Effect } from "babylonjs/Materials/effect";
  71859. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71860. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71861. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71862. import { Scene } from "babylonjs/scene";
  71863. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71864. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71865. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71866. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71867. /**
  71868. * This represents a GPU particle system in Babylon
  71869. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71870. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71871. */
  71872. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71873. /**
  71874. * The layer mask we are rendering the particles through.
  71875. */
  71876. layerMask: number;
  71877. private _capacity;
  71878. private _activeCount;
  71879. private _currentActiveCount;
  71880. private _accumulatedCount;
  71881. private _renderEffect;
  71882. private _updateEffect;
  71883. private _buffer0;
  71884. private _buffer1;
  71885. private _spriteBuffer;
  71886. private _updateVAO;
  71887. private _renderVAO;
  71888. private _targetIndex;
  71889. private _sourceBuffer;
  71890. private _targetBuffer;
  71891. private _currentRenderId;
  71892. private _started;
  71893. private _stopped;
  71894. private _timeDelta;
  71895. private _randomTexture;
  71896. private _randomTexture2;
  71897. private _attributesStrideSize;
  71898. private _updateEffectOptions;
  71899. private _randomTextureSize;
  71900. private _actualFrame;
  71901. private _customEffect;
  71902. private readonly _rawTextureWidth;
  71903. /**
  71904. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71905. */
  71906. static get IsSupported(): boolean;
  71907. /**
  71908. * An event triggered when the system is disposed.
  71909. */
  71910. onDisposeObservable: Observable<IParticleSystem>;
  71911. /**
  71912. * An event triggered when the system is stopped
  71913. */
  71914. onStoppedObservable: Observable<IParticleSystem>;
  71915. /**
  71916. * Gets the maximum number of particles active at the same time.
  71917. * @returns The max number of active particles.
  71918. */
  71919. getCapacity(): number;
  71920. /**
  71921. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71922. * to override the particles.
  71923. */
  71924. forceDepthWrite: boolean;
  71925. /**
  71926. * Gets or set the number of active particles
  71927. */
  71928. get activeParticleCount(): number;
  71929. set activeParticleCount(value: number);
  71930. private _preWarmDone;
  71931. /**
  71932. * Specifies if the particles are updated in emitter local space or world space.
  71933. */
  71934. isLocal: boolean;
  71935. /** Gets or sets a matrix to use to compute projection */
  71936. defaultProjectionMatrix: Matrix;
  71937. /**
  71938. * Is this system ready to be used/rendered
  71939. * @return true if the system is ready
  71940. */
  71941. isReady(): boolean;
  71942. /**
  71943. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71944. * @returns True if it has been started, otherwise false.
  71945. */
  71946. isStarted(): boolean;
  71947. /**
  71948. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71949. * @returns True if it has been stopped, otherwise false.
  71950. */
  71951. isStopped(): boolean;
  71952. /**
  71953. * Gets a boolean indicating that the system is stopping
  71954. * @returns true if the system is currently stopping
  71955. */
  71956. isStopping(): boolean;
  71957. /**
  71958. * Gets the number of particles active at the same time.
  71959. * @returns The number of active particles.
  71960. */
  71961. getActiveCount(): number;
  71962. /**
  71963. * Starts the particle system and begins to emit
  71964. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71965. */
  71966. start(delay?: number): void;
  71967. /**
  71968. * Stops the particle system.
  71969. */
  71970. stop(): void;
  71971. /**
  71972. * Remove all active particles
  71973. */
  71974. reset(): void;
  71975. /**
  71976. * Returns the string "GPUParticleSystem"
  71977. * @returns a string containing the class name
  71978. */
  71979. getClassName(): string;
  71980. /**
  71981. * Gets the custom effect used to render the particles
  71982. * @param blendMode Blend mode for which the effect should be retrieved
  71983. * @returns The effect
  71984. */
  71985. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71986. /**
  71987. * Sets the custom effect used to render the particles
  71988. * @param effect The effect to set
  71989. * @param blendMode Blend mode for which the effect should be set
  71990. */
  71991. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71992. /** @hidden */
  71993. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71994. /**
  71995. * Observable that will be called just before the particles are drawn
  71996. */
  71997. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71998. /**
  71999. * Gets the name of the particle vertex shader
  72000. */
  72001. get vertexShaderName(): string;
  72002. private _colorGradientsTexture;
  72003. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72004. /**
  72005. * Adds a new color gradient
  72006. * @param gradient defines the gradient to use (between 0 and 1)
  72007. * @param color1 defines the color to affect to the specified gradient
  72008. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72009. * @returns the current particle system
  72010. */
  72011. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72012. private _refreshColorGradient;
  72013. /** Force the system to rebuild all gradients that need to be resync */
  72014. forceRefreshGradients(): void;
  72015. /**
  72016. * Remove a specific color gradient
  72017. * @param gradient defines the gradient to remove
  72018. * @returns the current particle system
  72019. */
  72020. removeColorGradient(gradient: number): GPUParticleSystem;
  72021. private _angularSpeedGradientsTexture;
  72022. private _sizeGradientsTexture;
  72023. private _velocityGradientsTexture;
  72024. private _limitVelocityGradientsTexture;
  72025. private _dragGradientsTexture;
  72026. private _addFactorGradient;
  72027. /**
  72028. * Adds a new size gradient
  72029. * @param gradient defines the gradient to use (between 0 and 1)
  72030. * @param factor defines the size factor to affect to the specified gradient
  72031. * @returns the current particle system
  72032. */
  72033. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72034. /**
  72035. * Remove a specific size gradient
  72036. * @param gradient defines the gradient to remove
  72037. * @returns the current particle system
  72038. */
  72039. removeSizeGradient(gradient: number): GPUParticleSystem;
  72040. private _refreshFactorGradient;
  72041. /**
  72042. * Adds a new angular speed gradient
  72043. * @param gradient defines the gradient to use (between 0 and 1)
  72044. * @param factor defines the angular speed to affect to the specified gradient
  72045. * @returns the current particle system
  72046. */
  72047. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72048. /**
  72049. * Remove a specific angular speed gradient
  72050. * @param gradient defines the gradient to remove
  72051. * @returns the current particle system
  72052. */
  72053. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72054. /**
  72055. * Adds a new velocity gradient
  72056. * @param gradient defines the gradient to use (between 0 and 1)
  72057. * @param factor defines the velocity to affect to the specified gradient
  72058. * @returns the current particle system
  72059. */
  72060. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72061. /**
  72062. * Remove a specific velocity gradient
  72063. * @param gradient defines the gradient to remove
  72064. * @returns the current particle system
  72065. */
  72066. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72067. /**
  72068. * Adds a new limit velocity gradient
  72069. * @param gradient defines the gradient to use (between 0 and 1)
  72070. * @param factor defines the limit velocity value to affect to the specified gradient
  72071. * @returns the current particle system
  72072. */
  72073. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72074. /**
  72075. * Remove a specific limit velocity gradient
  72076. * @param gradient defines the gradient to remove
  72077. * @returns the current particle system
  72078. */
  72079. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72080. /**
  72081. * Adds a new drag gradient
  72082. * @param gradient defines the gradient to use (between 0 and 1)
  72083. * @param factor defines the drag value to affect to the specified gradient
  72084. * @returns the current particle system
  72085. */
  72086. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72087. /**
  72088. * Remove a specific drag gradient
  72089. * @param gradient defines the gradient to remove
  72090. * @returns the current particle system
  72091. */
  72092. removeDragGradient(gradient: number): GPUParticleSystem;
  72093. /**
  72094. * Not supported by GPUParticleSystem
  72095. * @param gradient defines the gradient to use (between 0 and 1)
  72096. * @param factor defines the emit rate value to affect to the specified gradient
  72097. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72098. * @returns the current particle system
  72099. */
  72100. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72101. /**
  72102. * Not supported by GPUParticleSystem
  72103. * @param gradient defines the gradient to remove
  72104. * @returns the current particle system
  72105. */
  72106. removeEmitRateGradient(gradient: number): IParticleSystem;
  72107. /**
  72108. * Not supported by GPUParticleSystem
  72109. * @param gradient defines the gradient to use (between 0 and 1)
  72110. * @param factor defines the start size value to affect to the specified gradient
  72111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72112. * @returns the current particle system
  72113. */
  72114. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72115. /**
  72116. * Not supported by GPUParticleSystem
  72117. * @param gradient defines the gradient to remove
  72118. * @returns the current particle system
  72119. */
  72120. removeStartSizeGradient(gradient: number): IParticleSystem;
  72121. /**
  72122. * Not supported by GPUParticleSystem
  72123. * @param gradient defines the gradient to use (between 0 and 1)
  72124. * @param min defines the color remap minimal range
  72125. * @param max defines the color remap maximal range
  72126. * @returns the current particle system
  72127. */
  72128. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72129. /**
  72130. * Not supported by GPUParticleSystem
  72131. * @param gradient defines the gradient to remove
  72132. * @returns the current particle system
  72133. */
  72134. removeColorRemapGradient(): IParticleSystem;
  72135. /**
  72136. * Not supported by GPUParticleSystem
  72137. * @param gradient defines the gradient to use (between 0 and 1)
  72138. * @param min defines the alpha remap minimal range
  72139. * @param max defines the alpha remap maximal range
  72140. * @returns the current particle system
  72141. */
  72142. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72143. /**
  72144. * Not supported by GPUParticleSystem
  72145. * @param gradient defines the gradient to remove
  72146. * @returns the current particle system
  72147. */
  72148. removeAlphaRemapGradient(): IParticleSystem;
  72149. /**
  72150. * Not supported by GPUParticleSystem
  72151. * @param gradient defines the gradient to use (between 0 and 1)
  72152. * @param color defines the color to affect to the specified gradient
  72153. * @returns the current particle system
  72154. */
  72155. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72156. /**
  72157. * Not supported by GPUParticleSystem
  72158. * @param gradient defines the gradient to remove
  72159. * @returns the current particle system
  72160. */
  72161. removeRampGradient(): IParticleSystem;
  72162. /**
  72163. * Not supported by GPUParticleSystem
  72164. * @returns the list of ramp gradients
  72165. */
  72166. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72167. /**
  72168. * Not supported by GPUParticleSystem
  72169. * Gets or sets a boolean indicating that ramp gradients must be used
  72170. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72171. */
  72172. get useRampGradients(): boolean;
  72173. set useRampGradients(value: boolean);
  72174. /**
  72175. * Not supported by GPUParticleSystem
  72176. * @param gradient defines the gradient to use (between 0 and 1)
  72177. * @param factor defines the life time factor to affect to the specified gradient
  72178. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72179. * @returns the current particle system
  72180. */
  72181. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72182. /**
  72183. * Not supported by GPUParticleSystem
  72184. * @param gradient defines the gradient to remove
  72185. * @returns the current particle system
  72186. */
  72187. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72188. /**
  72189. * Instantiates a GPU particle system.
  72190. * 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.
  72191. * @param name The name of the particle system
  72192. * @param options The options used to create the system
  72193. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72194. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72195. * @param customEffect a custom effect used to change the way particles are rendered by default
  72196. */
  72197. constructor(name: string, options: Partial<{
  72198. capacity: number;
  72199. randomTextureSize: number;
  72200. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72201. protected _reset(): void;
  72202. private _createUpdateVAO;
  72203. private _createRenderVAO;
  72204. private _initialize;
  72205. /** @hidden */
  72206. _recreateUpdateEffect(): void;
  72207. private _getEffect;
  72208. /**
  72209. * Fill the defines array according to the current settings of the particle system
  72210. * @param defines Array to be updated
  72211. * @param blendMode blend mode to take into account when updating the array
  72212. */
  72213. fillDefines(defines: Array<string>, blendMode?: number): void;
  72214. /**
  72215. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72216. * @param uniforms Uniforms array to fill
  72217. * @param attributes Attributes array to fill
  72218. * @param samplers Samplers array to fill
  72219. */
  72220. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72221. /** @hidden */
  72222. _recreateRenderEffect(): Effect;
  72223. /**
  72224. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72225. * @param preWarm defines if we are in the pre-warmimg phase
  72226. */
  72227. animate(preWarm?: boolean): void;
  72228. private _createFactorGradientTexture;
  72229. private _createSizeGradientTexture;
  72230. private _createAngularSpeedGradientTexture;
  72231. private _createVelocityGradientTexture;
  72232. private _createLimitVelocityGradientTexture;
  72233. private _createDragGradientTexture;
  72234. private _createColorGradientTexture;
  72235. /**
  72236. * Renders the particle system in its current state
  72237. * @param preWarm defines if the system should only update the particles but not render them
  72238. * @returns the current number of particles
  72239. */
  72240. render(preWarm?: boolean): number;
  72241. /**
  72242. * Rebuilds the particle system
  72243. */
  72244. rebuild(): void;
  72245. private _releaseBuffers;
  72246. private _releaseVAOs;
  72247. /**
  72248. * Disposes the particle system and free the associated resources
  72249. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72250. */
  72251. dispose(disposeTexture?: boolean): void;
  72252. /**
  72253. * Clones the particle system.
  72254. * @param name The name of the cloned object
  72255. * @param newEmitter The new emitter to use
  72256. * @returns the cloned particle system
  72257. */
  72258. clone(name: string, newEmitter: any): GPUParticleSystem;
  72259. /**
  72260. * Serializes the particle system to a JSON object
  72261. * @param serializeTexture defines if the texture must be serialized as well
  72262. * @returns the JSON object
  72263. */
  72264. serialize(serializeTexture?: boolean): any;
  72265. /**
  72266. * Parses a JSON object to create a GPU particle system.
  72267. * @param parsedParticleSystem The JSON object to parse
  72268. * @param sceneOrEngine The scene or the engine to create the particle system in
  72269. * @param rootUrl The root url to use to load external dependencies like texture
  72270. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72271. * @returns the parsed GPU particle system
  72272. */
  72273. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72274. }
  72275. }
  72276. declare module "babylonjs/Particles/particleSystemSet" {
  72277. import { Nullable } from "babylonjs/types";
  72278. import { Color3 } from "babylonjs/Maths/math.color";
  72279. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72281. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72282. import { Scene, IDisposable } from "babylonjs/scene";
  72283. /**
  72284. * Represents a set of particle systems working together to create a specific effect
  72285. */
  72286. export class ParticleSystemSet implements IDisposable {
  72287. /**
  72288. * Gets or sets base Assets URL
  72289. */
  72290. static BaseAssetsUrl: string;
  72291. private _emitterCreationOptions;
  72292. private _emitterNode;
  72293. /**
  72294. * Gets the particle system list
  72295. */
  72296. systems: IParticleSystem[];
  72297. /**
  72298. * Gets the emitter node used with this set
  72299. */
  72300. get emitterNode(): Nullable<TransformNode>;
  72301. /**
  72302. * Creates a new emitter mesh as a sphere
  72303. * @param options defines the options used to create the sphere
  72304. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72305. * @param scene defines the hosting scene
  72306. */
  72307. setEmitterAsSphere(options: {
  72308. diameter: number;
  72309. segments: number;
  72310. color: Color3;
  72311. }, renderingGroupId: number, scene: Scene): void;
  72312. /**
  72313. * Starts all particle systems of the set
  72314. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72315. */
  72316. start(emitter?: AbstractMesh): void;
  72317. /**
  72318. * Release all associated resources
  72319. */
  72320. dispose(): void;
  72321. /**
  72322. * Serialize the set into a JSON compatible object
  72323. * @param serializeTexture defines if the texture must be serialized as well
  72324. * @returns a JSON compatible representation of the set
  72325. */
  72326. serialize(serializeTexture?: boolean): any;
  72327. /**
  72328. * Parse a new ParticleSystemSet from a serialized source
  72329. * @param data defines a JSON compatible representation of the set
  72330. * @param scene defines the hosting scene
  72331. * @param gpu defines if we want GPU particles or CPU particles
  72332. * @returns a new ParticleSystemSet
  72333. */
  72334. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72335. }
  72336. }
  72337. declare module "babylonjs/Particles/particleHelper" {
  72338. import { Nullable } from "babylonjs/types";
  72339. import { Scene } from "babylonjs/scene";
  72340. import { Vector3 } from "babylonjs/Maths/math.vector";
  72341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72342. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72343. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  72344. /**
  72345. * This class is made for on one-liner static method to help creating particle system set.
  72346. */
  72347. export class ParticleHelper {
  72348. /**
  72349. * Gets or sets base Assets URL
  72350. */
  72351. static BaseAssetsUrl: string;
  72352. /** Define the Url to load snippets */
  72353. static SnippetUrl: string;
  72354. /**
  72355. * Create a default particle system that you can tweak
  72356. * @param emitter defines the emitter to use
  72357. * @param capacity defines the system capacity (default is 500 particles)
  72358. * @param scene defines the hosting scene
  72359. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72360. * @returns the new Particle system
  72361. */
  72362. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72363. /**
  72364. * This is the main static method (one-liner) of this helper to create different particle systems
  72365. * @param type This string represents the type to the particle system to create
  72366. * @param scene The scene where the particle system should live
  72367. * @param gpu If the system will use gpu
  72368. * @returns the ParticleSystemSet created
  72369. */
  72370. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72371. /**
  72372. * Static function used to export a particle system to a ParticleSystemSet variable.
  72373. * Please note that the emitter shape is not exported
  72374. * @param systems defines the particle systems to export
  72375. * @returns the created particle system set
  72376. */
  72377. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72378. /**
  72379. * Creates a particle system from a snippet saved in a remote file
  72380. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72381. * @param url defines the url to load from
  72382. * @param scene defines the hosting scene
  72383. * @param gpu If the system will use gpu
  72384. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72385. * @returns a promise that will resolve to the new particle system
  72386. */
  72387. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72388. /**
  72389. * Creates a particle system from a snippet saved by the particle system editor
  72390. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72391. * @param scene defines the hosting scene
  72392. * @param gpu If the system will use gpu
  72393. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72394. * @returns a promise that will resolve to the new particle system
  72395. */
  72396. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72397. }
  72398. }
  72399. declare module "babylonjs/Particles/particleSystemComponent" {
  72400. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72401. import { Effect } from "babylonjs/Materials/effect";
  72402. import "babylonjs/Shaders/particles.vertex";
  72403. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  72404. module "babylonjs/Engines/engine" {
  72405. interface Engine {
  72406. /**
  72407. * Create an effect to use with particle systems.
  72408. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72409. * the particle system for which you want to create a custom effect in the last parameter
  72410. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72411. * @param uniformsNames defines a list of attribute names
  72412. * @param samplers defines an array of string used to represent textures
  72413. * @param defines defines the string containing the defines to use to compile the shaders
  72414. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72415. * @param onCompiled defines a function to call when the effect creation is successful
  72416. * @param onError defines a function to call when the effect creation has failed
  72417. * @param particleSystem the particle system you want to create the effect for
  72418. * @returns the new Effect
  72419. */
  72420. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72421. }
  72422. }
  72423. module "babylonjs/Meshes/mesh" {
  72424. interface Mesh {
  72425. /**
  72426. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72427. * @returns an array of IParticleSystem
  72428. */
  72429. getEmittedParticleSystems(): IParticleSystem[];
  72430. /**
  72431. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72432. * @returns an array of IParticleSystem
  72433. */
  72434. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72435. }
  72436. }
  72437. }
  72438. declare module "babylonjs/Particles/pointsCloudSystem" {
  72439. import { Color4 } from "babylonjs/Maths/math";
  72440. import { Mesh } from "babylonjs/Meshes/mesh";
  72441. import { Scene, IDisposable } from "babylonjs/scene";
  72442. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  72443. /** Defines the 4 color options */
  72444. export enum PointColor {
  72445. /** color value */
  72446. Color = 2,
  72447. /** uv value */
  72448. UV = 1,
  72449. /** random value */
  72450. Random = 0,
  72451. /** stated value */
  72452. Stated = 3
  72453. }
  72454. /**
  72455. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72456. * 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.
  72457. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72458. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72459. *
  72460. * Full documentation here : TO BE ENTERED
  72461. */
  72462. export class PointsCloudSystem implements IDisposable {
  72463. /**
  72464. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72465. * Example : var p = SPS.particles[i];
  72466. */
  72467. particles: CloudPoint[];
  72468. /**
  72469. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72470. */
  72471. nbParticles: number;
  72472. /**
  72473. * This a counter for your own usage. It's not set by any SPS functions.
  72474. */
  72475. counter: number;
  72476. /**
  72477. * The PCS name. This name is also given to the underlying mesh.
  72478. */
  72479. name: string;
  72480. /**
  72481. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72482. */
  72483. mesh: Mesh;
  72484. /**
  72485. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72486. * Please read :
  72487. */
  72488. vars: any;
  72489. /**
  72490. * @hidden
  72491. */
  72492. _size: number;
  72493. private _scene;
  72494. private _promises;
  72495. private _positions;
  72496. private _indices;
  72497. private _normals;
  72498. private _colors;
  72499. private _uvs;
  72500. private _indices32;
  72501. private _positions32;
  72502. private _colors32;
  72503. private _uvs32;
  72504. private _updatable;
  72505. private _isVisibilityBoxLocked;
  72506. private _alwaysVisible;
  72507. private _groups;
  72508. private _groupCounter;
  72509. private _computeParticleColor;
  72510. private _computeParticleTexture;
  72511. private _computeParticleRotation;
  72512. private _computeBoundingBox;
  72513. private _isReady;
  72514. /**
  72515. * Creates a PCS (Points Cloud System) object
  72516. * @param name (String) is the PCS name, this will be the underlying mesh name
  72517. * @param pointSize (number) is the size for each point
  72518. * @param scene (Scene) is the scene in which the PCS is added
  72519. * @param options defines the options of the PCS e.g.
  72520. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72521. */
  72522. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72523. updatable?: boolean;
  72524. });
  72525. /**
  72526. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72527. * If no points were added to the PCS, the returned mesh is just a single point.
  72528. * @returns a promise for the created mesh
  72529. */
  72530. buildMeshAsync(): Promise<Mesh>;
  72531. /**
  72532. * @hidden
  72533. */
  72534. private _buildMesh;
  72535. private _addParticle;
  72536. private _randomUnitVector;
  72537. private _getColorIndicesForCoord;
  72538. private _setPointsColorOrUV;
  72539. private _colorFromTexture;
  72540. private _calculateDensity;
  72541. /**
  72542. * Adds points to the PCS in random positions within a unit sphere
  72543. * @param nb (positive integer) the number of particles to be created from this model
  72544. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72545. * @returns the number of groups in the system
  72546. */
  72547. addPoints(nb: number, pointFunction?: any): number;
  72548. /**
  72549. * Adds points to the PCS from the surface of the model shape
  72550. * @param mesh is any Mesh object that will be used as a surface model for the points
  72551. * @param nb (positive integer) the number of particles to be created from this model
  72552. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72553. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72554. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72555. * @returns the number of groups in the system
  72556. */
  72557. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72558. /**
  72559. * Adds points to the PCS inside the model shape
  72560. * @param mesh is any Mesh object that will be used as a surface model for the points
  72561. * @param nb (positive integer) the number of particles to be created from this model
  72562. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72563. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72564. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72565. * @returns the number of groups in the system
  72566. */
  72567. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72568. /**
  72569. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72570. * This method calls `updateParticle()` for each particle of the SPS.
  72571. * For an animated SPS, it is usually called within the render loop.
  72572. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72573. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72574. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72575. * @returns the PCS.
  72576. */
  72577. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72578. /**
  72579. * Disposes the PCS.
  72580. */
  72581. dispose(): void;
  72582. /**
  72583. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72584. * doc :
  72585. * @returns the PCS.
  72586. */
  72587. refreshVisibleSize(): PointsCloudSystem;
  72588. /**
  72589. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72590. * @param size the size (float) of the visibility box
  72591. * note : this doesn't lock the PCS mesh bounding box.
  72592. * doc :
  72593. */
  72594. setVisibilityBox(size: number): void;
  72595. /**
  72596. * Gets whether the PCS is always visible or not
  72597. * doc :
  72598. */
  72599. get isAlwaysVisible(): boolean;
  72600. /**
  72601. * Sets the PCS as always visible or not
  72602. * doc :
  72603. */
  72604. set isAlwaysVisible(val: boolean);
  72605. /**
  72606. * Tells to `setParticles()` to compute the particle rotations or not
  72607. * Default value : false. The PCS is faster when it's set to false
  72608. * Note : particle rotations are only applied to parent particles
  72609. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72610. */
  72611. set computeParticleRotation(val: boolean);
  72612. /**
  72613. * Tells to `setParticles()` to compute the particle colors or not.
  72614. * Default value : true. The PCS is faster when it's set to false.
  72615. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72616. */
  72617. set computeParticleColor(val: boolean);
  72618. set computeParticleTexture(val: boolean);
  72619. /**
  72620. * Gets if `setParticles()` computes the particle colors or not.
  72621. * Default value : false. The PCS is faster when it's set to false.
  72622. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72623. */
  72624. get computeParticleColor(): boolean;
  72625. /**
  72626. * Gets if `setParticles()` computes the particle textures or not.
  72627. * Default value : false. The PCS is faster when it's set to false.
  72628. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72629. */
  72630. get computeParticleTexture(): boolean;
  72631. /**
  72632. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72633. */
  72634. set computeBoundingBox(val: boolean);
  72635. /**
  72636. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72637. */
  72638. get computeBoundingBox(): boolean;
  72639. /**
  72640. * This function does nothing. It may be overwritten to set all the particle first values.
  72641. * The PCS doesn't call this function, you may have to call it by your own.
  72642. * doc :
  72643. */
  72644. initParticles(): void;
  72645. /**
  72646. * This function does nothing. It may be overwritten to recycle a particle
  72647. * The PCS doesn't call this function, you can to call it
  72648. * doc :
  72649. * @param particle The particle to recycle
  72650. * @returns the recycled particle
  72651. */
  72652. recycleParticle(particle: CloudPoint): CloudPoint;
  72653. /**
  72654. * Updates a particle : this function should be overwritten by the user.
  72655. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72656. * doc :
  72657. * @example : just set a particle position or velocity and recycle conditions
  72658. * @param particle The particle to update
  72659. * @returns the updated particle
  72660. */
  72661. updateParticle(particle: CloudPoint): CloudPoint;
  72662. /**
  72663. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72664. * This does nothing and may be overwritten by the user.
  72665. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72666. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72667. * @param update the boolean update value actually passed to setParticles()
  72668. */
  72669. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72670. /**
  72671. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72672. * This will be passed three parameters.
  72673. * This does nothing and may be overwritten by the user.
  72674. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72675. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72676. * @param update the boolean update value actually passed to setParticles()
  72677. */
  72678. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72679. }
  72680. }
  72681. declare module "babylonjs/Particles/cloudPoint" {
  72682. import { Nullable } from "babylonjs/types";
  72683. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  72684. import { Mesh } from "babylonjs/Meshes/mesh";
  72685. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  72686. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  72687. /**
  72688. * Represents one particle of a points cloud system.
  72689. */
  72690. export class CloudPoint {
  72691. /**
  72692. * particle global index
  72693. */
  72694. idx: number;
  72695. /**
  72696. * The color of the particle
  72697. */
  72698. color: Nullable<Color4>;
  72699. /**
  72700. * The world space position of the particle.
  72701. */
  72702. position: Vector3;
  72703. /**
  72704. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72705. */
  72706. rotation: Vector3;
  72707. /**
  72708. * The world space rotation quaternion of the particle.
  72709. */
  72710. rotationQuaternion: Nullable<Quaternion>;
  72711. /**
  72712. * The uv of the particle.
  72713. */
  72714. uv: Nullable<Vector2>;
  72715. /**
  72716. * The current speed of the particle.
  72717. */
  72718. velocity: Vector3;
  72719. /**
  72720. * The pivot point in the particle local space.
  72721. */
  72722. pivot: Vector3;
  72723. /**
  72724. * Must the particle be translated from its pivot point in its local space ?
  72725. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72726. * Default : false
  72727. */
  72728. translateFromPivot: boolean;
  72729. /**
  72730. * Index of this particle in the global "positions" array (Internal use)
  72731. * @hidden
  72732. */
  72733. _pos: number;
  72734. /**
  72735. * @hidden Index of this particle in the global "indices" array (Internal use)
  72736. */
  72737. _ind: number;
  72738. /**
  72739. * Group this particle belongs to
  72740. */
  72741. _group: PointsGroup;
  72742. /**
  72743. * Group id of this particle
  72744. */
  72745. groupId: number;
  72746. /**
  72747. * Index of the particle in its group id (Internal use)
  72748. */
  72749. idxInGroup: number;
  72750. /**
  72751. * @hidden Particle BoundingInfo object (Internal use)
  72752. */
  72753. _boundingInfo: BoundingInfo;
  72754. /**
  72755. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72756. */
  72757. _pcs: PointsCloudSystem;
  72758. /**
  72759. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72760. */
  72761. _stillInvisible: boolean;
  72762. /**
  72763. * @hidden Last computed particle rotation matrix
  72764. */
  72765. _rotationMatrix: number[];
  72766. /**
  72767. * Parent particle Id, if any.
  72768. * Default null.
  72769. */
  72770. parentId: Nullable<number>;
  72771. /**
  72772. * @hidden Internal global position in the PCS.
  72773. */
  72774. _globalPosition: Vector3;
  72775. /**
  72776. * Creates a Point Cloud object.
  72777. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72778. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72779. * @param group (PointsGroup) is the group the particle belongs to
  72780. * @param groupId (integer) is the group identifier in the PCS.
  72781. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72782. * @param pcs defines the PCS it is associated to
  72783. */
  72784. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72785. /**
  72786. * get point size
  72787. */
  72788. get size(): Vector3;
  72789. /**
  72790. * Set point size
  72791. */
  72792. set size(scale: Vector3);
  72793. /**
  72794. * Legacy support, changed quaternion to rotationQuaternion
  72795. */
  72796. get quaternion(): Nullable<Quaternion>;
  72797. /**
  72798. * Legacy support, changed quaternion to rotationQuaternion
  72799. */
  72800. set quaternion(q: Nullable<Quaternion>);
  72801. /**
  72802. * Returns a boolean. True if the particle intersects a mesh, else false
  72803. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72804. * @param target is the object (point or mesh) what the intersection is computed against
  72805. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72806. * @returns true if it intersects
  72807. */
  72808. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72809. /**
  72810. * get the rotation matrix of the particle
  72811. * @hidden
  72812. */
  72813. getRotationMatrix(m: Matrix): void;
  72814. }
  72815. /**
  72816. * Represents a group of points in a points cloud system
  72817. * * PCS internal tool, don't use it manually.
  72818. */
  72819. export class PointsGroup {
  72820. /**
  72821. * The group id
  72822. * @hidden
  72823. */
  72824. groupID: number;
  72825. /**
  72826. * image data for group (internal use)
  72827. * @hidden
  72828. */
  72829. _groupImageData: Nullable<ArrayBufferView>;
  72830. /**
  72831. * Image Width (internal use)
  72832. * @hidden
  72833. */
  72834. _groupImgWidth: number;
  72835. /**
  72836. * Image Height (internal use)
  72837. * @hidden
  72838. */
  72839. _groupImgHeight: number;
  72840. /**
  72841. * Custom position function (internal use)
  72842. * @hidden
  72843. */
  72844. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72845. /**
  72846. * density per facet for surface points
  72847. * @hidden
  72848. */
  72849. _groupDensity: number[];
  72850. /**
  72851. * Only when points are colored by texture carries pointer to texture list array
  72852. * @hidden
  72853. */
  72854. _textureNb: number;
  72855. /**
  72856. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72857. * PCS internal tool, don't use it manually.
  72858. * @hidden
  72859. */
  72860. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72861. }
  72862. }
  72863. declare module "babylonjs/Particles/index" {
  72864. export * from "babylonjs/Particles/baseParticleSystem";
  72865. export * from "babylonjs/Particles/EmitterTypes/index";
  72866. export * from "babylonjs/Particles/gpuParticleSystem";
  72867. export * from "babylonjs/Particles/IParticleSystem";
  72868. export * from "babylonjs/Particles/particle";
  72869. export * from "babylonjs/Particles/particleHelper";
  72870. export * from "babylonjs/Particles/particleSystem";
  72871. import "babylonjs/Particles/particleSystemComponent";
  72872. export * from "babylonjs/Particles/particleSystemComponent";
  72873. export * from "babylonjs/Particles/particleSystemSet";
  72874. export * from "babylonjs/Particles/solidParticle";
  72875. export * from "babylonjs/Particles/solidParticleSystem";
  72876. export * from "babylonjs/Particles/cloudPoint";
  72877. export * from "babylonjs/Particles/pointsCloudSystem";
  72878. export * from "babylonjs/Particles/subEmitter";
  72879. }
  72880. declare module "babylonjs/Physics/physicsEngineComponent" {
  72881. import { Nullable } from "babylonjs/types";
  72882. import { Observable, Observer } from "babylonjs/Misc/observable";
  72883. import { Vector3 } from "babylonjs/Maths/math.vector";
  72884. import { Mesh } from "babylonjs/Meshes/mesh";
  72885. import { ISceneComponent } from "babylonjs/sceneComponent";
  72886. import { Scene } from "babylonjs/scene";
  72887. import { Node } from "babylonjs/node";
  72888. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72889. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72890. module "babylonjs/scene" {
  72891. interface Scene {
  72892. /** @hidden (Backing field) */
  72893. _physicsEngine: Nullable<IPhysicsEngine>;
  72894. /** @hidden */
  72895. _physicsTimeAccumulator: number;
  72896. /**
  72897. * Gets the current physics engine
  72898. * @returns a IPhysicsEngine or null if none attached
  72899. */
  72900. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72901. /**
  72902. * Enables physics to the current scene
  72903. * @param gravity defines the scene's gravity for the physics engine
  72904. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72905. * @return a boolean indicating if the physics engine was initialized
  72906. */
  72907. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72908. /**
  72909. * Disables and disposes the physics engine associated with the scene
  72910. */
  72911. disablePhysicsEngine(): void;
  72912. /**
  72913. * Gets a boolean indicating if there is an active physics engine
  72914. * @returns a boolean indicating if there is an active physics engine
  72915. */
  72916. isPhysicsEnabled(): boolean;
  72917. /**
  72918. * Deletes a physics compound impostor
  72919. * @param compound defines the compound to delete
  72920. */
  72921. deleteCompoundImpostor(compound: any): void;
  72922. /**
  72923. * An event triggered when physic simulation is about to be run
  72924. */
  72925. onBeforePhysicsObservable: Observable<Scene>;
  72926. /**
  72927. * An event triggered when physic simulation has been done
  72928. */
  72929. onAfterPhysicsObservable: Observable<Scene>;
  72930. }
  72931. }
  72932. module "babylonjs/Meshes/abstractMesh" {
  72933. interface AbstractMesh {
  72934. /** @hidden */
  72935. _physicsImpostor: Nullable<PhysicsImpostor>;
  72936. /**
  72937. * Gets or sets impostor used for physic simulation
  72938. * @see https://doc.babylonjs.com/features/physics_engine
  72939. */
  72940. physicsImpostor: Nullable<PhysicsImpostor>;
  72941. /**
  72942. * Gets the current physics impostor
  72943. * @see https://doc.babylonjs.com/features/physics_engine
  72944. * @returns a physics impostor or null
  72945. */
  72946. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72947. /** Apply a physic impulse to the mesh
  72948. * @param force defines the force to apply
  72949. * @param contactPoint defines where to apply the force
  72950. * @returns the current mesh
  72951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72952. */
  72953. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72954. /**
  72955. * Creates a physic joint between two meshes
  72956. * @param otherMesh defines the other mesh to use
  72957. * @param pivot1 defines the pivot to use on this mesh
  72958. * @param pivot2 defines the pivot to use on the other mesh
  72959. * @param options defines additional options (can be plugin dependent)
  72960. * @returns the current mesh
  72961. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72962. */
  72963. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72964. /** @hidden */
  72965. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72966. }
  72967. }
  72968. /**
  72969. * Defines the physics engine scene component responsible to manage a physics engine
  72970. */
  72971. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72972. /**
  72973. * The component name helpful to identify the component in the list of scene components.
  72974. */
  72975. readonly name: string;
  72976. /**
  72977. * The scene the component belongs to.
  72978. */
  72979. scene: Scene;
  72980. /**
  72981. * Creates a new instance of the component for the given scene
  72982. * @param scene Defines the scene to register the component in
  72983. */
  72984. constructor(scene: Scene);
  72985. /**
  72986. * Registers the component in a given scene
  72987. */
  72988. register(): void;
  72989. /**
  72990. * Rebuilds the elements related to this component in case of
  72991. * context lost for instance.
  72992. */
  72993. rebuild(): void;
  72994. /**
  72995. * Disposes the component and the associated ressources
  72996. */
  72997. dispose(): void;
  72998. }
  72999. }
  73000. declare module "babylonjs/Physics/physicsHelper" {
  73001. import { Nullable } from "babylonjs/types";
  73002. import { Vector3 } from "babylonjs/Maths/math.vector";
  73003. import { Mesh } from "babylonjs/Meshes/mesh";
  73004. import { Scene } from "babylonjs/scene";
  73005. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73006. /**
  73007. * A helper for physics simulations
  73008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73009. */
  73010. export class PhysicsHelper {
  73011. private _scene;
  73012. private _physicsEngine;
  73013. /**
  73014. * Initializes the Physics helper
  73015. * @param scene Babylon.js scene
  73016. */
  73017. constructor(scene: Scene);
  73018. /**
  73019. * Applies a radial explosion impulse
  73020. * @param origin the origin of the explosion
  73021. * @param radiusOrEventOptions the radius or the options of radial explosion
  73022. * @param strength the explosion strength
  73023. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73024. * @returns A physics radial explosion event, or null
  73025. */
  73026. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73027. /**
  73028. * Applies a radial explosion force
  73029. * @param origin the origin of the explosion
  73030. * @param radiusOrEventOptions the radius or the options of radial explosion
  73031. * @param strength the explosion strength
  73032. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73033. * @returns A physics radial explosion event, or null
  73034. */
  73035. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73036. /**
  73037. * Creates a gravitational field
  73038. * @param origin the origin of the explosion
  73039. * @param radiusOrEventOptions the radius or the options of radial explosion
  73040. * @param strength the explosion strength
  73041. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73042. * @returns A physics gravitational field event, or null
  73043. */
  73044. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73045. /**
  73046. * Creates a physics updraft event
  73047. * @param origin the origin of the updraft
  73048. * @param radiusOrEventOptions the radius or the options of the updraft
  73049. * @param strength the strength of the updraft
  73050. * @param height the height of the updraft
  73051. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73052. * @returns A physics updraft event, or null
  73053. */
  73054. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73055. /**
  73056. * Creates a physics vortex event
  73057. * @param origin the of the vortex
  73058. * @param radiusOrEventOptions the radius or the options of the vortex
  73059. * @param strength the strength of the vortex
  73060. * @param height the height of the vortex
  73061. * @returns a Physics vortex event, or null
  73062. * A physics vortex event or null
  73063. */
  73064. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73065. }
  73066. /**
  73067. * Represents a physics radial explosion event
  73068. */
  73069. class PhysicsRadialExplosionEvent {
  73070. private _scene;
  73071. private _options;
  73072. private _sphere;
  73073. private _dataFetched;
  73074. /**
  73075. * Initializes a radial explosioin event
  73076. * @param _scene BabylonJS scene
  73077. * @param _options The options for the vortex event
  73078. */
  73079. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73080. /**
  73081. * Returns the data related to the radial explosion event (sphere).
  73082. * @returns The radial explosion event data
  73083. */
  73084. getData(): PhysicsRadialExplosionEventData;
  73085. /**
  73086. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73087. * @param impostor A physics imposter
  73088. * @param origin the origin of the explosion
  73089. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73090. */
  73091. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73092. /**
  73093. * Triggers affecterd impostors callbacks
  73094. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73095. */
  73096. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73097. /**
  73098. * Disposes the sphere.
  73099. * @param force Specifies if the sphere should be disposed by force
  73100. */
  73101. dispose(force?: boolean): void;
  73102. /*** Helpers ***/
  73103. private _prepareSphere;
  73104. private _intersectsWithSphere;
  73105. }
  73106. /**
  73107. * Represents a gravitational field event
  73108. */
  73109. class PhysicsGravitationalFieldEvent {
  73110. private _physicsHelper;
  73111. private _scene;
  73112. private _origin;
  73113. private _options;
  73114. private _tickCallback;
  73115. private _sphere;
  73116. private _dataFetched;
  73117. /**
  73118. * Initializes the physics gravitational field event
  73119. * @param _physicsHelper A physics helper
  73120. * @param _scene BabylonJS scene
  73121. * @param _origin The origin position of the gravitational field event
  73122. * @param _options The options for the vortex event
  73123. */
  73124. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73125. /**
  73126. * Returns the data related to the gravitational field event (sphere).
  73127. * @returns A gravitational field event
  73128. */
  73129. getData(): PhysicsGravitationalFieldEventData;
  73130. /**
  73131. * Enables the gravitational field.
  73132. */
  73133. enable(): void;
  73134. /**
  73135. * Disables the gravitational field.
  73136. */
  73137. disable(): void;
  73138. /**
  73139. * Disposes the sphere.
  73140. * @param force The force to dispose from the gravitational field event
  73141. */
  73142. dispose(force?: boolean): void;
  73143. private _tick;
  73144. }
  73145. /**
  73146. * Represents a physics updraft event
  73147. */
  73148. class PhysicsUpdraftEvent {
  73149. private _scene;
  73150. private _origin;
  73151. private _options;
  73152. private _physicsEngine;
  73153. private _originTop;
  73154. private _originDirection;
  73155. private _tickCallback;
  73156. private _cylinder;
  73157. private _cylinderPosition;
  73158. private _dataFetched;
  73159. /**
  73160. * Initializes the physics updraft event
  73161. * @param _scene BabylonJS scene
  73162. * @param _origin The origin position of the updraft
  73163. * @param _options The options for the updraft event
  73164. */
  73165. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73166. /**
  73167. * Returns the data related to the updraft event (cylinder).
  73168. * @returns A physics updraft event
  73169. */
  73170. getData(): PhysicsUpdraftEventData;
  73171. /**
  73172. * Enables the updraft.
  73173. */
  73174. enable(): void;
  73175. /**
  73176. * Disables the updraft.
  73177. */
  73178. disable(): void;
  73179. /**
  73180. * Disposes the cylinder.
  73181. * @param force Specifies if the updraft should be disposed by force
  73182. */
  73183. dispose(force?: boolean): void;
  73184. private getImpostorHitData;
  73185. private _tick;
  73186. /*** Helpers ***/
  73187. private _prepareCylinder;
  73188. private _intersectsWithCylinder;
  73189. }
  73190. /**
  73191. * Represents a physics vortex event
  73192. */
  73193. class PhysicsVortexEvent {
  73194. private _scene;
  73195. private _origin;
  73196. private _options;
  73197. private _physicsEngine;
  73198. private _originTop;
  73199. private _tickCallback;
  73200. private _cylinder;
  73201. private _cylinderPosition;
  73202. private _dataFetched;
  73203. /**
  73204. * Initializes the physics vortex event
  73205. * @param _scene The BabylonJS scene
  73206. * @param _origin The origin position of the vortex
  73207. * @param _options The options for the vortex event
  73208. */
  73209. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73210. /**
  73211. * Returns the data related to the vortex event (cylinder).
  73212. * @returns The physics vortex event data
  73213. */
  73214. getData(): PhysicsVortexEventData;
  73215. /**
  73216. * Enables the vortex.
  73217. */
  73218. enable(): void;
  73219. /**
  73220. * Disables the cortex.
  73221. */
  73222. disable(): void;
  73223. /**
  73224. * Disposes the sphere.
  73225. * @param force
  73226. */
  73227. dispose(force?: boolean): void;
  73228. private getImpostorHitData;
  73229. private _tick;
  73230. /*** Helpers ***/
  73231. private _prepareCylinder;
  73232. private _intersectsWithCylinder;
  73233. }
  73234. /**
  73235. * Options fot the radial explosion event
  73236. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73237. */
  73238. export class PhysicsRadialExplosionEventOptions {
  73239. /**
  73240. * The radius of the sphere for the radial explosion.
  73241. */
  73242. radius: number;
  73243. /**
  73244. * The strenth of the explosion.
  73245. */
  73246. strength: number;
  73247. /**
  73248. * The strenght of the force in correspondence to the distance of the affected object
  73249. */
  73250. falloff: PhysicsRadialImpulseFalloff;
  73251. /**
  73252. * Sphere options for the radial explosion.
  73253. */
  73254. sphere: {
  73255. segments: number;
  73256. diameter: number;
  73257. };
  73258. /**
  73259. * Sphere options for the radial explosion.
  73260. */
  73261. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73262. }
  73263. /**
  73264. * Options fot the updraft event
  73265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73266. */
  73267. export class PhysicsUpdraftEventOptions {
  73268. /**
  73269. * The radius of the cylinder for the vortex
  73270. */
  73271. radius: number;
  73272. /**
  73273. * The strenth of the updraft.
  73274. */
  73275. strength: number;
  73276. /**
  73277. * The height of the cylinder for the updraft.
  73278. */
  73279. height: number;
  73280. /**
  73281. * The mode for the the updraft.
  73282. */
  73283. updraftMode: PhysicsUpdraftMode;
  73284. }
  73285. /**
  73286. * Options fot the vortex event
  73287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73288. */
  73289. export class PhysicsVortexEventOptions {
  73290. /**
  73291. * The radius of the cylinder for the vortex
  73292. */
  73293. radius: number;
  73294. /**
  73295. * The strenth of the vortex.
  73296. */
  73297. strength: number;
  73298. /**
  73299. * The height of the cylinder for the vortex.
  73300. */
  73301. height: number;
  73302. /**
  73303. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73304. */
  73305. centripetalForceThreshold: number;
  73306. /**
  73307. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73308. */
  73309. centripetalForceMultiplier: number;
  73310. /**
  73311. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73312. */
  73313. centrifugalForceMultiplier: number;
  73314. /**
  73315. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73316. */
  73317. updraftForceMultiplier: number;
  73318. }
  73319. /**
  73320. * The strenght of the force in correspondence to the distance of the affected object
  73321. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73322. */
  73323. export enum PhysicsRadialImpulseFalloff {
  73324. /** Defines that impulse is constant in strength across it's whole radius */
  73325. Constant = 0,
  73326. /** Defines that impulse gets weaker if it's further from the origin */
  73327. Linear = 1
  73328. }
  73329. /**
  73330. * The strength of the force in correspondence to the distance of the affected object
  73331. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73332. */
  73333. export enum PhysicsUpdraftMode {
  73334. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73335. Center = 0,
  73336. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73337. Perpendicular = 1
  73338. }
  73339. /**
  73340. * Interface for a physics hit data
  73341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73342. */
  73343. export interface PhysicsHitData {
  73344. /**
  73345. * The force applied at the contact point
  73346. */
  73347. force: Vector3;
  73348. /**
  73349. * The contact point
  73350. */
  73351. contactPoint: Vector3;
  73352. /**
  73353. * The distance from the origin to the contact point
  73354. */
  73355. distanceFromOrigin: number;
  73356. }
  73357. /**
  73358. * Interface for radial explosion event data
  73359. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73360. */
  73361. export interface PhysicsRadialExplosionEventData {
  73362. /**
  73363. * A sphere used for the radial explosion event
  73364. */
  73365. sphere: Mesh;
  73366. }
  73367. /**
  73368. * Interface for gravitational field event data
  73369. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73370. */
  73371. export interface PhysicsGravitationalFieldEventData {
  73372. /**
  73373. * A sphere mesh used for the gravitational field event
  73374. */
  73375. sphere: Mesh;
  73376. }
  73377. /**
  73378. * Interface for updraft event data
  73379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73380. */
  73381. export interface PhysicsUpdraftEventData {
  73382. /**
  73383. * A cylinder used for the updraft event
  73384. */
  73385. cylinder: Mesh;
  73386. }
  73387. /**
  73388. * Interface for vortex event data
  73389. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73390. */
  73391. export interface PhysicsVortexEventData {
  73392. /**
  73393. * A cylinder used for the vortex event
  73394. */
  73395. cylinder: Mesh;
  73396. }
  73397. /**
  73398. * Interface for an affected physics impostor
  73399. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73400. */
  73401. export interface PhysicsAffectedImpostorWithData {
  73402. /**
  73403. * The impostor affected by the effect
  73404. */
  73405. impostor: PhysicsImpostor;
  73406. /**
  73407. * The data about the hit/horce from the explosion
  73408. */
  73409. hitData: PhysicsHitData;
  73410. }
  73411. }
  73412. declare module "babylonjs/Physics/Plugins/index" {
  73413. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  73414. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  73415. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  73416. }
  73417. declare module "babylonjs/Physics/index" {
  73418. export * from "babylonjs/Physics/IPhysicsEngine";
  73419. export * from "babylonjs/Physics/physicsEngine";
  73420. export * from "babylonjs/Physics/physicsEngineComponent";
  73421. export * from "babylonjs/Physics/physicsHelper";
  73422. export * from "babylonjs/Physics/physicsImpostor";
  73423. export * from "babylonjs/Physics/physicsJoint";
  73424. export * from "babylonjs/Physics/Plugins/index";
  73425. }
  73426. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  73427. /** @hidden */
  73428. export var blackAndWhitePixelShader: {
  73429. name: string;
  73430. shader: string;
  73431. };
  73432. }
  73433. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  73434. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73435. import { Camera } from "babylonjs/Cameras/camera";
  73436. import { Engine } from "babylonjs/Engines/engine";
  73437. import "babylonjs/Shaders/blackAndWhite.fragment";
  73438. import { Nullable } from "babylonjs/types";
  73439. import { Scene } from "babylonjs/scene";
  73440. /**
  73441. * Post process used to render in black and white
  73442. */
  73443. export class BlackAndWhitePostProcess extends PostProcess {
  73444. /**
  73445. * Linear about to convert he result to black and white (default: 1)
  73446. */
  73447. degree: number;
  73448. /**
  73449. * Gets a string identifying the name of the class
  73450. * @returns "BlackAndWhitePostProcess" string
  73451. */
  73452. getClassName(): string;
  73453. /**
  73454. * Creates a black and white post process
  73455. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73456. * @param name The name of the effect.
  73457. * @param options The required width/height ratio to downsize to before computing the render pass.
  73458. * @param camera The camera to apply the render pass to.
  73459. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73460. * @param engine The engine which the post process will be applied. (default: current engine)
  73461. * @param reusable If the post process can be reused on the same frame. (default: false)
  73462. */
  73463. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73464. /** @hidden */
  73465. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73466. }
  73467. }
  73468. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  73469. import { Nullable } from "babylonjs/types";
  73470. import { Camera } from "babylonjs/Cameras/camera";
  73471. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73472. import { Engine } from "babylonjs/Engines/engine";
  73473. /**
  73474. * This represents a set of one or more post processes in Babylon.
  73475. * A post process can be used to apply a shader to a texture after it is rendered.
  73476. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73477. */
  73478. export class PostProcessRenderEffect {
  73479. private _postProcesses;
  73480. private _getPostProcesses;
  73481. private _singleInstance;
  73482. private _cameras;
  73483. private _indicesForCamera;
  73484. /**
  73485. * Name of the effect
  73486. * @hidden
  73487. */
  73488. _name: string;
  73489. /**
  73490. * Instantiates a post process render effect.
  73491. * A post process can be used to apply a shader to a texture after it is rendered.
  73492. * @param engine The engine the effect is tied to
  73493. * @param name The name of the effect
  73494. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73495. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73496. */
  73497. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73498. /**
  73499. * Checks if all the post processes in the effect are supported.
  73500. */
  73501. get isSupported(): boolean;
  73502. /**
  73503. * Updates the current state of the effect
  73504. * @hidden
  73505. */
  73506. _update(): void;
  73507. /**
  73508. * Attaches the effect on cameras
  73509. * @param cameras The camera to attach to.
  73510. * @hidden
  73511. */
  73512. _attachCameras(cameras: Camera): void;
  73513. /**
  73514. * Attaches the effect on cameras
  73515. * @param cameras The camera to attach to.
  73516. * @hidden
  73517. */
  73518. _attachCameras(cameras: Camera[]): void;
  73519. /**
  73520. * Detaches the effect on cameras
  73521. * @param cameras The camera to detatch from.
  73522. * @hidden
  73523. */
  73524. _detachCameras(cameras: Camera): void;
  73525. /**
  73526. * Detatches the effect on cameras
  73527. * @param cameras The camera to detatch from.
  73528. * @hidden
  73529. */
  73530. _detachCameras(cameras: Camera[]): void;
  73531. /**
  73532. * Enables the effect on given cameras
  73533. * @param cameras The camera to enable.
  73534. * @hidden
  73535. */
  73536. _enable(cameras: Camera): void;
  73537. /**
  73538. * Enables the effect on given cameras
  73539. * @param cameras The camera to enable.
  73540. * @hidden
  73541. */
  73542. _enable(cameras: Nullable<Camera[]>): void;
  73543. /**
  73544. * Disables the effect on the given cameras
  73545. * @param cameras The camera to disable.
  73546. * @hidden
  73547. */
  73548. _disable(cameras: Camera): void;
  73549. /**
  73550. * Disables the effect on the given cameras
  73551. * @param cameras The camera to disable.
  73552. * @hidden
  73553. */
  73554. _disable(cameras: Nullable<Camera[]>): void;
  73555. /**
  73556. * Gets a list of the post processes contained in the effect.
  73557. * @param camera The camera to get the post processes on.
  73558. * @returns The list of the post processes in the effect.
  73559. */
  73560. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73561. }
  73562. }
  73563. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  73564. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73565. /** @hidden */
  73566. export var extractHighlightsPixelShader: {
  73567. name: string;
  73568. shader: string;
  73569. };
  73570. }
  73571. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  73572. import { Nullable } from "babylonjs/types";
  73573. import { Camera } from "babylonjs/Cameras/camera";
  73574. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73575. import { Engine } from "babylonjs/Engines/engine";
  73576. import "babylonjs/Shaders/extractHighlights.fragment";
  73577. /**
  73578. * 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.
  73579. */
  73580. export class ExtractHighlightsPostProcess extends PostProcess {
  73581. /**
  73582. * The luminance threshold, pixels below this value will be set to black.
  73583. */
  73584. threshold: number;
  73585. /** @hidden */
  73586. _exposure: number;
  73587. /**
  73588. * Post process which has the input texture to be used when performing highlight extraction
  73589. * @hidden
  73590. */
  73591. _inputPostProcess: Nullable<PostProcess>;
  73592. /**
  73593. * Gets a string identifying the name of the class
  73594. * @returns "ExtractHighlightsPostProcess" string
  73595. */
  73596. getClassName(): string;
  73597. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73598. }
  73599. }
  73600. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  73601. /** @hidden */
  73602. export var bloomMergePixelShader: {
  73603. name: string;
  73604. shader: string;
  73605. };
  73606. }
  73607. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  73608. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73609. import { Nullable } from "babylonjs/types";
  73610. import { Engine } from "babylonjs/Engines/engine";
  73611. import { Camera } from "babylonjs/Cameras/camera";
  73612. import "babylonjs/Shaders/bloomMerge.fragment";
  73613. /**
  73614. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73615. */
  73616. export class BloomMergePostProcess extends PostProcess {
  73617. /** Weight of the bloom to be added to the original input. */
  73618. weight: number;
  73619. /**
  73620. * Gets a string identifying the name of the class
  73621. * @returns "BloomMergePostProcess" string
  73622. */
  73623. getClassName(): string;
  73624. /**
  73625. * Creates a new instance of @see BloomMergePostProcess
  73626. * @param name The name of the effect.
  73627. * @param originalFromInput Post process which's input will be used for the merge.
  73628. * @param blurred Blurred highlights post process which's output will be used.
  73629. * @param weight Weight of the bloom to be added to the original input.
  73630. * @param options The required width/height ratio to downsize to before computing the render pass.
  73631. * @param camera The camera to apply the render pass to.
  73632. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73633. * @param engine The engine which the post process will be applied. (default: current engine)
  73634. * @param reusable If the post process can be reused on the same frame. (default: false)
  73635. * @param textureType Type of textures used when performing the post process. (default: 0)
  73636. * @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)
  73637. */
  73638. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73639. /** Weight of the bloom to be added to the original input. */
  73640. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73641. }
  73642. }
  73643. declare module "babylonjs/PostProcesses/bloomEffect" {
  73644. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73645. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73646. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  73647. import { Camera } from "babylonjs/Cameras/camera";
  73648. import { Scene } from "babylonjs/scene";
  73649. /**
  73650. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73651. */
  73652. export class BloomEffect extends PostProcessRenderEffect {
  73653. private bloomScale;
  73654. /**
  73655. * @hidden Internal
  73656. */
  73657. _effects: Array<PostProcess>;
  73658. /**
  73659. * @hidden Internal
  73660. */
  73661. _downscale: ExtractHighlightsPostProcess;
  73662. private _blurX;
  73663. private _blurY;
  73664. private _merge;
  73665. /**
  73666. * The luminance threshold to find bright areas of the image to bloom.
  73667. */
  73668. get threshold(): number;
  73669. set threshold(value: number);
  73670. /**
  73671. * The strength of the bloom.
  73672. */
  73673. get weight(): number;
  73674. set weight(value: number);
  73675. /**
  73676. * Specifies the size of the bloom blur kernel, relative to the final output size
  73677. */
  73678. get kernel(): number;
  73679. set kernel(value: number);
  73680. /**
  73681. * Creates a new instance of @see BloomEffect
  73682. * @param scene The scene the effect belongs to.
  73683. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73684. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73685. * @param bloomWeight The the strength of bloom.
  73686. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73687. * @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)
  73688. */
  73689. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73690. /**
  73691. * Disposes each of the internal effects for a given camera.
  73692. * @param camera The camera to dispose the effect on.
  73693. */
  73694. disposeEffects(camera: Camera): void;
  73695. /**
  73696. * @hidden Internal
  73697. */
  73698. _updateEffects(): void;
  73699. /**
  73700. * Internal
  73701. * @returns if all the contained post processes are ready.
  73702. * @hidden
  73703. */
  73704. _isReady(): boolean;
  73705. }
  73706. }
  73707. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  73708. /** @hidden */
  73709. export var chromaticAberrationPixelShader: {
  73710. name: string;
  73711. shader: string;
  73712. };
  73713. }
  73714. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  73715. import { Vector2 } from "babylonjs/Maths/math.vector";
  73716. import { Nullable } from "babylonjs/types";
  73717. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73718. import { Camera } from "babylonjs/Cameras/camera";
  73719. import { Engine } from "babylonjs/Engines/engine";
  73720. import "babylonjs/Shaders/chromaticAberration.fragment";
  73721. import { Scene } from "babylonjs/scene";
  73722. /**
  73723. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73724. */
  73725. export class ChromaticAberrationPostProcess extends PostProcess {
  73726. /**
  73727. * The amount of seperation of rgb channels (default: 30)
  73728. */
  73729. aberrationAmount: number;
  73730. /**
  73731. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73732. */
  73733. radialIntensity: number;
  73734. /**
  73735. * 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))
  73736. */
  73737. direction: Vector2;
  73738. /**
  73739. * 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))
  73740. */
  73741. centerPosition: Vector2;
  73742. /** The width of the screen to apply the effect on */
  73743. screenWidth: number;
  73744. /** The height of the screen to apply the effect on */
  73745. screenHeight: number;
  73746. /**
  73747. * Gets a string identifying the name of the class
  73748. * @returns "ChromaticAberrationPostProcess" string
  73749. */
  73750. getClassName(): string;
  73751. /**
  73752. * Creates a new instance ChromaticAberrationPostProcess
  73753. * @param name The name of the effect.
  73754. * @param screenWidth The width of the screen to apply the effect on.
  73755. * @param screenHeight The height of the screen to apply the effect on.
  73756. * @param options The required width/height ratio to downsize to before computing the render pass.
  73757. * @param camera The camera to apply the render pass to.
  73758. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73759. * @param engine The engine which the post process will be applied. (default: current engine)
  73760. * @param reusable If the post process can be reused on the same frame. (default: false)
  73761. * @param textureType Type of textures used when performing the post process. (default: 0)
  73762. * @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)
  73763. */
  73764. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73765. /** @hidden */
  73766. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73767. }
  73768. }
  73769. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73770. /** @hidden */
  73771. export var circleOfConfusionPixelShader: {
  73772. name: string;
  73773. shader: string;
  73774. };
  73775. }
  73776. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73777. import { Nullable } from "babylonjs/types";
  73778. import { Engine } from "babylonjs/Engines/engine";
  73779. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73780. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73781. import { Camera } from "babylonjs/Cameras/camera";
  73782. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73783. /**
  73784. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73785. */
  73786. export class CircleOfConfusionPostProcess extends PostProcess {
  73787. /**
  73788. * 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.
  73789. */
  73790. lensSize: number;
  73791. /**
  73792. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73793. */
  73794. fStop: number;
  73795. /**
  73796. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73797. */
  73798. focusDistance: number;
  73799. /**
  73800. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73801. */
  73802. focalLength: number;
  73803. /**
  73804. * Gets a string identifying the name of the class
  73805. * @returns "CircleOfConfusionPostProcess" string
  73806. */
  73807. getClassName(): string;
  73808. private _depthTexture;
  73809. /**
  73810. * Creates a new instance CircleOfConfusionPostProcess
  73811. * @param name The name of the effect.
  73812. * @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.
  73813. * @param options The required width/height ratio to downsize to before computing the render pass.
  73814. * @param camera The camera to apply the render pass to.
  73815. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73816. * @param engine The engine which the post process will be applied. (default: current engine)
  73817. * @param reusable If the post process can be reused on the same frame. (default: false)
  73818. * @param textureType Type of textures used when performing the post process. (default: 0)
  73819. * @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)
  73820. */
  73821. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73822. /**
  73823. * 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.
  73824. */
  73825. set depthTexture(value: RenderTargetTexture);
  73826. }
  73827. }
  73828. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73829. /** @hidden */
  73830. export var colorCorrectionPixelShader: {
  73831. name: string;
  73832. shader: string;
  73833. };
  73834. }
  73835. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73836. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73837. import { Engine } from "babylonjs/Engines/engine";
  73838. import { Camera } from "babylonjs/Cameras/camera";
  73839. import "babylonjs/Shaders/colorCorrection.fragment";
  73840. import { Nullable } from "babylonjs/types";
  73841. import { Scene } from "babylonjs/scene";
  73842. /**
  73843. *
  73844. * This post-process allows the modification of rendered colors by using
  73845. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73846. *
  73847. * The object needs to be provided an url to a texture containing the color
  73848. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73849. * Use an image editing software to tweak the LUT to match your needs.
  73850. *
  73851. * For an example of a color LUT, see here:
  73852. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73853. * For explanations on color grading, see here:
  73854. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73855. *
  73856. */
  73857. export class ColorCorrectionPostProcess extends PostProcess {
  73858. private _colorTableTexture;
  73859. /**
  73860. * Gets the color table url used to create the LUT texture
  73861. */
  73862. colorTableUrl: string;
  73863. /**
  73864. * Gets a string identifying the name of the class
  73865. * @returns "ColorCorrectionPostProcess" string
  73866. */
  73867. getClassName(): string;
  73868. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73869. /** @hidden */
  73870. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73871. }
  73872. }
  73873. declare module "babylonjs/Shaders/convolution.fragment" {
  73874. /** @hidden */
  73875. export var convolutionPixelShader: {
  73876. name: string;
  73877. shader: string;
  73878. };
  73879. }
  73880. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73881. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73882. import { Nullable } from "babylonjs/types";
  73883. import { Camera } from "babylonjs/Cameras/camera";
  73884. import { Engine } from "babylonjs/Engines/engine";
  73885. import "babylonjs/Shaders/convolution.fragment";
  73886. import { Scene } from "babylonjs/scene";
  73887. /**
  73888. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73889. * input texture to perform effects such as edge detection or sharpening
  73890. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73891. */
  73892. export class ConvolutionPostProcess extends PostProcess {
  73893. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73894. kernel: number[];
  73895. /**
  73896. * Gets a string identifying the name of the class
  73897. * @returns "ConvolutionPostProcess" string
  73898. */
  73899. getClassName(): string;
  73900. /**
  73901. * Creates a new instance ConvolutionPostProcess
  73902. * @param name The name of the effect.
  73903. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73904. * @param options The required width/height ratio to downsize to before computing the render pass.
  73905. * @param camera The camera to apply the render pass to.
  73906. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73907. * @param engine The engine which the post process will be applied. (default: current engine)
  73908. * @param reusable If the post process can be reused on the same frame. (default: false)
  73909. * @param textureType Type of textures used when performing the post process. (default: 0)
  73910. */
  73911. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73912. /** @hidden */
  73913. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73914. /**
  73915. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73916. */
  73917. static EdgeDetect0Kernel: number[];
  73918. /**
  73919. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73920. */
  73921. static EdgeDetect1Kernel: number[];
  73922. /**
  73923. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73924. */
  73925. static EdgeDetect2Kernel: number[];
  73926. /**
  73927. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73928. */
  73929. static SharpenKernel: number[];
  73930. /**
  73931. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73932. */
  73933. static EmbossKernel: number[];
  73934. /**
  73935. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73936. */
  73937. static GaussianKernel: number[];
  73938. }
  73939. }
  73940. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73941. import { Nullable } from "babylonjs/types";
  73942. import { Vector2 } from "babylonjs/Maths/math.vector";
  73943. import { Camera } from "babylonjs/Cameras/camera";
  73944. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73945. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73946. import { Engine } from "babylonjs/Engines/engine";
  73947. import { Scene } from "babylonjs/scene";
  73948. /**
  73949. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73950. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73951. * based on samples that have a large difference in distance than the center pixel.
  73952. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73953. */
  73954. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73955. /**
  73956. * The direction the blur should be applied
  73957. */
  73958. direction: Vector2;
  73959. /**
  73960. * Gets a string identifying the name of the class
  73961. * @returns "DepthOfFieldBlurPostProcess" string
  73962. */
  73963. getClassName(): string;
  73964. /**
  73965. * Creates a new instance CircleOfConfusionPostProcess
  73966. * @param name The name of the effect.
  73967. * @param scene The scene the effect belongs to.
  73968. * @param direction The direction the blur should be applied.
  73969. * @param kernel The size of the kernel used to blur.
  73970. * @param options The required width/height ratio to downsize to before computing the render pass.
  73971. * @param camera The camera to apply the render pass to.
  73972. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73973. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73974. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73975. * @param engine The engine which the post process will be applied. (default: current engine)
  73976. * @param reusable If the post process can be reused on the same frame. (default: false)
  73977. * @param textureType Type of textures used when performing the post process. (default: 0)
  73978. * @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)
  73979. */
  73980. 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);
  73981. }
  73982. }
  73983. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73984. /** @hidden */
  73985. export var depthOfFieldMergePixelShader: {
  73986. name: string;
  73987. shader: string;
  73988. };
  73989. }
  73990. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73991. import { Nullable } from "babylonjs/types";
  73992. import { Camera } from "babylonjs/Cameras/camera";
  73993. import { Effect } from "babylonjs/Materials/effect";
  73994. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73995. import { Engine } from "babylonjs/Engines/engine";
  73996. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73997. /**
  73998. * Options to be set when merging outputs from the default pipeline.
  73999. */
  74000. export class DepthOfFieldMergePostProcessOptions {
  74001. /**
  74002. * The original image to merge on top of
  74003. */
  74004. originalFromInput: PostProcess;
  74005. /**
  74006. * Parameters to perform the merge of the depth of field effect
  74007. */
  74008. depthOfField?: {
  74009. circleOfConfusion: PostProcess;
  74010. blurSteps: Array<PostProcess>;
  74011. };
  74012. /**
  74013. * Parameters to perform the merge of bloom effect
  74014. */
  74015. bloom?: {
  74016. blurred: PostProcess;
  74017. weight: number;
  74018. };
  74019. }
  74020. /**
  74021. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74022. */
  74023. export class DepthOfFieldMergePostProcess extends PostProcess {
  74024. private blurSteps;
  74025. /**
  74026. * Gets a string identifying the name of the class
  74027. * @returns "DepthOfFieldMergePostProcess" string
  74028. */
  74029. getClassName(): string;
  74030. /**
  74031. * Creates a new instance of DepthOfFieldMergePostProcess
  74032. * @param name The name of the effect.
  74033. * @param originalFromInput Post process which's input will be used for the merge.
  74034. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74035. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74036. * @param options The required width/height ratio to downsize to before computing the render pass.
  74037. * @param camera The camera to apply the render pass to.
  74038. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74039. * @param engine The engine which the post process will be applied. (default: current engine)
  74040. * @param reusable If the post process can be reused on the same frame. (default: false)
  74041. * @param textureType Type of textures used when performing the post process. (default: 0)
  74042. * @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)
  74043. */
  74044. 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);
  74045. /**
  74046. * Updates the effect with the current post process compile time values and recompiles the shader.
  74047. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74048. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74049. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74050. * @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
  74051. * @param onCompiled Called when the shader has been compiled.
  74052. * @param onError Called if there is an error when compiling a shader.
  74053. */
  74054. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74055. }
  74056. }
  74057. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  74058. import { Nullable } from "babylonjs/types";
  74059. import { Camera } from "babylonjs/Cameras/camera";
  74060. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74061. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74062. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74063. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74064. import { Scene } from "babylonjs/scene";
  74065. /**
  74066. * Specifies the level of max blur that should be applied when using the depth of field effect
  74067. */
  74068. export enum DepthOfFieldEffectBlurLevel {
  74069. /**
  74070. * Subtle blur
  74071. */
  74072. Low = 0,
  74073. /**
  74074. * Medium blur
  74075. */
  74076. Medium = 1,
  74077. /**
  74078. * Large blur
  74079. */
  74080. High = 2
  74081. }
  74082. /**
  74083. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74084. */
  74085. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74086. private _circleOfConfusion;
  74087. /**
  74088. * @hidden Internal, blurs from high to low
  74089. */
  74090. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74091. private _depthOfFieldBlurY;
  74092. private _dofMerge;
  74093. /**
  74094. * @hidden Internal post processes in depth of field effect
  74095. */
  74096. _effects: Array<PostProcess>;
  74097. /**
  74098. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74099. */
  74100. set focalLength(value: number);
  74101. get focalLength(): number;
  74102. /**
  74103. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74104. */
  74105. set fStop(value: number);
  74106. get fStop(): number;
  74107. /**
  74108. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74109. */
  74110. set focusDistance(value: number);
  74111. get focusDistance(): number;
  74112. /**
  74113. * 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.
  74114. */
  74115. set lensSize(value: number);
  74116. get lensSize(): number;
  74117. /**
  74118. * Creates a new instance DepthOfFieldEffect
  74119. * @param scene The scene the effect belongs to.
  74120. * @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.
  74121. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74122. * @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)
  74123. */
  74124. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74125. /**
  74126. * Get the current class name of the current effet
  74127. * @returns "DepthOfFieldEffect"
  74128. */
  74129. getClassName(): string;
  74130. /**
  74131. * 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.
  74132. */
  74133. set depthTexture(value: RenderTargetTexture);
  74134. /**
  74135. * Disposes each of the internal effects for a given camera.
  74136. * @param camera The camera to dispose the effect on.
  74137. */
  74138. disposeEffects(camera: Camera): void;
  74139. /**
  74140. * @hidden Internal
  74141. */
  74142. _updateEffects(): void;
  74143. /**
  74144. * Internal
  74145. * @returns if all the contained post processes are ready.
  74146. * @hidden
  74147. */
  74148. _isReady(): boolean;
  74149. }
  74150. }
  74151. declare module "babylonjs/Shaders/displayPass.fragment" {
  74152. /** @hidden */
  74153. export var displayPassPixelShader: {
  74154. name: string;
  74155. shader: string;
  74156. };
  74157. }
  74158. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  74159. import { Nullable } from "babylonjs/types";
  74160. import { Camera } from "babylonjs/Cameras/camera";
  74161. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74162. import { Engine } from "babylonjs/Engines/engine";
  74163. import "babylonjs/Shaders/displayPass.fragment";
  74164. import { Scene } from "babylonjs/scene";
  74165. /**
  74166. * DisplayPassPostProcess which produces an output the same as it's input
  74167. */
  74168. export class DisplayPassPostProcess extends PostProcess {
  74169. /**
  74170. * Gets a string identifying the name of the class
  74171. * @returns "DisplayPassPostProcess" string
  74172. */
  74173. getClassName(): string;
  74174. /**
  74175. * Creates the DisplayPassPostProcess
  74176. * @param name The name of the effect.
  74177. * @param options The required width/height ratio to downsize to before computing the render pass.
  74178. * @param camera The camera to apply the render pass to.
  74179. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74180. * @param engine The engine which the post process will be applied. (default: current engine)
  74181. * @param reusable If the post process can be reused on the same frame. (default: false)
  74182. */
  74183. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74184. /** @hidden */
  74185. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74186. }
  74187. }
  74188. declare module "babylonjs/Shaders/filter.fragment" {
  74189. /** @hidden */
  74190. export var filterPixelShader: {
  74191. name: string;
  74192. shader: string;
  74193. };
  74194. }
  74195. declare module "babylonjs/PostProcesses/filterPostProcess" {
  74196. import { Nullable } from "babylonjs/types";
  74197. import { Matrix } from "babylonjs/Maths/math.vector";
  74198. import { Camera } from "babylonjs/Cameras/camera";
  74199. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74200. import { Engine } from "babylonjs/Engines/engine";
  74201. import "babylonjs/Shaders/filter.fragment";
  74202. import { Scene } from "babylonjs/scene";
  74203. /**
  74204. * Applies a kernel filter to the image
  74205. */
  74206. export class FilterPostProcess extends PostProcess {
  74207. /** The matrix to be applied to the image */
  74208. kernelMatrix: Matrix;
  74209. /**
  74210. * Gets a string identifying the name of the class
  74211. * @returns "FilterPostProcess" string
  74212. */
  74213. getClassName(): string;
  74214. /**
  74215. *
  74216. * @param name The name of the effect.
  74217. * @param kernelMatrix The matrix to be applied to the image
  74218. * @param options The required width/height ratio to downsize to before computing the render pass.
  74219. * @param camera The camera to apply the render pass to.
  74220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74221. * @param engine The engine which the post process will be applied. (default: current engine)
  74222. * @param reusable If the post process can be reused on the same frame. (default: false)
  74223. */
  74224. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74225. /** @hidden */
  74226. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74227. }
  74228. }
  74229. declare module "babylonjs/Shaders/fxaa.fragment" {
  74230. /** @hidden */
  74231. export var fxaaPixelShader: {
  74232. name: string;
  74233. shader: string;
  74234. };
  74235. }
  74236. declare module "babylonjs/Shaders/fxaa.vertex" {
  74237. /** @hidden */
  74238. export var fxaaVertexShader: {
  74239. name: string;
  74240. shader: string;
  74241. };
  74242. }
  74243. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  74244. import { Nullable } from "babylonjs/types";
  74245. import { Camera } from "babylonjs/Cameras/camera";
  74246. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74247. import { Engine } from "babylonjs/Engines/engine";
  74248. import "babylonjs/Shaders/fxaa.fragment";
  74249. import "babylonjs/Shaders/fxaa.vertex";
  74250. import { Scene } from "babylonjs/scene";
  74251. /**
  74252. * Fxaa post process
  74253. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74254. */
  74255. export class FxaaPostProcess extends PostProcess {
  74256. /**
  74257. * Gets a string identifying the name of the class
  74258. * @returns "FxaaPostProcess" string
  74259. */
  74260. getClassName(): string;
  74261. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74262. private _getDefines;
  74263. /** @hidden */
  74264. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74265. }
  74266. }
  74267. declare module "babylonjs/Shaders/grain.fragment" {
  74268. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74269. /** @hidden */
  74270. export var grainPixelShader: {
  74271. name: string;
  74272. shader: string;
  74273. };
  74274. }
  74275. declare module "babylonjs/PostProcesses/grainPostProcess" {
  74276. import { Nullable } from "babylonjs/types";
  74277. import { Camera } from "babylonjs/Cameras/camera";
  74278. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74279. import { Engine } from "babylonjs/Engines/engine";
  74280. import "babylonjs/Shaders/grain.fragment";
  74281. import { Scene } from "babylonjs/scene";
  74282. /**
  74283. * The GrainPostProcess adds noise to the image at mid luminance levels
  74284. */
  74285. export class GrainPostProcess extends PostProcess {
  74286. /**
  74287. * The intensity of the grain added (default: 30)
  74288. */
  74289. intensity: number;
  74290. /**
  74291. * If the grain should be randomized on every frame
  74292. */
  74293. animated: boolean;
  74294. /**
  74295. * Gets a string identifying the name of the class
  74296. * @returns "GrainPostProcess" string
  74297. */
  74298. getClassName(): string;
  74299. /**
  74300. * Creates a new instance of @see GrainPostProcess
  74301. * @param name The name of the effect.
  74302. * @param options The required width/height ratio to downsize to before computing the render pass.
  74303. * @param camera The camera to apply the render pass to.
  74304. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74305. * @param engine The engine which the post process will be applied. (default: current engine)
  74306. * @param reusable If the post process can be reused on the same frame. (default: false)
  74307. * @param textureType Type of textures used when performing the post process. (default: 0)
  74308. * @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)
  74309. */
  74310. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74311. /** @hidden */
  74312. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74313. }
  74314. }
  74315. declare module "babylonjs/Shaders/highlights.fragment" {
  74316. /** @hidden */
  74317. export var highlightsPixelShader: {
  74318. name: string;
  74319. shader: string;
  74320. };
  74321. }
  74322. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  74323. import { Nullable } from "babylonjs/types";
  74324. import { Camera } from "babylonjs/Cameras/camera";
  74325. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74326. import { Engine } from "babylonjs/Engines/engine";
  74327. import "babylonjs/Shaders/highlights.fragment";
  74328. /**
  74329. * Extracts highlights from the image
  74330. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74331. */
  74332. export class HighlightsPostProcess extends PostProcess {
  74333. /**
  74334. * Gets a string identifying the name of the class
  74335. * @returns "HighlightsPostProcess" string
  74336. */
  74337. getClassName(): string;
  74338. /**
  74339. * Extracts highlights from the image
  74340. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74341. * @param name The name of the effect.
  74342. * @param options The required width/height ratio to downsize to before computing the render pass.
  74343. * @param camera The camera to apply the render pass to.
  74344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74345. * @param engine The engine which the post process will be applied. (default: current engine)
  74346. * @param reusable If the post process can be reused on the same frame. (default: false)
  74347. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74348. */
  74349. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74350. }
  74351. }
  74352. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  74353. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74354. /**
  74355. * Contains all parameters needed for the prepass to perform
  74356. * motion blur
  74357. */
  74358. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74359. /**
  74360. * Is motion blur enabled
  74361. */
  74362. enabled: boolean;
  74363. /**
  74364. * Name of the configuration
  74365. */
  74366. name: string;
  74367. /**
  74368. * Textures that should be present in the MRT for this effect to work
  74369. */
  74370. readonly texturesRequired: number[];
  74371. }
  74372. }
  74373. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  74374. import { Nullable } from "babylonjs/types";
  74375. import { Scene } from "babylonjs/scene";
  74376. import { ISceneComponent } from "babylonjs/sceneComponent";
  74377. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  74378. module "babylonjs/scene" {
  74379. interface Scene {
  74380. /** @hidden (Backing field) */
  74381. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74382. /**
  74383. * Gets or Sets the current geometry buffer associated to the scene.
  74384. */
  74385. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74386. /**
  74387. * Enables a GeometryBufferRender and associates it with the scene
  74388. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74389. * @returns the GeometryBufferRenderer
  74390. */
  74391. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74392. /**
  74393. * Disables the GeometryBufferRender associated with the scene
  74394. */
  74395. disableGeometryBufferRenderer(): void;
  74396. }
  74397. }
  74398. /**
  74399. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74400. * in several rendering techniques.
  74401. */
  74402. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74403. /**
  74404. * The component name helpful to identify the component in the list of scene components.
  74405. */
  74406. readonly name: string;
  74407. /**
  74408. * The scene the component belongs to.
  74409. */
  74410. scene: Scene;
  74411. /**
  74412. * Creates a new instance of the component for the given scene
  74413. * @param scene Defines the scene to register the component in
  74414. */
  74415. constructor(scene: Scene);
  74416. /**
  74417. * Registers the component in a given scene
  74418. */
  74419. register(): void;
  74420. /**
  74421. * Rebuilds the elements related to this component in case of
  74422. * context lost for instance.
  74423. */
  74424. rebuild(): void;
  74425. /**
  74426. * Disposes the component and the associated ressources
  74427. */
  74428. dispose(): void;
  74429. private _gatherRenderTargets;
  74430. }
  74431. }
  74432. declare module "babylonjs/Shaders/motionBlur.fragment" {
  74433. /** @hidden */
  74434. export var motionBlurPixelShader: {
  74435. name: string;
  74436. shader: string;
  74437. };
  74438. }
  74439. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  74440. import { Nullable } from "babylonjs/types";
  74441. import { Camera } from "babylonjs/Cameras/camera";
  74442. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74444. import "babylonjs/Animations/animatable";
  74445. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74446. import "babylonjs/Shaders/motionBlur.fragment";
  74447. import { Engine } from "babylonjs/Engines/engine";
  74448. import { Scene } from "babylonjs/scene";
  74449. /**
  74450. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74451. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74452. * As an example, all you have to do is to create the post-process:
  74453. * var mb = new BABYLON.MotionBlurPostProcess(
  74454. * 'mb', // The name of the effect.
  74455. * scene, // The scene containing the objects to blur according to their velocity.
  74456. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74457. * camera // The camera to apply the render pass to.
  74458. * );
  74459. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74460. */
  74461. export class MotionBlurPostProcess extends PostProcess {
  74462. /**
  74463. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74464. */
  74465. motionStrength: number;
  74466. /**
  74467. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74468. */
  74469. get motionBlurSamples(): number;
  74470. /**
  74471. * Sets the number of iterations to be used for motion blur quality
  74472. */
  74473. set motionBlurSamples(samples: number);
  74474. private _motionBlurSamples;
  74475. private _forceGeometryBuffer;
  74476. private _geometryBufferRenderer;
  74477. private _prePassRenderer;
  74478. /**
  74479. * Gets a string identifying the name of the class
  74480. * @returns "MotionBlurPostProcess" string
  74481. */
  74482. getClassName(): string;
  74483. /**
  74484. * Creates a new instance MotionBlurPostProcess
  74485. * @param name The name of the effect.
  74486. * @param scene The scene containing the objects to blur according to their velocity.
  74487. * @param options The required width/height ratio to downsize to before computing the render pass.
  74488. * @param camera The camera to apply the render pass to.
  74489. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74490. * @param engine The engine which the post process will be applied. (default: current engine)
  74491. * @param reusable If the post process can be reused on the same frame. (default: false)
  74492. * @param textureType Type of textures used when performing the post process. (default: 0)
  74493. * @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)
  74494. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74495. */
  74496. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74497. /**
  74498. * Excludes the given skinned mesh from computing bones velocities.
  74499. * 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.
  74500. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74501. */
  74502. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74503. /**
  74504. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74505. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74506. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74507. */
  74508. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74509. /**
  74510. * Disposes the post process.
  74511. * @param camera The camera to dispose the post process on.
  74512. */
  74513. dispose(camera?: Camera): void;
  74514. /** @hidden */
  74515. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74516. }
  74517. }
  74518. declare module "babylonjs/Shaders/refraction.fragment" {
  74519. /** @hidden */
  74520. export var refractionPixelShader: {
  74521. name: string;
  74522. shader: string;
  74523. };
  74524. }
  74525. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  74526. import { Color3 } from "babylonjs/Maths/math.color";
  74527. import { Camera } from "babylonjs/Cameras/camera";
  74528. import { Texture } from "babylonjs/Materials/Textures/texture";
  74529. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74530. import { Engine } from "babylonjs/Engines/engine";
  74531. import "babylonjs/Shaders/refraction.fragment";
  74532. import { Scene } from "babylonjs/scene";
  74533. /**
  74534. * Post process which applies a refractin texture
  74535. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74536. */
  74537. export class RefractionPostProcess extends PostProcess {
  74538. private _refTexture;
  74539. private _ownRefractionTexture;
  74540. /** the base color of the refraction (used to taint the rendering) */
  74541. color: Color3;
  74542. /** simulated refraction depth */
  74543. depth: number;
  74544. /** the coefficient of the base color (0 to remove base color tainting) */
  74545. colorLevel: number;
  74546. /** Gets the url used to load the refraction texture */
  74547. refractionTextureUrl: string;
  74548. /**
  74549. * Gets or sets the refraction texture
  74550. * Please note that you are responsible for disposing the texture if you set it manually
  74551. */
  74552. get refractionTexture(): Texture;
  74553. set refractionTexture(value: Texture);
  74554. /**
  74555. * Gets a string identifying the name of the class
  74556. * @returns "RefractionPostProcess" string
  74557. */
  74558. getClassName(): string;
  74559. /**
  74560. * Initializes the RefractionPostProcess
  74561. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74562. * @param name The name of the effect.
  74563. * @param refractionTextureUrl Url of the refraction texture to use
  74564. * @param color the base color of the refraction (used to taint the rendering)
  74565. * @param depth simulated refraction depth
  74566. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74567. * @param camera The camera to apply the render pass to.
  74568. * @param options The required width/height ratio to downsize to before computing the render pass.
  74569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74570. * @param engine The engine which the post process will be applied. (default: current engine)
  74571. * @param reusable If the post process can be reused on the same frame. (default: false)
  74572. */
  74573. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74574. /**
  74575. * Disposes of the post process
  74576. * @param camera Camera to dispose post process on
  74577. */
  74578. dispose(camera: Camera): void;
  74579. /** @hidden */
  74580. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74581. }
  74582. }
  74583. declare module "babylonjs/Shaders/sharpen.fragment" {
  74584. /** @hidden */
  74585. export var sharpenPixelShader: {
  74586. name: string;
  74587. shader: string;
  74588. };
  74589. }
  74590. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74591. import { Nullable } from "babylonjs/types";
  74592. import { Camera } from "babylonjs/Cameras/camera";
  74593. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74594. import "babylonjs/Shaders/sharpen.fragment";
  74595. import { Engine } from "babylonjs/Engines/engine";
  74596. import { Scene } from "babylonjs/scene";
  74597. /**
  74598. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74599. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74600. */
  74601. export class SharpenPostProcess extends PostProcess {
  74602. /**
  74603. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74604. */
  74605. colorAmount: number;
  74606. /**
  74607. * How much sharpness should be applied (default: 0.3)
  74608. */
  74609. edgeAmount: number;
  74610. /**
  74611. * Gets a string identifying the name of the class
  74612. * @returns "SharpenPostProcess" string
  74613. */
  74614. getClassName(): string;
  74615. /**
  74616. * Creates a new instance ConvolutionPostProcess
  74617. * @param name The name of the effect.
  74618. * @param options The required width/height ratio to downsize to before computing the render pass.
  74619. * @param camera The camera to apply the render pass to.
  74620. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74621. * @param engine The engine which the post process will be applied. (default: current engine)
  74622. * @param reusable If the post process can be reused on the same frame. (default: false)
  74623. * @param textureType Type of textures used when performing the post process. (default: 0)
  74624. * @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)
  74625. */
  74626. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74627. /** @hidden */
  74628. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74629. }
  74630. }
  74631. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74632. import { Nullable } from "babylonjs/types";
  74633. import { Camera } from "babylonjs/Cameras/camera";
  74634. import { Engine } from "babylonjs/Engines/engine";
  74635. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74636. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74637. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74638. /**
  74639. * PostProcessRenderPipeline
  74640. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74641. */
  74642. export class PostProcessRenderPipeline {
  74643. private engine;
  74644. private _renderEffects;
  74645. private _renderEffectsForIsolatedPass;
  74646. /**
  74647. * List of inspectable custom properties (used by the Inspector)
  74648. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74649. */
  74650. inspectableCustomProperties: IInspectable[];
  74651. /**
  74652. * @hidden
  74653. */
  74654. protected _cameras: Camera[];
  74655. /** @hidden */
  74656. _name: string;
  74657. /**
  74658. * Gets pipeline name
  74659. */
  74660. get name(): string;
  74661. /** Gets the list of attached cameras */
  74662. get cameras(): Camera[];
  74663. /**
  74664. * Initializes a PostProcessRenderPipeline
  74665. * @param engine engine to add the pipeline to
  74666. * @param name name of the pipeline
  74667. */
  74668. constructor(engine: Engine, name: string);
  74669. /**
  74670. * Gets the class name
  74671. * @returns "PostProcessRenderPipeline"
  74672. */
  74673. getClassName(): string;
  74674. /**
  74675. * If all the render effects in the pipeline are supported
  74676. */
  74677. get isSupported(): boolean;
  74678. /**
  74679. * Adds an effect to the pipeline
  74680. * @param renderEffect the effect to add
  74681. */
  74682. addEffect(renderEffect: PostProcessRenderEffect): void;
  74683. /** @hidden */
  74684. _rebuild(): void;
  74685. /** @hidden */
  74686. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74687. /** @hidden */
  74688. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74689. /** @hidden */
  74690. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74691. /** @hidden */
  74692. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74693. /** @hidden */
  74694. _attachCameras(cameras: Camera, unique: boolean): void;
  74695. /** @hidden */
  74696. _attachCameras(cameras: Camera[], unique: boolean): void;
  74697. /** @hidden */
  74698. _detachCameras(cameras: Camera): void;
  74699. /** @hidden */
  74700. _detachCameras(cameras: Nullable<Camera[]>): void;
  74701. /** @hidden */
  74702. _update(): void;
  74703. /** @hidden */
  74704. _reset(): void;
  74705. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74706. /**
  74707. * Sets the required values to the prepass renderer.
  74708. * @param prePassRenderer defines the prepass renderer to setup.
  74709. * @returns true if the pre pass is needed.
  74710. */
  74711. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74712. /**
  74713. * Disposes of the pipeline
  74714. */
  74715. dispose(): void;
  74716. }
  74717. }
  74718. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74719. import { Camera } from "babylonjs/Cameras/camera";
  74720. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74721. /**
  74722. * PostProcessRenderPipelineManager class
  74723. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74724. */
  74725. export class PostProcessRenderPipelineManager {
  74726. private _renderPipelines;
  74727. /**
  74728. * Initializes a PostProcessRenderPipelineManager
  74729. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74730. */
  74731. constructor();
  74732. /**
  74733. * Gets the list of supported render pipelines
  74734. */
  74735. get supportedPipelines(): PostProcessRenderPipeline[];
  74736. /**
  74737. * Adds a pipeline to the manager
  74738. * @param renderPipeline The pipeline to add
  74739. */
  74740. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74741. /**
  74742. * Attaches a camera to the pipeline
  74743. * @param renderPipelineName The name of the pipeline to attach to
  74744. * @param cameras the camera to attach
  74745. * @param unique if the camera can be attached multiple times to the pipeline
  74746. */
  74747. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74748. /**
  74749. * Detaches a camera from the pipeline
  74750. * @param renderPipelineName The name of the pipeline to detach from
  74751. * @param cameras the camera to detach
  74752. */
  74753. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74754. /**
  74755. * Enables an effect by name on a pipeline
  74756. * @param renderPipelineName the name of the pipeline to enable the effect in
  74757. * @param renderEffectName the name of the effect to enable
  74758. * @param cameras the cameras that the effect should be enabled on
  74759. */
  74760. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74761. /**
  74762. * Disables an effect by name on a pipeline
  74763. * @param renderPipelineName the name of the pipeline to disable the effect in
  74764. * @param renderEffectName the name of the effect to disable
  74765. * @param cameras the cameras that the effect should be disabled on
  74766. */
  74767. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74768. /**
  74769. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74770. */
  74771. update(): void;
  74772. /** @hidden */
  74773. _rebuild(): void;
  74774. /**
  74775. * Disposes of the manager and pipelines
  74776. */
  74777. dispose(): void;
  74778. }
  74779. }
  74780. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74781. import { ISceneComponent } from "babylonjs/sceneComponent";
  74782. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74783. import { Scene } from "babylonjs/scene";
  74784. module "babylonjs/scene" {
  74785. interface Scene {
  74786. /** @hidden (Backing field) */
  74787. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74788. /**
  74789. * Gets the postprocess render pipeline manager
  74790. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74791. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74792. */
  74793. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74794. }
  74795. }
  74796. /**
  74797. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74798. */
  74799. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74800. /**
  74801. * The component name helpfull to identify the component in the list of scene components.
  74802. */
  74803. readonly name: string;
  74804. /**
  74805. * The scene the component belongs to.
  74806. */
  74807. scene: Scene;
  74808. /**
  74809. * Creates a new instance of the component for the given scene
  74810. * @param scene Defines the scene to register the component in
  74811. */
  74812. constructor(scene: Scene);
  74813. /**
  74814. * Registers the component in a given scene
  74815. */
  74816. register(): void;
  74817. /**
  74818. * Rebuilds the elements related to this component in case of
  74819. * context lost for instance.
  74820. */
  74821. rebuild(): void;
  74822. /**
  74823. * Disposes the component and the associated ressources
  74824. */
  74825. dispose(): void;
  74826. private _gatherRenderTargets;
  74827. }
  74828. }
  74829. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74830. import { Nullable } from "babylonjs/types";
  74831. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74832. import { Camera } from "babylonjs/Cameras/camera";
  74833. import { IDisposable } from "babylonjs/scene";
  74834. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74835. import { Scene } from "babylonjs/scene";
  74836. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74837. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74838. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74839. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74840. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74841. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74842. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74843. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74844. import { Animation } from "babylonjs/Animations/animation";
  74845. /**
  74846. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74847. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74848. */
  74849. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74850. private _scene;
  74851. private _camerasToBeAttached;
  74852. /**
  74853. * ID of the sharpen post process,
  74854. */
  74855. private readonly SharpenPostProcessId;
  74856. /**
  74857. * @ignore
  74858. * ID of the image processing post process;
  74859. */
  74860. readonly ImageProcessingPostProcessId: string;
  74861. /**
  74862. * @ignore
  74863. * ID of the Fast Approximate Anti-Aliasing post process;
  74864. */
  74865. readonly FxaaPostProcessId: string;
  74866. /**
  74867. * ID of the chromatic aberration post process,
  74868. */
  74869. private readonly ChromaticAberrationPostProcessId;
  74870. /**
  74871. * ID of the grain post process
  74872. */
  74873. private readonly GrainPostProcessId;
  74874. /**
  74875. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74876. */
  74877. sharpen: SharpenPostProcess;
  74878. private _sharpenEffect;
  74879. private bloom;
  74880. /**
  74881. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74882. */
  74883. depthOfField: DepthOfFieldEffect;
  74884. /**
  74885. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74886. */
  74887. fxaa: FxaaPostProcess;
  74888. /**
  74889. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74890. */
  74891. imageProcessing: ImageProcessingPostProcess;
  74892. /**
  74893. * Chromatic aberration post process which will shift rgb colors in the image
  74894. */
  74895. chromaticAberration: ChromaticAberrationPostProcess;
  74896. private _chromaticAberrationEffect;
  74897. /**
  74898. * Grain post process which add noise to the image
  74899. */
  74900. grain: GrainPostProcess;
  74901. private _grainEffect;
  74902. /**
  74903. * Glow post process which adds a glow to emissive areas of the image
  74904. */
  74905. private _glowLayer;
  74906. /**
  74907. * Animations which can be used to tweak settings over a period of time
  74908. */
  74909. animations: Animation[];
  74910. private _imageProcessingConfigurationObserver;
  74911. private _sharpenEnabled;
  74912. private _bloomEnabled;
  74913. private _depthOfFieldEnabled;
  74914. private _depthOfFieldBlurLevel;
  74915. private _fxaaEnabled;
  74916. private _imageProcessingEnabled;
  74917. private _defaultPipelineTextureType;
  74918. private _bloomScale;
  74919. private _chromaticAberrationEnabled;
  74920. private _grainEnabled;
  74921. private _buildAllowed;
  74922. /**
  74923. * Gets active scene
  74924. */
  74925. get scene(): Scene;
  74926. /**
  74927. * Enable or disable the sharpen process from the pipeline
  74928. */
  74929. set sharpenEnabled(enabled: boolean);
  74930. get sharpenEnabled(): boolean;
  74931. private _resizeObserver;
  74932. private _hardwareScaleLevel;
  74933. private _bloomKernel;
  74934. /**
  74935. * Specifies the size of the bloom blur kernel, relative to the final output size
  74936. */
  74937. get bloomKernel(): number;
  74938. set bloomKernel(value: number);
  74939. /**
  74940. * Specifies the weight of the bloom in the final rendering
  74941. */
  74942. private _bloomWeight;
  74943. /**
  74944. * Specifies the luma threshold for the area that will be blurred by the bloom
  74945. */
  74946. private _bloomThreshold;
  74947. private _hdr;
  74948. /**
  74949. * The strength of the bloom.
  74950. */
  74951. set bloomWeight(value: number);
  74952. get bloomWeight(): number;
  74953. /**
  74954. * The strength of the bloom.
  74955. */
  74956. set bloomThreshold(value: number);
  74957. get bloomThreshold(): number;
  74958. /**
  74959. * The scale of the bloom, lower value will provide better performance.
  74960. */
  74961. set bloomScale(value: number);
  74962. get bloomScale(): number;
  74963. /**
  74964. * Enable or disable the bloom from the pipeline
  74965. */
  74966. set bloomEnabled(enabled: boolean);
  74967. get bloomEnabled(): boolean;
  74968. private _rebuildBloom;
  74969. /**
  74970. * If the depth of field is enabled.
  74971. */
  74972. get depthOfFieldEnabled(): boolean;
  74973. set depthOfFieldEnabled(enabled: boolean);
  74974. /**
  74975. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74976. */
  74977. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74978. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74979. /**
  74980. * If the anti aliasing is enabled.
  74981. */
  74982. set fxaaEnabled(enabled: boolean);
  74983. get fxaaEnabled(): boolean;
  74984. private _samples;
  74985. /**
  74986. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74987. */
  74988. set samples(sampleCount: number);
  74989. get samples(): number;
  74990. /**
  74991. * If image processing is enabled.
  74992. */
  74993. set imageProcessingEnabled(enabled: boolean);
  74994. get imageProcessingEnabled(): boolean;
  74995. /**
  74996. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74997. */
  74998. set glowLayerEnabled(enabled: boolean);
  74999. get glowLayerEnabled(): boolean;
  75000. /**
  75001. * Gets the glow layer (or null if not defined)
  75002. */
  75003. get glowLayer(): Nullable<GlowLayer>;
  75004. /**
  75005. * Enable or disable the chromaticAberration process from the pipeline
  75006. */
  75007. set chromaticAberrationEnabled(enabled: boolean);
  75008. get chromaticAberrationEnabled(): boolean;
  75009. /**
  75010. * Enable or disable the grain process from the pipeline
  75011. */
  75012. set grainEnabled(enabled: boolean);
  75013. get grainEnabled(): boolean;
  75014. /**
  75015. * @constructor
  75016. * @param name - The rendering pipeline name (default: "")
  75017. * @param hdr - If high dynamic range textures should be used (default: true)
  75018. * @param scene - The scene linked to this pipeline (default: the last created scene)
  75019. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  75020. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  75021. */
  75022. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  75023. /**
  75024. * Get the class name
  75025. * @returns "DefaultRenderingPipeline"
  75026. */
  75027. getClassName(): string;
  75028. /**
  75029. * Force the compilation of the entire pipeline.
  75030. */
  75031. prepare(): void;
  75032. private _hasCleared;
  75033. private _prevPostProcess;
  75034. private _prevPrevPostProcess;
  75035. private _setAutoClearAndTextureSharing;
  75036. private _depthOfFieldSceneObserver;
  75037. private _buildPipeline;
  75038. private _disposePostProcesses;
  75039. /**
  75040. * Adds a camera to the pipeline
  75041. * @param camera the camera to be added
  75042. */
  75043. addCamera(camera: Camera): void;
  75044. /**
  75045. * Removes a camera from the pipeline
  75046. * @param camera the camera to remove
  75047. */
  75048. removeCamera(camera: Camera): void;
  75049. /**
  75050. * Dispose of the pipeline and stop all post processes
  75051. */
  75052. dispose(): void;
  75053. /**
  75054. * Serialize the rendering pipeline (Used when exporting)
  75055. * @returns the serialized object
  75056. */
  75057. serialize(): any;
  75058. /**
  75059. * Parse the serialized pipeline
  75060. * @param source Source pipeline.
  75061. * @param scene The scene to load the pipeline to.
  75062. * @param rootUrl The URL of the serialized pipeline.
  75063. * @returns An instantiated pipeline from the serialized object.
  75064. */
  75065. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75066. }
  75067. }
  75068. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  75069. /** @hidden */
  75070. export var lensHighlightsPixelShader: {
  75071. name: string;
  75072. shader: string;
  75073. };
  75074. }
  75075. declare module "babylonjs/Shaders/depthOfField.fragment" {
  75076. /** @hidden */
  75077. export var depthOfFieldPixelShader: {
  75078. name: string;
  75079. shader: string;
  75080. };
  75081. }
  75082. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  75083. import { Camera } from "babylonjs/Cameras/camera";
  75084. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75085. import { Scene } from "babylonjs/scene";
  75086. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75087. import "babylonjs/Shaders/chromaticAberration.fragment";
  75088. import "babylonjs/Shaders/lensHighlights.fragment";
  75089. import "babylonjs/Shaders/depthOfField.fragment";
  75090. /**
  75091. * BABYLON.JS Chromatic Aberration GLSL Shader
  75092. * Author: Olivier Guyot
  75093. * Separates very slightly R, G and B colors on the edges of the screen
  75094. * Inspired by Francois Tarlier & Martins Upitis
  75095. */
  75096. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75097. /**
  75098. * @ignore
  75099. * The chromatic aberration PostProcess id in the pipeline
  75100. */
  75101. LensChromaticAberrationEffect: string;
  75102. /**
  75103. * @ignore
  75104. * The highlights enhancing PostProcess id in the pipeline
  75105. */
  75106. HighlightsEnhancingEffect: string;
  75107. /**
  75108. * @ignore
  75109. * The depth-of-field PostProcess id in the pipeline
  75110. */
  75111. LensDepthOfFieldEffect: string;
  75112. private _scene;
  75113. private _depthTexture;
  75114. private _grainTexture;
  75115. private _chromaticAberrationPostProcess;
  75116. private _highlightsPostProcess;
  75117. private _depthOfFieldPostProcess;
  75118. private _edgeBlur;
  75119. private _grainAmount;
  75120. private _chromaticAberration;
  75121. private _distortion;
  75122. private _highlightsGain;
  75123. private _highlightsThreshold;
  75124. private _dofDistance;
  75125. private _dofAperture;
  75126. private _dofDarken;
  75127. private _dofPentagon;
  75128. private _blurNoise;
  75129. /**
  75130. * @constructor
  75131. *
  75132. * Effect parameters are as follow:
  75133. * {
  75134. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75135. * edge_blur: number; // from 0 to x (1 for realism)
  75136. * distortion: number; // from 0 to x (1 for realism)
  75137. * grain_amount: number; // from 0 to 1
  75138. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75139. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75140. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75141. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75142. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75143. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75144. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75145. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75146. * }
  75147. * Note: if an effect parameter is unset, effect is disabled
  75148. *
  75149. * @param name The rendering pipeline name
  75150. * @param parameters - An object containing all parameters (see above)
  75151. * @param scene The scene linked to this pipeline
  75152. * @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)
  75153. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75154. */
  75155. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75156. /**
  75157. * Get the class name
  75158. * @returns "LensRenderingPipeline"
  75159. */
  75160. getClassName(): string;
  75161. /**
  75162. * Gets associated scene
  75163. */
  75164. get scene(): Scene;
  75165. /**
  75166. * Gets or sets the edge blur
  75167. */
  75168. get edgeBlur(): number;
  75169. set edgeBlur(value: number);
  75170. /**
  75171. * Gets or sets the grain amount
  75172. */
  75173. get grainAmount(): number;
  75174. set grainAmount(value: number);
  75175. /**
  75176. * Gets or sets the chromatic aberration amount
  75177. */
  75178. get chromaticAberration(): number;
  75179. set chromaticAberration(value: number);
  75180. /**
  75181. * Gets or sets the depth of field aperture
  75182. */
  75183. get dofAperture(): number;
  75184. set dofAperture(value: number);
  75185. /**
  75186. * Gets or sets the edge distortion
  75187. */
  75188. get edgeDistortion(): number;
  75189. set edgeDistortion(value: number);
  75190. /**
  75191. * Gets or sets the depth of field distortion
  75192. */
  75193. get dofDistortion(): number;
  75194. set dofDistortion(value: number);
  75195. /**
  75196. * Gets or sets the darken out of focus amount
  75197. */
  75198. get darkenOutOfFocus(): number;
  75199. set darkenOutOfFocus(value: number);
  75200. /**
  75201. * Gets or sets a boolean indicating if blur noise is enabled
  75202. */
  75203. get blurNoise(): boolean;
  75204. set blurNoise(value: boolean);
  75205. /**
  75206. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75207. */
  75208. get pentagonBokeh(): boolean;
  75209. set pentagonBokeh(value: boolean);
  75210. /**
  75211. * Gets or sets the highlight grain amount
  75212. */
  75213. get highlightsGain(): number;
  75214. set highlightsGain(value: number);
  75215. /**
  75216. * Gets or sets the highlight threshold
  75217. */
  75218. get highlightsThreshold(): number;
  75219. set highlightsThreshold(value: number);
  75220. /**
  75221. * Sets the amount of blur at the edges
  75222. * @param amount blur amount
  75223. */
  75224. setEdgeBlur(amount: number): void;
  75225. /**
  75226. * Sets edge blur to 0
  75227. */
  75228. disableEdgeBlur(): void;
  75229. /**
  75230. * Sets the amout of grain
  75231. * @param amount Amount of grain
  75232. */
  75233. setGrainAmount(amount: number): void;
  75234. /**
  75235. * Set grain amount to 0
  75236. */
  75237. disableGrain(): void;
  75238. /**
  75239. * Sets the chromatic aberration amount
  75240. * @param amount amount of chromatic aberration
  75241. */
  75242. setChromaticAberration(amount: number): void;
  75243. /**
  75244. * Sets chromatic aberration amount to 0
  75245. */
  75246. disableChromaticAberration(): void;
  75247. /**
  75248. * Sets the EdgeDistortion amount
  75249. * @param amount amount of EdgeDistortion
  75250. */
  75251. setEdgeDistortion(amount: number): void;
  75252. /**
  75253. * Sets edge distortion to 0
  75254. */
  75255. disableEdgeDistortion(): void;
  75256. /**
  75257. * Sets the FocusDistance amount
  75258. * @param amount amount of FocusDistance
  75259. */
  75260. setFocusDistance(amount: number): void;
  75261. /**
  75262. * Disables depth of field
  75263. */
  75264. disableDepthOfField(): void;
  75265. /**
  75266. * Sets the Aperture amount
  75267. * @param amount amount of Aperture
  75268. */
  75269. setAperture(amount: number): void;
  75270. /**
  75271. * Sets the DarkenOutOfFocus amount
  75272. * @param amount amount of DarkenOutOfFocus
  75273. */
  75274. setDarkenOutOfFocus(amount: number): void;
  75275. private _pentagonBokehIsEnabled;
  75276. /**
  75277. * Creates a pentagon bokeh effect
  75278. */
  75279. enablePentagonBokeh(): void;
  75280. /**
  75281. * Disables the pentagon bokeh effect
  75282. */
  75283. disablePentagonBokeh(): void;
  75284. /**
  75285. * Enables noise blur
  75286. */
  75287. enableNoiseBlur(): void;
  75288. /**
  75289. * Disables noise blur
  75290. */
  75291. disableNoiseBlur(): void;
  75292. /**
  75293. * Sets the HighlightsGain amount
  75294. * @param amount amount of HighlightsGain
  75295. */
  75296. setHighlightsGain(amount: number): void;
  75297. /**
  75298. * Sets the HighlightsThreshold amount
  75299. * @param amount amount of HighlightsThreshold
  75300. */
  75301. setHighlightsThreshold(amount: number): void;
  75302. /**
  75303. * Disables highlights
  75304. */
  75305. disableHighlights(): void;
  75306. /**
  75307. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75308. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75309. */
  75310. dispose(disableDepthRender?: boolean): void;
  75311. private _createChromaticAberrationPostProcess;
  75312. private _createHighlightsPostProcess;
  75313. private _createDepthOfFieldPostProcess;
  75314. private _createGrainTexture;
  75315. }
  75316. }
  75317. declare module "babylonjs/Rendering/ssao2Configuration" {
  75318. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75319. /**
  75320. * Contains all parameters needed for the prepass to perform
  75321. * screen space subsurface scattering
  75322. */
  75323. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75324. /**
  75325. * Is subsurface enabled
  75326. */
  75327. enabled: boolean;
  75328. /**
  75329. * Name of the configuration
  75330. */
  75331. name: string;
  75332. /**
  75333. * Textures that should be present in the MRT for this effect to work
  75334. */
  75335. readonly texturesRequired: number[];
  75336. }
  75337. }
  75338. declare module "babylonjs/Shaders/ssao2.fragment" {
  75339. /** @hidden */
  75340. export var ssao2PixelShader: {
  75341. name: string;
  75342. shader: string;
  75343. };
  75344. }
  75345. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  75346. /** @hidden */
  75347. export var ssaoCombinePixelShader: {
  75348. name: string;
  75349. shader: string;
  75350. };
  75351. }
  75352. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  75353. import { Camera } from "babylonjs/Cameras/camera";
  75354. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75355. import { Scene } from "babylonjs/scene";
  75356. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75357. import "babylonjs/Shaders/ssao2.fragment";
  75358. import "babylonjs/Shaders/ssaoCombine.fragment";
  75359. /**
  75360. * Render pipeline to produce ssao effect
  75361. */
  75362. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75363. /**
  75364. * @ignore
  75365. * The PassPostProcess id in the pipeline that contains the original scene color
  75366. */
  75367. SSAOOriginalSceneColorEffect: string;
  75368. /**
  75369. * @ignore
  75370. * The SSAO PostProcess id in the pipeline
  75371. */
  75372. SSAORenderEffect: string;
  75373. /**
  75374. * @ignore
  75375. * The horizontal blur PostProcess id in the pipeline
  75376. */
  75377. SSAOBlurHRenderEffect: string;
  75378. /**
  75379. * @ignore
  75380. * The vertical blur PostProcess id in the pipeline
  75381. */
  75382. SSAOBlurVRenderEffect: string;
  75383. /**
  75384. * @ignore
  75385. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75386. */
  75387. SSAOCombineRenderEffect: string;
  75388. /**
  75389. * The output strength of the SSAO post-process. Default value is 1.0.
  75390. */
  75391. totalStrength: number;
  75392. /**
  75393. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75394. */
  75395. maxZ: number;
  75396. /**
  75397. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75398. */
  75399. minZAspect: number;
  75400. private _samples;
  75401. /**
  75402. * Number of samples used for the SSAO calculations. Default value is 8
  75403. */
  75404. set samples(n: number);
  75405. get samples(): number;
  75406. private _textureSamples;
  75407. /**
  75408. * Number of samples to use for antialiasing
  75409. */
  75410. set textureSamples(n: number);
  75411. get textureSamples(): number;
  75412. /**
  75413. * Force rendering the geometry through geometry buffer
  75414. */
  75415. private _forceGeometryBuffer;
  75416. /**
  75417. * Ratio object used for SSAO ratio and blur ratio
  75418. */
  75419. private _ratio;
  75420. /**
  75421. * Dynamically generated sphere sampler.
  75422. */
  75423. private _sampleSphere;
  75424. /**
  75425. * Blur filter offsets
  75426. */
  75427. private _samplerOffsets;
  75428. private _expensiveBlur;
  75429. /**
  75430. * If bilateral blur should be used
  75431. */
  75432. set expensiveBlur(b: boolean);
  75433. get expensiveBlur(): boolean;
  75434. /**
  75435. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75436. */
  75437. radius: number;
  75438. /**
  75439. * The base color of the SSAO post-process
  75440. * The final result is "base + ssao" between [0, 1]
  75441. */
  75442. base: number;
  75443. /**
  75444. * Support test.
  75445. */
  75446. static get IsSupported(): boolean;
  75447. private _scene;
  75448. private _randomTexture;
  75449. private _originalColorPostProcess;
  75450. private _ssaoPostProcess;
  75451. private _blurHPostProcess;
  75452. private _blurVPostProcess;
  75453. private _ssaoCombinePostProcess;
  75454. private _prePassRenderer;
  75455. /**
  75456. * Gets active scene
  75457. */
  75458. get scene(): Scene;
  75459. /**
  75460. * @constructor
  75461. * @param name The rendering pipeline name
  75462. * @param scene The scene linked to this pipeline
  75463. * @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 }
  75464. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75465. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75466. */
  75467. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75468. /**
  75469. * Get the class name
  75470. * @returns "SSAO2RenderingPipeline"
  75471. */
  75472. getClassName(): string;
  75473. /**
  75474. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75475. */
  75476. dispose(disableGeometryBufferRenderer?: boolean): void;
  75477. private _createBlurPostProcess;
  75478. /** @hidden */
  75479. _rebuild(): void;
  75480. private _bits;
  75481. private _radicalInverse_VdC;
  75482. private _hammersley;
  75483. private _hemisphereSample_uniform;
  75484. private _generateHemisphere;
  75485. private _getDefinesForSSAO;
  75486. private _createSSAOPostProcess;
  75487. private _createSSAOCombinePostProcess;
  75488. private _createRandomTexture;
  75489. /**
  75490. * Serialize the rendering pipeline (Used when exporting)
  75491. * @returns the serialized object
  75492. */
  75493. serialize(): any;
  75494. /**
  75495. * Parse the serialized pipeline
  75496. * @param source Source pipeline.
  75497. * @param scene The scene to load the pipeline to.
  75498. * @param rootUrl The URL of the serialized pipeline.
  75499. * @returns An instantiated pipeline from the serialized object.
  75500. */
  75501. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75502. }
  75503. }
  75504. declare module "babylonjs/Shaders/ssao.fragment" {
  75505. /** @hidden */
  75506. export var ssaoPixelShader: {
  75507. name: string;
  75508. shader: string;
  75509. };
  75510. }
  75511. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  75512. import { Camera } from "babylonjs/Cameras/camera";
  75513. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75514. import { Scene } from "babylonjs/scene";
  75515. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75516. import "babylonjs/Shaders/ssao.fragment";
  75517. import "babylonjs/Shaders/ssaoCombine.fragment";
  75518. /**
  75519. * Render pipeline to produce ssao effect
  75520. */
  75521. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75522. /**
  75523. * @ignore
  75524. * The PassPostProcess id in the pipeline that contains the original scene color
  75525. */
  75526. SSAOOriginalSceneColorEffect: string;
  75527. /**
  75528. * @ignore
  75529. * The SSAO PostProcess id in the pipeline
  75530. */
  75531. SSAORenderEffect: string;
  75532. /**
  75533. * @ignore
  75534. * The horizontal blur PostProcess id in the pipeline
  75535. */
  75536. SSAOBlurHRenderEffect: string;
  75537. /**
  75538. * @ignore
  75539. * The vertical blur PostProcess id in the pipeline
  75540. */
  75541. SSAOBlurVRenderEffect: string;
  75542. /**
  75543. * @ignore
  75544. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75545. */
  75546. SSAOCombineRenderEffect: string;
  75547. /**
  75548. * The output strength of the SSAO post-process. Default value is 1.0.
  75549. */
  75550. totalStrength: number;
  75551. /**
  75552. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75553. */
  75554. radius: number;
  75555. /**
  75556. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75557. * Must not be equal to fallOff and superior to fallOff.
  75558. * Default value is 0.0075
  75559. */
  75560. area: number;
  75561. /**
  75562. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75563. * Must not be equal to area and inferior to area.
  75564. * Default value is 0.000001
  75565. */
  75566. fallOff: number;
  75567. /**
  75568. * The base color of the SSAO post-process
  75569. * The final result is "base + ssao" between [0, 1]
  75570. */
  75571. base: number;
  75572. private _scene;
  75573. private _depthTexture;
  75574. private _randomTexture;
  75575. private _originalColorPostProcess;
  75576. private _ssaoPostProcess;
  75577. private _blurHPostProcess;
  75578. private _blurVPostProcess;
  75579. private _ssaoCombinePostProcess;
  75580. private _firstUpdate;
  75581. /**
  75582. * Gets active scene
  75583. */
  75584. get scene(): Scene;
  75585. /**
  75586. * @constructor
  75587. * @param name - The rendering pipeline name
  75588. * @param scene - The scene linked to this pipeline
  75589. * @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 }
  75590. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75591. */
  75592. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75593. /**
  75594. * Get the class name
  75595. * @returns "SSAORenderingPipeline"
  75596. */
  75597. getClassName(): string;
  75598. /**
  75599. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75600. */
  75601. dispose(disableDepthRender?: boolean): void;
  75602. private _createBlurPostProcess;
  75603. /** @hidden */
  75604. _rebuild(): void;
  75605. private _createSSAOPostProcess;
  75606. private _createSSAOCombinePostProcess;
  75607. private _createRandomTexture;
  75608. }
  75609. }
  75610. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  75611. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75612. /**
  75613. * Contains all parameters needed for the prepass to perform
  75614. * screen space reflections
  75615. */
  75616. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75617. /**
  75618. * Is ssr enabled
  75619. */
  75620. enabled: boolean;
  75621. /**
  75622. * Name of the configuration
  75623. */
  75624. name: string;
  75625. /**
  75626. * Textures that should be present in the MRT for this effect to work
  75627. */
  75628. readonly texturesRequired: number[];
  75629. }
  75630. }
  75631. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75632. /** @hidden */
  75633. export var screenSpaceReflectionPixelShader: {
  75634. name: string;
  75635. shader: string;
  75636. };
  75637. }
  75638. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75639. import { Nullable } from "babylonjs/types";
  75640. import { Camera } from "babylonjs/Cameras/camera";
  75641. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75642. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75643. import { Engine } from "babylonjs/Engines/engine";
  75644. import { Scene } from "babylonjs/scene";
  75645. /**
  75646. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75647. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75648. */
  75649. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75650. /**
  75651. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75652. */
  75653. threshold: number;
  75654. /**
  75655. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75656. */
  75657. strength: number;
  75658. /**
  75659. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75660. */
  75661. reflectionSpecularFalloffExponent: number;
  75662. /**
  75663. * 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]
  75664. */
  75665. step: number;
  75666. /**
  75667. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75668. */
  75669. roughnessFactor: number;
  75670. private _forceGeometryBuffer;
  75671. private _geometryBufferRenderer;
  75672. private _prePassRenderer;
  75673. private _enableSmoothReflections;
  75674. private _reflectionSamples;
  75675. private _smoothSteps;
  75676. /**
  75677. * Gets a string identifying the name of the class
  75678. * @returns "ScreenSpaceReflectionPostProcess" string
  75679. */
  75680. getClassName(): string;
  75681. /**
  75682. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75683. * @param name The name of the effect.
  75684. * @param scene The scene containing the objects to calculate reflections.
  75685. * @param options The required width/height ratio to downsize to before computing the render pass.
  75686. * @param camera The camera to apply the render pass to.
  75687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75688. * @param engine The engine which the post process will be applied. (default: current engine)
  75689. * @param reusable If the post process can be reused on the same frame. (default: false)
  75690. * @param textureType Type of textures used when performing the post process. (default: 0)
  75691. * @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)
  75692. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75693. */
  75694. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75695. /**
  75696. * Gets wether or not smoothing reflections is enabled.
  75697. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75698. */
  75699. get enableSmoothReflections(): boolean;
  75700. /**
  75701. * Sets wether or not smoothing reflections is enabled.
  75702. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75703. */
  75704. set enableSmoothReflections(enabled: boolean);
  75705. /**
  75706. * Gets the number of samples taken while computing reflections. More samples count is high,
  75707. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75708. */
  75709. get reflectionSamples(): number;
  75710. /**
  75711. * Sets the number of samples taken while computing reflections. More samples count is high,
  75712. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75713. */
  75714. set reflectionSamples(samples: number);
  75715. /**
  75716. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75717. * more the post-process will require GPU power and can generate a drop in FPS.
  75718. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75719. */
  75720. get smoothSteps(): number;
  75721. set smoothSteps(steps: number);
  75722. private _updateEffectDefines;
  75723. /** @hidden */
  75724. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75725. }
  75726. }
  75727. declare module "babylonjs/Shaders/standard.fragment" {
  75728. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75729. /** @hidden */
  75730. export var standardPixelShader: {
  75731. name: string;
  75732. shader: string;
  75733. };
  75734. }
  75735. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75736. import { Nullable } from "babylonjs/types";
  75737. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75738. import { Camera } from "babylonjs/Cameras/camera";
  75739. import { Texture } from "babylonjs/Materials/Textures/texture";
  75740. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75741. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75742. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75743. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75744. import { IDisposable } from "babylonjs/scene";
  75745. import { SpotLight } from "babylonjs/Lights/spotLight";
  75746. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75747. import { Scene } from "babylonjs/scene";
  75748. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75749. import { Animation } from "babylonjs/Animations/animation";
  75750. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75751. import "babylonjs/Shaders/standard.fragment";
  75752. /**
  75753. * Standard rendering pipeline
  75754. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75755. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75756. */
  75757. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75758. /**
  75759. * Public members
  75760. */
  75761. /**
  75762. * Post-process which contains the original scene color before the pipeline applies all the effects
  75763. */
  75764. originalPostProcess: Nullable<PostProcess>;
  75765. /**
  75766. * Post-process used to down scale an image x4
  75767. */
  75768. downSampleX4PostProcess: Nullable<PostProcess>;
  75769. /**
  75770. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75771. */
  75772. brightPassPostProcess: Nullable<PostProcess>;
  75773. /**
  75774. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75775. */
  75776. blurHPostProcesses: PostProcess[];
  75777. /**
  75778. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75779. */
  75780. blurVPostProcesses: PostProcess[];
  75781. /**
  75782. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75783. */
  75784. textureAdderPostProcess: Nullable<PostProcess>;
  75785. /**
  75786. * Post-process used to create volumetric lighting effect
  75787. */
  75788. volumetricLightPostProcess: Nullable<PostProcess>;
  75789. /**
  75790. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75791. */
  75792. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75793. /**
  75794. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75795. */
  75796. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75797. /**
  75798. * Post-process used to merge the volumetric light effect and the real scene color
  75799. */
  75800. volumetricLightMergePostProces: Nullable<PostProcess>;
  75801. /**
  75802. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75803. */
  75804. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75805. /**
  75806. * Base post-process used to calculate the average luminance of the final image for HDR
  75807. */
  75808. luminancePostProcess: Nullable<PostProcess>;
  75809. /**
  75810. * Post-processes used to create down sample post-processes in order to get
  75811. * the average luminance of the final image for HDR
  75812. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75813. */
  75814. luminanceDownSamplePostProcesses: PostProcess[];
  75815. /**
  75816. * Post-process used to create a HDR effect (light adaptation)
  75817. */
  75818. hdrPostProcess: Nullable<PostProcess>;
  75819. /**
  75820. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75821. */
  75822. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75823. /**
  75824. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75825. */
  75826. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75827. /**
  75828. * Post-process used to merge the final HDR post-process and the real scene color
  75829. */
  75830. hdrFinalPostProcess: Nullable<PostProcess>;
  75831. /**
  75832. * Post-process used to create a lens flare effect
  75833. */
  75834. lensFlarePostProcess: Nullable<PostProcess>;
  75835. /**
  75836. * Post-process that merges the result of the lens flare post-process and the real scene color
  75837. */
  75838. lensFlareComposePostProcess: Nullable<PostProcess>;
  75839. /**
  75840. * Post-process used to create a motion blur effect
  75841. */
  75842. motionBlurPostProcess: Nullable<PostProcess>;
  75843. /**
  75844. * Post-process used to create a depth of field effect
  75845. */
  75846. depthOfFieldPostProcess: Nullable<PostProcess>;
  75847. /**
  75848. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75849. */
  75850. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75851. /**
  75852. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75853. */
  75854. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75855. /**
  75856. * Represents the brightness threshold in order to configure the illuminated surfaces
  75857. */
  75858. brightThreshold: number;
  75859. /**
  75860. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75861. */
  75862. blurWidth: number;
  75863. /**
  75864. * Sets if the blur for highlighted surfaces must be only horizontal
  75865. */
  75866. horizontalBlur: boolean;
  75867. /**
  75868. * Gets the overall exposure used by the pipeline
  75869. */
  75870. get exposure(): number;
  75871. /**
  75872. * Sets the overall exposure used by the pipeline
  75873. */
  75874. set exposure(value: number);
  75875. /**
  75876. * Texture used typically to simulate "dirty" on camera lens
  75877. */
  75878. lensTexture: Nullable<Texture>;
  75879. /**
  75880. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75881. */
  75882. volumetricLightCoefficient: number;
  75883. /**
  75884. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75885. */
  75886. volumetricLightPower: number;
  75887. /**
  75888. * Used the set the blur intensity to smooth the volumetric lights
  75889. */
  75890. volumetricLightBlurScale: number;
  75891. /**
  75892. * Light (spot or directional) used to generate the volumetric lights rays
  75893. * The source light must have a shadow generate so the pipeline can get its
  75894. * depth map
  75895. */
  75896. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75897. /**
  75898. * For eye adaptation, represents the minimum luminance the eye can see
  75899. */
  75900. hdrMinimumLuminance: number;
  75901. /**
  75902. * For eye adaptation, represents the decrease luminance speed
  75903. */
  75904. hdrDecreaseRate: number;
  75905. /**
  75906. * For eye adaptation, represents the increase luminance speed
  75907. */
  75908. hdrIncreaseRate: number;
  75909. /**
  75910. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75911. */
  75912. get hdrAutoExposure(): boolean;
  75913. /**
  75914. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75915. */
  75916. set hdrAutoExposure(value: boolean);
  75917. /**
  75918. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75919. */
  75920. lensColorTexture: Nullable<Texture>;
  75921. /**
  75922. * The overall strengh for the lens flare effect
  75923. */
  75924. lensFlareStrength: number;
  75925. /**
  75926. * Dispersion coefficient for lens flare ghosts
  75927. */
  75928. lensFlareGhostDispersal: number;
  75929. /**
  75930. * Main lens flare halo width
  75931. */
  75932. lensFlareHaloWidth: number;
  75933. /**
  75934. * Based on the lens distortion effect, defines how much the lens flare result
  75935. * is distorted
  75936. */
  75937. lensFlareDistortionStrength: number;
  75938. /**
  75939. * Configures the blur intensity used for for lens flare (halo)
  75940. */
  75941. lensFlareBlurWidth: number;
  75942. /**
  75943. * Lens star texture must be used to simulate rays on the flares and is available
  75944. * in the documentation
  75945. */
  75946. lensStarTexture: Nullable<Texture>;
  75947. /**
  75948. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75949. * flare effect by taking account of the dirt texture
  75950. */
  75951. lensFlareDirtTexture: Nullable<Texture>;
  75952. /**
  75953. * Represents the focal length for the depth of field effect
  75954. */
  75955. depthOfFieldDistance: number;
  75956. /**
  75957. * Represents the blur intensity for the blurred part of the depth of field effect
  75958. */
  75959. depthOfFieldBlurWidth: number;
  75960. /**
  75961. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75962. */
  75963. get motionStrength(): number;
  75964. /**
  75965. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75966. */
  75967. set motionStrength(strength: number);
  75968. /**
  75969. * Gets wether or not the motion blur post-process is object based or screen based.
  75970. */
  75971. get objectBasedMotionBlur(): boolean;
  75972. /**
  75973. * Sets wether or not the motion blur post-process should be object based or screen based
  75974. */
  75975. set objectBasedMotionBlur(value: boolean);
  75976. /**
  75977. * List of animations for the pipeline (IAnimatable implementation)
  75978. */
  75979. animations: Animation[];
  75980. /**
  75981. * Private members
  75982. */
  75983. private _scene;
  75984. private _currentDepthOfFieldSource;
  75985. private _basePostProcess;
  75986. private _fixedExposure;
  75987. private _currentExposure;
  75988. private _hdrAutoExposure;
  75989. private _hdrCurrentLuminance;
  75990. private _motionStrength;
  75991. private _isObjectBasedMotionBlur;
  75992. private _floatTextureType;
  75993. private _camerasToBeAttached;
  75994. private _ratio;
  75995. private _bloomEnabled;
  75996. private _depthOfFieldEnabled;
  75997. private _vlsEnabled;
  75998. private _lensFlareEnabled;
  75999. private _hdrEnabled;
  76000. private _motionBlurEnabled;
  76001. private _fxaaEnabled;
  76002. private _screenSpaceReflectionsEnabled;
  76003. private _motionBlurSamples;
  76004. private _volumetricLightStepsCount;
  76005. private _samples;
  76006. /**
  76007. * @ignore
  76008. * Specifies if the bloom pipeline is enabled
  76009. */
  76010. get BloomEnabled(): boolean;
  76011. set BloomEnabled(enabled: boolean);
  76012. /**
  76013. * @ignore
  76014. * Specifies if the depth of field pipeline is enabed
  76015. */
  76016. get DepthOfFieldEnabled(): boolean;
  76017. set DepthOfFieldEnabled(enabled: boolean);
  76018. /**
  76019. * @ignore
  76020. * Specifies if the lens flare pipeline is enabed
  76021. */
  76022. get LensFlareEnabled(): boolean;
  76023. set LensFlareEnabled(enabled: boolean);
  76024. /**
  76025. * @ignore
  76026. * Specifies if the HDR pipeline is enabled
  76027. */
  76028. get HDREnabled(): boolean;
  76029. set HDREnabled(enabled: boolean);
  76030. /**
  76031. * @ignore
  76032. * Specifies if the volumetric lights scattering effect is enabled
  76033. */
  76034. get VLSEnabled(): boolean;
  76035. set VLSEnabled(enabled: boolean);
  76036. /**
  76037. * @ignore
  76038. * Specifies if the motion blur effect is enabled
  76039. */
  76040. get MotionBlurEnabled(): boolean;
  76041. set MotionBlurEnabled(enabled: boolean);
  76042. /**
  76043. * Specifies if anti-aliasing is enabled
  76044. */
  76045. get fxaaEnabled(): boolean;
  76046. set fxaaEnabled(enabled: boolean);
  76047. /**
  76048. * Specifies if screen space reflections are enabled.
  76049. */
  76050. get screenSpaceReflectionsEnabled(): boolean;
  76051. set screenSpaceReflectionsEnabled(enabled: boolean);
  76052. /**
  76053. * Specifies the number of steps used to calculate the volumetric lights
  76054. * Typically in interval [50, 200]
  76055. */
  76056. get volumetricLightStepsCount(): number;
  76057. set volumetricLightStepsCount(count: number);
  76058. /**
  76059. * Specifies the number of samples used for the motion blur effect
  76060. * Typically in interval [16, 64]
  76061. */
  76062. get motionBlurSamples(): number;
  76063. set motionBlurSamples(samples: number);
  76064. /**
  76065. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76066. */
  76067. get samples(): number;
  76068. set samples(sampleCount: number);
  76069. /**
  76070. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76071. * @constructor
  76072. * @param name The rendering pipeline name
  76073. * @param scene The scene linked to this pipeline
  76074. * @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)
  76075. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76076. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76077. */
  76078. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76079. private _buildPipeline;
  76080. private _createDownSampleX4PostProcess;
  76081. private _createBrightPassPostProcess;
  76082. private _createBlurPostProcesses;
  76083. private _createTextureAdderPostProcess;
  76084. private _createVolumetricLightPostProcess;
  76085. private _createLuminancePostProcesses;
  76086. private _createHdrPostProcess;
  76087. private _createLensFlarePostProcess;
  76088. private _createDepthOfFieldPostProcess;
  76089. private _createMotionBlurPostProcess;
  76090. private _getDepthTexture;
  76091. private _disposePostProcesses;
  76092. /**
  76093. * Dispose of the pipeline and stop all post processes
  76094. */
  76095. dispose(): void;
  76096. /**
  76097. * Serialize the rendering pipeline (Used when exporting)
  76098. * @returns the serialized object
  76099. */
  76100. serialize(): any;
  76101. /**
  76102. * Parse the serialized pipeline
  76103. * @param source Source pipeline.
  76104. * @param scene The scene to load the pipeline to.
  76105. * @param rootUrl The URL of the serialized pipeline.
  76106. * @returns An instantiated pipeline from the serialized object.
  76107. */
  76108. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76109. /**
  76110. * Luminance steps
  76111. */
  76112. static LuminanceSteps: number;
  76113. }
  76114. }
  76115. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  76116. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  76117. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  76118. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  76119. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  76120. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  76121. }
  76122. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  76123. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  76124. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  76125. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76126. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  76127. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76128. }
  76129. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  76130. /** @hidden */
  76131. export var stereoscopicInterlacePixelShader: {
  76132. name: string;
  76133. shader: string;
  76134. };
  76135. }
  76136. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  76137. import { Camera } from "babylonjs/Cameras/camera";
  76138. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76139. import { Engine } from "babylonjs/Engines/engine";
  76140. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  76141. /**
  76142. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  76143. */
  76144. export class StereoscopicInterlacePostProcessI extends PostProcess {
  76145. private _stepSize;
  76146. private _passedProcess;
  76147. /**
  76148. * Gets a string identifying the name of the class
  76149. * @returns "StereoscopicInterlacePostProcessI" string
  76150. */
  76151. getClassName(): string;
  76152. /**
  76153. * Initializes a StereoscopicInterlacePostProcessI
  76154. * @param name The name of the effect.
  76155. * @param rigCameras The rig cameras to be appled to the post process
  76156. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  76157. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  76158. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76159. * @param engine The engine which the post process will be applied. (default: current engine)
  76160. * @param reusable If the post process can be reused on the same frame. (default: false)
  76161. */
  76162. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76163. }
  76164. /**
  76165. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  76166. */
  76167. export class StereoscopicInterlacePostProcess extends PostProcess {
  76168. private _stepSize;
  76169. private _passedProcess;
  76170. /**
  76171. * Gets a string identifying the name of the class
  76172. * @returns "StereoscopicInterlacePostProcess" string
  76173. */
  76174. getClassName(): string;
  76175. /**
  76176. * Initializes a StereoscopicInterlacePostProcess
  76177. * @param name The name of the effect.
  76178. * @param rigCameras The rig cameras to be appled to the post process
  76179. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  76180. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76181. * @param engine The engine which the post process will be applied. (default: current engine)
  76182. * @param reusable If the post process can be reused on the same frame. (default: false)
  76183. */
  76184. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76185. }
  76186. }
  76187. declare module "babylonjs/Shaders/tonemap.fragment" {
  76188. /** @hidden */
  76189. export var tonemapPixelShader: {
  76190. name: string;
  76191. shader: string;
  76192. };
  76193. }
  76194. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  76195. import { Camera } from "babylonjs/Cameras/camera";
  76196. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76197. import "babylonjs/Shaders/tonemap.fragment";
  76198. import { Engine } from "babylonjs/Engines/engine";
  76199. /** Defines operator used for tonemapping */
  76200. export enum TonemappingOperator {
  76201. /** Hable */
  76202. Hable = 0,
  76203. /** Reinhard */
  76204. Reinhard = 1,
  76205. /** HejiDawson */
  76206. HejiDawson = 2,
  76207. /** Photographic */
  76208. Photographic = 3
  76209. }
  76210. /**
  76211. * Defines a post process to apply tone mapping
  76212. */
  76213. export class TonemapPostProcess extends PostProcess {
  76214. private _operator;
  76215. /** Defines the required exposure adjustement */
  76216. exposureAdjustment: number;
  76217. /**
  76218. * Gets a string identifying the name of the class
  76219. * @returns "TonemapPostProcess" string
  76220. */
  76221. getClassName(): string;
  76222. /**
  76223. * Creates a new TonemapPostProcess
  76224. * @param name defines the name of the postprocess
  76225. * @param _operator defines the operator to use
  76226. * @param exposureAdjustment defines the required exposure adjustement
  76227. * @param camera defines the camera to use (can be null)
  76228. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76229. * @param engine defines the hosting engine (can be ignore if camera is set)
  76230. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76231. */
  76232. constructor(name: string, _operator: TonemappingOperator,
  76233. /** Defines the required exposure adjustement */
  76234. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76235. }
  76236. }
  76237. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  76238. /** @hidden */
  76239. export var volumetricLightScatteringPixelShader: {
  76240. name: string;
  76241. shader: string;
  76242. };
  76243. }
  76244. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  76245. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76246. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76247. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76248. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76249. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76250. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76251. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76252. /** @hidden */
  76253. export var volumetricLightScatteringPassVertexShader: {
  76254. name: string;
  76255. shader: string;
  76256. };
  76257. }
  76258. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  76259. /** @hidden */
  76260. export var volumetricLightScatteringPassPixelShader: {
  76261. name: string;
  76262. shader: string;
  76263. };
  76264. }
  76265. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  76266. import { Vector3 } from "babylonjs/Maths/math.vector";
  76267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76268. import { Mesh } from "babylonjs/Meshes/mesh";
  76269. import { Camera } from "babylonjs/Cameras/camera";
  76270. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  76271. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76272. import { Scene } from "babylonjs/scene";
  76273. import "babylonjs/Meshes/Builders/planeBuilder";
  76274. import "babylonjs/Shaders/depth.vertex";
  76275. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  76276. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  76277. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  76278. import { Engine } from "babylonjs/Engines/engine";
  76279. /**
  76280. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76281. */
  76282. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76283. private _volumetricLightScatteringPass;
  76284. private _volumetricLightScatteringRTT;
  76285. private _viewPort;
  76286. private _screenCoordinates;
  76287. private _cachedDefines;
  76288. /**
  76289. * If not undefined, the mesh position is computed from the attached node position
  76290. */
  76291. attachedNode: {
  76292. position: Vector3;
  76293. };
  76294. /**
  76295. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76296. */
  76297. customMeshPosition: Vector3;
  76298. /**
  76299. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76300. */
  76301. useCustomMeshPosition: boolean;
  76302. /**
  76303. * If the post-process should inverse the light scattering direction
  76304. */
  76305. invert: boolean;
  76306. /**
  76307. * The internal mesh used by the post-process
  76308. */
  76309. mesh: Mesh;
  76310. /**
  76311. * @hidden
  76312. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76313. */
  76314. get useDiffuseColor(): boolean;
  76315. set useDiffuseColor(useDiffuseColor: boolean);
  76316. /**
  76317. * Array containing the excluded meshes not rendered in the internal pass
  76318. */
  76319. excludedMeshes: AbstractMesh[];
  76320. /**
  76321. * Controls the overall intensity of the post-process
  76322. */
  76323. exposure: number;
  76324. /**
  76325. * Dissipates each sample's contribution in range [0, 1]
  76326. */
  76327. decay: number;
  76328. /**
  76329. * Controls the overall intensity of each sample
  76330. */
  76331. weight: number;
  76332. /**
  76333. * Controls the density of each sample
  76334. */
  76335. density: number;
  76336. /**
  76337. * @constructor
  76338. * @param name The post-process name
  76339. * @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)
  76340. * @param camera The camera that the post-process will be attached to
  76341. * @param mesh The mesh used to create the light scattering
  76342. * @param samples The post-process quality, default 100
  76343. * @param samplingModeThe post-process filtering mode
  76344. * @param engine The babylon engine
  76345. * @param reusable If the post-process is reusable
  76346. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76347. */
  76348. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76349. /**
  76350. * Returns the string "VolumetricLightScatteringPostProcess"
  76351. * @returns "VolumetricLightScatteringPostProcess"
  76352. */
  76353. getClassName(): string;
  76354. private _isReady;
  76355. /**
  76356. * Sets the new light position for light scattering effect
  76357. * @param position The new custom light position
  76358. */
  76359. setCustomMeshPosition(position: Vector3): void;
  76360. /**
  76361. * Returns the light position for light scattering effect
  76362. * @return Vector3 The custom light position
  76363. */
  76364. getCustomMeshPosition(): Vector3;
  76365. /**
  76366. * Disposes the internal assets and detaches the post-process from the camera
  76367. */
  76368. dispose(camera: Camera): void;
  76369. /**
  76370. * Returns the render target texture used by the post-process
  76371. * @return the render target texture used by the post-process
  76372. */
  76373. getPass(): RenderTargetTexture;
  76374. private _meshExcluded;
  76375. private _createPass;
  76376. private _updateMeshScreenCoordinates;
  76377. /**
  76378. * Creates a default mesh for the Volumeric Light Scattering post-process
  76379. * @param name The mesh name
  76380. * @param scene The scene where to create the mesh
  76381. * @return the default mesh
  76382. */
  76383. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76384. }
  76385. }
  76386. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  76387. /** @hidden */
  76388. export var screenSpaceCurvaturePixelShader: {
  76389. name: string;
  76390. shader: string;
  76391. };
  76392. }
  76393. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  76394. import { Nullable } from "babylonjs/types";
  76395. import { Camera } from "babylonjs/Cameras/camera";
  76396. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76397. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76398. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  76399. import { Engine } from "babylonjs/Engines/engine";
  76400. import { Scene } from "babylonjs/scene";
  76401. /**
  76402. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76403. */
  76404. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76405. /**
  76406. * Defines how much ridge the curvature effect displays.
  76407. */
  76408. ridge: number;
  76409. /**
  76410. * Defines how much valley the curvature effect displays.
  76411. */
  76412. valley: number;
  76413. private _geometryBufferRenderer;
  76414. /**
  76415. * Gets a string identifying the name of the class
  76416. * @returns "ScreenSpaceCurvaturePostProcess" string
  76417. */
  76418. getClassName(): string;
  76419. /**
  76420. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76421. * @param name The name of the effect.
  76422. * @param scene The scene containing the objects to blur according to their velocity.
  76423. * @param options The required width/height ratio to downsize to before computing the render pass.
  76424. * @param camera The camera to apply the render pass to.
  76425. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76426. * @param engine The engine which the post process will be applied. (default: current engine)
  76427. * @param reusable If the post process can be reused on the same frame. (default: false)
  76428. * @param textureType Type of textures used when performing the post process. (default: 0)
  76429. * @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)
  76430. */
  76431. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76432. /**
  76433. * Support test.
  76434. */
  76435. static get IsSupported(): boolean;
  76436. /** @hidden */
  76437. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76438. }
  76439. }
  76440. declare module "babylonjs/PostProcesses/index" {
  76441. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  76442. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  76443. export * from "babylonjs/PostProcesses/bloomEffect";
  76444. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  76445. export * from "babylonjs/PostProcesses/blurPostProcess";
  76446. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  76447. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  76448. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  76449. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  76450. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  76451. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  76452. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  76453. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  76454. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  76455. export * from "babylonjs/PostProcesses/filterPostProcess";
  76456. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  76457. export * from "babylonjs/PostProcesses/grainPostProcess";
  76458. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  76459. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  76460. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  76461. export * from "babylonjs/PostProcesses/passPostProcess";
  76462. export * from "babylonjs/PostProcesses/postProcess";
  76463. export * from "babylonjs/PostProcesses/postProcessManager";
  76464. export * from "babylonjs/PostProcesses/refractionPostProcess";
  76465. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  76466. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  76467. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  76468. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  76469. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  76470. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  76471. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  76472. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76473. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  76474. }
  76475. declare module "babylonjs/Probes/index" {
  76476. export * from "babylonjs/Probes/reflectionProbe";
  76477. }
  76478. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  76479. import { Scene } from "babylonjs/scene";
  76480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76481. import { SmartArray } from "babylonjs/Misc/smartArray";
  76482. import { ISceneComponent } from "babylonjs/sceneComponent";
  76483. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  76484. import "babylonjs/Meshes/Builders/boxBuilder";
  76485. import "babylonjs/Shaders/color.fragment";
  76486. import "babylonjs/Shaders/color.vertex";
  76487. import { Color3 } from "babylonjs/Maths/math.color";
  76488. import { Observable } from "babylonjs/Misc/observable";
  76489. module "babylonjs/scene" {
  76490. interface Scene {
  76491. /** @hidden (Backing field) */
  76492. _boundingBoxRenderer: BoundingBoxRenderer;
  76493. /** @hidden (Backing field) */
  76494. _forceShowBoundingBoxes: boolean;
  76495. /**
  76496. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76497. */
  76498. forceShowBoundingBoxes: boolean;
  76499. /**
  76500. * Gets the bounding box renderer associated with the scene
  76501. * @returns a BoundingBoxRenderer
  76502. */
  76503. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76504. }
  76505. }
  76506. module "babylonjs/Meshes/abstractMesh" {
  76507. interface AbstractMesh {
  76508. /** @hidden (Backing field) */
  76509. _showBoundingBox: boolean;
  76510. /**
  76511. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76512. */
  76513. showBoundingBox: boolean;
  76514. }
  76515. }
  76516. /**
  76517. * Component responsible of rendering the bounding box of the meshes in a scene.
  76518. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76519. */
  76520. export class BoundingBoxRenderer implements ISceneComponent {
  76521. /**
  76522. * The component name helpfull to identify the component in the list of scene components.
  76523. */
  76524. readonly name: string;
  76525. /**
  76526. * The scene the component belongs to.
  76527. */
  76528. scene: Scene;
  76529. /**
  76530. * Color of the bounding box lines placed in front of an object
  76531. */
  76532. frontColor: Color3;
  76533. /**
  76534. * Color of the bounding box lines placed behind an object
  76535. */
  76536. backColor: Color3;
  76537. /**
  76538. * Defines if the renderer should show the back lines or not
  76539. */
  76540. showBackLines: boolean;
  76541. /**
  76542. * Observable raised before rendering a bounding box
  76543. */
  76544. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76545. /**
  76546. * Observable raised after rendering a bounding box
  76547. */
  76548. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76549. /**
  76550. * When false, no bounding boxes will be rendered
  76551. */
  76552. enabled: boolean;
  76553. /**
  76554. * @hidden
  76555. */
  76556. renderList: SmartArray<BoundingBox>;
  76557. private _colorShader;
  76558. private _vertexBuffers;
  76559. private _indexBuffer;
  76560. private _fillIndexBuffer;
  76561. private _fillIndexData;
  76562. /**
  76563. * Instantiates a new bounding box renderer in a scene.
  76564. * @param scene the scene the renderer renders in
  76565. */
  76566. constructor(scene: Scene);
  76567. /**
  76568. * Registers the component in a given scene
  76569. */
  76570. register(): void;
  76571. private _evaluateSubMesh;
  76572. private _preActiveMesh;
  76573. private _prepareRessources;
  76574. private _createIndexBuffer;
  76575. /**
  76576. * Rebuilds the elements related to this component in case of
  76577. * context lost for instance.
  76578. */
  76579. rebuild(): void;
  76580. /**
  76581. * @hidden
  76582. */
  76583. reset(): void;
  76584. /**
  76585. * Render the bounding boxes of a specific rendering group
  76586. * @param renderingGroupId defines the rendering group to render
  76587. */
  76588. render(renderingGroupId: number): void;
  76589. /**
  76590. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76591. * @param mesh Define the mesh to render the occlusion bounding box for
  76592. */
  76593. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76594. /**
  76595. * Dispose and release the resources attached to this renderer.
  76596. */
  76597. dispose(): void;
  76598. }
  76599. }
  76600. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76601. import { Nullable } from "babylonjs/types";
  76602. import { Scene } from "babylonjs/scene";
  76603. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76604. import { Camera } from "babylonjs/Cameras/camera";
  76605. import { ISceneComponent } from "babylonjs/sceneComponent";
  76606. module "babylonjs/scene" {
  76607. interface Scene {
  76608. /** @hidden (Backing field) */
  76609. _depthRenderer: {
  76610. [id: string]: DepthRenderer;
  76611. };
  76612. /**
  76613. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76614. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76615. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76616. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76617. * @returns the created depth renderer
  76618. */
  76619. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76620. /**
  76621. * Disables a depth renderer for a given camera
  76622. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76623. */
  76624. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76625. }
  76626. }
  76627. /**
  76628. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76629. * in several rendering techniques.
  76630. */
  76631. export class DepthRendererSceneComponent implements ISceneComponent {
  76632. /**
  76633. * The component name helpfull to identify the component in the list of scene components.
  76634. */
  76635. readonly name: string;
  76636. /**
  76637. * The scene the component belongs to.
  76638. */
  76639. scene: Scene;
  76640. /**
  76641. * Creates a new instance of the component for the given scene
  76642. * @param scene Defines the scene to register the component in
  76643. */
  76644. constructor(scene: Scene);
  76645. /**
  76646. * Registers the component in a given scene
  76647. */
  76648. register(): void;
  76649. /**
  76650. * Rebuilds the elements related to this component in case of
  76651. * context lost for instance.
  76652. */
  76653. rebuild(): void;
  76654. /**
  76655. * Disposes the component and the associated ressources
  76656. */
  76657. dispose(): void;
  76658. private _gatherRenderTargets;
  76659. private _gatherActiveCameraRenderTargets;
  76660. }
  76661. }
  76662. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76663. import { Nullable } from "babylonjs/types";
  76664. import { Scene } from "babylonjs/scene";
  76665. import { ISceneComponent } from "babylonjs/sceneComponent";
  76666. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76667. module "babylonjs/abstractScene" {
  76668. interface AbstractScene {
  76669. /** @hidden (Backing field) */
  76670. _prePassRenderer: Nullable<PrePassRenderer>;
  76671. /**
  76672. * Gets or Sets the current prepass renderer associated to the scene.
  76673. */
  76674. prePassRenderer: Nullable<PrePassRenderer>;
  76675. /**
  76676. * Enables the prepass and associates it with the scene
  76677. * @returns the PrePassRenderer
  76678. */
  76679. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76680. /**
  76681. * Disables the prepass associated with the scene
  76682. */
  76683. disablePrePassRenderer(): void;
  76684. }
  76685. }
  76686. /**
  76687. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76688. * in several rendering techniques.
  76689. */
  76690. export class PrePassRendererSceneComponent implements ISceneComponent {
  76691. /**
  76692. * The component name helpful to identify the component in the list of scene components.
  76693. */
  76694. readonly name: string;
  76695. /**
  76696. * The scene the component belongs to.
  76697. */
  76698. scene: Scene;
  76699. /**
  76700. * Creates a new instance of the component for the given scene
  76701. * @param scene Defines the scene to register the component in
  76702. */
  76703. constructor(scene: Scene);
  76704. /**
  76705. * Registers the component in a given scene
  76706. */
  76707. register(): void;
  76708. private _beforeCameraDraw;
  76709. private _afterCameraDraw;
  76710. private _beforeClearStage;
  76711. /**
  76712. * Rebuilds the elements related to this component in case of
  76713. * context lost for instance.
  76714. */
  76715. rebuild(): void;
  76716. /**
  76717. * Disposes the component and the associated ressources
  76718. */
  76719. dispose(): void;
  76720. }
  76721. }
  76722. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  76723. /** @hidden */
  76724. export var fibonacci: {
  76725. name: string;
  76726. shader: string;
  76727. };
  76728. }
  76729. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  76730. /** @hidden */
  76731. export var diffusionProfile: {
  76732. name: string;
  76733. shader: string;
  76734. };
  76735. }
  76736. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  76737. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  76738. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  76739. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  76740. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  76741. /** @hidden */
  76742. export var subSurfaceScatteringPixelShader: {
  76743. name: string;
  76744. shader: string;
  76745. };
  76746. }
  76747. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  76748. import { Nullable } from "babylonjs/types";
  76749. import { Camera } from "babylonjs/Cameras/camera";
  76750. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76751. import { Engine } from "babylonjs/Engines/engine";
  76752. import { Scene } from "babylonjs/scene";
  76753. import "babylonjs/Shaders/imageProcessing.fragment";
  76754. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  76755. import "babylonjs/Shaders/postprocess.vertex";
  76756. /**
  76757. * Sub surface scattering post process
  76758. */
  76759. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76760. /**
  76761. * Gets a string identifying the name of the class
  76762. * @returns "SubSurfaceScatteringPostProcess" string
  76763. */
  76764. getClassName(): string;
  76765. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76766. }
  76767. }
  76768. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  76769. import { Scene } from "babylonjs/scene";
  76770. import { Color3 } from "babylonjs/Maths/math.color";
  76771. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  76772. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76773. /**
  76774. * Contains all parameters needed for the prepass to perform
  76775. * screen space subsurface scattering
  76776. */
  76777. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76778. /** @hidden */
  76779. static _SceneComponentInitialization: (scene: Scene) => void;
  76780. private _ssDiffusionS;
  76781. private _ssFilterRadii;
  76782. private _ssDiffusionD;
  76783. /**
  76784. * Post process to attach for screen space subsurface scattering
  76785. */
  76786. postProcess: SubSurfaceScatteringPostProcess;
  76787. /**
  76788. * Diffusion profile color for subsurface scattering
  76789. */
  76790. get ssDiffusionS(): number[];
  76791. /**
  76792. * Diffusion profile max color channel value for subsurface scattering
  76793. */
  76794. get ssDiffusionD(): number[];
  76795. /**
  76796. * Diffusion profile filter radius for subsurface scattering
  76797. */
  76798. get ssFilterRadii(): number[];
  76799. /**
  76800. * Is subsurface enabled
  76801. */
  76802. enabled: boolean;
  76803. /**
  76804. * Name of the configuration
  76805. */
  76806. name: string;
  76807. /**
  76808. * Diffusion profile colors for subsurface scattering
  76809. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76810. * See ...
  76811. * Note that you can only store up to 5 of them
  76812. */
  76813. ssDiffusionProfileColors: Color3[];
  76814. /**
  76815. * Defines the ratio real world => scene units.
  76816. * Used for subsurface scattering
  76817. */
  76818. metersPerUnit: number;
  76819. /**
  76820. * Textures that should be present in the MRT for this effect to work
  76821. */
  76822. readonly texturesRequired: number[];
  76823. private _scene;
  76824. /**
  76825. * Builds a subsurface configuration object
  76826. * @param scene The scene
  76827. */
  76828. constructor(scene: Scene);
  76829. /**
  76830. * Adds a new diffusion profile.
  76831. * Useful for more realistic subsurface scattering on diverse materials.
  76832. * @param color The color of the diffusion profile. Should be the average color of the material.
  76833. * @return The index of the diffusion profile for the material subsurface configuration
  76834. */
  76835. addDiffusionProfile(color: Color3): number;
  76836. /**
  76837. * Creates the sss post process
  76838. * @return The created post process
  76839. */
  76840. createPostProcess(): SubSurfaceScatteringPostProcess;
  76841. /**
  76842. * Deletes all diffusion profiles.
  76843. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76844. */
  76845. clearAllDiffusionProfiles(): void;
  76846. /**
  76847. * Disposes this object
  76848. */
  76849. dispose(): void;
  76850. /**
  76851. * @hidden
  76852. * https://zero-radiance.github.io/post/sampling-diffusion/
  76853. *
  76854. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76855. * ------------------------------------------------------------------------------------
  76856. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76857. * PDF[r, phi, s] = r * R[r, phi, s]
  76858. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76859. * ------------------------------------------------------------------------------------
  76860. * We importance sample the color channel with the widest scattering distance.
  76861. */
  76862. getDiffusionProfileParameters(color: Color3): number;
  76863. /**
  76864. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76865. * 'u' is the random number (the value of the CDF): [0, 1).
  76866. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76867. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76868. */
  76869. private _sampleBurleyDiffusionProfile;
  76870. }
  76871. }
  76872. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  76873. import { Nullable } from "babylonjs/types";
  76874. import { Scene } from "babylonjs/scene";
  76875. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76876. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  76877. import { AbstractScene } from "babylonjs/abstractScene";
  76878. module "babylonjs/abstractScene" {
  76879. interface AbstractScene {
  76880. /** @hidden (Backing field) */
  76881. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76882. /**
  76883. * Gets or Sets the current prepass renderer associated to the scene.
  76884. */
  76885. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76886. /**
  76887. * Enables the subsurface effect for prepass
  76888. * @returns the SubSurfaceConfiguration
  76889. */
  76890. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76891. /**
  76892. * Disables the subsurface effect for prepass
  76893. */
  76894. disableSubSurfaceForPrePass(): void;
  76895. }
  76896. }
  76897. /**
  76898. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76899. * in several rendering techniques.
  76900. */
  76901. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76902. /**
  76903. * The component name helpful to identify the component in the list of scene components.
  76904. */
  76905. readonly name: string;
  76906. /**
  76907. * The scene the component belongs to.
  76908. */
  76909. scene: Scene;
  76910. /**
  76911. * Creates a new instance of the component for the given scene
  76912. * @param scene Defines the scene to register the component in
  76913. */
  76914. constructor(scene: Scene);
  76915. /**
  76916. * Registers the component in a given scene
  76917. */
  76918. register(): void;
  76919. /**
  76920. * Serializes the component data to the specified json object
  76921. * @param serializationObject The object to serialize to
  76922. */
  76923. serialize(serializationObject: any): void;
  76924. /**
  76925. * Adds all the elements from the container to the scene
  76926. * @param container the container holding the elements
  76927. */
  76928. addFromContainer(container: AbstractScene): void;
  76929. /**
  76930. * Removes all the elements in the container from the scene
  76931. * @param container contains the elements to remove
  76932. * @param dispose if the removed element should be disposed (default: false)
  76933. */
  76934. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76935. /**
  76936. * Rebuilds the elements related to this component in case of
  76937. * context lost for instance.
  76938. */
  76939. rebuild(): void;
  76940. /**
  76941. * Disposes the component and the associated ressources
  76942. */
  76943. dispose(): void;
  76944. }
  76945. }
  76946. declare module "babylonjs/Shaders/outline.fragment" {
  76947. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76948. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76949. /** @hidden */
  76950. export var outlinePixelShader: {
  76951. name: string;
  76952. shader: string;
  76953. };
  76954. }
  76955. declare module "babylonjs/Shaders/outline.vertex" {
  76956. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76957. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76958. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76959. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76960. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76961. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76962. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76963. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76964. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76965. /** @hidden */
  76966. export var outlineVertexShader: {
  76967. name: string;
  76968. shader: string;
  76969. };
  76970. }
  76971. declare module "babylonjs/Rendering/outlineRenderer" {
  76972. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76973. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76974. import { Scene } from "babylonjs/scene";
  76975. import { ISceneComponent } from "babylonjs/sceneComponent";
  76976. import "babylonjs/Shaders/outline.fragment";
  76977. import "babylonjs/Shaders/outline.vertex";
  76978. module "babylonjs/scene" {
  76979. interface Scene {
  76980. /** @hidden */
  76981. _outlineRenderer: OutlineRenderer;
  76982. /**
  76983. * Gets the outline renderer associated with the scene
  76984. * @returns a OutlineRenderer
  76985. */
  76986. getOutlineRenderer(): OutlineRenderer;
  76987. }
  76988. }
  76989. module "babylonjs/Meshes/abstractMesh" {
  76990. interface AbstractMesh {
  76991. /** @hidden (Backing field) */
  76992. _renderOutline: boolean;
  76993. /**
  76994. * Gets or sets a boolean indicating if the outline must be rendered as well
  76995. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76996. */
  76997. renderOutline: boolean;
  76998. /** @hidden (Backing field) */
  76999. _renderOverlay: boolean;
  77000. /**
  77001. * Gets or sets a boolean indicating if the overlay must be rendered as well
  77002. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  77003. */
  77004. renderOverlay: boolean;
  77005. }
  77006. }
  77007. /**
  77008. * This class is responsible to draw bothe outline/overlay of meshes.
  77009. * It should not be used directly but through the available method on mesh.
  77010. */
  77011. export class OutlineRenderer implements ISceneComponent {
  77012. /**
  77013. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  77014. */
  77015. private static _StencilReference;
  77016. /**
  77017. * The name of the component. Each component must have a unique name.
  77018. */
  77019. name: string;
  77020. /**
  77021. * The scene the component belongs to.
  77022. */
  77023. scene: Scene;
  77024. /**
  77025. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  77026. */
  77027. zOffset: number;
  77028. private _engine;
  77029. private _effect;
  77030. private _cachedDefines;
  77031. private _savedDepthWrite;
  77032. /**
  77033. * Instantiates a new outline renderer. (There could be only one per scene).
  77034. * @param scene Defines the scene it belongs to
  77035. */
  77036. constructor(scene: Scene);
  77037. /**
  77038. * Register the component to one instance of a scene.
  77039. */
  77040. register(): void;
  77041. /**
  77042. * Rebuilds the elements related to this component in case of
  77043. * context lost for instance.
  77044. */
  77045. rebuild(): void;
  77046. /**
  77047. * Disposes the component and the associated ressources.
  77048. */
  77049. dispose(): void;
  77050. /**
  77051. * Renders the outline in the canvas.
  77052. * @param subMesh Defines the sumesh to render
  77053. * @param batch Defines the batch of meshes in case of instances
  77054. * @param useOverlay Defines if the rendering is for the overlay or the outline
  77055. */
  77056. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  77057. /**
  77058. * Returns whether or not the outline renderer is ready for a given submesh.
  77059. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  77060. * @param subMesh Defines the submesh to check readyness for
  77061. * @param useInstances Defines wheter wee are trying to render instances or not
  77062. * @returns true if ready otherwise false
  77063. */
  77064. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77065. private _beforeRenderingMesh;
  77066. private _afterRenderingMesh;
  77067. }
  77068. }
  77069. declare module "babylonjs/Rendering/index" {
  77070. export * from "babylonjs/Rendering/boundingBoxRenderer";
  77071. export * from "babylonjs/Rendering/depthRenderer";
  77072. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  77073. export * from "babylonjs/Rendering/edgesRenderer";
  77074. export * from "babylonjs/Rendering/geometryBufferRenderer";
  77075. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  77076. export * from "babylonjs/Rendering/prePassRenderer";
  77077. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  77078. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  77079. export * from "babylonjs/Rendering/outlineRenderer";
  77080. export * from "babylonjs/Rendering/renderingGroup";
  77081. export * from "babylonjs/Rendering/renderingManager";
  77082. export * from "babylonjs/Rendering/utilityLayerRenderer";
  77083. }
  77084. declare module "babylonjs/Sprites/ISprites" {
  77085. /**
  77086. * Defines the basic options interface of a Sprite Frame Source Size.
  77087. */
  77088. export interface ISpriteJSONSpriteSourceSize {
  77089. /**
  77090. * number of the original width of the Frame
  77091. */
  77092. w: number;
  77093. /**
  77094. * number of the original height of the Frame
  77095. */
  77096. h: number;
  77097. }
  77098. /**
  77099. * Defines the basic options interface of a Sprite Frame Data.
  77100. */
  77101. export interface ISpriteJSONSpriteFrameData {
  77102. /**
  77103. * number of the x offset of the Frame
  77104. */
  77105. x: number;
  77106. /**
  77107. * number of the y offset of the Frame
  77108. */
  77109. y: number;
  77110. /**
  77111. * number of the width of the Frame
  77112. */
  77113. w: number;
  77114. /**
  77115. * number of the height of the Frame
  77116. */
  77117. h: number;
  77118. }
  77119. /**
  77120. * Defines the basic options interface of a JSON Sprite.
  77121. */
  77122. export interface ISpriteJSONSprite {
  77123. /**
  77124. * string name of the Frame
  77125. */
  77126. filename: string;
  77127. /**
  77128. * ISpriteJSONSpriteFrame basic object of the frame data
  77129. */
  77130. frame: ISpriteJSONSpriteFrameData;
  77131. /**
  77132. * boolean to flag is the frame was rotated.
  77133. */
  77134. rotated: boolean;
  77135. /**
  77136. * boolean to flag is the frame was trimmed.
  77137. */
  77138. trimmed: boolean;
  77139. /**
  77140. * ISpriteJSONSpriteFrame basic object of the source data
  77141. */
  77142. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77143. /**
  77144. * ISpriteJSONSpriteFrame basic object of the source data
  77145. */
  77146. sourceSize: ISpriteJSONSpriteSourceSize;
  77147. }
  77148. /**
  77149. * Defines the basic options interface of a JSON atlas.
  77150. */
  77151. export interface ISpriteJSONAtlas {
  77152. /**
  77153. * Array of objects that contain the frame data.
  77154. */
  77155. frames: Array<ISpriteJSONSprite>;
  77156. /**
  77157. * object basic object containing the sprite meta data.
  77158. */
  77159. meta?: object;
  77160. }
  77161. }
  77162. declare module "babylonjs/Shaders/spriteMap.fragment" {
  77163. /** @hidden */
  77164. export var spriteMapPixelShader: {
  77165. name: string;
  77166. shader: string;
  77167. };
  77168. }
  77169. declare module "babylonjs/Shaders/spriteMap.vertex" {
  77170. /** @hidden */
  77171. export var spriteMapVertexShader: {
  77172. name: string;
  77173. shader: string;
  77174. };
  77175. }
  77176. declare module "babylonjs/Sprites/spriteMap" {
  77177. import { IDisposable, Scene } from "babylonjs/scene";
  77178. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  77179. import { Texture } from "babylonjs/Materials/Textures/texture";
  77180. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  77181. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  77182. import "babylonjs/Meshes/Builders/planeBuilder";
  77183. import "babylonjs/Shaders/spriteMap.fragment";
  77184. import "babylonjs/Shaders/spriteMap.vertex";
  77185. /**
  77186. * Defines the basic options interface of a SpriteMap
  77187. */
  77188. export interface ISpriteMapOptions {
  77189. /**
  77190. * Vector2 of the number of cells in the grid.
  77191. */
  77192. stageSize?: Vector2;
  77193. /**
  77194. * Vector2 of the size of the output plane in World Units.
  77195. */
  77196. outputSize?: Vector2;
  77197. /**
  77198. * Vector3 of the position of the output plane in World Units.
  77199. */
  77200. outputPosition?: Vector3;
  77201. /**
  77202. * Vector3 of the rotation of the output plane.
  77203. */
  77204. outputRotation?: Vector3;
  77205. /**
  77206. * number of layers that the system will reserve in resources.
  77207. */
  77208. layerCount?: number;
  77209. /**
  77210. * number of max animation frames a single cell will reserve in resources.
  77211. */
  77212. maxAnimationFrames?: number;
  77213. /**
  77214. * number cell index of the base tile when the system compiles.
  77215. */
  77216. baseTile?: number;
  77217. /**
  77218. * boolean flip the sprite after its been repositioned by the framing data.
  77219. */
  77220. flipU?: boolean;
  77221. /**
  77222. * Vector3 scalar of the global RGB values of the SpriteMap.
  77223. */
  77224. colorMultiply?: Vector3;
  77225. }
  77226. /**
  77227. * Defines the IDisposable interface in order to be cleanable from resources.
  77228. */
  77229. export interface ISpriteMap extends IDisposable {
  77230. /**
  77231. * String name of the SpriteMap.
  77232. */
  77233. name: string;
  77234. /**
  77235. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77236. */
  77237. atlasJSON: ISpriteJSONAtlas;
  77238. /**
  77239. * Texture of the SpriteMap.
  77240. */
  77241. spriteSheet: Texture;
  77242. /**
  77243. * The parameters to initialize the SpriteMap with.
  77244. */
  77245. options: ISpriteMapOptions;
  77246. }
  77247. /**
  77248. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77249. */
  77250. export class SpriteMap implements ISpriteMap {
  77251. /** The Name of the spriteMap */
  77252. name: string;
  77253. /** The JSON file with the frame and meta data */
  77254. atlasJSON: ISpriteJSONAtlas;
  77255. /** The systems Sprite Sheet Texture */
  77256. spriteSheet: Texture;
  77257. /** Arguments passed with the Constructor */
  77258. options: ISpriteMapOptions;
  77259. /** Public Sprite Storage array, parsed from atlasJSON */
  77260. sprites: Array<ISpriteJSONSprite>;
  77261. /** Returns the Number of Sprites in the System */
  77262. get spriteCount(): number;
  77263. /** Returns the Position of Output Plane*/
  77264. get position(): Vector3;
  77265. /** Returns the Position of Output Plane*/
  77266. set position(v: Vector3);
  77267. /** Returns the Rotation of Output Plane*/
  77268. get rotation(): Vector3;
  77269. /** Returns the Rotation of Output Plane*/
  77270. set rotation(v: Vector3);
  77271. /** Sets the AnimationMap*/
  77272. get animationMap(): RawTexture;
  77273. /** Sets the AnimationMap*/
  77274. set animationMap(v: RawTexture);
  77275. /** Scene that the SpriteMap was created in */
  77276. private _scene;
  77277. /** Texture Buffer of Float32 that holds tile frame data*/
  77278. private _frameMap;
  77279. /** Texture Buffers of Float32 that holds tileMap data*/
  77280. private _tileMaps;
  77281. /** Texture Buffer of Float32 that holds Animation Data*/
  77282. private _animationMap;
  77283. /** Custom ShaderMaterial Central to the System*/
  77284. private _material;
  77285. /** Custom ShaderMaterial Central to the System*/
  77286. private _output;
  77287. /** Systems Time Ticker*/
  77288. private _time;
  77289. /**
  77290. * Creates a new SpriteMap
  77291. * @param name defines the SpriteMaps Name
  77292. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77293. * @param spriteSheet is the Texture that the Sprites are on.
  77294. * @param options a basic deployment configuration
  77295. * @param scene The Scene that the map is deployed on
  77296. */
  77297. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77298. /**
  77299. * Returns tileID location
  77300. * @returns Vector2 the cell position ID
  77301. */
  77302. getTileID(): Vector2;
  77303. /**
  77304. * Gets the UV location of the mouse over the SpriteMap.
  77305. * @returns Vector2 the UV position of the mouse interaction
  77306. */
  77307. getMousePosition(): Vector2;
  77308. /**
  77309. * Creates the "frame" texture Buffer
  77310. * -------------------------------------
  77311. * Structure of frames
  77312. * "filename": "Falling-Water-2.png",
  77313. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77314. * "rotated": true,
  77315. * "trimmed": true,
  77316. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77317. * "sourceSize": {"w":32,"h":32}
  77318. * @returns RawTexture of the frameMap
  77319. */
  77320. private _createFrameBuffer;
  77321. /**
  77322. * Creates the tileMap texture Buffer
  77323. * @param buffer normally and array of numbers, or a false to generate from scratch
  77324. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77325. * @returns RawTexture of the tileMap
  77326. */
  77327. private _createTileBuffer;
  77328. /**
  77329. * Modifies the data of the tileMaps
  77330. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77331. * @param pos is the iVector2 Coordinates of the Tile
  77332. * @param tile The SpriteIndex of the new Tile
  77333. */
  77334. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77335. /**
  77336. * Creates the animationMap texture Buffer
  77337. * @param buffer normally and array of numbers, or a false to generate from scratch
  77338. * @returns RawTexture of the animationMap
  77339. */
  77340. private _createTileAnimationBuffer;
  77341. /**
  77342. * Modifies the data of the animationMap
  77343. * @param cellID is the Index of the Sprite
  77344. * @param _frame is the target Animation frame
  77345. * @param toCell is the Target Index of the next frame of the animation
  77346. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77347. * @param speed is a global scalar of the time variable on the map.
  77348. */
  77349. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77350. /**
  77351. * Exports the .tilemaps file
  77352. */
  77353. saveTileMaps(): void;
  77354. /**
  77355. * Imports the .tilemaps file
  77356. * @param url of the .tilemaps file
  77357. */
  77358. loadTileMaps(url: string): void;
  77359. /**
  77360. * Release associated resources
  77361. */
  77362. dispose(): void;
  77363. }
  77364. }
  77365. declare module "babylonjs/Sprites/spritePackedManager" {
  77366. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  77367. import { Scene } from "babylonjs/scene";
  77368. /**
  77369. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77370. * @see https://doc.babylonjs.com/babylon101/sprites
  77371. */
  77372. export class SpritePackedManager extends SpriteManager {
  77373. /** defines the packed manager's name */
  77374. name: string;
  77375. /**
  77376. * Creates a new sprite manager from a packed sprite sheet
  77377. * @param name defines the manager's name
  77378. * @param imgUrl defines the sprite sheet url
  77379. * @param capacity defines the maximum allowed number of sprites
  77380. * @param scene defines the hosting scene
  77381. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77382. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77383. * @param samplingMode defines the smapling mode to use with spritesheet
  77384. * @param fromPacked set to true; do not alter
  77385. */
  77386. constructor(
  77387. /** defines the packed manager's name */
  77388. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77389. }
  77390. }
  77391. declare module "babylonjs/Sprites/index" {
  77392. export * from "babylonjs/Sprites/sprite";
  77393. export * from "babylonjs/Sprites/ISprites";
  77394. export * from "babylonjs/Sprites/spriteManager";
  77395. export * from "babylonjs/Sprites/spriteMap";
  77396. export * from "babylonjs/Sprites/spritePackedManager";
  77397. export * from "babylonjs/Sprites/spriteSceneComponent";
  77398. }
  77399. declare module "babylonjs/States/index" {
  77400. export * from "babylonjs/States/alphaCullingState";
  77401. export * from "babylonjs/States/depthCullingState";
  77402. export * from "babylonjs/States/stencilState";
  77403. }
  77404. declare module "babylonjs/Misc/assetsManager" {
  77405. import { Scene } from "babylonjs/scene";
  77406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77407. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  77408. import { Skeleton } from "babylonjs/Bones/skeleton";
  77409. import { Observable } from "babylonjs/Misc/observable";
  77410. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  77411. import { Texture } from "babylonjs/Materials/Textures/texture";
  77412. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  77413. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  77414. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  77415. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  77416. import { AssetContainer } from "babylonjs/assetContainer";
  77417. /**
  77418. * Defines the list of states available for a task inside a AssetsManager
  77419. */
  77420. export enum AssetTaskState {
  77421. /**
  77422. * Initialization
  77423. */
  77424. INIT = 0,
  77425. /**
  77426. * Running
  77427. */
  77428. RUNNING = 1,
  77429. /**
  77430. * Done
  77431. */
  77432. DONE = 2,
  77433. /**
  77434. * Error
  77435. */
  77436. ERROR = 3
  77437. }
  77438. /**
  77439. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77440. */
  77441. export abstract class AbstractAssetTask {
  77442. /**
  77443. * Task name
  77444. */ name: string;
  77445. /**
  77446. * Callback called when the task is successful
  77447. */
  77448. onSuccess: (task: any) => void;
  77449. /**
  77450. * Callback called when the task is not successful
  77451. */
  77452. onError: (task: any, message?: string, exception?: any) => void;
  77453. /**
  77454. * Creates a new AssetsManager
  77455. * @param name defines the name of the task
  77456. */
  77457. constructor(
  77458. /**
  77459. * Task name
  77460. */ name: string);
  77461. private _isCompleted;
  77462. private _taskState;
  77463. private _errorObject;
  77464. /**
  77465. * Get if the task is completed
  77466. */
  77467. get isCompleted(): boolean;
  77468. /**
  77469. * Gets the current state of the task
  77470. */
  77471. get taskState(): AssetTaskState;
  77472. /**
  77473. * Gets the current error object (if task is in error)
  77474. */
  77475. get errorObject(): {
  77476. message?: string;
  77477. exception?: any;
  77478. };
  77479. /**
  77480. * Internal only
  77481. * @hidden
  77482. */
  77483. _setErrorObject(message?: string, exception?: any): void;
  77484. /**
  77485. * Execute the current task
  77486. * @param scene defines the scene where you want your assets to be loaded
  77487. * @param onSuccess is a callback called when the task is successfully executed
  77488. * @param onError is a callback called if an error occurs
  77489. */
  77490. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77491. /**
  77492. * Execute the current task
  77493. * @param scene defines the scene where you want your assets to be loaded
  77494. * @param onSuccess is a callback called when the task is successfully executed
  77495. * @param onError is a callback called if an error occurs
  77496. */
  77497. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77498. /**
  77499. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77500. * This can be used with failed tasks that have the reason for failure fixed.
  77501. */
  77502. reset(): void;
  77503. private onErrorCallback;
  77504. private onDoneCallback;
  77505. }
  77506. /**
  77507. * Define the interface used by progress events raised during assets loading
  77508. */
  77509. export interface IAssetsProgressEvent {
  77510. /**
  77511. * Defines the number of remaining tasks to process
  77512. */
  77513. remainingCount: number;
  77514. /**
  77515. * Defines the total number of tasks
  77516. */
  77517. totalCount: number;
  77518. /**
  77519. * Defines the task that was just processed
  77520. */
  77521. task: AbstractAssetTask;
  77522. }
  77523. /**
  77524. * Class used to share progress information about assets loading
  77525. */
  77526. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77527. /**
  77528. * Defines the number of remaining tasks to process
  77529. */
  77530. remainingCount: number;
  77531. /**
  77532. * Defines the total number of tasks
  77533. */
  77534. totalCount: number;
  77535. /**
  77536. * Defines the task that was just processed
  77537. */
  77538. task: AbstractAssetTask;
  77539. /**
  77540. * Creates a AssetsProgressEvent
  77541. * @param remainingCount defines the number of remaining tasks to process
  77542. * @param totalCount defines the total number of tasks
  77543. * @param task defines the task that was just processed
  77544. */
  77545. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77546. }
  77547. /**
  77548. * Define a task used by AssetsManager to load assets into a container
  77549. */
  77550. export class ContainerAssetTask extends AbstractAssetTask {
  77551. /**
  77552. * Defines the name of the task
  77553. */
  77554. name: string;
  77555. /**
  77556. * Defines the list of mesh's names you want to load
  77557. */
  77558. meshesNames: any;
  77559. /**
  77560. * Defines the root url to use as a base to load your meshes and associated resources
  77561. */
  77562. rootUrl: string;
  77563. /**
  77564. * Defines the filename or File of the scene to load from
  77565. */
  77566. sceneFilename: string | File;
  77567. /**
  77568. * Get the loaded asset container
  77569. */
  77570. loadedContainer: AssetContainer;
  77571. /**
  77572. * Gets the list of loaded meshes
  77573. */
  77574. loadedMeshes: Array<AbstractMesh>;
  77575. /**
  77576. * Gets the list of loaded particle systems
  77577. */
  77578. loadedParticleSystems: Array<IParticleSystem>;
  77579. /**
  77580. * Gets the list of loaded skeletons
  77581. */
  77582. loadedSkeletons: Array<Skeleton>;
  77583. /**
  77584. * Gets the list of loaded animation groups
  77585. */
  77586. loadedAnimationGroups: Array<AnimationGroup>;
  77587. /**
  77588. * Callback called when the task is successful
  77589. */
  77590. onSuccess: (task: ContainerAssetTask) => void;
  77591. /**
  77592. * Callback called when the task is successful
  77593. */
  77594. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77595. /**
  77596. * Creates a new ContainerAssetTask
  77597. * @param name defines the name of the task
  77598. * @param meshesNames defines the list of mesh's names you want to load
  77599. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77600. * @param sceneFilename defines the filename or File of the scene to load from
  77601. */
  77602. constructor(
  77603. /**
  77604. * Defines the name of the task
  77605. */
  77606. name: string,
  77607. /**
  77608. * Defines the list of mesh's names you want to load
  77609. */
  77610. meshesNames: any,
  77611. /**
  77612. * Defines the root url to use as a base to load your meshes and associated resources
  77613. */
  77614. rootUrl: string,
  77615. /**
  77616. * Defines the filename or File of the scene to load from
  77617. */
  77618. sceneFilename: string | File);
  77619. /**
  77620. * Execute the current task
  77621. * @param scene defines the scene where you want your assets to be loaded
  77622. * @param onSuccess is a callback called when the task is successfully executed
  77623. * @param onError is a callback called if an error occurs
  77624. */
  77625. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77626. }
  77627. /**
  77628. * Define a task used by AssetsManager to load meshes
  77629. */
  77630. export class MeshAssetTask extends AbstractAssetTask {
  77631. /**
  77632. * Defines the name of the task
  77633. */
  77634. name: string;
  77635. /**
  77636. * Defines the list of mesh's names you want to load
  77637. */
  77638. meshesNames: any;
  77639. /**
  77640. * Defines the root url to use as a base to load your meshes and associated resources
  77641. */
  77642. rootUrl: string;
  77643. /**
  77644. * Defines the filename or File of the scene to load from
  77645. */
  77646. sceneFilename: string | File;
  77647. /**
  77648. * Gets the list of loaded meshes
  77649. */
  77650. loadedMeshes: Array<AbstractMesh>;
  77651. /**
  77652. * Gets the list of loaded particle systems
  77653. */
  77654. loadedParticleSystems: Array<IParticleSystem>;
  77655. /**
  77656. * Gets the list of loaded skeletons
  77657. */
  77658. loadedSkeletons: Array<Skeleton>;
  77659. /**
  77660. * Gets the list of loaded animation groups
  77661. */
  77662. loadedAnimationGroups: Array<AnimationGroup>;
  77663. /**
  77664. * Callback called when the task is successful
  77665. */
  77666. onSuccess: (task: MeshAssetTask) => void;
  77667. /**
  77668. * Callback called when the task is successful
  77669. */
  77670. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77671. /**
  77672. * Creates a new MeshAssetTask
  77673. * @param name defines the name of the task
  77674. * @param meshesNames defines the list of mesh's names you want to load
  77675. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77676. * @param sceneFilename defines the filename or File of the scene to load from
  77677. */
  77678. constructor(
  77679. /**
  77680. * Defines the name of the task
  77681. */
  77682. name: string,
  77683. /**
  77684. * Defines the list of mesh's names you want to load
  77685. */
  77686. meshesNames: any,
  77687. /**
  77688. * Defines the root url to use as a base to load your meshes and associated resources
  77689. */
  77690. rootUrl: string,
  77691. /**
  77692. * Defines the filename or File of the scene to load from
  77693. */
  77694. sceneFilename: string | File);
  77695. /**
  77696. * Execute the current task
  77697. * @param scene defines the scene where you want your assets to be loaded
  77698. * @param onSuccess is a callback called when the task is successfully executed
  77699. * @param onError is a callback called if an error occurs
  77700. */
  77701. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77702. }
  77703. /**
  77704. * Define a task used by AssetsManager to load text content
  77705. */
  77706. export class TextFileAssetTask extends AbstractAssetTask {
  77707. /**
  77708. * Defines the name of the task
  77709. */
  77710. name: string;
  77711. /**
  77712. * Defines the location of the file to load
  77713. */
  77714. url: string;
  77715. /**
  77716. * Gets the loaded text string
  77717. */
  77718. text: string;
  77719. /**
  77720. * Callback called when the task is successful
  77721. */
  77722. onSuccess: (task: TextFileAssetTask) => void;
  77723. /**
  77724. * Callback called when the task is successful
  77725. */
  77726. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77727. /**
  77728. * Creates a new TextFileAssetTask object
  77729. * @param name defines the name of the task
  77730. * @param url defines the location of the file to load
  77731. */
  77732. constructor(
  77733. /**
  77734. * Defines the name of the task
  77735. */
  77736. name: string,
  77737. /**
  77738. * Defines the location of the file to load
  77739. */
  77740. url: string);
  77741. /**
  77742. * Execute the current task
  77743. * @param scene defines the scene where you want your assets to be loaded
  77744. * @param onSuccess is a callback called when the task is successfully executed
  77745. * @param onError is a callback called if an error occurs
  77746. */
  77747. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77748. }
  77749. /**
  77750. * Define a task used by AssetsManager to load binary data
  77751. */
  77752. export class BinaryFileAssetTask extends AbstractAssetTask {
  77753. /**
  77754. * Defines the name of the task
  77755. */
  77756. name: string;
  77757. /**
  77758. * Defines the location of the file to load
  77759. */
  77760. url: string;
  77761. /**
  77762. * Gets the lodaded data (as an array buffer)
  77763. */
  77764. data: ArrayBuffer;
  77765. /**
  77766. * Callback called when the task is successful
  77767. */
  77768. onSuccess: (task: BinaryFileAssetTask) => void;
  77769. /**
  77770. * Callback called when the task is successful
  77771. */
  77772. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77773. /**
  77774. * Creates a new BinaryFileAssetTask object
  77775. * @param name defines the name of the new task
  77776. * @param url defines the location of the file to load
  77777. */
  77778. constructor(
  77779. /**
  77780. * Defines the name of the task
  77781. */
  77782. name: string,
  77783. /**
  77784. * Defines the location of the file to load
  77785. */
  77786. url: string);
  77787. /**
  77788. * Execute the current task
  77789. * @param scene defines the scene where you want your assets to be loaded
  77790. * @param onSuccess is a callback called when the task is successfully executed
  77791. * @param onError is a callback called if an error occurs
  77792. */
  77793. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77794. }
  77795. /**
  77796. * Define a task used by AssetsManager to load images
  77797. */
  77798. export class ImageAssetTask extends AbstractAssetTask {
  77799. /**
  77800. * Defines the name of the task
  77801. */
  77802. name: string;
  77803. /**
  77804. * Defines the location of the image to load
  77805. */
  77806. url: string;
  77807. /**
  77808. * Gets the loaded images
  77809. */
  77810. image: HTMLImageElement;
  77811. /**
  77812. * Callback called when the task is successful
  77813. */
  77814. onSuccess: (task: ImageAssetTask) => void;
  77815. /**
  77816. * Callback called when the task is successful
  77817. */
  77818. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77819. /**
  77820. * Creates a new ImageAssetTask
  77821. * @param name defines the name of the task
  77822. * @param url defines the location of the image to load
  77823. */
  77824. constructor(
  77825. /**
  77826. * Defines the name of the task
  77827. */
  77828. name: string,
  77829. /**
  77830. * Defines the location of the image to load
  77831. */
  77832. url: string);
  77833. /**
  77834. * Execute the current task
  77835. * @param scene defines the scene where you want your assets to be loaded
  77836. * @param onSuccess is a callback called when the task is successfully executed
  77837. * @param onError is a callback called if an error occurs
  77838. */
  77839. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77840. }
  77841. /**
  77842. * Defines the interface used by texture loading tasks
  77843. */
  77844. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77845. /**
  77846. * Gets the loaded texture
  77847. */
  77848. texture: TEX;
  77849. }
  77850. /**
  77851. * Define a task used by AssetsManager to load 2D textures
  77852. */
  77853. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77854. /**
  77855. * Defines the name of the task
  77856. */
  77857. name: string;
  77858. /**
  77859. * Defines the location of the file to load
  77860. */
  77861. url: string;
  77862. /**
  77863. * Defines if mipmap should not be generated (default is false)
  77864. */
  77865. noMipmap?: boolean | undefined;
  77866. /**
  77867. * Defines if texture must be inverted on Y axis (default is true)
  77868. */
  77869. invertY: boolean;
  77870. /**
  77871. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77872. */
  77873. samplingMode: number;
  77874. /**
  77875. * Gets the loaded texture
  77876. */
  77877. texture: Texture;
  77878. /**
  77879. * Callback called when the task is successful
  77880. */
  77881. onSuccess: (task: TextureAssetTask) => void;
  77882. /**
  77883. * Callback called when the task is successful
  77884. */
  77885. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77886. /**
  77887. * Creates a new TextureAssetTask object
  77888. * @param name defines the name of the task
  77889. * @param url defines the location of the file to load
  77890. * @param noMipmap defines if mipmap should not be generated (default is false)
  77891. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77892. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77893. */
  77894. constructor(
  77895. /**
  77896. * Defines the name of the task
  77897. */
  77898. name: string,
  77899. /**
  77900. * Defines the location of the file to load
  77901. */
  77902. url: string,
  77903. /**
  77904. * Defines if mipmap should not be generated (default is false)
  77905. */
  77906. noMipmap?: boolean | undefined,
  77907. /**
  77908. * Defines if texture must be inverted on Y axis (default is true)
  77909. */
  77910. invertY?: boolean,
  77911. /**
  77912. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77913. */
  77914. samplingMode?: number);
  77915. /**
  77916. * Execute the current task
  77917. * @param scene defines the scene where you want your assets to be loaded
  77918. * @param onSuccess is a callback called when the task is successfully executed
  77919. * @param onError is a callback called if an error occurs
  77920. */
  77921. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77922. }
  77923. /**
  77924. * Define a task used by AssetsManager to load cube textures
  77925. */
  77926. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77927. /**
  77928. * Defines the name of the task
  77929. */
  77930. name: string;
  77931. /**
  77932. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77933. */
  77934. url: string;
  77935. /**
  77936. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77937. */
  77938. extensions?: string[] | undefined;
  77939. /**
  77940. * Defines if mipmaps should not be generated (default is false)
  77941. */
  77942. noMipmap?: boolean | undefined;
  77943. /**
  77944. * Defines the explicit list of files (undefined by default)
  77945. */
  77946. files?: string[] | undefined;
  77947. /**
  77948. * Gets the loaded texture
  77949. */
  77950. texture: CubeTexture;
  77951. /**
  77952. * Callback called when the task is successful
  77953. */
  77954. onSuccess: (task: CubeTextureAssetTask) => void;
  77955. /**
  77956. * Callback called when the task is successful
  77957. */
  77958. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77959. /**
  77960. * Creates a new CubeTextureAssetTask
  77961. * @param name defines the name of the task
  77962. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77963. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77964. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77965. * @param files defines the explicit list of files (undefined by default)
  77966. */
  77967. constructor(
  77968. /**
  77969. * Defines the name of the task
  77970. */
  77971. name: string,
  77972. /**
  77973. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77974. */
  77975. url: string,
  77976. /**
  77977. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77978. */
  77979. extensions?: string[] | undefined,
  77980. /**
  77981. * Defines if mipmaps should not be generated (default is false)
  77982. */
  77983. noMipmap?: boolean | undefined,
  77984. /**
  77985. * Defines the explicit list of files (undefined by default)
  77986. */
  77987. files?: string[] | undefined);
  77988. /**
  77989. * Execute the current task
  77990. * @param scene defines the scene where you want your assets to be loaded
  77991. * @param onSuccess is a callback called when the task is successfully executed
  77992. * @param onError is a callback called if an error occurs
  77993. */
  77994. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77995. }
  77996. /**
  77997. * Define a task used by AssetsManager to load HDR cube textures
  77998. */
  77999. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  78000. /**
  78001. * Defines the name of the task
  78002. */
  78003. name: string;
  78004. /**
  78005. * Defines the location of the file to load
  78006. */
  78007. url: string;
  78008. /**
  78009. * Defines the desired size (the more it increases the longer the generation will be)
  78010. */
  78011. size: number;
  78012. /**
  78013. * Defines if mipmaps should not be generated (default is false)
  78014. */
  78015. noMipmap: boolean;
  78016. /**
  78017. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78018. */
  78019. generateHarmonics: boolean;
  78020. /**
  78021. * 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)
  78022. */
  78023. gammaSpace: boolean;
  78024. /**
  78025. * Internal Use Only
  78026. */
  78027. reserved: boolean;
  78028. /**
  78029. * Gets the loaded texture
  78030. */
  78031. texture: HDRCubeTexture;
  78032. /**
  78033. * Callback called when the task is successful
  78034. */
  78035. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  78036. /**
  78037. * Callback called when the task is successful
  78038. */
  78039. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  78040. /**
  78041. * Creates a new HDRCubeTextureAssetTask object
  78042. * @param name defines the name of the task
  78043. * @param url defines the location of the file to load
  78044. * @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.
  78045. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78046. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78047. * @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)
  78048. * @param reserved Internal use only
  78049. */
  78050. constructor(
  78051. /**
  78052. * Defines the name of the task
  78053. */
  78054. name: string,
  78055. /**
  78056. * Defines the location of the file to load
  78057. */
  78058. url: string,
  78059. /**
  78060. * Defines the desired size (the more it increases the longer the generation will be)
  78061. */
  78062. size: number,
  78063. /**
  78064. * Defines if mipmaps should not be generated (default is false)
  78065. */
  78066. noMipmap?: boolean,
  78067. /**
  78068. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78069. */
  78070. generateHarmonics?: boolean,
  78071. /**
  78072. * 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)
  78073. */
  78074. gammaSpace?: boolean,
  78075. /**
  78076. * Internal Use Only
  78077. */
  78078. reserved?: boolean);
  78079. /**
  78080. * Execute the current task
  78081. * @param scene defines the scene where you want your assets to be loaded
  78082. * @param onSuccess is a callback called when the task is successfully executed
  78083. * @param onError is a callback called if an error occurs
  78084. */
  78085. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78086. }
  78087. /**
  78088. * Define a task used by AssetsManager to load Equirectangular cube textures
  78089. */
  78090. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  78091. /**
  78092. * Defines the name of the task
  78093. */
  78094. name: string;
  78095. /**
  78096. * Defines the location of the file to load
  78097. */
  78098. url: string;
  78099. /**
  78100. * Defines the desired size (the more it increases the longer the generation will be)
  78101. */
  78102. size: number;
  78103. /**
  78104. * Defines if mipmaps should not be generated (default is false)
  78105. */
  78106. noMipmap: boolean;
  78107. /**
  78108. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78109. * but the standard material would require them in Gamma space) (default is true)
  78110. */
  78111. gammaSpace: boolean;
  78112. /**
  78113. * Gets the loaded texture
  78114. */
  78115. texture: EquiRectangularCubeTexture;
  78116. /**
  78117. * Callback called when the task is successful
  78118. */
  78119. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  78120. /**
  78121. * Callback called when the task is successful
  78122. */
  78123. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  78124. /**
  78125. * Creates a new EquiRectangularCubeTextureAssetTask object
  78126. * @param name defines the name of the task
  78127. * @param url defines the location of the file to load
  78128. * @param size defines the desired size (the more it increases the longer the generation will be)
  78129. * If the size is omitted this implies you are using a preprocessed cubemap.
  78130. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78131. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  78132. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  78133. * (default is true)
  78134. */
  78135. constructor(
  78136. /**
  78137. * Defines the name of the task
  78138. */
  78139. name: string,
  78140. /**
  78141. * Defines the location of the file to load
  78142. */
  78143. url: string,
  78144. /**
  78145. * Defines the desired size (the more it increases the longer the generation will be)
  78146. */
  78147. size: number,
  78148. /**
  78149. * Defines if mipmaps should not be generated (default is false)
  78150. */
  78151. noMipmap?: boolean,
  78152. /**
  78153. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78154. * but the standard material would require them in Gamma space) (default is true)
  78155. */
  78156. gammaSpace?: boolean);
  78157. /**
  78158. * Execute the current task
  78159. * @param scene defines the scene where you want your assets to be loaded
  78160. * @param onSuccess is a callback called when the task is successfully executed
  78161. * @param onError is a callback called if an error occurs
  78162. */
  78163. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78164. }
  78165. /**
  78166. * This class can be used to easily import assets into a scene
  78167. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78168. */
  78169. export class AssetsManager {
  78170. private _scene;
  78171. private _isLoading;
  78172. protected _tasks: AbstractAssetTask[];
  78173. protected _waitingTasksCount: number;
  78174. protected _totalTasksCount: number;
  78175. /**
  78176. * Callback called when all tasks are processed
  78177. */
  78178. onFinish: (tasks: AbstractAssetTask[]) => void;
  78179. /**
  78180. * Callback called when a task is successful
  78181. */
  78182. onTaskSuccess: (task: AbstractAssetTask) => void;
  78183. /**
  78184. * Callback called when a task had an error
  78185. */
  78186. onTaskError: (task: AbstractAssetTask) => void;
  78187. /**
  78188. * Callback called when a task is done (whatever the result is)
  78189. */
  78190. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78191. /**
  78192. * Observable called when all tasks are processed
  78193. */
  78194. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78195. /**
  78196. * Observable called when a task had an error
  78197. */
  78198. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78199. /**
  78200. * Observable called when all tasks were executed
  78201. */
  78202. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78203. /**
  78204. * Observable called when a task is done (whatever the result is)
  78205. */
  78206. onProgressObservable: Observable<IAssetsProgressEvent>;
  78207. /**
  78208. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78209. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78210. */
  78211. useDefaultLoadingScreen: boolean;
  78212. /**
  78213. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78214. * when all assets have been downloaded.
  78215. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78216. */
  78217. autoHideLoadingUI: boolean;
  78218. /**
  78219. * Creates a new AssetsManager
  78220. * @param scene defines the scene to work on
  78221. */
  78222. constructor(scene: Scene);
  78223. /**
  78224. * Add a ContainerAssetTask to the list of active tasks
  78225. * @param taskName defines the name of the new task
  78226. * @param meshesNames defines the name of meshes to load
  78227. * @param rootUrl defines the root url to use to locate files
  78228. * @param sceneFilename defines the filename of the scene file
  78229. * @returns a new ContainerAssetTask object
  78230. */
  78231. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78232. /**
  78233. * Add a MeshAssetTask to the list of active tasks
  78234. * @param taskName defines the name of the new task
  78235. * @param meshesNames defines the name of meshes to load
  78236. * @param rootUrl defines the root url to use to locate files
  78237. * @param sceneFilename defines the filename of the scene file
  78238. * @returns a new MeshAssetTask object
  78239. */
  78240. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78241. /**
  78242. * Add a TextFileAssetTask to the list of active tasks
  78243. * @param taskName defines the name of the new task
  78244. * @param url defines the url of the file to load
  78245. * @returns a new TextFileAssetTask object
  78246. */
  78247. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78248. /**
  78249. * Add a BinaryFileAssetTask to the list of active tasks
  78250. * @param taskName defines the name of the new task
  78251. * @param url defines the url of the file to load
  78252. * @returns a new BinaryFileAssetTask object
  78253. */
  78254. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78255. /**
  78256. * Add a ImageAssetTask to the list of active tasks
  78257. * @param taskName defines the name of the new task
  78258. * @param url defines the url of the file to load
  78259. * @returns a new ImageAssetTask object
  78260. */
  78261. addImageTask(taskName: string, url: string): ImageAssetTask;
  78262. /**
  78263. * Add a TextureAssetTask to the list of active tasks
  78264. * @param taskName defines the name of the new task
  78265. * @param url defines the url of the file to load
  78266. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78267. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78268. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78269. * @returns a new TextureAssetTask object
  78270. */
  78271. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78272. /**
  78273. * Add a CubeTextureAssetTask to the list of active tasks
  78274. * @param taskName defines the name of the new task
  78275. * @param url defines the url of the file to load
  78276. * @param extensions defines the extension to use to load the cube map (can be null)
  78277. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78278. * @param files defines the list of files to load (can be null)
  78279. * @returns a new CubeTextureAssetTask object
  78280. */
  78281. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78282. /**
  78283. *
  78284. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78285. * @param taskName defines the name of the new task
  78286. * @param url defines the url of the file to load
  78287. * @param size defines the size you want for the cubemap (can be null)
  78288. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78289. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78290. * @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)
  78291. * @param reserved Internal use only
  78292. * @returns a new HDRCubeTextureAssetTask object
  78293. */
  78294. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78295. /**
  78296. *
  78297. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78298. * @param taskName defines the name of the new task
  78299. * @param url defines the url of the file to load
  78300. * @param size defines the size you want for the cubemap (can be null)
  78301. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78302. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78303. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78304. * @returns a new EquiRectangularCubeTextureAssetTask object
  78305. */
  78306. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78307. /**
  78308. * Remove a task from the assets manager.
  78309. * @param task the task to remove
  78310. */
  78311. removeTask(task: AbstractAssetTask): void;
  78312. private _decreaseWaitingTasksCount;
  78313. private _runTask;
  78314. /**
  78315. * Reset the AssetsManager and remove all tasks
  78316. * @return the current instance of the AssetsManager
  78317. */
  78318. reset(): AssetsManager;
  78319. /**
  78320. * Start the loading process
  78321. * @return the current instance of the AssetsManager
  78322. */
  78323. load(): AssetsManager;
  78324. /**
  78325. * Start the loading process as an async operation
  78326. * @return a promise returning the list of failed tasks
  78327. */
  78328. loadAsync(): Promise<void>;
  78329. }
  78330. }
  78331. declare module "babylonjs/Misc/deferred" {
  78332. /**
  78333. * Wrapper class for promise with external resolve and reject.
  78334. */
  78335. export class Deferred<T> {
  78336. /**
  78337. * The promise associated with this deferred object.
  78338. */
  78339. readonly promise: Promise<T>;
  78340. private _resolve;
  78341. private _reject;
  78342. /**
  78343. * The resolve method of the promise associated with this deferred object.
  78344. */
  78345. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  78346. /**
  78347. * The reject method of the promise associated with this deferred object.
  78348. */
  78349. get reject(): (reason?: any) => void;
  78350. /**
  78351. * Constructor for this deferred object.
  78352. */
  78353. constructor();
  78354. }
  78355. }
  78356. declare module "babylonjs/Misc/meshExploder" {
  78357. import { Mesh } from "babylonjs/Meshes/mesh";
  78358. /**
  78359. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78360. */
  78361. export class MeshExploder {
  78362. private _centerMesh;
  78363. private _meshes;
  78364. private _meshesOrigins;
  78365. private _toCenterVectors;
  78366. private _scaledDirection;
  78367. private _newPosition;
  78368. private _centerPosition;
  78369. /**
  78370. * Explodes meshes from a center mesh.
  78371. * @param meshes The meshes to explode.
  78372. * @param centerMesh The mesh to be center of explosion.
  78373. */
  78374. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78375. private _setCenterMesh;
  78376. /**
  78377. * Get class name
  78378. * @returns "MeshExploder"
  78379. */
  78380. getClassName(): string;
  78381. /**
  78382. * "Exploded meshes"
  78383. * @returns Array of meshes with the centerMesh at index 0.
  78384. */
  78385. getMeshes(): Array<Mesh>;
  78386. /**
  78387. * Explodes meshes giving a specific direction
  78388. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78389. */
  78390. explode(direction?: number): void;
  78391. }
  78392. }
  78393. declare module "babylonjs/Misc/filesInput" {
  78394. import { Engine } from "babylonjs/Engines/engine";
  78395. import { Scene } from "babylonjs/scene";
  78396. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  78397. import { Nullable } from "babylonjs/types";
  78398. /**
  78399. * Class used to help managing file picking and drag'n'drop
  78400. */
  78401. export class FilesInput {
  78402. /**
  78403. * List of files ready to be loaded
  78404. */
  78405. static get FilesToLoad(): {
  78406. [key: string]: File;
  78407. };
  78408. /**
  78409. * Callback called when a file is processed
  78410. */
  78411. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  78412. private _engine;
  78413. private _currentScene;
  78414. private _sceneLoadedCallback;
  78415. private _progressCallback;
  78416. private _additionalRenderLoopLogicCallback;
  78417. private _textureLoadingCallback;
  78418. private _startingProcessingFilesCallback;
  78419. private _onReloadCallback;
  78420. private _errorCallback;
  78421. private _elementToMonitor;
  78422. private _sceneFileToLoad;
  78423. private _filesToLoad;
  78424. /**
  78425. * Creates a new FilesInput
  78426. * @param engine defines the rendering engine
  78427. * @param scene defines the hosting scene
  78428. * @param sceneLoadedCallback callback called when scene is loaded
  78429. * @param progressCallback callback called to track progress
  78430. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78431. * @param textureLoadingCallback callback called when a texture is loading
  78432. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78433. * @param onReloadCallback callback called when a reload is requested
  78434. * @param errorCallback callback call if an error occurs
  78435. */
  78436. 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>);
  78437. private _dragEnterHandler;
  78438. private _dragOverHandler;
  78439. private _dropHandler;
  78440. /**
  78441. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78442. * @param elementToMonitor defines the DOM element to track
  78443. */
  78444. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78445. /** Gets the current list of files to load */
  78446. get filesToLoad(): File[];
  78447. /**
  78448. * Release all associated resources
  78449. */
  78450. dispose(): void;
  78451. private renderFunction;
  78452. private drag;
  78453. private drop;
  78454. private _traverseFolder;
  78455. private _processFiles;
  78456. /**
  78457. * Load files from a drop event
  78458. * @param event defines the drop event to use as source
  78459. */
  78460. loadFiles(event: any): void;
  78461. private _processReload;
  78462. /**
  78463. * Reload the current scene from the loaded files
  78464. */
  78465. reload(): void;
  78466. }
  78467. }
  78468. declare module "babylonjs/Misc/HighDynamicRange/index" {
  78469. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  78470. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  78471. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  78472. }
  78473. declare module "babylonjs/Misc/sceneOptimizer" {
  78474. import { Scene, IDisposable } from "babylonjs/scene";
  78475. import { Observable } from "babylonjs/Misc/observable";
  78476. /**
  78477. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78478. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78479. */
  78480. export class SceneOptimization {
  78481. /**
  78482. * Defines the priority of this optimization (0 by default which means first in the list)
  78483. */
  78484. priority: number;
  78485. /**
  78486. * Gets a string describing the action executed by the current optimization
  78487. * @returns description string
  78488. */
  78489. getDescription(): string;
  78490. /**
  78491. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78492. * @param scene defines the current scene where to apply this optimization
  78493. * @param optimizer defines the current optimizer
  78494. * @returns true if everything that can be done was applied
  78495. */
  78496. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78497. /**
  78498. * Creates the SceneOptimization object
  78499. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78500. * @param desc defines the description associated with the optimization
  78501. */
  78502. constructor(
  78503. /**
  78504. * Defines the priority of this optimization (0 by default which means first in the list)
  78505. */
  78506. priority?: number);
  78507. }
  78508. /**
  78509. * Defines an optimization used to reduce the size of render target textures
  78510. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78511. */
  78512. export class TextureOptimization extends SceneOptimization {
  78513. /**
  78514. * Defines the priority of this optimization (0 by default which means first in the list)
  78515. */
  78516. priority: number;
  78517. /**
  78518. * 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
  78519. */
  78520. maximumSize: number;
  78521. /**
  78522. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78523. */
  78524. step: number;
  78525. /**
  78526. * Gets a string describing the action executed by the current optimization
  78527. * @returns description string
  78528. */
  78529. getDescription(): string;
  78530. /**
  78531. * Creates the TextureOptimization object
  78532. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78533. * @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
  78534. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78535. */
  78536. constructor(
  78537. /**
  78538. * Defines the priority of this optimization (0 by default which means first in the list)
  78539. */
  78540. priority?: number,
  78541. /**
  78542. * 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
  78543. */
  78544. maximumSize?: number,
  78545. /**
  78546. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78547. */
  78548. step?: number);
  78549. /**
  78550. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78551. * @param scene defines the current scene where to apply this optimization
  78552. * @param optimizer defines the current optimizer
  78553. * @returns true if everything that can be done was applied
  78554. */
  78555. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78556. }
  78557. /**
  78558. * Defines an optimization used to increase or decrease the rendering resolution
  78559. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78560. */
  78561. export class HardwareScalingOptimization extends SceneOptimization {
  78562. /**
  78563. * Defines the priority of this optimization (0 by default which means first in the list)
  78564. */
  78565. priority: number;
  78566. /**
  78567. * Defines the maximum scale to use (2 by default)
  78568. */
  78569. maximumScale: number;
  78570. /**
  78571. * Defines the step to use between two passes (0.5 by default)
  78572. */
  78573. step: number;
  78574. private _currentScale;
  78575. private _directionOffset;
  78576. /**
  78577. * Gets a string describing the action executed by the current optimization
  78578. * @return description string
  78579. */
  78580. getDescription(): string;
  78581. /**
  78582. * Creates the HardwareScalingOptimization object
  78583. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78584. * @param maximumScale defines the maximum scale to use (2 by default)
  78585. * @param step defines the step to use between two passes (0.5 by default)
  78586. */
  78587. constructor(
  78588. /**
  78589. * Defines the priority of this optimization (0 by default which means first in the list)
  78590. */
  78591. priority?: number,
  78592. /**
  78593. * Defines the maximum scale to use (2 by default)
  78594. */
  78595. maximumScale?: number,
  78596. /**
  78597. * Defines the step to use between two passes (0.5 by default)
  78598. */
  78599. step?: number);
  78600. /**
  78601. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78602. * @param scene defines the current scene where to apply this optimization
  78603. * @param optimizer defines the current optimizer
  78604. * @returns true if everything that can be done was applied
  78605. */
  78606. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78607. }
  78608. /**
  78609. * Defines an optimization used to remove shadows
  78610. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78611. */
  78612. export class ShadowsOptimization extends SceneOptimization {
  78613. /**
  78614. * Gets a string describing the action executed by the current optimization
  78615. * @return description string
  78616. */
  78617. getDescription(): string;
  78618. /**
  78619. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78620. * @param scene defines the current scene where to apply this optimization
  78621. * @param optimizer defines the current optimizer
  78622. * @returns true if everything that can be done was applied
  78623. */
  78624. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78625. }
  78626. /**
  78627. * Defines an optimization used to turn post-processes off
  78628. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78629. */
  78630. export class PostProcessesOptimization extends SceneOptimization {
  78631. /**
  78632. * Gets a string describing the action executed by the current optimization
  78633. * @return description string
  78634. */
  78635. getDescription(): string;
  78636. /**
  78637. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78638. * @param scene defines the current scene where to apply this optimization
  78639. * @param optimizer defines the current optimizer
  78640. * @returns true if everything that can be done was applied
  78641. */
  78642. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78643. }
  78644. /**
  78645. * Defines an optimization used to turn lens flares off
  78646. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78647. */
  78648. export class LensFlaresOptimization extends SceneOptimization {
  78649. /**
  78650. * Gets a string describing the action executed by the current optimization
  78651. * @return description string
  78652. */
  78653. getDescription(): string;
  78654. /**
  78655. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78656. * @param scene defines the current scene where to apply this optimization
  78657. * @param optimizer defines the current optimizer
  78658. * @returns true if everything that can be done was applied
  78659. */
  78660. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78661. }
  78662. /**
  78663. * Defines an optimization based on user defined callback.
  78664. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78665. */
  78666. export class CustomOptimization extends SceneOptimization {
  78667. /**
  78668. * Callback called to apply the custom optimization.
  78669. */
  78670. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78671. /**
  78672. * Callback called to get custom description
  78673. */
  78674. onGetDescription: () => string;
  78675. /**
  78676. * Gets a string describing the action executed by the current optimization
  78677. * @returns description string
  78678. */
  78679. getDescription(): string;
  78680. /**
  78681. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78682. * @param scene defines the current scene where to apply this optimization
  78683. * @param optimizer defines the current optimizer
  78684. * @returns true if everything that can be done was applied
  78685. */
  78686. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78687. }
  78688. /**
  78689. * Defines an optimization used to turn particles off
  78690. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78691. */
  78692. export class ParticlesOptimization extends SceneOptimization {
  78693. /**
  78694. * Gets a string describing the action executed by the current optimization
  78695. * @return description string
  78696. */
  78697. getDescription(): string;
  78698. /**
  78699. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78700. * @param scene defines the current scene where to apply this optimization
  78701. * @param optimizer defines the current optimizer
  78702. * @returns true if everything that can be done was applied
  78703. */
  78704. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78705. }
  78706. /**
  78707. * Defines an optimization used to turn render targets off
  78708. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78709. */
  78710. export class RenderTargetsOptimization extends SceneOptimization {
  78711. /**
  78712. * Gets a string describing the action executed by the current optimization
  78713. * @return description string
  78714. */
  78715. getDescription(): string;
  78716. /**
  78717. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78718. * @param scene defines the current scene where to apply this optimization
  78719. * @param optimizer defines the current optimizer
  78720. * @returns true if everything that can be done was applied
  78721. */
  78722. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78723. }
  78724. /**
  78725. * Defines an optimization used to merge meshes with compatible materials
  78726. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78727. */
  78728. export class MergeMeshesOptimization extends SceneOptimization {
  78729. private static _UpdateSelectionTree;
  78730. /**
  78731. * Gets or sets a boolean which defines if optimization octree has to be updated
  78732. */
  78733. static get UpdateSelectionTree(): boolean;
  78734. /**
  78735. * Gets or sets a boolean which defines if optimization octree has to be updated
  78736. */
  78737. static set UpdateSelectionTree(value: boolean);
  78738. /**
  78739. * Gets a string describing the action executed by the current optimization
  78740. * @return description string
  78741. */
  78742. getDescription(): string;
  78743. private _canBeMerged;
  78744. /**
  78745. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78746. * @param scene defines the current scene where to apply this optimization
  78747. * @param optimizer defines the current optimizer
  78748. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78749. * @returns true if everything that can be done was applied
  78750. */
  78751. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78752. }
  78753. /**
  78754. * Defines a list of options used by SceneOptimizer
  78755. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78756. */
  78757. export class SceneOptimizerOptions {
  78758. /**
  78759. * Defines the target frame rate to reach (60 by default)
  78760. */
  78761. targetFrameRate: number;
  78762. /**
  78763. * Defines the interval between two checkes (2000ms by default)
  78764. */
  78765. trackerDuration: number;
  78766. /**
  78767. * Gets the list of optimizations to apply
  78768. */
  78769. optimizations: SceneOptimization[];
  78770. /**
  78771. * Creates a new list of options used by SceneOptimizer
  78772. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78773. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78774. */
  78775. constructor(
  78776. /**
  78777. * Defines the target frame rate to reach (60 by default)
  78778. */
  78779. targetFrameRate?: number,
  78780. /**
  78781. * Defines the interval between two checkes (2000ms by default)
  78782. */
  78783. trackerDuration?: number);
  78784. /**
  78785. * Add a new optimization
  78786. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78787. * @returns the current SceneOptimizerOptions
  78788. */
  78789. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78790. /**
  78791. * Add a new custom optimization
  78792. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78793. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78794. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78795. * @returns the current SceneOptimizerOptions
  78796. */
  78797. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78798. /**
  78799. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78800. * @param targetFrameRate defines the target frame rate (60 by default)
  78801. * @returns a SceneOptimizerOptions object
  78802. */
  78803. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78804. /**
  78805. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78806. * @param targetFrameRate defines the target frame rate (60 by default)
  78807. * @returns a SceneOptimizerOptions object
  78808. */
  78809. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78810. /**
  78811. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78812. * @param targetFrameRate defines the target frame rate (60 by default)
  78813. * @returns a SceneOptimizerOptions object
  78814. */
  78815. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78816. }
  78817. /**
  78818. * Class used to run optimizations in order to reach a target frame rate
  78819. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78820. */
  78821. export class SceneOptimizer implements IDisposable {
  78822. private _isRunning;
  78823. private _options;
  78824. private _scene;
  78825. private _currentPriorityLevel;
  78826. private _targetFrameRate;
  78827. private _trackerDuration;
  78828. private _currentFrameRate;
  78829. private _sceneDisposeObserver;
  78830. private _improvementMode;
  78831. /**
  78832. * Defines an observable called when the optimizer reaches the target frame rate
  78833. */
  78834. onSuccessObservable: Observable<SceneOptimizer>;
  78835. /**
  78836. * Defines an observable called when the optimizer enables an optimization
  78837. */
  78838. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78839. /**
  78840. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78841. */
  78842. onFailureObservable: Observable<SceneOptimizer>;
  78843. /**
  78844. * Gets a boolean indicating if the optimizer is in improvement mode
  78845. */
  78846. get isInImprovementMode(): boolean;
  78847. /**
  78848. * Gets the current priority level (0 at start)
  78849. */
  78850. get currentPriorityLevel(): number;
  78851. /**
  78852. * Gets the current frame rate checked by the SceneOptimizer
  78853. */
  78854. get currentFrameRate(): number;
  78855. /**
  78856. * Gets or sets the current target frame rate (60 by default)
  78857. */
  78858. get targetFrameRate(): number;
  78859. /**
  78860. * Gets or sets the current target frame rate (60 by default)
  78861. */
  78862. set targetFrameRate(value: number);
  78863. /**
  78864. * Gets or sets the current interval between two checks (every 2000ms by default)
  78865. */
  78866. get trackerDuration(): number;
  78867. /**
  78868. * Gets or sets the current interval between two checks (every 2000ms by default)
  78869. */
  78870. set trackerDuration(value: number);
  78871. /**
  78872. * Gets the list of active optimizations
  78873. */
  78874. get optimizations(): SceneOptimization[];
  78875. /**
  78876. * Creates a new SceneOptimizer
  78877. * @param scene defines the scene to work on
  78878. * @param options defines the options to use with the SceneOptimizer
  78879. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78880. * @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)
  78881. */
  78882. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78883. /**
  78884. * Stops the current optimizer
  78885. */
  78886. stop(): void;
  78887. /**
  78888. * Reset the optimizer to initial step (current priority level = 0)
  78889. */
  78890. reset(): void;
  78891. /**
  78892. * Start the optimizer. By default it will try to reach a specific framerate
  78893. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78894. */
  78895. start(): void;
  78896. private _checkCurrentState;
  78897. /**
  78898. * Release all resources
  78899. */
  78900. dispose(): void;
  78901. /**
  78902. * Helper function to create a SceneOptimizer with one single line of code
  78903. * @param scene defines the scene to work on
  78904. * @param options defines the options to use with the SceneOptimizer
  78905. * @param onSuccess defines a callback to call on success
  78906. * @param onFailure defines a callback to call on failure
  78907. * @returns the new SceneOptimizer object
  78908. */
  78909. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78910. }
  78911. }
  78912. declare module "babylonjs/Misc/sceneSerializer" {
  78913. import { Scene } from "babylonjs/scene";
  78914. /**
  78915. * Class used to serialize a scene into a string
  78916. */
  78917. export class SceneSerializer {
  78918. /**
  78919. * Clear cache used by a previous serialization
  78920. */
  78921. static ClearCache(): void;
  78922. /**
  78923. * Serialize a scene into a JSON compatible object
  78924. * @param scene defines the scene to serialize
  78925. * @returns a JSON compatible object
  78926. */
  78927. static Serialize(scene: Scene): any;
  78928. /**
  78929. * Serialize a mesh into a JSON compatible object
  78930. * @param toSerialize defines the mesh to serialize
  78931. * @param withParents defines if parents must be serialized as well
  78932. * @param withChildren defines if children must be serialized as well
  78933. * @returns a JSON compatible object
  78934. */
  78935. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78936. }
  78937. }
  78938. declare module "babylonjs/Misc/textureTools" {
  78939. import { Texture } from "babylonjs/Materials/Textures/texture";
  78940. /**
  78941. * Class used to host texture specific utilities
  78942. */
  78943. export class TextureTools {
  78944. /**
  78945. * Uses the GPU to create a copy texture rescaled at a given size
  78946. * @param texture Texture to copy from
  78947. * @param width defines the desired width
  78948. * @param height defines the desired height
  78949. * @param useBilinearMode defines if bilinear mode has to be used
  78950. * @return the generated texture
  78951. */
  78952. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78953. }
  78954. }
  78955. declare module "babylonjs/Misc/videoRecorder" {
  78956. import { Nullable } from "babylonjs/types";
  78957. import { Engine } from "babylonjs/Engines/engine";
  78958. /**
  78959. * This represents the different options available for the video capture.
  78960. */
  78961. export interface VideoRecorderOptions {
  78962. /** Defines the mime type of the video. */
  78963. mimeType: string;
  78964. /** Defines the FPS the video should be recorded at. */
  78965. fps: number;
  78966. /** Defines the chunk size for the recording data. */
  78967. recordChunckSize: number;
  78968. /** The audio tracks to attach to the recording. */
  78969. audioTracks?: MediaStreamTrack[];
  78970. }
  78971. /**
  78972. * This can help with recording videos from BabylonJS.
  78973. * This is based on the available WebRTC functionalities of the browser.
  78974. *
  78975. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78976. */
  78977. export class VideoRecorder {
  78978. private static readonly _defaultOptions;
  78979. /**
  78980. * Returns whether or not the VideoRecorder is available in your browser.
  78981. * @param engine Defines the Babylon Engine.
  78982. * @returns true if supported otherwise false.
  78983. */
  78984. static IsSupported(engine: Engine): boolean;
  78985. private readonly _options;
  78986. private _canvas;
  78987. private _mediaRecorder;
  78988. private _recordedChunks;
  78989. private _fileName;
  78990. private _resolve;
  78991. private _reject;
  78992. /**
  78993. * True when a recording is already in progress.
  78994. */
  78995. get isRecording(): boolean;
  78996. /**
  78997. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78998. * @param engine Defines the BabylonJS Engine you wish to record.
  78999. * @param options Defines options that can be used to customize the capture.
  79000. */
  79001. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  79002. /**
  79003. * Stops the current recording before the default capture timeout passed in the startRecording function.
  79004. */
  79005. stopRecording(): void;
  79006. /**
  79007. * Starts recording the canvas for a max duration specified in parameters.
  79008. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  79009. * If null no automatic download will start and you can rely on the promise to get the data back.
  79010. * @param maxDuration Defines the maximum recording time in seconds.
  79011. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  79012. * @return A promise callback at the end of the recording with the video data in Blob.
  79013. */
  79014. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  79015. /**
  79016. * Releases internal resources used during the recording.
  79017. */
  79018. dispose(): void;
  79019. private _handleDataAvailable;
  79020. private _handleError;
  79021. private _handleStop;
  79022. }
  79023. }
  79024. declare module "babylonjs/Misc/screenshotTools" {
  79025. import { Camera } from "babylonjs/Cameras/camera";
  79026. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  79027. import { Engine } from "babylonjs/Engines/engine";
  79028. /**
  79029. * Class containing a set of static utilities functions for screenshots
  79030. */
  79031. export class ScreenshotTools {
  79032. /**
  79033. * Captures a screenshot of the current rendering
  79034. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79035. * @param engine defines the rendering engine
  79036. * @param camera defines the source camera
  79037. * @param size This parameter can be set to a single number or to an object with the
  79038. * following (optional) properties: precision, width, height. If a single number is passed,
  79039. * it will be used for both width and height. If an object is passed, the screenshot size
  79040. * will be derived from the parameters. The precision property is a multiplier allowing
  79041. * rendering at a higher or lower resolution
  79042. * @param successCallback defines the callback receives a single parameter which contains the
  79043. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79044. * src parameter of an <img> to display it
  79045. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79046. * Check your browser for supported MIME types
  79047. */
  79048. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  79049. /**
  79050. * Captures a screenshot of the current rendering
  79051. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79052. * @param engine defines the rendering engine
  79053. * @param camera defines the source camera
  79054. * @param size This parameter can be set to a single number or to an object with the
  79055. * following (optional) properties: precision, width, height. If a single number is passed,
  79056. * it will be used for both width and height. If an object is passed, the screenshot size
  79057. * will be derived from the parameters. The precision property is a multiplier allowing
  79058. * rendering at a higher or lower resolution
  79059. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79060. * Check your browser for supported MIME types
  79061. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79062. * to the src parameter of an <img> to display it
  79063. */
  79064. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  79065. /**
  79066. * Generates an image screenshot from the specified camera.
  79067. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79068. * @param engine The engine to use for rendering
  79069. * @param camera The camera to use for rendering
  79070. * @param size This parameter can be set to a single number or to an object with the
  79071. * following (optional) properties: precision, width, height. If a single number is passed,
  79072. * it will be used for both width and height. If an object is passed, the screenshot size
  79073. * will be derived from the parameters. The precision property is a multiplier allowing
  79074. * rendering at a higher or lower resolution
  79075. * @param successCallback The callback receives a single parameter which contains the
  79076. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79077. * src parameter of an <img> to display it
  79078. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79079. * Check your browser for supported MIME types
  79080. * @param samples Texture samples (default: 1)
  79081. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79082. * @param fileName A name for for the downloaded file.
  79083. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79084. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  79085. */
  79086. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  79087. /**
  79088. * Generates an image screenshot from the specified camera.
  79089. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79090. * @param engine The engine to use for rendering
  79091. * @param camera The camera to use for rendering
  79092. * @param size This parameter can be set to a single number or to an object with the
  79093. * following (optional) properties: precision, width, height. If a single number is passed,
  79094. * it will be used for both width and height. If an object is passed, the screenshot size
  79095. * will be derived from the parameters. The precision property is a multiplier allowing
  79096. * rendering at a higher or lower resolution
  79097. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79098. * Check your browser for supported MIME types
  79099. * @param samples Texture samples (default: 1)
  79100. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79101. * @param fileName A name for for the downloaded file.
  79102. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79103. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79104. * to the src parameter of an <img> to display it
  79105. */
  79106. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  79107. /**
  79108. * Gets height and width for screenshot size
  79109. * @private
  79110. */
  79111. private static _getScreenshotSize;
  79112. }
  79113. }
  79114. declare module "babylonjs/Misc/dataReader" {
  79115. /**
  79116. * Interface for a data buffer
  79117. */
  79118. export interface IDataBuffer {
  79119. /**
  79120. * Reads bytes from the data buffer.
  79121. * @param byteOffset The byte offset to read
  79122. * @param byteLength The byte length to read
  79123. * @returns A promise that resolves when the bytes are read
  79124. */
  79125. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  79126. /**
  79127. * The byte length of the buffer.
  79128. */
  79129. readonly byteLength: number;
  79130. }
  79131. /**
  79132. * Utility class for reading from a data buffer
  79133. */
  79134. export class DataReader {
  79135. /**
  79136. * The data buffer associated with this data reader.
  79137. */
  79138. readonly buffer: IDataBuffer;
  79139. /**
  79140. * The current byte offset from the beginning of the data buffer.
  79141. */
  79142. byteOffset: number;
  79143. private _dataView;
  79144. private _dataByteOffset;
  79145. /**
  79146. * Constructor
  79147. * @param buffer The buffer to read
  79148. */
  79149. constructor(buffer: IDataBuffer);
  79150. /**
  79151. * Loads the given byte length.
  79152. * @param byteLength The byte length to load
  79153. * @returns A promise that resolves when the load is complete
  79154. */
  79155. loadAsync(byteLength: number): Promise<void>;
  79156. /**
  79157. * Read a unsigned 32-bit integer from the currently loaded data range.
  79158. * @returns The 32-bit integer read
  79159. */
  79160. readUint32(): number;
  79161. /**
  79162. * Read a byte array from the currently loaded data range.
  79163. * @param byteLength The byte length to read
  79164. * @returns The byte array read
  79165. */
  79166. readUint8Array(byteLength: number): Uint8Array;
  79167. /**
  79168. * Read a string from the currently loaded data range.
  79169. * @param byteLength The byte length to read
  79170. * @returns The string read
  79171. */
  79172. readString(byteLength: number): string;
  79173. /**
  79174. * Skips the given byte length the currently loaded data range.
  79175. * @param byteLength The byte length to skip
  79176. */
  79177. skipBytes(byteLength: number): void;
  79178. }
  79179. }
  79180. declare module "babylonjs/Misc/dataStorage" {
  79181. /**
  79182. * Class for storing data to local storage if available or in-memory storage otherwise
  79183. */
  79184. export class DataStorage {
  79185. private static _Storage;
  79186. private static _GetStorage;
  79187. /**
  79188. * Reads a string from the data storage
  79189. * @param key The key to read
  79190. * @param defaultValue The value if the key doesn't exist
  79191. * @returns The string value
  79192. */
  79193. static ReadString(key: string, defaultValue: string): string;
  79194. /**
  79195. * Writes a string to the data storage
  79196. * @param key The key to write
  79197. * @param value The value to write
  79198. */
  79199. static WriteString(key: string, value: string): void;
  79200. /**
  79201. * Reads a boolean from the data storage
  79202. * @param key The key to read
  79203. * @param defaultValue The value if the key doesn't exist
  79204. * @returns The boolean value
  79205. */
  79206. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79207. /**
  79208. * Writes a boolean to the data storage
  79209. * @param key The key to write
  79210. * @param value The value to write
  79211. */
  79212. static WriteBoolean(key: string, value: boolean): void;
  79213. /**
  79214. * Reads a number from the data storage
  79215. * @param key The key to read
  79216. * @param defaultValue The value if the key doesn't exist
  79217. * @returns The number value
  79218. */
  79219. static ReadNumber(key: string, defaultValue: number): number;
  79220. /**
  79221. * Writes a number to the data storage
  79222. * @param key The key to write
  79223. * @param value The value to write
  79224. */
  79225. static WriteNumber(key: string, value: number): void;
  79226. }
  79227. }
  79228. declare module "babylonjs/Misc/sceneRecorder" {
  79229. import { Scene } from "babylonjs/scene";
  79230. /**
  79231. * Class used to record delta files between 2 scene states
  79232. */
  79233. export class SceneRecorder {
  79234. private _trackedScene;
  79235. private _savedJSON;
  79236. /**
  79237. * Track a given scene. This means the current scene state will be considered the original state
  79238. * @param scene defines the scene to track
  79239. */
  79240. track(scene: Scene): void;
  79241. /**
  79242. * Get the delta between current state and original state
  79243. * @returns a string containing the delta
  79244. */
  79245. getDelta(): any;
  79246. private _compareArray;
  79247. private _compareObjects;
  79248. private _compareCollections;
  79249. private static GetShadowGeneratorById;
  79250. /**
  79251. * Apply a given delta to a given scene
  79252. * @param deltaJSON defines the JSON containing the delta
  79253. * @param scene defines the scene to apply the delta to
  79254. */
  79255. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79256. private static _ApplyPropertiesToEntity;
  79257. private static _ApplyDeltaForEntity;
  79258. }
  79259. }
  79260. declare module "babylonjs/Misc/trajectoryClassifier" {
  79261. import { DeepImmutable, Nullable } from "babylonjs/types";
  79262. import { Vector3 } from "babylonjs/Maths/math.vector";
  79263. /**
  79264. * A 3D trajectory consisting of an order list of vectors describing a
  79265. * path of motion through 3D space.
  79266. */
  79267. export class Trajectory {
  79268. private _points;
  79269. private readonly _segmentLength;
  79270. /**
  79271. * Serialize to JSON.
  79272. * @returns serialized JSON string
  79273. */
  79274. serialize(): string;
  79275. /**
  79276. * Deserialize from JSON.
  79277. * @param json serialized JSON string
  79278. * @returns deserialized Trajectory
  79279. */
  79280. static Deserialize(json: string): Trajectory;
  79281. /**
  79282. * Create a new empty Trajectory.
  79283. * @param segmentLength radius of discretization for Trajectory points
  79284. */
  79285. constructor(segmentLength?: number);
  79286. /**
  79287. * Get the length of the Trajectory.
  79288. * @returns length of the Trajectory
  79289. */
  79290. getLength(): number;
  79291. /**
  79292. * Append a new point to the Trajectory.
  79293. * NOTE: This implementation has many allocations.
  79294. * @param point point to append to the Trajectory
  79295. */
  79296. add(point: DeepImmutable<Vector3>): void;
  79297. /**
  79298. * Create a new Trajectory with a segment length chosen to make it
  79299. * probable that the new Trajectory will have a specified number of
  79300. * segments. This operation is imprecise.
  79301. * @param targetResolution number of segments desired
  79302. * @returns new Trajectory with approximately the requested number of segments
  79303. */
  79304. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79305. /**
  79306. * Convert Trajectory segments into tokenized representation. This
  79307. * representation is an array of numbers where each nth number is the
  79308. * index of the token which is most similar to the nth segment of the
  79309. * Trajectory.
  79310. * @param tokens list of vectors which serve as discrete tokens
  79311. * @returns list of indices of most similar token per segment
  79312. */
  79313. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79314. private static _forwardDir;
  79315. private static _inverseFromVec;
  79316. private static _upDir;
  79317. private static _fromToVec;
  79318. private static _lookMatrix;
  79319. /**
  79320. * Transform the rotation (i.e., direction) of a segment to isolate
  79321. * the relative transformation represented by the segment. This operation
  79322. * may or may not succeed due to singularities in the equations that define
  79323. * motion relativity in this context.
  79324. * @param priorVec the origin of the prior segment
  79325. * @param fromVec the origin of the current segment
  79326. * @param toVec the destination of the current segment
  79327. * @param result reference to output variable
  79328. * @returns whether or not transformation was successful
  79329. */
  79330. private static _transformSegmentDirToRef;
  79331. private static _bestMatch;
  79332. private static _score;
  79333. private static _bestScore;
  79334. /**
  79335. * Determine which token vector is most similar to the
  79336. * segment vector.
  79337. * @param segment segment vector
  79338. * @param tokens token vector list
  79339. * @returns index of the most similar token to the segment
  79340. */
  79341. private static _tokenizeSegment;
  79342. }
  79343. /**
  79344. * Class representing a set of known, named trajectories to which Trajectories can be
  79345. * added and using which Trajectories can be recognized.
  79346. */
  79347. export class TrajectoryClassifier {
  79348. private _maximumAllowableMatchCost;
  79349. private _vector3Alphabet;
  79350. private _levenshteinAlphabet;
  79351. private _nameToDescribedTrajectory;
  79352. /**
  79353. * Serialize to JSON.
  79354. * @returns JSON serialization
  79355. */
  79356. serialize(): string;
  79357. /**
  79358. * Deserialize from JSON.
  79359. * @param json JSON serialization
  79360. * @returns deserialized TrajectorySet
  79361. */
  79362. static Deserialize(json: string): TrajectoryClassifier;
  79363. /**
  79364. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79365. * VERY naive, need to be generating these things from known
  79366. * sets. Better version later, probably eliminating this one.
  79367. * @returns auto-generated TrajectorySet
  79368. */
  79369. static Generate(): TrajectoryClassifier;
  79370. private constructor();
  79371. /**
  79372. * Add a new Trajectory to the set with a given name.
  79373. * @param trajectory new Trajectory to be added
  79374. * @param classification name to which to add the Trajectory
  79375. */
  79376. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79377. /**
  79378. * Remove a known named trajectory and all Trajectories associated with it.
  79379. * @param classification name to remove
  79380. * @returns whether anything was removed
  79381. */
  79382. deleteClassification(classification: string): boolean;
  79383. /**
  79384. * Attempt to recognize a Trajectory from among all the classifications
  79385. * already known to the classifier.
  79386. * @param trajectory Trajectory to be recognized
  79387. * @returns classification of Trajectory if recognized, null otherwise
  79388. */
  79389. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79390. }
  79391. }
  79392. declare module "babylonjs/Misc/index" {
  79393. export * from "babylonjs/Misc/andOrNotEvaluator";
  79394. export * from "babylonjs/Misc/assetsManager";
  79395. export * from "babylonjs/Misc/basis";
  79396. export * from "babylonjs/Misc/dds";
  79397. export * from "babylonjs/Misc/decorators";
  79398. export * from "babylonjs/Misc/deferred";
  79399. export * from "babylonjs/Misc/environmentTextureTools";
  79400. export * from "babylonjs/Misc/meshExploder";
  79401. export * from "babylonjs/Misc/filesInput";
  79402. export * from "babylonjs/Misc/HighDynamicRange/index";
  79403. export * from "babylonjs/Misc/khronosTextureContainer";
  79404. export * from "babylonjs/Misc/observable";
  79405. export * from "babylonjs/Misc/performanceMonitor";
  79406. export * from "babylonjs/Misc/promise";
  79407. export * from "babylonjs/Misc/sceneOptimizer";
  79408. export * from "babylonjs/Misc/sceneSerializer";
  79409. export * from "babylonjs/Misc/smartArray";
  79410. export * from "babylonjs/Misc/stringDictionary";
  79411. export * from "babylonjs/Misc/tags";
  79412. export * from "babylonjs/Misc/textureTools";
  79413. export * from "babylonjs/Misc/tga";
  79414. export * from "babylonjs/Misc/tools";
  79415. export * from "babylonjs/Misc/videoRecorder";
  79416. export * from "babylonjs/Misc/virtualJoystick";
  79417. export * from "babylonjs/Misc/workerPool";
  79418. export * from "babylonjs/Misc/logger";
  79419. export * from "babylonjs/Misc/typeStore";
  79420. export * from "babylonjs/Misc/filesInputStore";
  79421. export * from "babylonjs/Misc/deepCopier";
  79422. export * from "babylonjs/Misc/pivotTools";
  79423. export * from "babylonjs/Misc/precisionDate";
  79424. export * from "babylonjs/Misc/screenshotTools";
  79425. export * from "babylonjs/Misc/typeStore";
  79426. export * from "babylonjs/Misc/webRequest";
  79427. export * from "babylonjs/Misc/iInspectable";
  79428. export * from "babylonjs/Misc/brdfTextureTools";
  79429. export * from "babylonjs/Misc/rgbdTextureTools";
  79430. export * from "babylonjs/Misc/gradients";
  79431. export * from "babylonjs/Misc/perfCounter";
  79432. export * from "babylonjs/Misc/fileRequest";
  79433. export * from "babylonjs/Misc/customAnimationFrameRequester";
  79434. export * from "babylonjs/Misc/retryStrategy";
  79435. export * from "babylonjs/Misc/interfaces/screenshotSize";
  79436. export * from "babylonjs/Misc/canvasGenerator";
  79437. export * from "babylonjs/Misc/fileTools";
  79438. export * from "babylonjs/Misc/stringTools";
  79439. export * from "babylonjs/Misc/dataReader";
  79440. export * from "babylonjs/Misc/minMaxReducer";
  79441. export * from "babylonjs/Misc/depthReducer";
  79442. export * from "babylonjs/Misc/dataStorage";
  79443. export * from "babylonjs/Misc/sceneRecorder";
  79444. export * from "babylonjs/Misc/khronosTextureContainer2";
  79445. export * from "babylonjs/Misc/trajectoryClassifier";
  79446. export * from "babylonjs/Misc/timer";
  79447. }
  79448. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  79449. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  79450. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79451. import { Observable } from "babylonjs/Misc/observable";
  79452. import { Matrix } from "babylonjs/Maths/math.vector";
  79453. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79454. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79455. /**
  79456. * An interface for all Hit test features
  79457. */
  79458. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79459. /**
  79460. * Triggered when new babylon (transformed) hit test results are available
  79461. */
  79462. onHitTestResultObservable: Observable<T[]>;
  79463. }
  79464. /**
  79465. * Options used for hit testing
  79466. */
  79467. export interface IWebXRLegacyHitTestOptions {
  79468. /**
  79469. * Only test when user interacted with the scene. Default - hit test every frame
  79470. */
  79471. testOnPointerDownOnly?: boolean;
  79472. /**
  79473. * The node to use to transform the local results to world coordinates
  79474. */
  79475. worldParentNode?: TransformNode;
  79476. }
  79477. /**
  79478. * Interface defining the babylon result of raycasting/hit-test
  79479. */
  79480. export interface IWebXRLegacyHitResult {
  79481. /**
  79482. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79483. */
  79484. transformationMatrix: Matrix;
  79485. /**
  79486. * The native hit test result
  79487. */
  79488. xrHitResult: XRHitResult | XRHitTestResult;
  79489. }
  79490. /**
  79491. * The currently-working hit-test module.
  79492. * Hit test (or Ray-casting) is used to interact with the real world.
  79493. * For further information read here - https://github.com/immersive-web/hit-test
  79494. */
  79495. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79496. /**
  79497. * options to use when constructing this feature
  79498. */
  79499. readonly options: IWebXRLegacyHitTestOptions;
  79500. private _direction;
  79501. private _mat;
  79502. private _onSelectEnabled;
  79503. private _origin;
  79504. /**
  79505. * The module's name
  79506. */
  79507. static readonly Name: string;
  79508. /**
  79509. * The (Babylon) version of this module.
  79510. * This is an integer representing the implementation version.
  79511. * This number does not correspond to the WebXR specs version
  79512. */
  79513. static readonly Version: number;
  79514. /**
  79515. * Populated with the last native XR Hit Results
  79516. */
  79517. lastNativeXRHitResults: XRHitResult[];
  79518. /**
  79519. * Triggered when new babylon (transformed) hit test results are available
  79520. */
  79521. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79522. /**
  79523. * Creates a new instance of the (legacy version) hit test feature
  79524. * @param _xrSessionManager an instance of WebXRSessionManager
  79525. * @param options options to use when constructing this feature
  79526. */
  79527. constructor(_xrSessionManager: WebXRSessionManager,
  79528. /**
  79529. * options to use when constructing this feature
  79530. */
  79531. options?: IWebXRLegacyHitTestOptions);
  79532. /**
  79533. * execute a hit test with an XR Ray
  79534. *
  79535. * @param xrSession a native xrSession that will execute this hit test
  79536. * @param xrRay the ray (position and direction) to use for ray-casting
  79537. * @param referenceSpace native XR reference space to use for the hit-test
  79538. * @param filter filter function that will filter the results
  79539. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79540. */
  79541. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79542. /**
  79543. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79544. * @param event the (select) event to use to select with
  79545. * @param referenceSpace the reference space to use for this hit test
  79546. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79547. */
  79548. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79549. /**
  79550. * attach this feature
  79551. * Will usually be called by the features manager
  79552. *
  79553. * @returns true if successful.
  79554. */
  79555. attach(): boolean;
  79556. /**
  79557. * detach this feature.
  79558. * Will usually be called by the features manager
  79559. *
  79560. * @returns true if successful.
  79561. */
  79562. detach(): boolean;
  79563. /**
  79564. * Dispose this feature and all of the resources attached
  79565. */
  79566. dispose(): void;
  79567. protected _onXRFrame(frame: XRFrame): void;
  79568. private _onHitTestResults;
  79569. private _onSelect;
  79570. }
  79571. }
  79572. declare module "babylonjs/XR/features/WebXRHitTest" {
  79573. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79574. import { Observable } from "babylonjs/Misc/observable";
  79575. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79576. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79577. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  79578. /**
  79579. * Options used for hit testing (version 2)
  79580. */
  79581. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79582. /**
  79583. * Do not create a permanent hit test. Will usually be used when only
  79584. * transient inputs are needed.
  79585. */
  79586. disablePermanentHitTest?: boolean;
  79587. /**
  79588. * Enable transient (for example touch-based) hit test inspections
  79589. */
  79590. enableTransientHitTest?: boolean;
  79591. /**
  79592. * Offset ray for the permanent hit test
  79593. */
  79594. offsetRay?: Vector3;
  79595. /**
  79596. * Offset ray for the transient hit test
  79597. */
  79598. transientOffsetRay?: Vector3;
  79599. /**
  79600. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79601. */
  79602. useReferenceSpace?: boolean;
  79603. /**
  79604. * Override the default entity type(s) of the hit-test result
  79605. */
  79606. entityTypes?: XRHitTestTrackableType[];
  79607. }
  79608. /**
  79609. * Interface defining the babylon result of hit-test
  79610. */
  79611. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79612. /**
  79613. * The input source that generated this hit test (if transient)
  79614. */
  79615. inputSource?: XRInputSource;
  79616. /**
  79617. * Is this a transient hit test
  79618. */
  79619. isTransient?: boolean;
  79620. /**
  79621. * Position of the hit test result
  79622. */
  79623. position: Vector3;
  79624. /**
  79625. * Rotation of the hit test result
  79626. */
  79627. rotationQuaternion: Quaternion;
  79628. /**
  79629. * The native hit test result
  79630. */
  79631. xrHitResult: XRHitTestResult;
  79632. }
  79633. /**
  79634. * The currently-working hit-test module.
  79635. * Hit test (or Ray-casting) is used to interact with the real world.
  79636. * For further information read here - https://github.com/immersive-web/hit-test
  79637. *
  79638. * Tested on chrome (mobile) 80.
  79639. */
  79640. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79641. /**
  79642. * options to use when constructing this feature
  79643. */
  79644. readonly options: IWebXRHitTestOptions;
  79645. private _tmpMat;
  79646. private _tmpPos;
  79647. private _tmpQuat;
  79648. private _transientXrHitTestSource;
  79649. private _xrHitTestSource;
  79650. private initHitTestSource;
  79651. /**
  79652. * The module's name
  79653. */
  79654. static readonly Name: string;
  79655. /**
  79656. * The (Babylon) version of this module.
  79657. * This is an integer representing the implementation version.
  79658. * This number does not correspond to the WebXR specs version
  79659. */
  79660. static readonly Version: number;
  79661. /**
  79662. * When set to true, each hit test will have its own position/rotation objects
  79663. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79664. * the developers will clone them or copy them as they see fit.
  79665. */
  79666. autoCloneTransformation: boolean;
  79667. /**
  79668. * Triggered when new babylon (transformed) hit test results are available
  79669. * Note - this will be called when results come back from the device. It can be an empty array!!
  79670. */
  79671. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79672. /**
  79673. * Use this to temporarily pause hit test checks.
  79674. */
  79675. paused: boolean;
  79676. /**
  79677. * Creates a new instance of the hit test feature
  79678. * @param _xrSessionManager an instance of WebXRSessionManager
  79679. * @param options options to use when constructing this feature
  79680. */
  79681. constructor(_xrSessionManager: WebXRSessionManager,
  79682. /**
  79683. * options to use when constructing this feature
  79684. */
  79685. options?: IWebXRHitTestOptions);
  79686. /**
  79687. * attach this feature
  79688. * Will usually be called by the features manager
  79689. *
  79690. * @returns true if successful.
  79691. */
  79692. attach(): boolean;
  79693. /**
  79694. * detach this feature.
  79695. * Will usually be called by the features manager
  79696. *
  79697. * @returns true if successful.
  79698. */
  79699. detach(): boolean;
  79700. /**
  79701. * Dispose this feature and all of the resources attached
  79702. */
  79703. dispose(): void;
  79704. protected _onXRFrame(frame: XRFrame): void;
  79705. private _processWebXRHitTestResult;
  79706. }
  79707. }
  79708. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  79709. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79710. import { Observable } from "babylonjs/Misc/observable";
  79711. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79712. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79713. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79714. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  79715. /**
  79716. * Configuration options of the anchor system
  79717. */
  79718. export interface IWebXRAnchorSystemOptions {
  79719. /**
  79720. * a node that will be used to convert local to world coordinates
  79721. */
  79722. worldParentNode?: TransformNode;
  79723. /**
  79724. * If set to true a reference of the created anchors will be kept until the next session starts
  79725. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79726. */
  79727. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79728. }
  79729. /**
  79730. * A babylon container for an XR Anchor
  79731. */
  79732. export interface IWebXRAnchor {
  79733. /**
  79734. * A babylon-assigned ID for this anchor
  79735. */
  79736. id: number;
  79737. /**
  79738. * Transformation matrix to apply to an object attached to this anchor
  79739. */
  79740. transformationMatrix: Matrix;
  79741. /**
  79742. * The native anchor object
  79743. */
  79744. xrAnchor: XRAnchor;
  79745. /**
  79746. * if defined, this object will be constantly updated by the anchor's position and rotation
  79747. */
  79748. attachedNode?: TransformNode;
  79749. }
  79750. /**
  79751. * An implementation of the anchor system for WebXR.
  79752. * For further information see https://github.com/immersive-web/anchors/
  79753. */
  79754. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79755. private _options;
  79756. private _lastFrameDetected;
  79757. private _trackedAnchors;
  79758. private _referenceSpaceForFrameAnchors;
  79759. private _futureAnchors;
  79760. /**
  79761. * The module's name
  79762. */
  79763. static readonly Name: string;
  79764. /**
  79765. * The (Babylon) version of this module.
  79766. * This is an integer representing the implementation version.
  79767. * This number does not correspond to the WebXR specs version
  79768. */
  79769. static readonly Version: number;
  79770. /**
  79771. * Observers registered here will be executed when a new anchor was added to the session
  79772. */
  79773. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79774. /**
  79775. * Observers registered here will be executed when an anchor was removed from the session
  79776. */
  79777. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79778. /**
  79779. * Observers registered here will be executed when an existing anchor updates
  79780. * This can execute N times every frame
  79781. */
  79782. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79783. /**
  79784. * Set the reference space to use for anchor creation, when not using a hit test.
  79785. * Will default to the session's reference space if not defined
  79786. */
  79787. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79788. /**
  79789. * constructs a new anchor system
  79790. * @param _xrSessionManager an instance of WebXRSessionManager
  79791. * @param _options configuration object for this feature
  79792. */
  79793. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79794. private _tmpVector;
  79795. private _tmpQuaternion;
  79796. private _populateTmpTransformation;
  79797. /**
  79798. * Create a new anchor point using a hit test result at a specific point in the scene
  79799. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79800. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79801. *
  79802. * @param hitTestResult The hit test result to use for this anchor creation
  79803. * @param position an optional position offset for this anchor
  79804. * @param rotationQuaternion an optional rotation offset for this anchor
  79805. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79806. */
  79807. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  79808. /**
  79809. * Add a new anchor at a specific position and rotation
  79810. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79811. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79812. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79813. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79814. *
  79815. * @param position the position in which to add an anchor
  79816. * @param rotationQuaternion an optional rotation for the anchor transformation
  79817. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79818. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79819. */
  79820. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  79821. /**
  79822. * detach this feature.
  79823. * Will usually be called by the features manager
  79824. *
  79825. * @returns true if successful.
  79826. */
  79827. detach(): boolean;
  79828. /**
  79829. * Dispose this feature and all of the resources attached
  79830. */
  79831. dispose(): void;
  79832. protected _onXRFrame(frame: XRFrame): void;
  79833. /**
  79834. * avoiding using Array.find for global support.
  79835. * @param xrAnchor the plane to find in the array
  79836. */
  79837. private _findIndexInAnchorArray;
  79838. private _updateAnchorWithXRFrame;
  79839. private _createAnchorAtTransformation;
  79840. }
  79841. }
  79842. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  79843. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79844. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79845. import { Observable } from "babylonjs/Misc/observable";
  79846. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  79847. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79848. /**
  79849. * Options used in the plane detector module
  79850. */
  79851. export interface IWebXRPlaneDetectorOptions {
  79852. /**
  79853. * The node to use to transform the local results to world coordinates
  79854. */
  79855. worldParentNode?: TransformNode;
  79856. /**
  79857. * If set to true a reference of the created planes will be kept until the next session starts
  79858. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79859. */
  79860. doNotRemovePlanesOnSessionEnded?: boolean;
  79861. }
  79862. /**
  79863. * A babylon interface for a WebXR plane.
  79864. * A Plane is actually a polygon, built from N points in space
  79865. *
  79866. * Supported in chrome 79, not supported in canary 81 ATM
  79867. */
  79868. export interface IWebXRPlane {
  79869. /**
  79870. * a babylon-assigned ID for this polygon
  79871. */
  79872. id: number;
  79873. /**
  79874. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79875. */
  79876. polygonDefinition: Array<Vector3>;
  79877. /**
  79878. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79879. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79880. */
  79881. transformationMatrix: Matrix;
  79882. /**
  79883. * the native xr-plane object
  79884. */
  79885. xrPlane: XRPlane;
  79886. }
  79887. /**
  79888. * The plane detector is used to detect planes in the real world when in AR
  79889. * For more information see https://github.com/immersive-web/real-world-geometry/
  79890. */
  79891. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79892. private _options;
  79893. private _detectedPlanes;
  79894. private _enabled;
  79895. private _lastFrameDetected;
  79896. /**
  79897. * The module's name
  79898. */
  79899. static readonly Name: string;
  79900. /**
  79901. * The (Babylon) version of this module.
  79902. * This is an integer representing the implementation version.
  79903. * This number does not correspond to the WebXR specs version
  79904. */
  79905. static readonly Version: number;
  79906. /**
  79907. * Observers registered here will be executed when a new plane was added to the session
  79908. */
  79909. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79910. /**
  79911. * Observers registered here will be executed when a plane is no longer detected in the session
  79912. */
  79913. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79914. /**
  79915. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79916. * This can execute N times every frame
  79917. */
  79918. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79919. /**
  79920. * construct a new Plane Detector
  79921. * @param _xrSessionManager an instance of xr Session manager
  79922. * @param _options configuration to use when constructing this feature
  79923. */
  79924. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79925. /**
  79926. * detach this feature.
  79927. * Will usually be called by the features manager
  79928. *
  79929. * @returns true if successful.
  79930. */
  79931. detach(): boolean;
  79932. /**
  79933. * Dispose this feature and all of the resources attached
  79934. */
  79935. dispose(): void;
  79936. protected _onXRFrame(frame: XRFrame): void;
  79937. private _init;
  79938. private _updatePlaneWithXRPlane;
  79939. /**
  79940. * avoiding using Array.find for global support.
  79941. * @param xrPlane the plane to find in the array
  79942. */
  79943. private findIndexInPlaneArray;
  79944. }
  79945. }
  79946. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  79947. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79949. import { Observable } from "babylonjs/Misc/observable";
  79950. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79951. /**
  79952. * Options interface for the background remover plugin
  79953. */
  79954. export interface IWebXRBackgroundRemoverOptions {
  79955. /**
  79956. * Further background meshes to disable when entering AR
  79957. */
  79958. backgroundMeshes?: AbstractMesh[];
  79959. /**
  79960. * flags to configure the removal of the environment helper.
  79961. * If not set, the entire background will be removed. If set, flags should be set as well.
  79962. */
  79963. environmentHelperRemovalFlags?: {
  79964. /**
  79965. * Should the skybox be removed (default false)
  79966. */
  79967. skyBox?: boolean;
  79968. /**
  79969. * Should the ground be removed (default false)
  79970. */
  79971. ground?: boolean;
  79972. };
  79973. /**
  79974. * don't disable the environment helper
  79975. */
  79976. ignoreEnvironmentHelper?: boolean;
  79977. }
  79978. /**
  79979. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79980. */
  79981. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79982. /**
  79983. * read-only options to be used in this module
  79984. */
  79985. readonly options: IWebXRBackgroundRemoverOptions;
  79986. /**
  79987. * The module's name
  79988. */
  79989. static readonly Name: string;
  79990. /**
  79991. * The (Babylon) version of this module.
  79992. * This is an integer representing the implementation version.
  79993. * This number does not correspond to the WebXR specs version
  79994. */
  79995. static readonly Version: number;
  79996. /**
  79997. * registered observers will be triggered when the background state changes
  79998. */
  79999. onBackgroundStateChangedObservable: Observable<boolean>;
  80000. /**
  80001. * constructs a new background remover module
  80002. * @param _xrSessionManager the session manager for this module
  80003. * @param options read-only options to be used in this module
  80004. */
  80005. constructor(_xrSessionManager: WebXRSessionManager,
  80006. /**
  80007. * read-only options to be used in this module
  80008. */
  80009. options?: IWebXRBackgroundRemoverOptions);
  80010. /**
  80011. * attach this feature
  80012. * Will usually be called by the features manager
  80013. *
  80014. * @returns true if successful.
  80015. */
  80016. attach(): boolean;
  80017. /**
  80018. * detach this feature.
  80019. * Will usually be called by the features manager
  80020. *
  80021. * @returns true if successful.
  80022. */
  80023. detach(): boolean;
  80024. /**
  80025. * Dispose this feature and all of the resources attached
  80026. */
  80027. dispose(): void;
  80028. protected _onXRFrame(_xrFrame: XRFrame): void;
  80029. private _setBackgroundState;
  80030. }
  80031. }
  80032. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  80033. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80034. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80035. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  80036. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80037. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80038. import { Nullable } from "babylonjs/types";
  80039. /**
  80040. * Options for the controller physics feature
  80041. */
  80042. export class IWebXRControllerPhysicsOptions {
  80043. /**
  80044. * Should the headset get its own impostor
  80045. */
  80046. enableHeadsetImpostor?: boolean;
  80047. /**
  80048. * Optional parameters for the headset impostor
  80049. */
  80050. headsetImpostorParams?: {
  80051. /**
  80052. * The type of impostor to create. Default is sphere
  80053. */
  80054. impostorType: number;
  80055. /**
  80056. * the size of the impostor. Defaults to 10cm
  80057. */
  80058. impostorSize?: number | {
  80059. width: number;
  80060. height: number;
  80061. depth: number;
  80062. };
  80063. /**
  80064. * Friction definitions
  80065. */
  80066. friction?: number;
  80067. /**
  80068. * Restitution
  80069. */
  80070. restitution?: number;
  80071. };
  80072. /**
  80073. * The physics properties of the future impostors
  80074. */
  80075. physicsProperties?: {
  80076. /**
  80077. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  80078. * Note that this requires a physics engine that supports mesh impostors!
  80079. */
  80080. useControllerMesh?: boolean;
  80081. /**
  80082. * The type of impostor to create. Default is sphere
  80083. */
  80084. impostorType?: number;
  80085. /**
  80086. * the size of the impostor. Defaults to 10cm
  80087. */
  80088. impostorSize?: number | {
  80089. width: number;
  80090. height: number;
  80091. depth: number;
  80092. };
  80093. /**
  80094. * Friction definitions
  80095. */
  80096. friction?: number;
  80097. /**
  80098. * Restitution
  80099. */
  80100. restitution?: number;
  80101. };
  80102. /**
  80103. * the xr input to use with this pointer selection
  80104. */
  80105. xrInput: WebXRInput;
  80106. }
  80107. /**
  80108. * Add physics impostor to your webxr controllers,
  80109. * including naive calculation of their linear and angular velocity
  80110. */
  80111. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  80112. private readonly _options;
  80113. private _attachController;
  80114. private _controllers;
  80115. private _debugMode;
  80116. private _delta;
  80117. private _headsetImpostor?;
  80118. private _headsetMesh?;
  80119. private _lastTimestamp;
  80120. private _tmpQuaternion;
  80121. private _tmpVector;
  80122. /**
  80123. * The module's name
  80124. */
  80125. static readonly Name: string;
  80126. /**
  80127. * The (Babylon) version of this module.
  80128. * This is an integer representing the implementation version.
  80129. * This number does not correspond to the webxr specs version
  80130. */
  80131. static readonly Version: number;
  80132. /**
  80133. * Construct a new Controller Physics Feature
  80134. * @param _xrSessionManager the corresponding xr session manager
  80135. * @param _options options to create this feature with
  80136. */
  80137. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80138. /**
  80139. * @hidden
  80140. * enable debugging - will show console outputs and the impostor mesh
  80141. */
  80142. _enablePhysicsDebug(): void;
  80143. /**
  80144. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80145. * @param xrController the controller to add
  80146. */
  80147. addController(xrController: WebXRInputSource): void;
  80148. /**
  80149. * attach this feature
  80150. * Will usually be called by the features manager
  80151. *
  80152. * @returns true if successful.
  80153. */
  80154. attach(): boolean;
  80155. /**
  80156. * detach this feature.
  80157. * Will usually be called by the features manager
  80158. *
  80159. * @returns true if successful.
  80160. */
  80161. detach(): boolean;
  80162. /**
  80163. * Get the headset impostor, if enabled
  80164. * @returns the impostor
  80165. */
  80166. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80167. /**
  80168. * Get the physics impostor of a specific controller.
  80169. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80170. * @param controller the controller or the controller id of which to get the impostor
  80171. * @returns the impostor or null
  80172. */
  80173. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80174. /**
  80175. * Update the physics properties provided in the constructor
  80176. * @param newProperties the new properties object
  80177. */
  80178. setPhysicsProperties(newProperties: {
  80179. impostorType?: number;
  80180. impostorSize?: number | {
  80181. width: number;
  80182. height: number;
  80183. depth: number;
  80184. };
  80185. friction?: number;
  80186. restitution?: number;
  80187. }): void;
  80188. protected _onXRFrame(_xrFrame: any): void;
  80189. private _detachController;
  80190. }
  80191. }
  80192. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  80193. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80194. import { Observable } from "babylonjs/Misc/observable";
  80195. import { Vector3 } from "babylonjs/Maths/math.vector";
  80196. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80197. /**
  80198. * A babylon interface for a "WebXR" feature point.
  80199. * Represents the position and confidence value of a given feature point.
  80200. */
  80201. export interface IWebXRFeaturePoint {
  80202. /**
  80203. * Represents the position of the feature point in world space.
  80204. */
  80205. position: Vector3;
  80206. /**
  80207. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80208. */
  80209. confidenceValue: number;
  80210. }
  80211. /**
  80212. * The feature point system is used to detect feature points from real world geometry.
  80213. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80214. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80215. */
  80216. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80217. private _enabled;
  80218. private _featurePointCloud;
  80219. /**
  80220. * The module's name
  80221. */
  80222. static readonly Name: string;
  80223. /**
  80224. * The (Babylon) version of this module.
  80225. * This is an integer representing the implementation version.
  80226. * This number does not correspond to the WebXR specs version
  80227. */
  80228. static readonly Version: number;
  80229. /**
  80230. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80231. * Will notify the observers about which feature points have been added.
  80232. */
  80233. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80234. /**
  80235. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80236. * Will notify the observers about which feature points have been updated.
  80237. */
  80238. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80239. /**
  80240. * The current feature point cloud maintained across frames.
  80241. */
  80242. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80243. /**
  80244. * construct the feature point system
  80245. * @param _xrSessionManager an instance of xr Session manager
  80246. */
  80247. constructor(_xrSessionManager: WebXRSessionManager);
  80248. /**
  80249. * Detach this feature.
  80250. * Will usually be called by the features manager
  80251. *
  80252. * @returns true if successful.
  80253. */
  80254. detach(): boolean;
  80255. /**
  80256. * Dispose this feature and all of the resources attached
  80257. */
  80258. dispose(): void;
  80259. /**
  80260. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80261. */
  80262. protected _onXRFrame(frame: XRFrame): void;
  80263. /**
  80264. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80265. */
  80266. private _init;
  80267. }
  80268. }
  80269. declare module "babylonjs/XR/features/WebXRHandTracking" {
  80270. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80271. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80273. import { Mesh } from "babylonjs/Meshes/mesh";
  80274. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80275. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80276. import { Nullable } from "babylonjs/types";
  80277. import { IDisposable } from "babylonjs/scene";
  80278. import { Observable } from "babylonjs/Misc/observable";
  80279. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  80280. /**
  80281. * Configuration interface for the hand tracking feature
  80282. */
  80283. export interface IWebXRHandTrackingOptions {
  80284. /**
  80285. * The xrInput that will be used as source for new hands
  80286. */
  80287. xrInput: WebXRInput;
  80288. /**
  80289. * Configuration object for the joint meshes
  80290. */
  80291. jointMeshes?: {
  80292. /**
  80293. * Should the meshes created be invisible (defaults to false)
  80294. */
  80295. invisible?: boolean;
  80296. /**
  80297. * A source mesh to be used to create instances. Defaults to a sphere.
  80298. * This mesh will be the source for all other (25) meshes.
  80299. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80300. */
  80301. sourceMesh?: Mesh;
  80302. /**
  80303. * This function will be called after a mesh was created for a specific joint.
  80304. * Using this function you can either manipulate the instance or return a new mesh.
  80305. * When returning a new mesh the instance created before will be disposed
  80306. */
  80307. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80308. /**
  80309. * Should the source mesh stay visible. Defaults to false
  80310. */
  80311. keepOriginalVisible?: boolean;
  80312. /**
  80313. * Scale factor for all instances (defaults to 2)
  80314. */
  80315. scaleFactor?: number;
  80316. /**
  80317. * Should each instance have its own physics impostor
  80318. */
  80319. enablePhysics?: boolean;
  80320. /**
  80321. * If enabled, override default physics properties
  80322. */
  80323. physicsProps?: {
  80324. friction?: number;
  80325. restitution?: number;
  80326. impostorType?: number;
  80327. };
  80328. /**
  80329. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  80330. */
  80331. handMesh?: AbstractMesh;
  80332. };
  80333. }
  80334. /**
  80335. * Parts of the hands divided to writs and finger names
  80336. */
  80337. export const enum HandPart {
  80338. /**
  80339. * HandPart - Wrist
  80340. */
  80341. WRIST = "wrist",
  80342. /**
  80343. * HandPart - The THumb
  80344. */
  80345. THUMB = "thumb",
  80346. /**
  80347. * HandPart - Index finger
  80348. */
  80349. INDEX = "index",
  80350. /**
  80351. * HandPart - Middle finger
  80352. */
  80353. MIDDLE = "middle",
  80354. /**
  80355. * HandPart - Ring finger
  80356. */
  80357. RING = "ring",
  80358. /**
  80359. * HandPart - Little finger
  80360. */
  80361. LITTLE = "little"
  80362. }
  80363. /**
  80364. * Representing a single hand (with its corresponding native XRHand object)
  80365. */
  80366. export class WebXRHand implements IDisposable {
  80367. /** the controller to which the hand correlates */
  80368. readonly xrController: WebXRInputSource;
  80369. /** the meshes to be used to track the hand joints */
  80370. readonly trackedMeshes: AbstractMesh[];
  80371. /**
  80372. * Hand-parts definition (key is HandPart)
  80373. */
  80374. handPartsDefinition: {
  80375. [key: string]: number[];
  80376. };
  80377. /**
  80378. * Populate the HandPartsDefinition object.
  80379. * This is called as a side effect since certain browsers don't have XRHand defined.
  80380. */
  80381. private generateHandPartsDefinition;
  80382. /**
  80383. * Construct a new hand object
  80384. * @param xrController the controller to which the hand correlates
  80385. * @param trackedMeshes the meshes to be used to track the hand joints
  80386. */
  80387. constructor(
  80388. /** the controller to which the hand correlates */
  80389. xrController: WebXRInputSource,
  80390. /** the meshes to be used to track the hand joints */
  80391. trackedMeshes: AbstractMesh[]);
  80392. /**
  80393. * Update this hand from the latest xr frame
  80394. * @param xrFrame xrFrame to update from
  80395. * @param referenceSpace The current viewer reference space
  80396. * @param scaleFactor optional scale factor for the meshes
  80397. */
  80398. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80399. /**
  80400. * Get meshes of part of the hand
  80401. * @param part the part of hand to get
  80402. * @returns An array of meshes that correlate to the hand part requested
  80403. */
  80404. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80405. /**
  80406. * Dispose this Hand object
  80407. */
  80408. dispose(): void;
  80409. }
  80410. /**
  80411. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80412. */
  80413. export class WebXRHandTracking extends WebXRAbstractFeature {
  80414. /**
  80415. * options to use when constructing this feature
  80416. */
  80417. readonly options: IWebXRHandTrackingOptions;
  80418. private static _idCounter;
  80419. /**
  80420. * The module's name
  80421. */
  80422. static readonly Name: string;
  80423. /**
  80424. * The (Babylon) version of this module.
  80425. * This is an integer representing the implementation version.
  80426. * This number does not correspond to the WebXR specs version
  80427. */
  80428. static readonly Version: number;
  80429. /**
  80430. * This observable will notify registered observers when a new hand object was added and initialized
  80431. */
  80432. onHandAddedObservable: Observable<WebXRHand>;
  80433. /**
  80434. * This observable will notify its observers right before the hand object is disposed
  80435. */
  80436. onHandRemovedObservable: Observable<WebXRHand>;
  80437. private _hands;
  80438. /**
  80439. * Creates a new instance of the hit test feature
  80440. * @param _xrSessionManager an instance of WebXRSessionManager
  80441. * @param options options to use when constructing this feature
  80442. */
  80443. constructor(_xrSessionManager: WebXRSessionManager,
  80444. /**
  80445. * options to use when constructing this feature
  80446. */
  80447. options: IWebXRHandTrackingOptions);
  80448. /**
  80449. * Check if the needed objects are defined.
  80450. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80451. */
  80452. isCompatible(): boolean;
  80453. /**
  80454. * attach this feature
  80455. * Will usually be called by the features manager
  80456. *
  80457. * @returns true if successful.
  80458. */
  80459. attach(): boolean;
  80460. /**
  80461. * detach this feature.
  80462. * Will usually be called by the features manager
  80463. *
  80464. * @returns true if successful.
  80465. */
  80466. detach(): boolean;
  80467. /**
  80468. * Dispose this feature and all of the resources attached
  80469. */
  80470. dispose(): void;
  80471. /**
  80472. * Get the hand object according to the controller id
  80473. * @param controllerId the controller id to which we want to get the hand
  80474. * @returns null if not found or the WebXRHand object if found
  80475. */
  80476. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80477. /**
  80478. * Get a hand object according to the requested handedness
  80479. * @param handedness the handedness to request
  80480. * @returns null if not found or the WebXRHand object if found
  80481. */
  80482. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80483. protected _onXRFrame(_xrFrame: XRFrame): void;
  80484. private _attachHand;
  80485. private _detachHand;
  80486. }
  80487. }
  80488. declare module "babylonjs/XR/features/index" {
  80489. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  80490. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  80491. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  80492. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  80493. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  80494. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  80495. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  80496. export * from "babylonjs/XR/features/WebXRHitTest";
  80497. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  80498. export * from "babylonjs/XR/features/WebXRHandTracking";
  80499. }
  80500. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  80501. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80503. import { Scene } from "babylonjs/scene";
  80504. /**
  80505. * The motion controller class for all microsoft mixed reality controllers
  80506. */
  80507. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80508. protected readonly _mapping: {
  80509. defaultButton: {
  80510. valueNodeName: string;
  80511. unpressedNodeName: string;
  80512. pressedNodeName: string;
  80513. };
  80514. defaultAxis: {
  80515. valueNodeName: string;
  80516. minNodeName: string;
  80517. maxNodeName: string;
  80518. };
  80519. buttons: {
  80520. "xr-standard-trigger": {
  80521. rootNodeName: string;
  80522. componentProperty: string;
  80523. states: string[];
  80524. };
  80525. "xr-standard-squeeze": {
  80526. rootNodeName: string;
  80527. componentProperty: string;
  80528. states: string[];
  80529. };
  80530. "xr-standard-touchpad": {
  80531. rootNodeName: string;
  80532. labelAnchorNodeName: string;
  80533. touchPointNodeName: string;
  80534. };
  80535. "xr-standard-thumbstick": {
  80536. rootNodeName: string;
  80537. componentProperty: string;
  80538. states: string[];
  80539. };
  80540. };
  80541. axes: {
  80542. "xr-standard-touchpad": {
  80543. "x-axis": {
  80544. rootNodeName: string;
  80545. };
  80546. "y-axis": {
  80547. rootNodeName: string;
  80548. };
  80549. };
  80550. "xr-standard-thumbstick": {
  80551. "x-axis": {
  80552. rootNodeName: string;
  80553. };
  80554. "y-axis": {
  80555. rootNodeName: string;
  80556. };
  80557. };
  80558. };
  80559. };
  80560. /**
  80561. * The base url used to load the left and right controller models
  80562. */
  80563. static MODEL_BASE_URL: string;
  80564. /**
  80565. * The name of the left controller model file
  80566. */
  80567. static MODEL_LEFT_FILENAME: string;
  80568. /**
  80569. * The name of the right controller model file
  80570. */
  80571. static MODEL_RIGHT_FILENAME: string;
  80572. profileId: string;
  80573. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80574. protected _getFilenameAndPath(): {
  80575. filename: string;
  80576. path: string;
  80577. };
  80578. protected _getModelLoadingConstraints(): boolean;
  80579. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80580. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80581. protected _updateModel(): void;
  80582. }
  80583. }
  80584. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  80585. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80587. import { Scene } from "babylonjs/scene";
  80588. /**
  80589. * The motion controller class for oculus touch (quest, rift).
  80590. * This class supports legacy mapping as well the standard xr mapping
  80591. */
  80592. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80593. private _forceLegacyControllers;
  80594. private _modelRootNode;
  80595. /**
  80596. * The base url used to load the left and right controller models
  80597. */
  80598. static MODEL_BASE_URL: string;
  80599. /**
  80600. * The name of the left controller model file
  80601. */
  80602. static MODEL_LEFT_FILENAME: string;
  80603. /**
  80604. * The name of the right controller model file
  80605. */
  80606. static MODEL_RIGHT_FILENAME: string;
  80607. /**
  80608. * Base Url for the Quest controller model.
  80609. */
  80610. static QUEST_MODEL_BASE_URL: string;
  80611. profileId: string;
  80612. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80613. protected _getFilenameAndPath(): {
  80614. filename: string;
  80615. path: string;
  80616. };
  80617. protected _getModelLoadingConstraints(): boolean;
  80618. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80619. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80620. protected _updateModel(): void;
  80621. /**
  80622. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80623. * between the touch and touch 2.
  80624. */
  80625. private _isQuest;
  80626. }
  80627. }
  80628. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  80629. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80630. import { Scene } from "babylonjs/scene";
  80631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80632. /**
  80633. * The motion controller class for the standard HTC-Vive controllers
  80634. */
  80635. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80636. private _modelRootNode;
  80637. /**
  80638. * The base url used to load the left and right controller models
  80639. */
  80640. static MODEL_BASE_URL: string;
  80641. /**
  80642. * File name for the controller model.
  80643. */
  80644. static MODEL_FILENAME: string;
  80645. profileId: string;
  80646. /**
  80647. * Create a new Vive motion controller object
  80648. * @param scene the scene to use to create this controller
  80649. * @param gamepadObject the corresponding gamepad object
  80650. * @param handedness the handedness of the controller
  80651. */
  80652. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80653. protected _getFilenameAndPath(): {
  80654. filename: string;
  80655. path: string;
  80656. };
  80657. protected _getModelLoadingConstraints(): boolean;
  80658. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80659. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80660. protected _updateModel(): void;
  80661. }
  80662. }
  80663. declare module "babylonjs/XR/motionController/index" {
  80664. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80665. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  80666. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  80667. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  80668. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  80669. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  80670. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  80671. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  80672. }
  80673. declare module "babylonjs/XR/index" {
  80674. export * from "babylonjs/XR/webXRCamera";
  80675. export * from "babylonjs/XR/webXREnterExitUI";
  80676. export * from "babylonjs/XR/webXRExperienceHelper";
  80677. export * from "babylonjs/XR/webXRInput";
  80678. export * from "babylonjs/XR/webXRInputSource";
  80679. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  80680. export * from "babylonjs/XR/webXRTypes";
  80681. export * from "babylonjs/XR/webXRSessionManager";
  80682. export * from "babylonjs/XR/webXRDefaultExperience";
  80683. export * from "babylonjs/XR/webXRFeaturesManager";
  80684. export * from "babylonjs/XR/features/index";
  80685. export * from "babylonjs/XR/motionController/index";
  80686. }
  80687. declare module "babylonjs/index" {
  80688. export * from "babylonjs/abstractScene";
  80689. export * from "babylonjs/Actions/index";
  80690. export * from "babylonjs/Animations/index";
  80691. export * from "babylonjs/assetContainer";
  80692. export * from "babylonjs/Audio/index";
  80693. export * from "babylonjs/Behaviors/index";
  80694. export * from "babylonjs/Bones/index";
  80695. export * from "babylonjs/Cameras/index";
  80696. export * from "babylonjs/Collisions/index";
  80697. export * from "babylonjs/Culling/index";
  80698. export * from "babylonjs/Debug/index";
  80699. export * from "babylonjs/DeviceInput/index";
  80700. export * from "babylonjs/Engines/index";
  80701. export * from "babylonjs/Events/index";
  80702. export * from "babylonjs/Gamepads/index";
  80703. export * from "babylonjs/Gizmos/index";
  80704. export * from "babylonjs/Helpers/index";
  80705. export * from "babylonjs/Instrumentation/index";
  80706. export * from "babylonjs/Layers/index";
  80707. export * from "babylonjs/LensFlares/index";
  80708. export * from "babylonjs/Lights/index";
  80709. export * from "babylonjs/Loading/index";
  80710. export * from "babylonjs/Materials/index";
  80711. export * from "babylonjs/Maths/index";
  80712. export * from "babylonjs/Meshes/index";
  80713. export * from "babylonjs/Morph/index";
  80714. export * from "babylonjs/Navigation/index";
  80715. export * from "babylonjs/node";
  80716. export * from "babylonjs/Offline/index";
  80717. export * from "babylonjs/Particles/index";
  80718. export * from "babylonjs/Physics/index";
  80719. export * from "babylonjs/PostProcesses/index";
  80720. export * from "babylonjs/Probes/index";
  80721. export * from "babylonjs/Rendering/index";
  80722. export * from "babylonjs/scene";
  80723. export * from "babylonjs/sceneComponent";
  80724. export * from "babylonjs/Sprites/index";
  80725. export * from "babylonjs/States/index";
  80726. export * from "babylonjs/Misc/index";
  80727. export * from "babylonjs/XR/index";
  80728. export * from "babylonjs/types";
  80729. }
  80730. declare module "babylonjs/Animations/pathCursor" {
  80731. import { Vector3 } from "babylonjs/Maths/math.vector";
  80732. import { Path2 } from "babylonjs/Maths/math.path";
  80733. /**
  80734. * A cursor which tracks a point on a path
  80735. */
  80736. export class PathCursor {
  80737. private path;
  80738. /**
  80739. * Stores path cursor callbacks for when an onchange event is triggered
  80740. */
  80741. private _onchange;
  80742. /**
  80743. * The value of the path cursor
  80744. */
  80745. value: number;
  80746. /**
  80747. * The animation array of the path cursor
  80748. */
  80749. animations: Animation[];
  80750. /**
  80751. * Initializes the path cursor
  80752. * @param path The path to track
  80753. */
  80754. constructor(path: Path2);
  80755. /**
  80756. * Gets the cursor point on the path
  80757. * @returns A point on the path cursor at the cursor location
  80758. */
  80759. getPoint(): Vector3;
  80760. /**
  80761. * Moves the cursor ahead by the step amount
  80762. * @param step The amount to move the cursor forward
  80763. * @returns This path cursor
  80764. */
  80765. moveAhead(step?: number): PathCursor;
  80766. /**
  80767. * Moves the cursor behind by the step amount
  80768. * @param step The amount to move the cursor back
  80769. * @returns This path cursor
  80770. */
  80771. moveBack(step?: number): PathCursor;
  80772. /**
  80773. * Moves the cursor by the step amount
  80774. * If the step amount is greater than one, an exception is thrown
  80775. * @param step The amount to move the cursor
  80776. * @returns This path cursor
  80777. */
  80778. move(step: number): PathCursor;
  80779. /**
  80780. * Ensures that the value is limited between zero and one
  80781. * @returns This path cursor
  80782. */
  80783. private ensureLimits;
  80784. /**
  80785. * Runs onchange callbacks on change (used by the animation engine)
  80786. * @returns This path cursor
  80787. */
  80788. private raiseOnChange;
  80789. /**
  80790. * Executes a function on change
  80791. * @param f A path cursor onchange callback
  80792. * @returns This path cursor
  80793. */
  80794. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80795. }
  80796. }
  80797. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  80798. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  80799. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  80800. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  80801. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  80802. }
  80803. declare module "babylonjs/Engines/Processors/Expressions/index" {
  80804. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  80805. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  80806. }
  80807. declare module "babylonjs/Engines/Processors/index" {
  80808. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  80809. export * from "babylonjs/Engines/Processors/Expressions/index";
  80810. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  80811. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  80812. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  80813. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  80814. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  80815. export * from "babylonjs/Engines/Processors/shaderProcessor";
  80816. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  80817. }
  80818. declare module "babylonjs/Legacy/legacy" {
  80819. import * as Babylon from "babylonjs/index";
  80820. export * from "babylonjs/index";
  80821. }
  80822. declare module "babylonjs/Shaders/blur.fragment" {
  80823. /** @hidden */
  80824. export var blurPixelShader: {
  80825. name: string;
  80826. shader: string;
  80827. };
  80828. }
  80829. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  80830. /** @hidden */
  80831. export var pointCloudVertexDeclaration: {
  80832. name: string;
  80833. shader: string;
  80834. };
  80835. }
  80836. declare module "babylonjs" {
  80837. export * from "babylonjs/Legacy/legacy";
  80838. }
  80839. declare module BABYLON {
  80840. /** Alias type for value that can be null */
  80841. export type Nullable<T> = T | null;
  80842. /**
  80843. * Alias type for number that are floats
  80844. * @ignorenaming
  80845. */
  80846. export type float = number;
  80847. /**
  80848. * Alias type for number that are doubles.
  80849. * @ignorenaming
  80850. */
  80851. export type double = number;
  80852. /**
  80853. * Alias type for number that are integer
  80854. * @ignorenaming
  80855. */
  80856. export type int = number;
  80857. /** Alias type for number array or Float32Array */
  80858. export type FloatArray = number[] | Float32Array;
  80859. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  80860. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  80861. /**
  80862. * Alias for types that can be used by a Buffer or VertexBuffer.
  80863. */
  80864. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  80865. /**
  80866. * Alias type for primitive types
  80867. * @ignorenaming
  80868. */
  80869. type Primitive = undefined | null | boolean | string | number | Function;
  80870. /**
  80871. * Type modifier to make all the properties of an object Readonly
  80872. */
  80873. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  80874. /**
  80875. * Type modifier to make all the properties of an object Readonly recursively
  80876. */
  80877. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  80878. /**
  80879. * Type modifier to make object properties readonly.
  80880. */
  80881. export type DeepImmutableObject<T> = {
  80882. readonly [K in keyof T]: DeepImmutable<T[K]>;
  80883. };
  80884. /** @hidden */
  80885. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  80886. }
  80887. }
  80888. declare module BABYLON {
  80889. /**
  80890. * A class serves as a medium between the observable and its observers
  80891. */
  80892. export class EventState {
  80893. /**
  80894. * Create a new EventState
  80895. * @param mask defines the mask associated with this state
  80896. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80897. * @param target defines the original target of the state
  80898. * @param currentTarget defines the current target of the state
  80899. */
  80900. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  80901. /**
  80902. * Initialize the current event state
  80903. * @param mask defines the mask associated with this state
  80904. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80905. * @param target defines the original target of the state
  80906. * @param currentTarget defines the current target of the state
  80907. * @returns the current event state
  80908. */
  80909. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  80910. /**
  80911. * An Observer can set this property to true to prevent subsequent observers of being notified
  80912. */
  80913. skipNextObservers: boolean;
  80914. /**
  80915. * Get the mask value that were used to trigger the event corresponding to this EventState object
  80916. */
  80917. mask: number;
  80918. /**
  80919. * The object that originally notified the event
  80920. */
  80921. target?: any;
  80922. /**
  80923. * The current object in the bubbling phase
  80924. */
  80925. currentTarget?: any;
  80926. /**
  80927. * This will be populated with the return value of the last function that was executed.
  80928. * If it is the first function in the callback chain it will be the event data.
  80929. */
  80930. lastReturnValue?: any;
  80931. /**
  80932. * User defined information that will be sent to observers
  80933. */
  80934. userInfo?: any;
  80935. }
  80936. /**
  80937. * Represent an Observer registered to a given Observable object.
  80938. */
  80939. export class Observer<T> {
  80940. /**
  80941. * Defines the callback to call when the observer is notified
  80942. */
  80943. callback: (eventData: T, eventState: EventState) => void;
  80944. /**
  80945. * Defines the mask of the observer (used to filter notifications)
  80946. */
  80947. mask: number;
  80948. /**
  80949. * Defines the current scope used to restore the JS context
  80950. */
  80951. scope: any;
  80952. /** @hidden */
  80953. _willBeUnregistered: boolean;
  80954. /**
  80955. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  80956. */
  80957. unregisterOnNextCall: boolean;
  80958. /**
  80959. * Creates a new observer
  80960. * @param callback defines the callback to call when the observer is notified
  80961. * @param mask defines the mask of the observer (used to filter notifications)
  80962. * @param scope defines the current scope used to restore the JS context
  80963. */
  80964. constructor(
  80965. /**
  80966. * Defines the callback to call when the observer is notified
  80967. */
  80968. callback: (eventData: T, eventState: EventState) => void,
  80969. /**
  80970. * Defines the mask of the observer (used to filter notifications)
  80971. */
  80972. mask: number,
  80973. /**
  80974. * Defines the current scope used to restore the JS context
  80975. */
  80976. scope?: any);
  80977. }
  80978. /**
  80979. * Represent a list of observers registered to multiple Observables object.
  80980. */
  80981. export class MultiObserver<T> {
  80982. private _observers;
  80983. private _observables;
  80984. /**
  80985. * Release associated resources
  80986. */
  80987. dispose(): void;
  80988. /**
  80989. * Raise a callback when one of the observable will notify
  80990. * @param observables defines a list of observables to watch
  80991. * @param callback defines the callback to call on notification
  80992. * @param mask defines the mask used to filter notifications
  80993. * @param scope defines the current scope used to restore the JS context
  80994. * @returns the new MultiObserver
  80995. */
  80996. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80997. }
  80998. /**
  80999. * The Observable class is a simple implementation of the Observable pattern.
  81000. *
  81001. * 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.
  81002. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  81003. * 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).
  81004. * 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.
  81005. */
  81006. export class Observable<T> {
  81007. private _observers;
  81008. private _eventState;
  81009. private _onObserverAdded;
  81010. /**
  81011. * Gets the list of observers
  81012. */
  81013. get observers(): Array<Observer<T>>;
  81014. /**
  81015. * Creates a new observable
  81016. * @param onObserverAdded defines a callback to call when a new observer is added
  81017. */
  81018. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  81019. /**
  81020. * Create a new Observer with the specified callback
  81021. * @param callback the callback that will be executed for that Observer
  81022. * @param mask the mask used to filter observers
  81023. * @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.
  81024. * @param scope optional scope for the callback to be called from
  81025. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  81026. * @returns the new observer created for the callback
  81027. */
  81028. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  81029. /**
  81030. * Create a new Observer with the specified callback and unregisters after the next notification
  81031. * @param callback the callback that will be executed for that Observer
  81032. * @returns the new observer created for the callback
  81033. */
  81034. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  81035. /**
  81036. * Remove an Observer from the Observable object
  81037. * @param observer the instance of the Observer to remove
  81038. * @returns false if it doesn't belong to this Observable
  81039. */
  81040. remove(observer: Nullable<Observer<T>>): boolean;
  81041. /**
  81042. * Remove a callback from the Observable object
  81043. * @param callback the callback to remove
  81044. * @param scope optional scope. If used only the callbacks with this scope will be removed
  81045. * @returns false if it doesn't belong to this Observable
  81046. */
  81047. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  81048. private _deferUnregister;
  81049. private _remove;
  81050. /**
  81051. * Moves the observable to the top of the observer list making it get called first when notified
  81052. * @param observer the observer to move
  81053. */
  81054. makeObserverTopPriority(observer: Observer<T>): void;
  81055. /**
  81056. * Moves the observable to the bottom of the observer list making it get called last when notified
  81057. * @param observer the observer to move
  81058. */
  81059. makeObserverBottomPriority(observer: Observer<T>): void;
  81060. /**
  81061. * Notify all Observers by calling their respective callback with the given data
  81062. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  81063. * @param eventData defines the data to send to all observers
  81064. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  81065. * @param target defines the original target of the state
  81066. * @param currentTarget defines the current target of the state
  81067. * @param userInfo defines any user info to send to observers
  81068. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  81069. */
  81070. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  81071. /**
  81072. * Calling this will execute each callback, expecting it to be a promise or return a value.
  81073. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  81074. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  81075. * and it is crucial that all callbacks will be executed.
  81076. * The order of the callbacks is kept, callbacks are not executed parallel.
  81077. *
  81078. * @param eventData The data to be sent to each callback
  81079. * @param mask is used to filter observers defaults to -1
  81080. * @param target defines the callback target (see EventState)
  81081. * @param currentTarget defines he current object in the bubbling phase
  81082. * @param userInfo defines any user info to send to observers
  81083. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  81084. */
  81085. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  81086. /**
  81087. * Notify a specific observer
  81088. * @param observer defines the observer to notify
  81089. * @param eventData defines the data to be sent to each callback
  81090. * @param mask is used to filter observers defaults to -1
  81091. */
  81092. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  81093. /**
  81094. * Gets a boolean indicating if the observable has at least one observer
  81095. * @returns true is the Observable has at least one Observer registered
  81096. */
  81097. hasObservers(): boolean;
  81098. /**
  81099. * Clear the list of observers
  81100. */
  81101. clear(): void;
  81102. /**
  81103. * Clone the current observable
  81104. * @returns a new observable
  81105. */
  81106. clone(): Observable<T>;
  81107. /**
  81108. * Does this observable handles observer registered with a given mask
  81109. * @param mask defines the mask to be tested
  81110. * @return whether or not one observer registered with the given mask is handeled
  81111. **/
  81112. hasSpecificMask(mask?: number): boolean;
  81113. }
  81114. }
  81115. declare module BABYLON {
  81116. /**
  81117. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  81118. * Babylon.js
  81119. */
  81120. export class DomManagement {
  81121. /**
  81122. * Checks if the window object exists
  81123. * @returns true if the window object exists
  81124. */
  81125. static IsWindowObjectExist(): boolean;
  81126. /**
  81127. * Checks if the navigator object exists
  81128. * @returns true if the navigator object exists
  81129. */
  81130. static IsNavigatorAvailable(): boolean;
  81131. /**
  81132. * Check if the document object exists
  81133. * @returns true if the document object exists
  81134. */
  81135. static IsDocumentAvailable(): boolean;
  81136. /**
  81137. * Extracts text content from a DOM element hierarchy
  81138. * @param element defines the root element
  81139. * @returns a string
  81140. */
  81141. static GetDOMTextContent(element: HTMLElement): string;
  81142. }
  81143. }
  81144. declare module BABYLON {
  81145. /**
  81146. * Logger used througouht the application to allow configuration of
  81147. * the log level required for the messages.
  81148. */
  81149. export class Logger {
  81150. /**
  81151. * No log
  81152. */
  81153. static readonly NoneLogLevel: number;
  81154. /**
  81155. * Only message logs
  81156. */
  81157. static readonly MessageLogLevel: number;
  81158. /**
  81159. * Only warning logs
  81160. */
  81161. static readonly WarningLogLevel: number;
  81162. /**
  81163. * Only error logs
  81164. */
  81165. static readonly ErrorLogLevel: number;
  81166. /**
  81167. * All logs
  81168. */
  81169. static readonly AllLogLevel: number;
  81170. private static _LogCache;
  81171. /**
  81172. * Gets a value indicating the number of loading errors
  81173. * @ignorenaming
  81174. */
  81175. static errorsCount: number;
  81176. /**
  81177. * Callback called when a new log is added
  81178. */
  81179. static OnNewCacheEntry: (entry: string) => void;
  81180. private static _AddLogEntry;
  81181. private static _FormatMessage;
  81182. private static _LogDisabled;
  81183. private static _LogEnabled;
  81184. private static _WarnDisabled;
  81185. private static _WarnEnabled;
  81186. private static _ErrorDisabled;
  81187. private static _ErrorEnabled;
  81188. /**
  81189. * Log a message to the console
  81190. */
  81191. static Log: (message: string) => void;
  81192. /**
  81193. * Write a warning message to the console
  81194. */
  81195. static Warn: (message: string) => void;
  81196. /**
  81197. * Write an error message to the console
  81198. */
  81199. static Error: (message: string) => void;
  81200. /**
  81201. * Gets current log cache (list of logs)
  81202. */
  81203. static get LogCache(): string;
  81204. /**
  81205. * Clears the log cache
  81206. */
  81207. static ClearLogCache(): void;
  81208. /**
  81209. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  81210. */
  81211. static set LogLevels(level: number);
  81212. }
  81213. }
  81214. declare module BABYLON {
  81215. /** @hidden */
  81216. export class _TypeStore {
  81217. /** @hidden */
  81218. static RegisteredTypes: {
  81219. [key: string]: Object;
  81220. };
  81221. /** @hidden */
  81222. static GetClass(fqdn: string): any;
  81223. }
  81224. }
  81225. declare module BABYLON {
  81226. /**
  81227. * Helper to manipulate strings
  81228. */
  81229. export class StringTools {
  81230. /**
  81231. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  81232. * @param str Source string
  81233. * @param suffix Suffix to search for in the source string
  81234. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81235. */
  81236. static EndsWith(str: string, suffix: string): boolean;
  81237. /**
  81238. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  81239. * @param str Source string
  81240. * @param suffix Suffix to search for in the source string
  81241. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81242. */
  81243. static StartsWith(str: string, suffix: string): boolean;
  81244. /**
  81245. * Decodes a buffer into a string
  81246. * @param buffer The buffer to decode
  81247. * @returns The decoded string
  81248. */
  81249. static Decode(buffer: Uint8Array | Uint16Array): string;
  81250. /**
  81251. * Encode a buffer to a base64 string
  81252. * @param buffer defines the buffer to encode
  81253. * @returns the encoded string
  81254. */
  81255. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  81256. /**
  81257. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  81258. * @param num the number to convert and pad
  81259. * @param length the expected length of the string
  81260. * @returns the padded string
  81261. */
  81262. static PadNumber(num: number, length: number): string;
  81263. }
  81264. }
  81265. declare module BABYLON {
  81266. /**
  81267. * Class containing a set of static utilities functions for deep copy.
  81268. */
  81269. export class DeepCopier {
  81270. /**
  81271. * Tries to copy an object by duplicating every property
  81272. * @param source defines the source object
  81273. * @param destination defines the target object
  81274. * @param doNotCopyList defines a list of properties to avoid
  81275. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  81276. */
  81277. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  81278. }
  81279. }
  81280. declare module BABYLON {
  81281. /**
  81282. * Class containing a set of static utilities functions for precision date
  81283. */
  81284. export class PrecisionDate {
  81285. /**
  81286. * Gets either window.performance.now() if supported or Date.now() else
  81287. */
  81288. static get Now(): number;
  81289. }
  81290. }
  81291. declare module BABYLON {
  81292. /** @hidden */
  81293. export class _DevTools {
  81294. static WarnImport(name: string): string;
  81295. }
  81296. }
  81297. declare module BABYLON {
  81298. /**
  81299. * Interface used to define the mechanism to get data from the network
  81300. */
  81301. export interface IWebRequest {
  81302. /**
  81303. * Returns client's response url
  81304. */
  81305. responseURL: string;
  81306. /**
  81307. * Returns client's status
  81308. */
  81309. status: number;
  81310. /**
  81311. * Returns client's status as a text
  81312. */
  81313. statusText: string;
  81314. }
  81315. }
  81316. declare module BABYLON {
  81317. /**
  81318. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  81319. */
  81320. export class WebRequest implements IWebRequest {
  81321. private _xhr;
  81322. /**
  81323. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  81324. * i.e. when loading files, where the server/service expects an Authorization header
  81325. */
  81326. static CustomRequestHeaders: {
  81327. [key: string]: string;
  81328. };
  81329. /**
  81330. * Add callback functions in this array to update all the requests before they get sent to the network
  81331. */
  81332. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  81333. private _injectCustomRequestHeaders;
  81334. /**
  81335. * Gets or sets a function to be called when loading progress changes
  81336. */
  81337. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  81338. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  81339. /**
  81340. * Returns client's state
  81341. */
  81342. get readyState(): number;
  81343. /**
  81344. * Returns client's status
  81345. */
  81346. get status(): number;
  81347. /**
  81348. * Returns client's status as a text
  81349. */
  81350. get statusText(): string;
  81351. /**
  81352. * Returns client's response
  81353. */
  81354. get response(): any;
  81355. /**
  81356. * Returns client's response url
  81357. */
  81358. get responseURL(): string;
  81359. /**
  81360. * Returns client's response as text
  81361. */
  81362. get responseText(): string;
  81363. /**
  81364. * Gets or sets the expected response type
  81365. */
  81366. get responseType(): XMLHttpRequestResponseType;
  81367. set responseType(value: XMLHttpRequestResponseType);
  81368. /** @hidden */
  81369. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  81370. /** @hidden */
  81371. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  81372. /**
  81373. * Cancels any network activity
  81374. */
  81375. abort(): void;
  81376. /**
  81377. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  81378. * @param body defines an optional request body
  81379. */
  81380. send(body?: Document | BodyInit | null): void;
  81381. /**
  81382. * Sets the request method, request URL
  81383. * @param method defines the method to use (GET, POST, etc..)
  81384. * @param url defines the url to connect with
  81385. */
  81386. open(method: string, url: string): void;
  81387. /**
  81388. * Sets the value of a request header.
  81389. * @param name The name of the header whose value is to be set
  81390. * @param value The value to set as the body of the header
  81391. */
  81392. setRequestHeader(name: string, value: string): void;
  81393. /**
  81394. * Get the string containing the text of a particular header's value.
  81395. * @param name The name of the header
  81396. * @returns The string containing the text of the given header name
  81397. */
  81398. getResponseHeader(name: string): Nullable<string>;
  81399. }
  81400. }
  81401. declare module BABYLON {
  81402. /**
  81403. * File request interface
  81404. */
  81405. export interface IFileRequest {
  81406. /**
  81407. * Raised when the request is complete (success or error).
  81408. */
  81409. onCompleteObservable: Observable<IFileRequest>;
  81410. /**
  81411. * Aborts the request for a file.
  81412. */
  81413. abort: () => void;
  81414. }
  81415. }
  81416. declare module BABYLON {
  81417. /**
  81418. * Define options used to create a render target texture
  81419. */
  81420. export class RenderTargetCreationOptions {
  81421. /**
  81422. * Specifies is mipmaps must be generated
  81423. */
  81424. generateMipMaps?: boolean;
  81425. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  81426. generateDepthBuffer?: boolean;
  81427. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  81428. generateStencilBuffer?: boolean;
  81429. /** Defines texture type (int by default) */
  81430. type?: number;
  81431. /** Defines sampling mode (trilinear by default) */
  81432. samplingMode?: number;
  81433. /** Defines format (RGBA by default) */
  81434. format?: number;
  81435. }
  81436. }
  81437. declare module BABYLON {
  81438. /** Defines the cross module used constants to avoid circular dependncies */
  81439. export class Constants {
  81440. /** Defines that alpha blending is disabled */
  81441. static readonly ALPHA_DISABLE: number;
  81442. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  81443. static readonly ALPHA_ADD: number;
  81444. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  81445. static readonly ALPHA_COMBINE: number;
  81446. /** Defines that alpha blending is DEST - SRC * DEST */
  81447. static readonly ALPHA_SUBTRACT: number;
  81448. /** Defines that alpha blending is SRC * DEST */
  81449. static readonly ALPHA_MULTIPLY: number;
  81450. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  81451. static readonly ALPHA_MAXIMIZED: number;
  81452. /** Defines that alpha blending is SRC + DEST */
  81453. static readonly ALPHA_ONEONE: number;
  81454. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  81455. static readonly ALPHA_PREMULTIPLIED: number;
  81456. /**
  81457. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  81458. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  81459. */
  81460. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  81461. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  81462. static readonly ALPHA_INTERPOLATE: number;
  81463. /**
  81464. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  81465. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  81466. */
  81467. static readonly ALPHA_SCREENMODE: number;
  81468. /**
  81469. * Defines that alpha blending is SRC + DST
  81470. * Alpha will be set to SRC ALPHA + DST ALPHA
  81471. */
  81472. static readonly ALPHA_ONEONE_ONEONE: number;
  81473. /**
  81474. * Defines that alpha blending is SRC * DST ALPHA + DST
  81475. * Alpha will be set to 0
  81476. */
  81477. static readonly ALPHA_ALPHATOCOLOR: number;
  81478. /**
  81479. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81480. */
  81481. static readonly ALPHA_REVERSEONEMINUS: number;
  81482. /**
  81483. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  81484. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  81485. */
  81486. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  81487. /**
  81488. * Defines that alpha blending is SRC + DST
  81489. * Alpha will be set to SRC ALPHA
  81490. */
  81491. static readonly ALPHA_ONEONE_ONEZERO: number;
  81492. /**
  81493. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81494. * Alpha will be set to DST ALPHA
  81495. */
  81496. static readonly ALPHA_EXCLUSION: number;
  81497. /** Defines that alpha blending equation a SUM */
  81498. static readonly ALPHA_EQUATION_ADD: number;
  81499. /** Defines that alpha blending equation a SUBSTRACTION */
  81500. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  81501. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  81502. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  81503. /** Defines that alpha blending equation a MAX operation */
  81504. static readonly ALPHA_EQUATION_MAX: number;
  81505. /** Defines that alpha blending equation a MIN operation */
  81506. static readonly ALPHA_EQUATION_MIN: number;
  81507. /**
  81508. * Defines that alpha blending equation a DARKEN operation:
  81509. * It takes the min of the src and sums the alpha channels.
  81510. */
  81511. static readonly ALPHA_EQUATION_DARKEN: number;
  81512. /** Defines that the ressource is not delayed*/
  81513. static readonly DELAYLOADSTATE_NONE: number;
  81514. /** Defines that the ressource was successfully delay loaded */
  81515. static readonly DELAYLOADSTATE_LOADED: number;
  81516. /** Defines that the ressource is currently delay loading */
  81517. static readonly DELAYLOADSTATE_LOADING: number;
  81518. /** Defines that the ressource is delayed and has not started loading */
  81519. static readonly DELAYLOADSTATE_NOTLOADED: number;
  81520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  81521. static readonly NEVER: number;
  81522. /** 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 */
  81523. static readonly ALWAYS: number;
  81524. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  81525. static readonly LESS: number;
  81526. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  81527. static readonly EQUAL: number;
  81528. /** 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 */
  81529. static readonly LEQUAL: number;
  81530. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  81531. static readonly GREATER: number;
  81532. /** 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 */
  81533. static readonly GEQUAL: number;
  81534. /** 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 */
  81535. static readonly NOTEQUAL: number;
  81536. /** Passed to stencilOperation to specify that stencil value must be kept */
  81537. static readonly KEEP: number;
  81538. /** Passed to stencilOperation to specify that stencil value must be replaced */
  81539. static readonly REPLACE: number;
  81540. /** Passed to stencilOperation to specify that stencil value must be incremented */
  81541. static readonly INCR: number;
  81542. /** Passed to stencilOperation to specify that stencil value must be decremented */
  81543. static readonly DECR: number;
  81544. /** Passed to stencilOperation to specify that stencil value must be inverted */
  81545. static readonly INVERT: number;
  81546. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  81547. static readonly INCR_WRAP: number;
  81548. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  81549. static readonly DECR_WRAP: number;
  81550. /** Texture is not repeating outside of 0..1 UVs */
  81551. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  81552. /** Texture is repeating outside of 0..1 UVs */
  81553. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  81554. /** Texture is repeating and mirrored */
  81555. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  81556. /** ALPHA */
  81557. static readonly TEXTUREFORMAT_ALPHA: number;
  81558. /** LUMINANCE */
  81559. static readonly TEXTUREFORMAT_LUMINANCE: number;
  81560. /** LUMINANCE_ALPHA */
  81561. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  81562. /** RGB */
  81563. static readonly TEXTUREFORMAT_RGB: number;
  81564. /** RGBA */
  81565. static readonly TEXTUREFORMAT_RGBA: number;
  81566. /** RED */
  81567. static readonly TEXTUREFORMAT_RED: number;
  81568. /** RED (2nd reference) */
  81569. static readonly TEXTUREFORMAT_R: number;
  81570. /** RG */
  81571. static readonly TEXTUREFORMAT_RG: number;
  81572. /** RED_INTEGER */
  81573. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  81574. /** RED_INTEGER (2nd reference) */
  81575. static readonly TEXTUREFORMAT_R_INTEGER: number;
  81576. /** RG_INTEGER */
  81577. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  81578. /** RGB_INTEGER */
  81579. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  81580. /** RGBA_INTEGER */
  81581. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  81582. /** UNSIGNED_BYTE */
  81583. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  81584. /** UNSIGNED_BYTE (2nd reference) */
  81585. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  81586. /** FLOAT */
  81587. static readonly TEXTURETYPE_FLOAT: number;
  81588. /** HALF_FLOAT */
  81589. static readonly TEXTURETYPE_HALF_FLOAT: number;
  81590. /** BYTE */
  81591. static readonly TEXTURETYPE_BYTE: number;
  81592. /** SHORT */
  81593. static readonly TEXTURETYPE_SHORT: number;
  81594. /** UNSIGNED_SHORT */
  81595. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81596. /** INT */
  81597. static readonly TEXTURETYPE_INT: number;
  81598. /** UNSIGNED_INT */
  81599. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81600. /** UNSIGNED_SHORT_4_4_4_4 */
  81601. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81602. /** UNSIGNED_SHORT_5_5_5_1 */
  81603. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81604. /** UNSIGNED_SHORT_5_6_5 */
  81605. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81606. /** UNSIGNED_INT_2_10_10_10_REV */
  81607. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81608. /** UNSIGNED_INT_24_8 */
  81609. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81610. /** UNSIGNED_INT_10F_11F_11F_REV */
  81611. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81612. /** UNSIGNED_INT_5_9_9_9_REV */
  81613. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81614. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81615. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81616. /** nearest is mag = nearest and min = nearest and no mip */
  81617. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81618. /** mag = nearest and min = nearest and mip = none */
  81619. static readonly TEXTURE_NEAREST_NEAREST: number;
  81620. /** Bilinear is mag = linear and min = linear and no mip */
  81621. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81622. /** mag = linear and min = linear and mip = none */
  81623. static readonly TEXTURE_LINEAR_LINEAR: number;
  81624. /** Trilinear is mag = linear and min = linear and mip = linear */
  81625. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  81626. /** Trilinear is mag = linear and min = linear and mip = linear */
  81627. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  81628. /** mag = nearest and min = nearest and mip = nearest */
  81629. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  81630. /** mag = nearest and min = linear and mip = nearest */
  81631. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  81632. /** mag = nearest and min = linear and mip = linear */
  81633. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  81634. /** mag = nearest and min = linear and mip = none */
  81635. static readonly TEXTURE_NEAREST_LINEAR: number;
  81636. /** nearest is mag = nearest and min = nearest and mip = linear */
  81637. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  81638. /** mag = linear and min = nearest and mip = nearest */
  81639. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  81640. /** mag = linear and min = nearest and mip = linear */
  81641. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  81642. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81643. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  81644. /** mag = linear and min = nearest and mip = none */
  81645. static readonly TEXTURE_LINEAR_NEAREST: number;
  81646. /** Explicit coordinates mode */
  81647. static readonly TEXTURE_EXPLICIT_MODE: number;
  81648. /** Spherical coordinates mode */
  81649. static readonly TEXTURE_SPHERICAL_MODE: number;
  81650. /** Planar coordinates mode */
  81651. static readonly TEXTURE_PLANAR_MODE: number;
  81652. /** Cubic coordinates mode */
  81653. static readonly TEXTURE_CUBIC_MODE: number;
  81654. /** Projection coordinates mode */
  81655. static readonly TEXTURE_PROJECTION_MODE: number;
  81656. /** Skybox coordinates mode */
  81657. static readonly TEXTURE_SKYBOX_MODE: number;
  81658. /** Inverse Cubic coordinates mode */
  81659. static readonly TEXTURE_INVCUBIC_MODE: number;
  81660. /** Equirectangular coordinates mode */
  81661. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  81662. /** Equirectangular Fixed coordinates mode */
  81663. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  81664. /** Equirectangular Fixed Mirrored coordinates mode */
  81665. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81666. /** Offline (baking) quality for texture filtering */
  81667. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  81668. /** High quality for texture filtering */
  81669. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  81670. /** Medium quality for texture filtering */
  81671. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  81672. /** Low quality for texture filtering */
  81673. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  81674. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  81675. static readonly SCALEMODE_FLOOR: number;
  81676. /** Defines that texture rescaling will look for the nearest power of 2 size */
  81677. static readonly SCALEMODE_NEAREST: number;
  81678. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  81679. static readonly SCALEMODE_CEILING: number;
  81680. /**
  81681. * The dirty texture flag value
  81682. */
  81683. static readonly MATERIAL_TextureDirtyFlag: number;
  81684. /**
  81685. * The dirty light flag value
  81686. */
  81687. static readonly MATERIAL_LightDirtyFlag: number;
  81688. /**
  81689. * The dirty fresnel flag value
  81690. */
  81691. static readonly MATERIAL_FresnelDirtyFlag: number;
  81692. /**
  81693. * The dirty attribute flag value
  81694. */
  81695. static readonly MATERIAL_AttributesDirtyFlag: number;
  81696. /**
  81697. * The dirty misc flag value
  81698. */
  81699. static readonly MATERIAL_MiscDirtyFlag: number;
  81700. /**
  81701. * The dirty prepass flag value
  81702. */
  81703. static readonly MATERIAL_PrePassDirtyFlag: number;
  81704. /**
  81705. * The all dirty flag value
  81706. */
  81707. static readonly MATERIAL_AllDirtyFlag: number;
  81708. /**
  81709. * Returns the triangle fill mode
  81710. */
  81711. static readonly MATERIAL_TriangleFillMode: number;
  81712. /**
  81713. * Returns the wireframe mode
  81714. */
  81715. static readonly MATERIAL_WireFrameFillMode: number;
  81716. /**
  81717. * Returns the point fill mode
  81718. */
  81719. static readonly MATERIAL_PointFillMode: number;
  81720. /**
  81721. * Returns the point list draw mode
  81722. */
  81723. static readonly MATERIAL_PointListDrawMode: number;
  81724. /**
  81725. * Returns the line list draw mode
  81726. */
  81727. static readonly MATERIAL_LineListDrawMode: number;
  81728. /**
  81729. * Returns the line loop draw mode
  81730. */
  81731. static readonly MATERIAL_LineLoopDrawMode: number;
  81732. /**
  81733. * Returns the line strip draw mode
  81734. */
  81735. static readonly MATERIAL_LineStripDrawMode: number;
  81736. /**
  81737. * Returns the triangle strip draw mode
  81738. */
  81739. static readonly MATERIAL_TriangleStripDrawMode: number;
  81740. /**
  81741. * Returns the triangle fan draw mode
  81742. */
  81743. static readonly MATERIAL_TriangleFanDrawMode: number;
  81744. /**
  81745. * Stores the clock-wise side orientation
  81746. */
  81747. static readonly MATERIAL_ClockWiseSideOrientation: number;
  81748. /**
  81749. * Stores the counter clock-wise side orientation
  81750. */
  81751. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  81752. /**
  81753. * Nothing
  81754. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81755. */
  81756. static readonly ACTION_NothingTrigger: number;
  81757. /**
  81758. * On pick
  81759. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81760. */
  81761. static readonly ACTION_OnPickTrigger: number;
  81762. /**
  81763. * On left pick
  81764. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81765. */
  81766. static readonly ACTION_OnLeftPickTrigger: number;
  81767. /**
  81768. * On right pick
  81769. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81770. */
  81771. static readonly ACTION_OnRightPickTrigger: number;
  81772. /**
  81773. * On center pick
  81774. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81775. */
  81776. static readonly ACTION_OnCenterPickTrigger: number;
  81777. /**
  81778. * On pick down
  81779. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81780. */
  81781. static readonly ACTION_OnPickDownTrigger: number;
  81782. /**
  81783. * On double pick
  81784. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81785. */
  81786. static readonly ACTION_OnDoublePickTrigger: number;
  81787. /**
  81788. * On pick up
  81789. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81790. */
  81791. static readonly ACTION_OnPickUpTrigger: number;
  81792. /**
  81793. * On pick out.
  81794. * This trigger will only be raised if you also declared a OnPickDown
  81795. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81796. */
  81797. static readonly ACTION_OnPickOutTrigger: number;
  81798. /**
  81799. * On long press
  81800. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81801. */
  81802. static readonly ACTION_OnLongPressTrigger: number;
  81803. /**
  81804. * On pointer over
  81805. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81806. */
  81807. static readonly ACTION_OnPointerOverTrigger: number;
  81808. /**
  81809. * On pointer out
  81810. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81811. */
  81812. static readonly ACTION_OnPointerOutTrigger: number;
  81813. /**
  81814. * On every frame
  81815. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81816. */
  81817. static readonly ACTION_OnEveryFrameTrigger: number;
  81818. /**
  81819. * On intersection enter
  81820. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81821. */
  81822. static readonly ACTION_OnIntersectionEnterTrigger: number;
  81823. /**
  81824. * On intersection exit
  81825. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81826. */
  81827. static readonly ACTION_OnIntersectionExitTrigger: number;
  81828. /**
  81829. * On key down
  81830. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81831. */
  81832. static readonly ACTION_OnKeyDownTrigger: number;
  81833. /**
  81834. * On key up
  81835. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81836. */
  81837. static readonly ACTION_OnKeyUpTrigger: number;
  81838. /**
  81839. * Billboard mode will only apply to Y axis
  81840. */
  81841. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  81842. /**
  81843. * Billboard mode will apply to all axes
  81844. */
  81845. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  81846. /**
  81847. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81848. */
  81849. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  81850. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81851. * Test order :
  81852. * Is the bounding sphere outside the frustum ?
  81853. * If not, are the bounding box vertices outside the frustum ?
  81854. * It not, then the cullable object is in the frustum.
  81855. */
  81856. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  81857. /** Culling strategy : Bounding Sphere Only.
  81858. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81859. * It's also less accurate than the standard because some not visible objects can still be selected.
  81860. * Test : is the bounding sphere outside the frustum ?
  81861. * If not, then the cullable object is in the frustum.
  81862. */
  81863. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81864. /** Culling strategy : Optimistic Inclusion.
  81865. * This in an inclusion test first, then the standard exclusion test.
  81866. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81867. * 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.
  81868. * Anyway, it's as accurate as the standard strategy.
  81869. * Test :
  81870. * Is the cullable object bounding sphere center in the frustum ?
  81871. * If not, apply the default culling strategy.
  81872. */
  81873. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81874. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81875. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81876. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81877. * 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.
  81878. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81879. * Test :
  81880. * Is the cullable object bounding sphere center in the frustum ?
  81881. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81882. */
  81883. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81884. /**
  81885. * No logging while loading
  81886. */
  81887. static readonly SCENELOADER_NO_LOGGING: number;
  81888. /**
  81889. * Minimal logging while loading
  81890. */
  81891. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  81892. /**
  81893. * Summary logging while loading
  81894. */
  81895. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  81896. /**
  81897. * Detailled logging while loading
  81898. */
  81899. static readonly SCENELOADER_DETAILED_LOGGING: number;
  81900. /**
  81901. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  81902. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  81903. */
  81904. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  81905. /**
  81906. * Constant used to retrieve the position texture index in the textures array in the prepass
  81907. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  81908. */
  81909. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  81910. /**
  81911. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  81912. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  81913. */
  81914. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  81915. /**
  81916. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  81917. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  81918. */
  81919. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  81920. /**
  81921. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  81922. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  81923. */
  81924. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  81925. /**
  81926. * Constant used to retrieve depth + normal index in the textures array in the prepass
  81927. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  81928. */
  81929. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  81930. /**
  81931. * Constant used to retrieve albedo index in the textures array in the prepass
  81932. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  81933. */
  81934. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  81935. }
  81936. }
  81937. declare module BABYLON {
  81938. /**
  81939. * This represents the required contract to create a new type of texture loader.
  81940. */
  81941. export interface IInternalTextureLoader {
  81942. /**
  81943. * Defines wether the loader supports cascade loading the different faces.
  81944. */
  81945. supportCascades: boolean;
  81946. /**
  81947. * This returns if the loader support the current file information.
  81948. * @param extension defines the file extension of the file being loaded
  81949. * @param mimeType defines the optional mime type of the file being loaded
  81950. * @returns true if the loader can load the specified file
  81951. */
  81952. canLoad(extension: string, mimeType?: string): boolean;
  81953. /**
  81954. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  81955. * @param data contains the texture data
  81956. * @param texture defines the BabylonJS internal texture
  81957. * @param createPolynomials will be true if polynomials have been requested
  81958. * @param onLoad defines the callback to trigger once the texture is ready
  81959. * @param onError defines the callback to trigger in case of error
  81960. * @param options options to be passed to the loader
  81961. */
  81962. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  81963. /**
  81964. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  81965. * @param data contains the texture data
  81966. * @param texture defines the BabylonJS internal texture
  81967. * @param callback defines the method to call once ready to upload
  81968. * @param options options to be passed to the loader
  81969. */
  81970. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  81971. }
  81972. }
  81973. declare module BABYLON {
  81974. /**
  81975. * Class used to store and describe the pipeline context associated with an effect
  81976. */
  81977. export interface IPipelineContext {
  81978. /**
  81979. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  81980. */
  81981. isAsync: boolean;
  81982. /**
  81983. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  81984. */
  81985. isReady: boolean;
  81986. /** @hidden */
  81987. _getVertexShaderCode(): string | null;
  81988. /** @hidden */
  81989. _getFragmentShaderCode(): string | null;
  81990. /** @hidden */
  81991. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  81992. }
  81993. }
  81994. declare module BABYLON {
  81995. /**
  81996. * Class used to store gfx data (like WebGLBuffer)
  81997. */
  81998. export class DataBuffer {
  81999. /**
  82000. * Gets or sets the number of objects referencing this buffer
  82001. */
  82002. references: number;
  82003. /** Gets or sets the size of the underlying buffer */
  82004. capacity: number;
  82005. /**
  82006. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  82007. */
  82008. is32Bits: boolean;
  82009. /**
  82010. * Gets the underlying buffer
  82011. */
  82012. get underlyingResource(): any;
  82013. }
  82014. }
  82015. declare module BABYLON {
  82016. /** @hidden */
  82017. export interface IShaderProcessor {
  82018. attributeProcessor?: (attribute: string) => string;
  82019. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  82020. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  82021. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  82022. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  82023. lineProcessor?: (line: string, isFragment: boolean) => string;
  82024. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  82025. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  82026. }
  82027. }
  82028. declare module BABYLON {
  82029. /** @hidden */
  82030. export interface ProcessingOptions {
  82031. defines: string[];
  82032. indexParameters: any;
  82033. isFragment: boolean;
  82034. shouldUseHighPrecisionShader: boolean;
  82035. supportsUniformBuffers: boolean;
  82036. shadersRepository: string;
  82037. includesShadersStore: {
  82038. [key: string]: string;
  82039. };
  82040. processor?: IShaderProcessor;
  82041. version: string;
  82042. platformName: string;
  82043. lookForClosingBracketForUniformBuffer?: boolean;
  82044. }
  82045. }
  82046. declare module BABYLON {
  82047. /** @hidden */
  82048. export class ShaderCodeNode {
  82049. line: string;
  82050. children: ShaderCodeNode[];
  82051. additionalDefineKey?: string;
  82052. additionalDefineValue?: string;
  82053. isValid(preprocessors: {
  82054. [key: string]: string;
  82055. }): boolean;
  82056. process(preprocessors: {
  82057. [key: string]: string;
  82058. }, options: ProcessingOptions): string;
  82059. }
  82060. }
  82061. declare module BABYLON {
  82062. /** @hidden */
  82063. export class ShaderCodeCursor {
  82064. private _lines;
  82065. lineIndex: number;
  82066. get currentLine(): string;
  82067. get canRead(): boolean;
  82068. set lines(value: string[]);
  82069. }
  82070. }
  82071. declare module BABYLON {
  82072. /** @hidden */
  82073. export class ShaderCodeConditionNode extends ShaderCodeNode {
  82074. process(preprocessors: {
  82075. [key: string]: string;
  82076. }, options: ProcessingOptions): string;
  82077. }
  82078. }
  82079. declare module BABYLON {
  82080. /** @hidden */
  82081. export class ShaderDefineExpression {
  82082. isTrue(preprocessors: {
  82083. [key: string]: string;
  82084. }): boolean;
  82085. private static _OperatorPriority;
  82086. private static _Stack;
  82087. static postfixToInfix(postfix: string[]): string;
  82088. static infixToPostfix(infix: string): string[];
  82089. }
  82090. }
  82091. declare module BABYLON {
  82092. /** @hidden */
  82093. export class ShaderCodeTestNode extends ShaderCodeNode {
  82094. testExpression: ShaderDefineExpression;
  82095. isValid(preprocessors: {
  82096. [key: string]: string;
  82097. }): boolean;
  82098. }
  82099. }
  82100. declare module BABYLON {
  82101. /** @hidden */
  82102. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  82103. define: string;
  82104. not: boolean;
  82105. constructor(define: string, not?: boolean);
  82106. isTrue(preprocessors: {
  82107. [key: string]: string;
  82108. }): boolean;
  82109. }
  82110. }
  82111. declare module BABYLON {
  82112. /** @hidden */
  82113. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  82114. leftOperand: ShaderDefineExpression;
  82115. rightOperand: ShaderDefineExpression;
  82116. isTrue(preprocessors: {
  82117. [key: string]: string;
  82118. }): boolean;
  82119. }
  82120. }
  82121. declare module BABYLON {
  82122. /** @hidden */
  82123. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  82124. leftOperand: ShaderDefineExpression;
  82125. rightOperand: ShaderDefineExpression;
  82126. isTrue(preprocessors: {
  82127. [key: string]: string;
  82128. }): boolean;
  82129. }
  82130. }
  82131. declare module BABYLON {
  82132. /** @hidden */
  82133. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  82134. define: string;
  82135. operand: string;
  82136. testValue: string;
  82137. constructor(define: string, operand: string, testValue: string);
  82138. isTrue(preprocessors: {
  82139. [key: string]: string;
  82140. }): boolean;
  82141. }
  82142. }
  82143. declare module BABYLON {
  82144. /**
  82145. * Class used to enable access to offline support
  82146. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  82147. */
  82148. export interface IOfflineProvider {
  82149. /**
  82150. * Gets a boolean indicating if scene must be saved in the database
  82151. */
  82152. enableSceneOffline: boolean;
  82153. /**
  82154. * Gets a boolean indicating if textures must be saved in the database
  82155. */
  82156. enableTexturesOffline: boolean;
  82157. /**
  82158. * Open the offline support and make it available
  82159. * @param successCallback defines the callback to call on success
  82160. * @param errorCallback defines the callback to call on error
  82161. */
  82162. open(successCallback: () => void, errorCallback: () => void): void;
  82163. /**
  82164. * Loads an image from the offline support
  82165. * @param url defines the url to load from
  82166. * @param image defines the target DOM image
  82167. */
  82168. loadImage(url: string, image: HTMLImageElement): void;
  82169. /**
  82170. * Loads a file from offline support
  82171. * @param url defines the URL to load from
  82172. * @param sceneLoaded defines a callback to call on success
  82173. * @param progressCallBack defines a callback to call when progress changed
  82174. * @param errorCallback defines a callback to call on error
  82175. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  82176. */
  82177. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  82178. }
  82179. }
  82180. declare module BABYLON {
  82181. /**
  82182. * Class used to help managing file picking and drag'n'drop
  82183. * File Storage
  82184. */
  82185. export class FilesInputStore {
  82186. /**
  82187. * List of files ready to be loaded
  82188. */
  82189. static FilesToLoad: {
  82190. [key: string]: File;
  82191. };
  82192. }
  82193. }
  82194. declare module BABYLON {
  82195. /**
  82196. * Class used to define a retry strategy when error happens while loading assets
  82197. */
  82198. export class RetryStrategy {
  82199. /**
  82200. * Function used to defines an exponential back off strategy
  82201. * @param maxRetries defines the maximum number of retries (3 by default)
  82202. * @param baseInterval defines the interval between retries
  82203. * @returns the strategy function to use
  82204. */
  82205. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  82206. }
  82207. }
  82208. declare module BABYLON {
  82209. /**
  82210. * @ignore
  82211. * Application error to support additional information when loading a file
  82212. */
  82213. export abstract class BaseError extends Error {
  82214. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  82215. }
  82216. }
  82217. declare module BABYLON {
  82218. /** @ignore */
  82219. export class LoadFileError extends BaseError {
  82220. request?: WebRequest;
  82221. file?: File;
  82222. /**
  82223. * Creates a new LoadFileError
  82224. * @param message defines the message of the error
  82225. * @param request defines the optional web request
  82226. * @param file defines the optional file
  82227. */
  82228. constructor(message: string, object?: WebRequest | File);
  82229. }
  82230. /** @ignore */
  82231. export class RequestFileError extends BaseError {
  82232. request: WebRequest;
  82233. /**
  82234. * Creates a new LoadFileError
  82235. * @param message defines the message of the error
  82236. * @param request defines the optional web request
  82237. */
  82238. constructor(message: string, request: WebRequest);
  82239. }
  82240. /** @ignore */
  82241. export class ReadFileError extends BaseError {
  82242. file: File;
  82243. /**
  82244. * Creates a new ReadFileError
  82245. * @param message defines the message of the error
  82246. * @param file defines the optional file
  82247. */
  82248. constructor(message: string, file: File);
  82249. }
  82250. /**
  82251. * @hidden
  82252. */
  82253. export class FileTools {
  82254. /**
  82255. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  82256. */
  82257. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  82258. /**
  82259. * Gets or sets the base URL to use to load assets
  82260. */
  82261. static BaseUrl: string;
  82262. /**
  82263. * Default behaviour for cors in the application.
  82264. * It can be a string if the expected behavior is identical in the entire app.
  82265. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  82266. */
  82267. static CorsBehavior: string | ((url: string | string[]) => string);
  82268. /**
  82269. * Gets or sets a function used to pre-process url before using them to load assets
  82270. */
  82271. static PreprocessUrl: (url: string) => string;
  82272. /**
  82273. * Removes unwanted characters from an url
  82274. * @param url defines the url to clean
  82275. * @returns the cleaned url
  82276. */
  82277. private static _CleanUrl;
  82278. /**
  82279. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  82280. * @param url define the url we are trying
  82281. * @param element define the dom element where to configure the cors policy
  82282. */
  82283. static SetCorsBehavior(url: string | string[], element: {
  82284. crossOrigin: string | null;
  82285. }): void;
  82286. /**
  82287. * Loads an image as an HTMLImageElement.
  82288. * @param input url string, ArrayBuffer, or Blob to load
  82289. * @param onLoad callback called when the image successfully loads
  82290. * @param onError callback called when the image fails to load
  82291. * @param offlineProvider offline provider for caching
  82292. * @param mimeType optional mime type
  82293. * @returns the HTMLImageElement of the loaded image
  82294. */
  82295. 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>;
  82296. /**
  82297. * Reads a file from a File object
  82298. * @param file defines the file to load
  82299. * @param onSuccess defines the callback to call when data is loaded
  82300. * @param onProgress defines the callback to call during loading process
  82301. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  82302. * @param onError defines the callback to call when an error occurs
  82303. * @returns a file request object
  82304. */
  82305. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  82306. /**
  82307. * Loads a file from a url
  82308. * @param url url to load
  82309. * @param onSuccess callback called when the file successfully loads
  82310. * @param onProgress callback called while file is loading (if the server supports this mode)
  82311. * @param offlineProvider defines the offline provider for caching
  82312. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82313. * @param onError callback called when the file fails to load
  82314. * @returns a file request object
  82315. */
  82316. 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;
  82317. /**
  82318. * Loads a file
  82319. * @param url url to load
  82320. * @param onSuccess callback called when the file successfully loads
  82321. * @param onProgress callback called while file is loading (if the server supports this mode)
  82322. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82323. * @param onError callback called when the file fails to load
  82324. * @param onOpened callback called when the web request is opened
  82325. * @returns a file request object
  82326. */
  82327. 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;
  82328. /**
  82329. * Checks if the loaded document was accessed via `file:`-Protocol.
  82330. * @returns boolean
  82331. */
  82332. static IsFileURL(): boolean;
  82333. }
  82334. }
  82335. declare module BABYLON {
  82336. /** @hidden */
  82337. export class ShaderProcessor {
  82338. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  82339. private static _ProcessPrecision;
  82340. private static _ExtractOperation;
  82341. private static _BuildSubExpression;
  82342. private static _BuildExpression;
  82343. private static _MoveCursorWithinIf;
  82344. private static _MoveCursor;
  82345. private static _EvaluatePreProcessors;
  82346. private static _PreparePreProcessors;
  82347. private static _ProcessShaderConversion;
  82348. private static _ProcessIncludes;
  82349. /**
  82350. * Loads a file from a url
  82351. * @param url url to load
  82352. * @param onSuccess callback called when the file successfully loads
  82353. * @param onProgress callback called while file is loading (if the server supports this mode)
  82354. * @param offlineProvider defines the offline provider for caching
  82355. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82356. * @param onError callback called when the file fails to load
  82357. * @returns a file request object
  82358. * @hidden
  82359. */
  82360. 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;
  82361. }
  82362. }
  82363. declare module BABYLON {
  82364. /**
  82365. * @hidden
  82366. */
  82367. export interface IColor4Like {
  82368. r: float;
  82369. g: float;
  82370. b: float;
  82371. a: float;
  82372. }
  82373. /**
  82374. * @hidden
  82375. */
  82376. export interface IColor3Like {
  82377. r: float;
  82378. g: float;
  82379. b: float;
  82380. }
  82381. /**
  82382. * @hidden
  82383. */
  82384. export interface IVector4Like {
  82385. x: float;
  82386. y: float;
  82387. z: float;
  82388. w: float;
  82389. }
  82390. /**
  82391. * @hidden
  82392. */
  82393. export interface IVector3Like {
  82394. x: float;
  82395. y: float;
  82396. z: float;
  82397. }
  82398. /**
  82399. * @hidden
  82400. */
  82401. export interface IVector2Like {
  82402. x: float;
  82403. y: float;
  82404. }
  82405. /**
  82406. * @hidden
  82407. */
  82408. export interface IMatrixLike {
  82409. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82410. updateFlag: int;
  82411. }
  82412. /**
  82413. * @hidden
  82414. */
  82415. export interface IViewportLike {
  82416. x: float;
  82417. y: float;
  82418. width: float;
  82419. height: float;
  82420. }
  82421. /**
  82422. * @hidden
  82423. */
  82424. export interface IPlaneLike {
  82425. normal: IVector3Like;
  82426. d: float;
  82427. normalize(): void;
  82428. }
  82429. }
  82430. declare module BABYLON {
  82431. /**
  82432. * Interface used to define common properties for effect fallbacks
  82433. */
  82434. export interface IEffectFallbacks {
  82435. /**
  82436. * Removes the defines that should be removed when falling back.
  82437. * @param currentDefines defines the current define statements for the shader.
  82438. * @param effect defines the current effect we try to compile
  82439. * @returns The resulting defines with defines of the current rank removed.
  82440. */
  82441. reduce(currentDefines: string, effect: Effect): string;
  82442. /**
  82443. * Removes the fallback from the bound mesh.
  82444. */
  82445. unBindMesh(): void;
  82446. /**
  82447. * Checks to see if more fallbacks are still availible.
  82448. */
  82449. hasMoreFallbacks: boolean;
  82450. }
  82451. }
  82452. declare module BABYLON {
  82453. /**
  82454. * Class used to evalaute queries containing `and` and `or` operators
  82455. */
  82456. export class AndOrNotEvaluator {
  82457. /**
  82458. * Evaluate a query
  82459. * @param query defines the query to evaluate
  82460. * @param evaluateCallback defines the callback used to filter result
  82461. * @returns true if the query matches
  82462. */
  82463. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  82464. private static _HandleParenthesisContent;
  82465. private static _SimplifyNegation;
  82466. }
  82467. }
  82468. declare module BABYLON {
  82469. /**
  82470. * Class used to store custom tags
  82471. */
  82472. export class Tags {
  82473. /**
  82474. * Adds support for tags on the given object
  82475. * @param obj defines the object to use
  82476. */
  82477. static EnableFor(obj: any): void;
  82478. /**
  82479. * Removes tags support
  82480. * @param obj defines the object to use
  82481. */
  82482. static DisableFor(obj: any): void;
  82483. /**
  82484. * Gets a boolean indicating if the given object has tags
  82485. * @param obj defines the object to use
  82486. * @returns a boolean
  82487. */
  82488. static HasTags(obj: any): boolean;
  82489. /**
  82490. * Gets the tags available on a given object
  82491. * @param obj defines the object to use
  82492. * @param asString defines if the tags must be returned as a string instead of an array of strings
  82493. * @returns the tags
  82494. */
  82495. static GetTags(obj: any, asString?: boolean): any;
  82496. /**
  82497. * Adds tags to an object
  82498. * @param obj defines the object to use
  82499. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  82500. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  82501. */
  82502. static AddTagsTo(obj: any, tagsString: string): void;
  82503. /**
  82504. * @hidden
  82505. */
  82506. static _AddTagTo(obj: any, tag: string): void;
  82507. /**
  82508. * Removes specific tags from a specific object
  82509. * @param obj defines the object to use
  82510. * @param tagsString defines the tags to remove
  82511. */
  82512. static RemoveTagsFrom(obj: any, tagsString: string): void;
  82513. /**
  82514. * @hidden
  82515. */
  82516. static _RemoveTagFrom(obj: any, tag: string): void;
  82517. /**
  82518. * Defines if tags hosted on an object match a given query
  82519. * @param obj defines the object to use
  82520. * @param tagsQuery defines the tag query
  82521. * @returns a boolean
  82522. */
  82523. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  82524. }
  82525. }
  82526. declare module BABYLON {
  82527. /**
  82528. * Scalar computation library
  82529. */
  82530. export class Scalar {
  82531. /**
  82532. * Two pi constants convenient for computation.
  82533. */
  82534. static TwoPi: number;
  82535. /**
  82536. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82537. * @param a number
  82538. * @param b number
  82539. * @param epsilon (default = 1.401298E-45)
  82540. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82541. */
  82542. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  82543. /**
  82544. * Returns a string : the upper case translation of the number i to hexadecimal.
  82545. * @param i number
  82546. * @returns the upper case translation of the number i to hexadecimal.
  82547. */
  82548. static ToHex(i: number): string;
  82549. /**
  82550. * Returns -1 if value is negative and +1 is value is positive.
  82551. * @param value the value
  82552. * @returns the value itself if it's equal to zero.
  82553. */
  82554. static Sign(value: number): number;
  82555. /**
  82556. * Returns the value itself if it's between min and max.
  82557. * Returns min if the value is lower than min.
  82558. * Returns max if the value is greater than max.
  82559. * @param value the value to clmap
  82560. * @param min the min value to clamp to (default: 0)
  82561. * @param max the max value to clamp to (default: 1)
  82562. * @returns the clamped value
  82563. */
  82564. static Clamp(value: number, min?: number, max?: number): number;
  82565. /**
  82566. * the log2 of value.
  82567. * @param value the value to compute log2 of
  82568. * @returns the log2 of value.
  82569. */
  82570. static Log2(value: number): number;
  82571. /**
  82572. * Loops the value, so that it is never larger than length and never smaller than 0.
  82573. *
  82574. * This is similar to the modulo operator but it works with floating point numbers.
  82575. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82576. * With t = 5 and length = 2.5, the result would be 0.0.
  82577. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82578. * @param value the value
  82579. * @param length the length
  82580. * @returns the looped value
  82581. */
  82582. static Repeat(value: number, length: number): number;
  82583. /**
  82584. * Normalize the value between 0.0 and 1.0 using min and max values
  82585. * @param value value to normalize
  82586. * @param min max to normalize between
  82587. * @param max min to normalize between
  82588. * @returns the normalized value
  82589. */
  82590. static Normalize(value: number, min: number, max: number): number;
  82591. /**
  82592. * Denormalize the value from 0.0 and 1.0 using min and max values
  82593. * @param normalized value to denormalize
  82594. * @param min max to denormalize between
  82595. * @param max min to denormalize between
  82596. * @returns the denormalized value
  82597. */
  82598. static Denormalize(normalized: number, min: number, max: number): number;
  82599. /**
  82600. * Calculates the shortest difference between two given angles given in degrees.
  82601. * @param current current angle in degrees
  82602. * @param target target angle in degrees
  82603. * @returns the delta
  82604. */
  82605. static DeltaAngle(current: number, target: number): number;
  82606. /**
  82607. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82608. * @param tx value
  82609. * @param length length
  82610. * @returns The returned value will move back and forth between 0 and length
  82611. */
  82612. static PingPong(tx: number, length: number): number;
  82613. /**
  82614. * Interpolates between min and max with smoothing at the limits.
  82615. *
  82616. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82617. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82618. * @param from from
  82619. * @param to to
  82620. * @param tx value
  82621. * @returns the smooth stepped value
  82622. */
  82623. static SmoothStep(from: number, to: number, tx: number): number;
  82624. /**
  82625. * Moves a value current towards target.
  82626. *
  82627. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82628. * Negative values of maxDelta pushes the value away from target.
  82629. * @param current current value
  82630. * @param target target value
  82631. * @param maxDelta max distance to move
  82632. * @returns resulting value
  82633. */
  82634. static MoveTowards(current: number, target: number, maxDelta: number): number;
  82635. /**
  82636. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82637. *
  82638. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82639. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82640. * @param current current value
  82641. * @param target target value
  82642. * @param maxDelta max distance to move
  82643. * @returns resulting angle
  82644. */
  82645. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  82646. /**
  82647. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82648. * @param start start value
  82649. * @param end target value
  82650. * @param amount amount to lerp between
  82651. * @returns the lerped value
  82652. */
  82653. static Lerp(start: number, end: number, amount: number): number;
  82654. /**
  82655. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82656. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82657. * @param start start value
  82658. * @param end target value
  82659. * @param amount amount to lerp between
  82660. * @returns the lerped value
  82661. */
  82662. static LerpAngle(start: number, end: number, amount: number): number;
  82663. /**
  82664. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82665. * @param a start value
  82666. * @param b target value
  82667. * @param value value between a and b
  82668. * @returns the inverseLerp value
  82669. */
  82670. static InverseLerp(a: number, b: number, value: number): number;
  82671. /**
  82672. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82673. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82674. * @param value1 spline value
  82675. * @param tangent1 spline value
  82676. * @param value2 spline value
  82677. * @param tangent2 spline value
  82678. * @param amount input value
  82679. * @returns hermite result
  82680. */
  82681. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  82682. /**
  82683. * Returns a random float number between and min and max values
  82684. * @param min min value of random
  82685. * @param max max value of random
  82686. * @returns random value
  82687. */
  82688. static RandomRange(min: number, max: number): number;
  82689. /**
  82690. * This function returns percentage of a number in a given range.
  82691. *
  82692. * RangeToPercent(40,20,60) will return 0.5 (50%)
  82693. * RangeToPercent(34,0,100) will return 0.34 (34%)
  82694. * @param number to convert to percentage
  82695. * @param min min range
  82696. * @param max max range
  82697. * @returns the percentage
  82698. */
  82699. static RangeToPercent(number: number, min: number, max: number): number;
  82700. /**
  82701. * This function returns number that corresponds to the percentage in a given range.
  82702. *
  82703. * PercentToRange(0.34,0,100) will return 34.
  82704. * @param percent to convert to number
  82705. * @param min min range
  82706. * @param max max range
  82707. * @returns the number
  82708. */
  82709. static PercentToRange(percent: number, min: number, max: number): number;
  82710. /**
  82711. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  82712. * @param angle The angle to normalize in radian.
  82713. * @return The converted angle.
  82714. */
  82715. static NormalizeRadians(angle: number): number;
  82716. }
  82717. }
  82718. declare module BABYLON {
  82719. /**
  82720. * Constant used to convert a value to gamma space
  82721. * @ignorenaming
  82722. */
  82723. export const ToGammaSpace: number;
  82724. /**
  82725. * Constant used to convert a value to linear space
  82726. * @ignorenaming
  82727. */
  82728. export const ToLinearSpace = 2.2;
  82729. /**
  82730. * Constant used to define the minimal number value in Babylon.js
  82731. * @ignorenaming
  82732. */
  82733. let Epsilon: number;
  82734. }
  82735. declare module BABYLON {
  82736. /**
  82737. * Class used to represent a viewport on screen
  82738. */
  82739. export class Viewport {
  82740. /** viewport left coordinate */
  82741. x: number;
  82742. /** viewport top coordinate */
  82743. y: number;
  82744. /**viewport width */
  82745. width: number;
  82746. /** viewport height */
  82747. height: number;
  82748. /**
  82749. * Creates a Viewport object located at (x, y) and sized (width, height)
  82750. * @param x defines viewport left coordinate
  82751. * @param y defines viewport top coordinate
  82752. * @param width defines the viewport width
  82753. * @param height defines the viewport height
  82754. */
  82755. constructor(
  82756. /** viewport left coordinate */
  82757. x: number,
  82758. /** viewport top coordinate */
  82759. y: number,
  82760. /**viewport width */
  82761. width: number,
  82762. /** viewport height */
  82763. height: number);
  82764. /**
  82765. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  82766. * @param renderWidth defines the rendering width
  82767. * @param renderHeight defines the rendering height
  82768. * @returns a new Viewport
  82769. */
  82770. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  82771. /**
  82772. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  82773. * @param renderWidth defines the rendering width
  82774. * @param renderHeight defines the rendering height
  82775. * @param ref defines the target viewport
  82776. * @returns the current viewport
  82777. */
  82778. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  82779. /**
  82780. * Returns a new Viewport copied from the current one
  82781. * @returns a new Viewport
  82782. */
  82783. clone(): Viewport;
  82784. }
  82785. }
  82786. declare module BABYLON {
  82787. /**
  82788. * Class containing a set of static utilities functions for arrays.
  82789. */
  82790. export class ArrayTools {
  82791. /**
  82792. * Returns an array of the given size filled with element built from the given constructor and the paramters
  82793. * @param size the number of element to construct and put in the array
  82794. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  82795. * @returns a new array filled with new objects
  82796. */
  82797. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  82798. }
  82799. }
  82800. declare module BABYLON {
  82801. /**
  82802. * Represents a plane by the equation ax + by + cz + d = 0
  82803. */
  82804. export class Plane {
  82805. private static _TmpMatrix;
  82806. /**
  82807. * Normal of the plane (a,b,c)
  82808. */
  82809. normal: Vector3;
  82810. /**
  82811. * d component of the plane
  82812. */
  82813. d: number;
  82814. /**
  82815. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  82816. * @param a a component of the plane
  82817. * @param b b component of the plane
  82818. * @param c c component of the plane
  82819. * @param d d component of the plane
  82820. */
  82821. constructor(a: number, b: number, c: number, d: number);
  82822. /**
  82823. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  82824. */
  82825. asArray(): number[];
  82826. /**
  82827. * @returns a new plane copied from the current Plane.
  82828. */
  82829. clone(): Plane;
  82830. /**
  82831. * @returns the string "Plane".
  82832. */
  82833. getClassName(): string;
  82834. /**
  82835. * @returns the Plane hash code.
  82836. */
  82837. getHashCode(): number;
  82838. /**
  82839. * Normalize the current Plane in place.
  82840. * @returns the updated Plane.
  82841. */
  82842. normalize(): Plane;
  82843. /**
  82844. * Applies a transformation the plane and returns the result
  82845. * @param transformation the transformation matrix to be applied to the plane
  82846. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  82847. */
  82848. transform(transformation: DeepImmutable<Matrix>): Plane;
  82849. /**
  82850. * Compute the dot product between the point and the plane normal
  82851. * @param point point to calculate the dot product with
  82852. * @returns the dot product (float) of the point coordinates and the plane normal.
  82853. */
  82854. dotCoordinate(point: DeepImmutable<Vector3>): number;
  82855. /**
  82856. * Updates the current Plane from the plane defined by the three given points.
  82857. * @param point1 one of the points used to contruct the plane
  82858. * @param point2 one of the points used to contruct the plane
  82859. * @param point3 one of the points used to contruct the plane
  82860. * @returns the updated Plane.
  82861. */
  82862. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82863. /**
  82864. * Checks if the plane is facing a given direction
  82865. * @param direction the direction to check if the plane is facing
  82866. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  82867. * @returns True is the vector "direction" is the same side than the plane normal.
  82868. */
  82869. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  82870. /**
  82871. * Calculates the distance to a point
  82872. * @param point point to calculate distance to
  82873. * @returns the signed distance (float) from the given point to the Plane.
  82874. */
  82875. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  82876. /**
  82877. * Creates a plane from an array
  82878. * @param array the array to create a plane from
  82879. * @returns a new Plane from the given array.
  82880. */
  82881. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  82882. /**
  82883. * Creates a plane from three points
  82884. * @param point1 point used to create the plane
  82885. * @param point2 point used to create the plane
  82886. * @param point3 point used to create the plane
  82887. * @returns a new Plane defined by the three given points.
  82888. */
  82889. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82890. /**
  82891. * Creates a plane from an origin point and a normal
  82892. * @param origin origin of the plane to be constructed
  82893. * @param normal normal of the plane to be constructed
  82894. * @returns a new Plane the normal vector to this plane at the given origin point.
  82895. * Note : the vector "normal" is updated because normalized.
  82896. */
  82897. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  82898. /**
  82899. * Calculates the distance from a plane and a point
  82900. * @param origin origin of the plane to be constructed
  82901. * @param normal normal of the plane to be constructed
  82902. * @param point point to calculate distance to
  82903. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  82904. */
  82905. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  82906. }
  82907. }
  82908. declare module BABYLON {
  82909. /** @hidden */
  82910. export class PerformanceConfigurator {
  82911. /** @hidden */
  82912. static MatrixUse64Bits: boolean;
  82913. /** @hidden */
  82914. static MatrixTrackPrecisionChange: boolean;
  82915. /** @hidden */
  82916. static MatrixCurrentType: any;
  82917. /** @hidden */
  82918. static MatrixTrackedMatrices: Array<any> | null;
  82919. /** @hidden */
  82920. static SetMatrixPrecision(use64bits: boolean): void;
  82921. }
  82922. }
  82923. declare module BABYLON {
  82924. /**
  82925. * Class representing a vector containing 2 coordinates
  82926. */
  82927. export class Vector2 {
  82928. /** defines the first coordinate */
  82929. x: number;
  82930. /** defines the second coordinate */
  82931. y: number;
  82932. /**
  82933. * Creates a new Vector2 from the given x and y coordinates
  82934. * @param x defines the first coordinate
  82935. * @param y defines the second coordinate
  82936. */
  82937. constructor(
  82938. /** defines the first coordinate */
  82939. x?: number,
  82940. /** defines the second coordinate */
  82941. y?: number);
  82942. /**
  82943. * Gets a string with the Vector2 coordinates
  82944. * @returns a string with the Vector2 coordinates
  82945. */
  82946. toString(): string;
  82947. /**
  82948. * Gets class name
  82949. * @returns the string "Vector2"
  82950. */
  82951. getClassName(): string;
  82952. /**
  82953. * Gets current vector hash code
  82954. * @returns the Vector2 hash code as a number
  82955. */
  82956. getHashCode(): number;
  82957. /**
  82958. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  82959. * @param array defines the source array
  82960. * @param index defines the offset in source array
  82961. * @returns the current Vector2
  82962. */
  82963. toArray(array: FloatArray, index?: number): Vector2;
  82964. /**
  82965. * Update the current vector from an array
  82966. * @param array defines the destination array
  82967. * @param index defines the offset in the destination array
  82968. * @returns the current Vector3
  82969. */
  82970. fromArray(array: FloatArray, index?: number): Vector2;
  82971. /**
  82972. * Copy the current vector to an array
  82973. * @returns a new array with 2 elements: the Vector2 coordinates.
  82974. */
  82975. asArray(): number[];
  82976. /**
  82977. * Sets the Vector2 coordinates with the given Vector2 coordinates
  82978. * @param source defines the source Vector2
  82979. * @returns the current updated Vector2
  82980. */
  82981. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  82982. /**
  82983. * Sets the Vector2 coordinates with the given floats
  82984. * @param x defines the first coordinate
  82985. * @param y defines the second coordinate
  82986. * @returns the current updated Vector2
  82987. */
  82988. copyFromFloats(x: number, y: number): Vector2;
  82989. /**
  82990. * Sets the Vector2 coordinates with the given floats
  82991. * @param x defines the first coordinate
  82992. * @param y defines the second coordinate
  82993. * @returns the current updated Vector2
  82994. */
  82995. set(x: number, y: number): Vector2;
  82996. /**
  82997. * Add another vector with the current one
  82998. * @param otherVector defines the other vector
  82999. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  83000. */
  83001. add(otherVector: DeepImmutable<Vector2>): Vector2;
  83002. /**
  83003. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  83004. * @param otherVector defines the other vector
  83005. * @param result defines the target vector
  83006. * @returns the unmodified current Vector2
  83007. */
  83008. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83009. /**
  83010. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  83011. * @param otherVector defines the other vector
  83012. * @returns the current updated Vector2
  83013. */
  83014. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83015. /**
  83016. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  83017. * @param otherVector defines the other vector
  83018. * @returns a new Vector2
  83019. */
  83020. addVector3(otherVector: Vector3): Vector2;
  83021. /**
  83022. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  83023. * @param otherVector defines the other vector
  83024. * @returns a new Vector2
  83025. */
  83026. subtract(otherVector: Vector2): Vector2;
  83027. /**
  83028. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  83029. * @param otherVector defines the other vector
  83030. * @param result defines the target vector
  83031. * @returns the unmodified current Vector2
  83032. */
  83033. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83034. /**
  83035. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  83036. * @param otherVector defines the other vector
  83037. * @returns the current updated Vector2
  83038. */
  83039. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83040. /**
  83041. * Multiplies in place the current Vector2 coordinates by the given ones
  83042. * @param otherVector defines the other vector
  83043. * @returns the current updated Vector2
  83044. */
  83045. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83046. /**
  83047. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  83048. * @param otherVector defines the other vector
  83049. * @returns a new Vector2
  83050. */
  83051. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  83052. /**
  83053. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  83054. * @param otherVector defines the other vector
  83055. * @param result defines the target vector
  83056. * @returns the unmodified current Vector2
  83057. */
  83058. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83059. /**
  83060. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  83061. * @param x defines the first coordinate
  83062. * @param y defines the second coordinate
  83063. * @returns a new Vector2
  83064. */
  83065. multiplyByFloats(x: number, y: number): Vector2;
  83066. /**
  83067. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  83068. * @param otherVector defines the other vector
  83069. * @returns a new Vector2
  83070. */
  83071. divide(otherVector: Vector2): Vector2;
  83072. /**
  83073. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  83074. * @param otherVector defines the other vector
  83075. * @param result defines the target vector
  83076. * @returns the unmodified current Vector2
  83077. */
  83078. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83079. /**
  83080. * Divides the current Vector2 coordinates by the given ones
  83081. * @param otherVector defines the other vector
  83082. * @returns the current updated Vector2
  83083. */
  83084. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83085. /**
  83086. * Gets a new Vector2 with current Vector2 negated coordinates
  83087. * @returns a new Vector2
  83088. */
  83089. negate(): Vector2;
  83090. /**
  83091. * Negate this vector in place
  83092. * @returns this
  83093. */
  83094. negateInPlace(): Vector2;
  83095. /**
  83096. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  83097. * @param result defines the Vector3 object where to store the result
  83098. * @returns the current Vector2
  83099. */
  83100. negateToRef(result: Vector2): Vector2;
  83101. /**
  83102. * Multiply the Vector2 coordinates by scale
  83103. * @param scale defines the scaling factor
  83104. * @returns the current updated Vector2
  83105. */
  83106. scaleInPlace(scale: number): Vector2;
  83107. /**
  83108. * Returns a new Vector2 scaled by "scale" from the current Vector2
  83109. * @param scale defines the scaling factor
  83110. * @returns a new Vector2
  83111. */
  83112. scale(scale: number): Vector2;
  83113. /**
  83114. * Scale the current Vector2 values by a factor to a given Vector2
  83115. * @param scale defines the scale factor
  83116. * @param result defines the Vector2 object where to store the result
  83117. * @returns the unmodified current Vector2
  83118. */
  83119. scaleToRef(scale: number, result: Vector2): Vector2;
  83120. /**
  83121. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  83122. * @param scale defines the scale factor
  83123. * @param result defines the Vector2 object where to store the result
  83124. * @returns the unmodified current Vector2
  83125. */
  83126. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  83127. /**
  83128. * Gets a boolean if two vectors are equals
  83129. * @param otherVector defines the other vector
  83130. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  83131. */
  83132. equals(otherVector: DeepImmutable<Vector2>): boolean;
  83133. /**
  83134. * Gets a boolean if two vectors are equals (using an epsilon value)
  83135. * @param otherVector defines the other vector
  83136. * @param epsilon defines the minimal distance to consider equality
  83137. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  83138. */
  83139. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  83140. /**
  83141. * Gets a new Vector2 from current Vector2 floored values
  83142. * @returns a new Vector2
  83143. */
  83144. floor(): Vector2;
  83145. /**
  83146. * Gets a new Vector2 from current Vector2 floored values
  83147. * @returns a new Vector2
  83148. */
  83149. fract(): Vector2;
  83150. /**
  83151. * Gets the length of the vector
  83152. * @returns the vector length (float)
  83153. */
  83154. length(): number;
  83155. /**
  83156. * Gets the vector squared length
  83157. * @returns the vector squared length (float)
  83158. */
  83159. lengthSquared(): number;
  83160. /**
  83161. * Normalize the vector
  83162. * @returns the current updated Vector2
  83163. */
  83164. normalize(): Vector2;
  83165. /**
  83166. * Gets a new Vector2 copied from the Vector2
  83167. * @returns a new Vector2
  83168. */
  83169. clone(): Vector2;
  83170. /**
  83171. * Gets a new Vector2(0, 0)
  83172. * @returns a new Vector2
  83173. */
  83174. static Zero(): Vector2;
  83175. /**
  83176. * Gets a new Vector2(1, 1)
  83177. * @returns a new Vector2
  83178. */
  83179. static One(): Vector2;
  83180. /**
  83181. * Gets a new Vector2 set from the given index element of the given array
  83182. * @param array defines the data source
  83183. * @param offset defines the offset in the data source
  83184. * @returns a new Vector2
  83185. */
  83186. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  83187. /**
  83188. * Sets "result" from the given index element of the given array
  83189. * @param array defines the data source
  83190. * @param offset defines the offset in the data source
  83191. * @param result defines the target vector
  83192. */
  83193. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  83194. /**
  83195. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  83196. * @param value1 defines 1st point of control
  83197. * @param value2 defines 2nd point of control
  83198. * @param value3 defines 3rd point of control
  83199. * @param value4 defines 4th point of control
  83200. * @param amount defines the interpolation factor
  83201. * @returns a new Vector2
  83202. */
  83203. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  83204. /**
  83205. * 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".
  83206. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  83207. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  83208. * @param value defines the value to clamp
  83209. * @param min defines the lower limit
  83210. * @param max defines the upper limit
  83211. * @returns a new Vector2
  83212. */
  83213. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  83214. /**
  83215. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  83216. * @param value1 defines the 1st control point
  83217. * @param tangent1 defines the outgoing tangent
  83218. * @param value2 defines the 2nd control point
  83219. * @param tangent2 defines the incoming tangent
  83220. * @param amount defines the interpolation factor
  83221. * @returns a new Vector2
  83222. */
  83223. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  83224. /**
  83225. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  83226. * @param start defines the start vector
  83227. * @param end defines the end vector
  83228. * @param amount defines the interpolation factor
  83229. * @returns a new Vector2
  83230. */
  83231. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  83232. /**
  83233. * Gets the dot product of the vector "left" and the vector "right"
  83234. * @param left defines first vector
  83235. * @param right defines second vector
  83236. * @returns the dot product (float)
  83237. */
  83238. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  83239. /**
  83240. * Returns a new Vector2 equal to the normalized given vector
  83241. * @param vector defines the vector to normalize
  83242. * @returns a new Vector2
  83243. */
  83244. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  83245. /**
  83246. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  83247. * @param left defines 1st vector
  83248. * @param right defines 2nd vector
  83249. * @returns a new Vector2
  83250. */
  83251. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83252. /**
  83253. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  83254. * @param left defines 1st vector
  83255. * @param right defines 2nd vector
  83256. * @returns a new Vector2
  83257. */
  83258. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83259. /**
  83260. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  83261. * @param vector defines the vector to transform
  83262. * @param transformation defines the matrix to apply
  83263. * @returns a new Vector2
  83264. */
  83265. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  83266. /**
  83267. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  83268. * @param vector defines the vector to transform
  83269. * @param transformation defines the matrix to apply
  83270. * @param result defines the target vector
  83271. */
  83272. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  83273. /**
  83274. * Determines if a given vector is included in a triangle
  83275. * @param p defines the vector to test
  83276. * @param p0 defines 1st triangle point
  83277. * @param p1 defines 2nd triangle point
  83278. * @param p2 defines 3rd triangle point
  83279. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  83280. */
  83281. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  83282. /**
  83283. * Gets the distance between the vectors "value1" and "value2"
  83284. * @param value1 defines first vector
  83285. * @param value2 defines second vector
  83286. * @returns the distance between vectors
  83287. */
  83288. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83289. /**
  83290. * Returns the squared distance between the vectors "value1" and "value2"
  83291. * @param value1 defines first vector
  83292. * @param value2 defines second vector
  83293. * @returns the squared distance between vectors
  83294. */
  83295. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83296. /**
  83297. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  83298. * @param value1 defines first vector
  83299. * @param value2 defines second vector
  83300. * @returns a new Vector2
  83301. */
  83302. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  83303. /**
  83304. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  83305. * @param p defines the middle point
  83306. * @param segA defines one point of the segment
  83307. * @param segB defines the other point of the segment
  83308. * @returns the shortest distance
  83309. */
  83310. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  83311. }
  83312. /**
  83313. * Class used to store (x,y,z) vector representation
  83314. * A Vector3 is the main object used in 3D geometry
  83315. * It can represent etiher the coordinates of a point the space, either a direction
  83316. * Reminder: js uses a left handed forward facing system
  83317. */
  83318. export class Vector3 {
  83319. private static _UpReadOnly;
  83320. private static _ZeroReadOnly;
  83321. /** @hidden */
  83322. _x: number;
  83323. /** @hidden */
  83324. _y: number;
  83325. /** @hidden */
  83326. _z: number;
  83327. /** @hidden */
  83328. _isDirty: boolean;
  83329. /** Gets or sets the x coordinate */
  83330. get x(): number;
  83331. set x(value: number);
  83332. /** Gets or sets the y coordinate */
  83333. get y(): number;
  83334. set y(value: number);
  83335. /** Gets or sets the z coordinate */
  83336. get z(): number;
  83337. set z(value: number);
  83338. /**
  83339. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  83340. * @param x defines the first coordinates (on X axis)
  83341. * @param y defines the second coordinates (on Y axis)
  83342. * @param z defines the third coordinates (on Z axis)
  83343. */
  83344. constructor(x?: number, y?: number, z?: number);
  83345. /**
  83346. * Creates a string representation of the Vector3
  83347. * @returns a string with the Vector3 coordinates.
  83348. */
  83349. toString(): string;
  83350. /**
  83351. * Gets the class name
  83352. * @returns the string "Vector3"
  83353. */
  83354. getClassName(): string;
  83355. /**
  83356. * Creates the Vector3 hash code
  83357. * @returns a number which tends to be unique between Vector3 instances
  83358. */
  83359. getHashCode(): number;
  83360. /**
  83361. * Creates an array containing three elements : the coordinates of the Vector3
  83362. * @returns a new array of numbers
  83363. */
  83364. asArray(): number[];
  83365. /**
  83366. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  83367. * @param array defines the destination array
  83368. * @param index defines the offset in the destination array
  83369. * @returns the current Vector3
  83370. */
  83371. toArray(array: FloatArray, index?: number): Vector3;
  83372. /**
  83373. * Update the current vector from an array
  83374. * @param array defines the destination array
  83375. * @param index defines the offset in the destination array
  83376. * @returns the current Vector3
  83377. */
  83378. fromArray(array: FloatArray, index?: number): Vector3;
  83379. /**
  83380. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  83381. * @returns a new Quaternion object, computed from the Vector3 coordinates
  83382. */
  83383. toQuaternion(): Quaternion;
  83384. /**
  83385. * Adds the given vector to the current Vector3
  83386. * @param otherVector defines the second operand
  83387. * @returns the current updated Vector3
  83388. */
  83389. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83390. /**
  83391. * Adds the given coordinates to the current Vector3
  83392. * @param x defines the x coordinate of the operand
  83393. * @param y defines the y coordinate of the operand
  83394. * @param z defines the z coordinate of the operand
  83395. * @returns the current updated Vector3
  83396. */
  83397. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83398. /**
  83399. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  83400. * @param otherVector defines the second operand
  83401. * @returns the resulting Vector3
  83402. */
  83403. add(otherVector: DeepImmutable<Vector3>): Vector3;
  83404. /**
  83405. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  83406. * @param otherVector defines the second operand
  83407. * @param result defines the Vector3 object where to store the result
  83408. * @returns the current Vector3
  83409. */
  83410. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83411. /**
  83412. * Subtract the given vector from the current Vector3
  83413. * @param otherVector defines the second operand
  83414. * @returns the current updated Vector3
  83415. */
  83416. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83417. /**
  83418. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  83419. * @param otherVector defines the second operand
  83420. * @returns the resulting Vector3
  83421. */
  83422. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  83423. /**
  83424. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  83425. * @param otherVector defines the second operand
  83426. * @param result defines the Vector3 object where to store the result
  83427. * @returns the current Vector3
  83428. */
  83429. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83430. /**
  83431. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  83432. * @param x defines the x coordinate of the operand
  83433. * @param y defines the y coordinate of the operand
  83434. * @param z defines the z coordinate of the operand
  83435. * @returns the resulting Vector3
  83436. */
  83437. subtractFromFloats(x: number, y: number, z: number): Vector3;
  83438. /**
  83439. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  83440. * @param x defines the x coordinate of the operand
  83441. * @param y defines the y coordinate of the operand
  83442. * @param z defines the z coordinate of the operand
  83443. * @param result defines the Vector3 object where to store the result
  83444. * @returns the current Vector3
  83445. */
  83446. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  83447. /**
  83448. * Gets a new Vector3 set with the current Vector3 negated coordinates
  83449. * @returns a new Vector3
  83450. */
  83451. negate(): Vector3;
  83452. /**
  83453. * Negate this vector in place
  83454. * @returns this
  83455. */
  83456. negateInPlace(): Vector3;
  83457. /**
  83458. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  83459. * @param result defines the Vector3 object where to store the result
  83460. * @returns the current Vector3
  83461. */
  83462. negateToRef(result: Vector3): Vector3;
  83463. /**
  83464. * Multiplies the Vector3 coordinates by the float "scale"
  83465. * @param scale defines the multiplier factor
  83466. * @returns the current updated Vector3
  83467. */
  83468. scaleInPlace(scale: number): Vector3;
  83469. /**
  83470. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  83471. * @param scale defines the multiplier factor
  83472. * @returns a new Vector3
  83473. */
  83474. scale(scale: number): Vector3;
  83475. /**
  83476. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  83477. * @param scale defines the multiplier factor
  83478. * @param result defines the Vector3 object where to store the result
  83479. * @returns the current Vector3
  83480. */
  83481. scaleToRef(scale: number, result: Vector3): Vector3;
  83482. /**
  83483. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  83484. * @param scale defines the scale factor
  83485. * @param result defines the Vector3 object where to store the result
  83486. * @returns the unmodified current Vector3
  83487. */
  83488. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  83489. /**
  83490. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83491. * @param origin defines the origin of the projection ray
  83492. * @param plane defines the plane to project to
  83493. * @returns the projected vector3
  83494. */
  83495. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  83496. /**
  83497. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83498. * @param origin defines the origin of the projection ray
  83499. * @param plane defines the plane to project to
  83500. * @param result defines the Vector3 where to store the result
  83501. */
  83502. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  83503. /**
  83504. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  83505. * @param otherVector defines the second operand
  83506. * @returns true if both vectors are equals
  83507. */
  83508. equals(otherVector: DeepImmutable<Vector3>): boolean;
  83509. /**
  83510. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  83511. * @param otherVector defines the second operand
  83512. * @param epsilon defines the minimal distance to define values as equals
  83513. * @returns true if both vectors are distant less than epsilon
  83514. */
  83515. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  83516. /**
  83517. * Returns true if the current Vector3 coordinates equals the given floats
  83518. * @param x defines the x coordinate of the operand
  83519. * @param y defines the y coordinate of the operand
  83520. * @param z defines the z coordinate of the operand
  83521. * @returns true if both vectors are equals
  83522. */
  83523. equalsToFloats(x: number, y: number, z: number): boolean;
  83524. /**
  83525. * Multiplies the current Vector3 coordinates by the given ones
  83526. * @param otherVector defines the second operand
  83527. * @returns the current updated Vector3
  83528. */
  83529. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83530. /**
  83531. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  83532. * @param otherVector defines the second operand
  83533. * @returns the new Vector3
  83534. */
  83535. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  83536. /**
  83537. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  83538. * @param otherVector defines the second operand
  83539. * @param result defines the Vector3 object where to store the result
  83540. * @returns the current Vector3
  83541. */
  83542. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83543. /**
  83544. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  83545. * @param x defines the x coordinate of the operand
  83546. * @param y defines the y coordinate of the operand
  83547. * @param z defines the z coordinate of the operand
  83548. * @returns the new Vector3
  83549. */
  83550. multiplyByFloats(x: number, y: number, z: number): Vector3;
  83551. /**
  83552. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  83553. * @param otherVector defines the second operand
  83554. * @returns the new Vector3
  83555. */
  83556. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  83557. /**
  83558. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  83559. * @param otherVector defines the second operand
  83560. * @param result defines the Vector3 object where to store the result
  83561. * @returns the current Vector3
  83562. */
  83563. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83564. /**
  83565. * Divides the current Vector3 coordinates by the given ones.
  83566. * @param otherVector defines the second operand
  83567. * @returns the current updated Vector3
  83568. */
  83569. divideInPlace(otherVector: Vector3): Vector3;
  83570. /**
  83571. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83572. * @param other defines the second operand
  83573. * @returns the current updated Vector3
  83574. */
  83575. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83576. /**
  83577. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83578. * @param other defines the second operand
  83579. * @returns the current updated Vector3
  83580. */
  83581. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83582. /**
  83583. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83584. * @param x defines the x coordinate of the operand
  83585. * @param y defines the y coordinate of the operand
  83586. * @param z defines the z coordinate of the operand
  83587. * @returns the current updated Vector3
  83588. */
  83589. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83590. /**
  83591. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83592. * @param x defines the x coordinate of the operand
  83593. * @param y defines the y coordinate of the operand
  83594. * @param z defines the z coordinate of the operand
  83595. * @returns the current updated Vector3
  83596. */
  83597. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83598. /**
  83599. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83600. * Check if is non uniform within a certain amount of decimal places to account for this
  83601. * @param epsilon the amount the values can differ
  83602. * @returns if the the vector is non uniform to a certain number of decimal places
  83603. */
  83604. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83605. /**
  83606. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83607. */
  83608. get isNonUniform(): boolean;
  83609. /**
  83610. * Gets a new Vector3 from current Vector3 floored values
  83611. * @returns a new Vector3
  83612. */
  83613. floor(): Vector3;
  83614. /**
  83615. * Gets a new Vector3 from current Vector3 floored values
  83616. * @returns a new Vector3
  83617. */
  83618. fract(): Vector3;
  83619. /**
  83620. * Gets the length of the Vector3
  83621. * @returns the length of the Vector3
  83622. */
  83623. length(): number;
  83624. /**
  83625. * Gets the squared length of the Vector3
  83626. * @returns squared length of the Vector3
  83627. */
  83628. lengthSquared(): number;
  83629. /**
  83630. * Normalize the current Vector3.
  83631. * Please note that this is an in place operation.
  83632. * @returns the current updated Vector3
  83633. */
  83634. normalize(): Vector3;
  83635. /**
  83636. * Reorders the x y z properties of the vector in place
  83637. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83638. * @returns the current updated vector
  83639. */
  83640. reorderInPlace(order: string): this;
  83641. /**
  83642. * Rotates the vector around 0,0,0 by a quaternion
  83643. * @param quaternion the rotation quaternion
  83644. * @param result vector to store the result
  83645. * @returns the resulting vector
  83646. */
  83647. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  83648. /**
  83649. * Rotates a vector around a given point
  83650. * @param quaternion the rotation quaternion
  83651. * @param point the point to rotate around
  83652. * @param result vector to store the result
  83653. * @returns the resulting vector
  83654. */
  83655. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  83656. /**
  83657. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  83658. * The cross product is then orthogonal to both current and "other"
  83659. * @param other defines the right operand
  83660. * @returns the cross product
  83661. */
  83662. cross(other: Vector3): Vector3;
  83663. /**
  83664. * Normalize the current Vector3 with the given input length.
  83665. * Please note that this is an in place operation.
  83666. * @param len the length of the vector
  83667. * @returns the current updated Vector3
  83668. */
  83669. normalizeFromLength(len: number): Vector3;
  83670. /**
  83671. * Normalize the current Vector3 to a new vector
  83672. * @returns the new Vector3
  83673. */
  83674. normalizeToNew(): Vector3;
  83675. /**
  83676. * Normalize the current Vector3 to the reference
  83677. * @param reference define the Vector3 to update
  83678. * @returns the updated Vector3
  83679. */
  83680. normalizeToRef(reference: Vector3): Vector3;
  83681. /**
  83682. * Creates a new Vector3 copied from the current Vector3
  83683. * @returns the new Vector3
  83684. */
  83685. clone(): Vector3;
  83686. /**
  83687. * Copies the given vector coordinates to the current Vector3 ones
  83688. * @param source defines the source Vector3
  83689. * @returns the current updated Vector3
  83690. */
  83691. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  83692. /**
  83693. * Copies the given floats to the current Vector3 coordinates
  83694. * @param x defines the x coordinate of the operand
  83695. * @param y defines the y coordinate of the operand
  83696. * @param z defines the z coordinate of the operand
  83697. * @returns the current updated Vector3
  83698. */
  83699. copyFromFloats(x: number, y: number, z: number): Vector3;
  83700. /**
  83701. * Copies the given floats to the current Vector3 coordinates
  83702. * @param x defines the x coordinate of the operand
  83703. * @param y defines the y coordinate of the operand
  83704. * @param z defines the z coordinate of the operand
  83705. * @returns the current updated Vector3
  83706. */
  83707. set(x: number, y: number, z: number): Vector3;
  83708. /**
  83709. * Copies the given float to the current Vector3 coordinates
  83710. * @param v defines the x, y and z coordinates of the operand
  83711. * @returns the current updated Vector3
  83712. */
  83713. setAll(v: number): Vector3;
  83714. /**
  83715. * Get the clip factor between two vectors
  83716. * @param vector0 defines the first operand
  83717. * @param vector1 defines the second operand
  83718. * @param axis defines the axis to use
  83719. * @param size defines the size along the axis
  83720. * @returns the clip factor
  83721. */
  83722. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  83723. /**
  83724. * Get angle between two vectors
  83725. * @param vector0 angle between vector0 and vector1
  83726. * @param vector1 angle between vector0 and vector1
  83727. * @param normal direction of the normal
  83728. * @return the angle between vector0 and vector1
  83729. */
  83730. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  83731. /**
  83732. * Returns a new Vector3 set from the index "offset" of the given array
  83733. * @param array defines the source array
  83734. * @param offset defines the offset in the source array
  83735. * @returns the new Vector3
  83736. */
  83737. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  83738. /**
  83739. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  83740. * @param array defines the source array
  83741. * @param offset defines the offset in the source array
  83742. * @returns the new Vector3
  83743. * @deprecated Please use FromArray instead.
  83744. */
  83745. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  83746. /**
  83747. * Sets the given vector "result" with the element values from the index "offset" of the given array
  83748. * @param array defines the source array
  83749. * @param offset defines the offset in the source array
  83750. * @param result defines the Vector3 where to store the result
  83751. */
  83752. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  83753. /**
  83754. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  83755. * @param array defines the source array
  83756. * @param offset defines the offset in the source array
  83757. * @param result defines the Vector3 where to store the result
  83758. * @deprecated Please use FromArrayToRef instead.
  83759. */
  83760. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  83761. /**
  83762. * Sets the given vector "result" with the given floats.
  83763. * @param x defines the x coordinate of the source
  83764. * @param y defines the y coordinate of the source
  83765. * @param z defines the z coordinate of the source
  83766. * @param result defines the Vector3 where to store the result
  83767. */
  83768. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  83769. /**
  83770. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  83771. * @returns a new empty Vector3
  83772. */
  83773. static Zero(): Vector3;
  83774. /**
  83775. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  83776. * @returns a new unit Vector3
  83777. */
  83778. static One(): Vector3;
  83779. /**
  83780. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  83781. * @returns a new up Vector3
  83782. */
  83783. static Up(): Vector3;
  83784. /**
  83785. * Gets a up Vector3 that must not be updated
  83786. */
  83787. static get UpReadOnly(): DeepImmutable<Vector3>;
  83788. /**
  83789. * Gets a zero Vector3 that must not be updated
  83790. */
  83791. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  83792. /**
  83793. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  83794. * @returns a new down Vector3
  83795. */
  83796. static Down(): Vector3;
  83797. /**
  83798. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  83799. * @param rightHandedSystem is the scene right-handed (negative z)
  83800. * @returns a new forward Vector3
  83801. */
  83802. static Forward(rightHandedSystem?: boolean): Vector3;
  83803. /**
  83804. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  83805. * @param rightHandedSystem is the scene right-handed (negative-z)
  83806. * @returns a new forward Vector3
  83807. */
  83808. static Backward(rightHandedSystem?: boolean): Vector3;
  83809. /**
  83810. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  83811. * @returns a new right Vector3
  83812. */
  83813. static Right(): Vector3;
  83814. /**
  83815. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  83816. * @returns a new left Vector3
  83817. */
  83818. static Left(): Vector3;
  83819. /**
  83820. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  83821. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83822. * @param vector defines the Vector3 to transform
  83823. * @param transformation defines the transformation matrix
  83824. * @returns the transformed Vector3
  83825. */
  83826. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83827. /**
  83828. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  83829. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83830. * @param vector defines the Vector3 to transform
  83831. * @param transformation defines the transformation matrix
  83832. * @param result defines the Vector3 where to store the result
  83833. */
  83834. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83835. /**
  83836. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  83837. * This method computes tranformed coordinates only, not transformed direction vectors
  83838. * @param x define the x coordinate of the source vector
  83839. * @param y define the y coordinate of the source vector
  83840. * @param z define the z coordinate of the source vector
  83841. * @param transformation defines the transformation matrix
  83842. * @param result defines the Vector3 where to store the result
  83843. */
  83844. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83845. /**
  83846. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  83847. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83848. * @param vector defines the Vector3 to transform
  83849. * @param transformation defines the transformation matrix
  83850. * @returns the new Vector3
  83851. */
  83852. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83853. /**
  83854. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  83855. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83856. * @param vector defines the Vector3 to transform
  83857. * @param transformation defines the transformation matrix
  83858. * @param result defines the Vector3 where to store the result
  83859. */
  83860. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83861. /**
  83862. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  83863. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83864. * @param x define the x coordinate of the source vector
  83865. * @param y define the y coordinate of the source vector
  83866. * @param z define the z coordinate of the source vector
  83867. * @param transformation defines the transformation matrix
  83868. * @param result defines the Vector3 where to store the result
  83869. */
  83870. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83871. /**
  83872. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  83873. * @param value1 defines the first control point
  83874. * @param value2 defines the second control point
  83875. * @param value3 defines the third control point
  83876. * @param value4 defines the fourth control point
  83877. * @param amount defines the amount on the spline to use
  83878. * @returns the new Vector3
  83879. */
  83880. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  83881. /**
  83882. * 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"
  83883. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83884. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83885. * @param value defines the current value
  83886. * @param min defines the lower range value
  83887. * @param max defines the upper range value
  83888. * @returns the new Vector3
  83889. */
  83890. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  83891. /**
  83892. * 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"
  83893. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83894. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83895. * @param value defines the current value
  83896. * @param min defines the lower range value
  83897. * @param max defines the upper range value
  83898. * @param result defines the Vector3 where to store the result
  83899. */
  83900. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  83901. /**
  83902. * Checks if a given vector is inside a specific range
  83903. * @param v defines the vector to test
  83904. * @param min defines the minimum range
  83905. * @param max defines the maximum range
  83906. */
  83907. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  83908. /**
  83909. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  83910. * @param value1 defines the first control point
  83911. * @param tangent1 defines the first tangent vector
  83912. * @param value2 defines the second control point
  83913. * @param tangent2 defines the second tangent vector
  83914. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  83915. * @returns the new Vector3
  83916. */
  83917. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  83918. /**
  83919. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  83920. * @param start defines the start value
  83921. * @param end defines the end value
  83922. * @param amount max defines amount between both (between 0 and 1)
  83923. * @returns the new Vector3
  83924. */
  83925. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  83926. /**
  83927. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  83928. * @param start defines the start value
  83929. * @param end defines the end value
  83930. * @param amount max defines amount between both (between 0 and 1)
  83931. * @param result defines the Vector3 where to store the result
  83932. */
  83933. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  83934. /**
  83935. * Returns the dot product (float) between the vectors "left" and "right"
  83936. * @param left defines the left operand
  83937. * @param right defines the right operand
  83938. * @returns the dot product
  83939. */
  83940. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  83941. /**
  83942. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  83943. * The cross product is then orthogonal to both "left" and "right"
  83944. * @param left defines the left operand
  83945. * @param right defines the right operand
  83946. * @returns the cross product
  83947. */
  83948. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83949. /**
  83950. * Sets the given vector "result" with the cross product of "left" and "right"
  83951. * The cross product is then orthogonal to both "left" and "right"
  83952. * @param left defines the left operand
  83953. * @param right defines the right operand
  83954. * @param result defines the Vector3 where to store the result
  83955. */
  83956. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  83957. /**
  83958. * Returns a new Vector3 as the normalization of the given vector
  83959. * @param vector defines the Vector3 to normalize
  83960. * @returns the new Vector3
  83961. */
  83962. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  83963. /**
  83964. * Sets the given vector "result" with the normalization of the given first vector
  83965. * @param vector defines the Vector3 to normalize
  83966. * @param result defines the Vector3 where to store the result
  83967. */
  83968. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  83969. /**
  83970. * Project a Vector3 onto screen space
  83971. * @param vector defines the Vector3 to project
  83972. * @param world defines the world matrix to use
  83973. * @param transform defines the transform (view x projection) matrix to use
  83974. * @param viewport defines the screen viewport to use
  83975. * @returns the new Vector3
  83976. */
  83977. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  83978. /**
  83979. * Project a Vector3 onto screen space to reference
  83980. * @param vector defines the Vector3 to project
  83981. * @param world defines the world matrix to use
  83982. * @param transform defines the transform (view x projection) matrix to use
  83983. * @param viewport defines the screen viewport to use
  83984. * @param result the vector in which the screen space will be stored
  83985. * @returns the new Vector3
  83986. */
  83987. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  83988. /** @hidden */
  83989. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  83990. /**
  83991. * Unproject from screen space to object space
  83992. * @param source defines the screen space Vector3 to use
  83993. * @param viewportWidth defines the current width of the viewport
  83994. * @param viewportHeight defines the current height of the viewport
  83995. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83996. * @param transform defines the transform (view x projection) matrix to use
  83997. * @returns the new Vector3
  83998. */
  83999. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  84000. /**
  84001. * Unproject from screen space to object space
  84002. * @param source defines the screen space Vector3 to use
  84003. * @param viewportWidth defines the current width of the viewport
  84004. * @param viewportHeight defines the current height of the viewport
  84005. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84006. * @param view defines the view matrix to use
  84007. * @param projection defines the projection matrix to use
  84008. * @returns the new Vector3
  84009. */
  84010. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  84011. /**
  84012. * Unproject from screen space to object space
  84013. * @param source defines the screen space Vector3 to use
  84014. * @param viewportWidth defines the current width of the viewport
  84015. * @param viewportHeight defines the current height of the viewport
  84016. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84017. * @param view defines the view matrix to use
  84018. * @param projection defines the projection matrix to use
  84019. * @param result defines the Vector3 where to store the result
  84020. */
  84021. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  84022. /**
  84023. * Unproject from screen space to object space
  84024. * @param sourceX defines the screen space x coordinate to use
  84025. * @param sourceY defines the screen space y coordinate to use
  84026. * @param sourceZ defines the screen space z coordinate to use
  84027. * @param viewportWidth defines the current width of the viewport
  84028. * @param viewportHeight defines the current height of the viewport
  84029. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84030. * @param view defines the view matrix to use
  84031. * @param projection defines the projection matrix to use
  84032. * @param result defines the Vector3 where to store the result
  84033. */
  84034. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  84035. /**
  84036. * Gets the minimal coordinate values between two Vector3
  84037. * @param left defines the first operand
  84038. * @param right defines the second operand
  84039. * @returns the new Vector3
  84040. */
  84041. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  84042. /**
  84043. * Gets the maximal coordinate values between two Vector3
  84044. * @param left defines the first operand
  84045. * @param right defines the second operand
  84046. * @returns the new Vector3
  84047. */
  84048. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  84049. /**
  84050. * Returns the distance between the vectors "value1" and "value2"
  84051. * @param value1 defines the first operand
  84052. * @param value2 defines the second operand
  84053. * @returns the distance
  84054. */
  84055. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  84056. /**
  84057. * Returns the squared distance between the vectors "value1" and "value2"
  84058. * @param value1 defines the first operand
  84059. * @param value2 defines the second operand
  84060. * @returns the squared distance
  84061. */
  84062. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  84063. /**
  84064. * Returns a new Vector3 located at the center between "value1" and "value2"
  84065. * @param value1 defines the first operand
  84066. * @param value2 defines the second operand
  84067. * @returns the new Vector3
  84068. */
  84069. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  84070. /**
  84071. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  84072. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  84073. * to something in order to rotate it from its local system to the given target system
  84074. * Note: axis1, axis2 and axis3 are normalized during this operation
  84075. * @param axis1 defines the first axis
  84076. * @param axis2 defines the second axis
  84077. * @param axis3 defines the third axis
  84078. * @returns a new Vector3
  84079. */
  84080. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  84081. /**
  84082. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  84083. * @param axis1 defines the first axis
  84084. * @param axis2 defines the second axis
  84085. * @param axis3 defines the third axis
  84086. * @param ref defines the Vector3 where to store the result
  84087. */
  84088. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  84089. }
  84090. /**
  84091. * Vector4 class created for EulerAngle class conversion to Quaternion
  84092. */
  84093. export class Vector4 {
  84094. /** x value of the vector */
  84095. x: number;
  84096. /** y value of the vector */
  84097. y: number;
  84098. /** z value of the vector */
  84099. z: number;
  84100. /** w value of the vector */
  84101. w: number;
  84102. /**
  84103. * Creates a Vector4 object from the given floats.
  84104. * @param x x value of the vector
  84105. * @param y y value of the vector
  84106. * @param z z value of the vector
  84107. * @param w w value of the vector
  84108. */
  84109. constructor(
  84110. /** x value of the vector */
  84111. x: number,
  84112. /** y value of the vector */
  84113. y: number,
  84114. /** z value of the vector */
  84115. z: number,
  84116. /** w value of the vector */
  84117. w: number);
  84118. /**
  84119. * Returns the string with the Vector4 coordinates.
  84120. * @returns a string containing all the vector values
  84121. */
  84122. toString(): string;
  84123. /**
  84124. * Returns the string "Vector4".
  84125. * @returns "Vector4"
  84126. */
  84127. getClassName(): string;
  84128. /**
  84129. * Returns the Vector4 hash code.
  84130. * @returns a unique hash code
  84131. */
  84132. getHashCode(): number;
  84133. /**
  84134. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  84135. * @returns the resulting array
  84136. */
  84137. asArray(): number[];
  84138. /**
  84139. * Populates the given array from the given index with the Vector4 coordinates.
  84140. * @param array array to populate
  84141. * @param index index of the array to start at (default: 0)
  84142. * @returns the Vector4.
  84143. */
  84144. toArray(array: FloatArray, index?: number): Vector4;
  84145. /**
  84146. * Update the current vector from an array
  84147. * @param array defines the destination array
  84148. * @param index defines the offset in the destination array
  84149. * @returns the current Vector3
  84150. */
  84151. fromArray(array: FloatArray, index?: number): Vector4;
  84152. /**
  84153. * Adds the given vector to the current Vector4.
  84154. * @param otherVector the vector to add
  84155. * @returns the updated Vector4.
  84156. */
  84157. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84158. /**
  84159. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  84160. * @param otherVector the vector to add
  84161. * @returns the resulting vector
  84162. */
  84163. add(otherVector: DeepImmutable<Vector4>): Vector4;
  84164. /**
  84165. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  84166. * @param otherVector the vector to add
  84167. * @param result the vector to store the result
  84168. * @returns the current Vector4.
  84169. */
  84170. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84171. /**
  84172. * Subtract in place the given vector from the current Vector4.
  84173. * @param otherVector the vector to subtract
  84174. * @returns the updated Vector4.
  84175. */
  84176. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84177. /**
  84178. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  84179. * @param otherVector the vector to add
  84180. * @returns the new vector with the result
  84181. */
  84182. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  84183. /**
  84184. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  84185. * @param otherVector the vector to subtract
  84186. * @param result the vector to store the result
  84187. * @returns the current Vector4.
  84188. */
  84189. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84190. /**
  84191. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84192. */
  84193. /**
  84194. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84195. * @param x value to subtract
  84196. * @param y value to subtract
  84197. * @param z value to subtract
  84198. * @param w value to subtract
  84199. * @returns new vector containing the result
  84200. */
  84201. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84202. /**
  84203. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84204. * @param x value to subtract
  84205. * @param y value to subtract
  84206. * @param z value to subtract
  84207. * @param w value to subtract
  84208. * @param result the vector to store the result in
  84209. * @returns the current Vector4.
  84210. */
  84211. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  84212. /**
  84213. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  84214. * @returns a new vector with the negated values
  84215. */
  84216. negate(): Vector4;
  84217. /**
  84218. * Negate this vector in place
  84219. * @returns this
  84220. */
  84221. negateInPlace(): Vector4;
  84222. /**
  84223. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  84224. * @param result defines the Vector3 object where to store the result
  84225. * @returns the current Vector4
  84226. */
  84227. negateToRef(result: Vector4): Vector4;
  84228. /**
  84229. * Multiplies the current Vector4 coordinates by scale (float).
  84230. * @param scale the number to scale with
  84231. * @returns the updated Vector4.
  84232. */
  84233. scaleInPlace(scale: number): Vector4;
  84234. /**
  84235. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  84236. * @param scale the number to scale with
  84237. * @returns a new vector with the result
  84238. */
  84239. scale(scale: number): Vector4;
  84240. /**
  84241. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  84242. * @param scale the number to scale with
  84243. * @param result a vector to store the result in
  84244. * @returns the current Vector4.
  84245. */
  84246. scaleToRef(scale: number, result: Vector4): Vector4;
  84247. /**
  84248. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  84249. * @param scale defines the scale factor
  84250. * @param result defines the Vector4 object where to store the result
  84251. * @returns the unmodified current Vector4
  84252. */
  84253. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  84254. /**
  84255. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  84256. * @param otherVector the vector to compare against
  84257. * @returns true if they are equal
  84258. */
  84259. equals(otherVector: DeepImmutable<Vector4>): boolean;
  84260. /**
  84261. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  84262. * @param otherVector vector to compare against
  84263. * @param epsilon (Default: very small number)
  84264. * @returns true if they are equal
  84265. */
  84266. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  84267. /**
  84268. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  84269. * @param x x value to compare against
  84270. * @param y y value to compare against
  84271. * @param z z value to compare against
  84272. * @param w w value to compare against
  84273. * @returns true if equal
  84274. */
  84275. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  84276. /**
  84277. * Multiplies in place the current Vector4 by the given one.
  84278. * @param otherVector vector to multiple with
  84279. * @returns the updated Vector4.
  84280. */
  84281. multiplyInPlace(otherVector: Vector4): Vector4;
  84282. /**
  84283. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  84284. * @param otherVector vector to multiple with
  84285. * @returns resulting new vector
  84286. */
  84287. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  84288. /**
  84289. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  84290. * @param otherVector vector to multiple with
  84291. * @param result vector to store the result
  84292. * @returns the current Vector4.
  84293. */
  84294. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84295. /**
  84296. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  84297. * @param x x value multiply with
  84298. * @param y y value multiply with
  84299. * @param z z value multiply with
  84300. * @param w w value multiply with
  84301. * @returns resulting new vector
  84302. */
  84303. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  84304. /**
  84305. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  84306. * @param otherVector vector to devide with
  84307. * @returns resulting new vector
  84308. */
  84309. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  84310. /**
  84311. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  84312. * @param otherVector vector to devide with
  84313. * @param result vector to store the result
  84314. * @returns the current Vector4.
  84315. */
  84316. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84317. /**
  84318. * Divides the current Vector3 coordinates by the given ones.
  84319. * @param otherVector vector to devide with
  84320. * @returns the updated Vector3.
  84321. */
  84322. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84323. /**
  84324. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  84325. * @param other defines the second operand
  84326. * @returns the current updated Vector4
  84327. */
  84328. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84329. /**
  84330. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  84331. * @param other defines the second operand
  84332. * @returns the current updated Vector4
  84333. */
  84334. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84335. /**
  84336. * Gets a new Vector4 from current Vector4 floored values
  84337. * @returns a new Vector4
  84338. */
  84339. floor(): Vector4;
  84340. /**
  84341. * Gets a new Vector4 from current Vector3 floored values
  84342. * @returns a new Vector4
  84343. */
  84344. fract(): Vector4;
  84345. /**
  84346. * Returns the Vector4 length (float).
  84347. * @returns the length
  84348. */
  84349. length(): number;
  84350. /**
  84351. * Returns the Vector4 squared length (float).
  84352. * @returns the length squared
  84353. */
  84354. lengthSquared(): number;
  84355. /**
  84356. * Normalizes in place the Vector4.
  84357. * @returns the updated Vector4.
  84358. */
  84359. normalize(): Vector4;
  84360. /**
  84361. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  84362. * @returns this converted to a new vector3
  84363. */
  84364. toVector3(): Vector3;
  84365. /**
  84366. * Returns a new Vector4 copied from the current one.
  84367. * @returns the new cloned vector
  84368. */
  84369. clone(): Vector4;
  84370. /**
  84371. * Updates the current Vector4 with the given one coordinates.
  84372. * @param source the source vector to copy from
  84373. * @returns the updated Vector4.
  84374. */
  84375. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  84376. /**
  84377. * Updates the current Vector4 coordinates with the given floats.
  84378. * @param x float to copy from
  84379. * @param y float to copy from
  84380. * @param z float to copy from
  84381. * @param w float to copy from
  84382. * @returns the updated Vector4.
  84383. */
  84384. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84385. /**
  84386. * Updates the current Vector4 coordinates with the given floats.
  84387. * @param x float to set from
  84388. * @param y float to set from
  84389. * @param z float to set from
  84390. * @param w float to set from
  84391. * @returns the updated Vector4.
  84392. */
  84393. set(x: number, y: number, z: number, w: number): Vector4;
  84394. /**
  84395. * Copies the given float to the current Vector3 coordinates
  84396. * @param v defines the x, y, z and w coordinates of the operand
  84397. * @returns the current updated Vector3
  84398. */
  84399. setAll(v: number): Vector4;
  84400. /**
  84401. * Returns a new Vector4 set from the starting index of the given array.
  84402. * @param array the array to pull values from
  84403. * @param offset the offset into the array to start at
  84404. * @returns the new vector
  84405. */
  84406. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  84407. /**
  84408. * Updates the given vector "result" from the starting index of the given array.
  84409. * @param array the array to pull values from
  84410. * @param offset the offset into the array to start at
  84411. * @param result the vector to store the result in
  84412. */
  84413. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  84414. /**
  84415. * Updates the given vector "result" from the starting index of the given Float32Array.
  84416. * @param array the array to pull values from
  84417. * @param offset the offset into the array to start at
  84418. * @param result the vector to store the result in
  84419. */
  84420. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  84421. /**
  84422. * Updates the given vector "result" coordinates from the given floats.
  84423. * @param x float to set from
  84424. * @param y float to set from
  84425. * @param z float to set from
  84426. * @param w float to set from
  84427. * @param result the vector to the floats in
  84428. */
  84429. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  84430. /**
  84431. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  84432. * @returns the new vector
  84433. */
  84434. static Zero(): Vector4;
  84435. /**
  84436. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  84437. * @returns the new vector
  84438. */
  84439. static One(): Vector4;
  84440. /**
  84441. * Returns a new normalized Vector4 from the given one.
  84442. * @param vector the vector to normalize
  84443. * @returns the vector
  84444. */
  84445. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  84446. /**
  84447. * Updates the given vector "result" from the normalization of the given one.
  84448. * @param vector the vector to normalize
  84449. * @param result the vector to store the result in
  84450. */
  84451. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  84452. /**
  84453. * Returns a vector with the minimum values from the left and right vectors
  84454. * @param left left vector to minimize
  84455. * @param right right vector to minimize
  84456. * @returns a new vector with the minimum of the left and right vector values
  84457. */
  84458. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84459. /**
  84460. * Returns a vector with the maximum values from the left and right vectors
  84461. * @param left left vector to maximize
  84462. * @param right right vector to maximize
  84463. * @returns a new vector with the maximum of the left and right vector values
  84464. */
  84465. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84466. /**
  84467. * Returns the distance (float) between the vectors "value1" and "value2".
  84468. * @param value1 value to calulate the distance between
  84469. * @param value2 value to calulate the distance between
  84470. * @return the distance between the two vectors
  84471. */
  84472. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84473. /**
  84474. * Returns the squared distance (float) between the vectors "value1" and "value2".
  84475. * @param value1 value to calulate the distance between
  84476. * @param value2 value to calulate the distance between
  84477. * @return the distance between the two vectors squared
  84478. */
  84479. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84480. /**
  84481. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  84482. * @param value1 value to calulate the center between
  84483. * @param value2 value to calulate the center between
  84484. * @return the center between the two vectors
  84485. */
  84486. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  84487. /**
  84488. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  84489. * This methods computes transformed normalized direction vectors only.
  84490. * @param vector the vector to transform
  84491. * @param transformation the transformation matrix to apply
  84492. * @returns the new vector
  84493. */
  84494. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  84495. /**
  84496. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  84497. * This methods computes transformed normalized direction vectors only.
  84498. * @param vector the vector to transform
  84499. * @param transformation the transformation matrix to apply
  84500. * @param result the vector to store the result in
  84501. */
  84502. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84503. /**
  84504. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  84505. * This methods computes transformed normalized direction vectors only.
  84506. * @param x value to transform
  84507. * @param y value to transform
  84508. * @param z value to transform
  84509. * @param w value to transform
  84510. * @param transformation the transformation matrix to apply
  84511. * @param result the vector to store the results in
  84512. */
  84513. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84514. /**
  84515. * Creates a new Vector4 from a Vector3
  84516. * @param source defines the source data
  84517. * @param w defines the 4th component (default is 0)
  84518. * @returns a new Vector4
  84519. */
  84520. static FromVector3(source: Vector3, w?: number): Vector4;
  84521. }
  84522. /**
  84523. * Class used to store quaternion data
  84524. * @see https://en.wikipedia.org/wiki/Quaternion
  84525. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  84526. */
  84527. export class Quaternion {
  84528. /** @hidden */
  84529. _x: number;
  84530. /** @hidden */
  84531. _y: number;
  84532. /** @hidden */
  84533. _z: number;
  84534. /** @hidden */
  84535. _w: number;
  84536. /** @hidden */
  84537. _isDirty: boolean;
  84538. /** Gets or sets the x coordinate */
  84539. get x(): number;
  84540. set x(value: number);
  84541. /** Gets or sets the y coordinate */
  84542. get y(): number;
  84543. set y(value: number);
  84544. /** Gets or sets the z coordinate */
  84545. get z(): number;
  84546. set z(value: number);
  84547. /** Gets or sets the w coordinate */
  84548. get w(): number;
  84549. set w(value: number);
  84550. /**
  84551. * Creates a new Quaternion from the given floats
  84552. * @param x defines the first component (0 by default)
  84553. * @param y defines the second component (0 by default)
  84554. * @param z defines the third component (0 by default)
  84555. * @param w defines the fourth component (1.0 by default)
  84556. */
  84557. constructor(x?: number, y?: number, z?: number, w?: number);
  84558. /**
  84559. * Gets a string representation for the current quaternion
  84560. * @returns a string with the Quaternion coordinates
  84561. */
  84562. toString(): string;
  84563. /**
  84564. * Gets the class name of the quaternion
  84565. * @returns the string "Quaternion"
  84566. */
  84567. getClassName(): string;
  84568. /**
  84569. * Gets a hash code for this quaternion
  84570. * @returns the quaternion hash code
  84571. */
  84572. getHashCode(): number;
  84573. /**
  84574. * Copy the quaternion to an array
  84575. * @returns a new array populated with 4 elements from the quaternion coordinates
  84576. */
  84577. asArray(): number[];
  84578. /**
  84579. * Check if two quaternions are equals
  84580. * @param otherQuaternion defines the second operand
  84581. * @return true if the current quaternion and the given one coordinates are strictly equals
  84582. */
  84583. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  84584. /**
  84585. * Gets a boolean if two quaternions are equals (using an epsilon value)
  84586. * @param otherQuaternion defines the other quaternion
  84587. * @param epsilon defines the minimal distance to consider equality
  84588. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  84589. */
  84590. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  84591. /**
  84592. * Clone the current quaternion
  84593. * @returns a new quaternion copied from the current one
  84594. */
  84595. clone(): Quaternion;
  84596. /**
  84597. * Copy a quaternion to the current one
  84598. * @param other defines the other quaternion
  84599. * @returns the updated current quaternion
  84600. */
  84601. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  84602. /**
  84603. * Updates the current quaternion with the given float coordinates
  84604. * @param x defines the x coordinate
  84605. * @param y defines the y coordinate
  84606. * @param z defines the z coordinate
  84607. * @param w defines the w coordinate
  84608. * @returns the updated current quaternion
  84609. */
  84610. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84611. /**
  84612. * Updates the current quaternion from the given float coordinates
  84613. * @param x defines the x coordinate
  84614. * @param y defines the y coordinate
  84615. * @param z defines the z coordinate
  84616. * @param w defines the w coordinate
  84617. * @returns the updated current quaternion
  84618. */
  84619. set(x: number, y: number, z: number, w: number): Quaternion;
  84620. /**
  84621. * Adds two quaternions
  84622. * @param other defines the second operand
  84623. * @returns a new quaternion as the addition result of the given one and the current quaternion
  84624. */
  84625. add(other: DeepImmutable<Quaternion>): Quaternion;
  84626. /**
  84627. * Add a quaternion to the current one
  84628. * @param other defines the quaternion to add
  84629. * @returns the current quaternion
  84630. */
  84631. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  84632. /**
  84633. * Subtract two quaternions
  84634. * @param other defines the second operand
  84635. * @returns a new quaternion as the subtraction result of the given one from the current one
  84636. */
  84637. subtract(other: Quaternion): Quaternion;
  84638. /**
  84639. * Multiplies the current quaternion by a scale factor
  84640. * @param value defines the scale factor
  84641. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  84642. */
  84643. scale(value: number): Quaternion;
  84644. /**
  84645. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  84646. * @param scale defines the scale factor
  84647. * @param result defines the Quaternion object where to store the result
  84648. * @returns the unmodified current quaternion
  84649. */
  84650. scaleToRef(scale: number, result: Quaternion): Quaternion;
  84651. /**
  84652. * Multiplies in place the current quaternion by a scale factor
  84653. * @param value defines the scale factor
  84654. * @returns the current modified quaternion
  84655. */
  84656. scaleInPlace(value: number): Quaternion;
  84657. /**
  84658. * Scale the current quaternion values by a factor and add the result to a given quaternion
  84659. * @param scale defines the scale factor
  84660. * @param result defines the Quaternion object where to store the result
  84661. * @returns the unmodified current quaternion
  84662. */
  84663. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  84664. /**
  84665. * Multiplies two quaternions
  84666. * @param q1 defines the second operand
  84667. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  84668. */
  84669. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  84670. /**
  84671. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  84672. * @param q1 defines the second operand
  84673. * @param result defines the target quaternion
  84674. * @returns the current quaternion
  84675. */
  84676. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  84677. /**
  84678. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  84679. * @param q1 defines the second operand
  84680. * @returns the currentupdated quaternion
  84681. */
  84682. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  84683. /**
  84684. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  84685. * @param ref defines the target quaternion
  84686. * @returns the current quaternion
  84687. */
  84688. conjugateToRef(ref: Quaternion): Quaternion;
  84689. /**
  84690. * Conjugates in place (1-q) the current quaternion
  84691. * @returns the current updated quaternion
  84692. */
  84693. conjugateInPlace(): Quaternion;
  84694. /**
  84695. * Conjugates in place (1-q) the current quaternion
  84696. * @returns a new quaternion
  84697. */
  84698. conjugate(): Quaternion;
  84699. /**
  84700. * Gets length of current quaternion
  84701. * @returns the quaternion length (float)
  84702. */
  84703. length(): number;
  84704. /**
  84705. * Normalize in place the current quaternion
  84706. * @returns the current updated quaternion
  84707. */
  84708. normalize(): Quaternion;
  84709. /**
  84710. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  84711. * @param order is a reserved parameter and is ignored for now
  84712. * @returns a new Vector3 containing the Euler angles
  84713. */
  84714. toEulerAngles(order?: string): Vector3;
  84715. /**
  84716. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  84717. * @param result defines the vector which will be filled with the Euler angles
  84718. * @returns the current unchanged quaternion
  84719. */
  84720. toEulerAnglesToRef(result: Vector3): Quaternion;
  84721. /**
  84722. * Updates the given rotation matrix with the current quaternion values
  84723. * @param result defines the target matrix
  84724. * @returns the current unchanged quaternion
  84725. */
  84726. toRotationMatrix(result: Matrix): Quaternion;
  84727. /**
  84728. * Updates the current quaternion from the given rotation matrix values
  84729. * @param matrix defines the source matrix
  84730. * @returns the current updated quaternion
  84731. */
  84732. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84733. /**
  84734. * Creates a new quaternion from a rotation matrix
  84735. * @param matrix defines the source matrix
  84736. * @returns a new quaternion created from the given rotation matrix values
  84737. */
  84738. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84739. /**
  84740. * Updates the given quaternion with the given rotation matrix values
  84741. * @param matrix defines the source matrix
  84742. * @param result defines the target quaternion
  84743. */
  84744. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  84745. /**
  84746. * Returns the dot product (float) between the quaternions "left" and "right"
  84747. * @param left defines the left operand
  84748. * @param right defines the right operand
  84749. * @returns the dot product
  84750. */
  84751. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  84752. /**
  84753. * Checks if the two quaternions are close to each other
  84754. * @param quat0 defines the first quaternion to check
  84755. * @param quat1 defines the second quaternion to check
  84756. * @returns true if the two quaternions are close to each other
  84757. */
  84758. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  84759. /**
  84760. * Creates an empty quaternion
  84761. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  84762. */
  84763. static Zero(): Quaternion;
  84764. /**
  84765. * Inverse a given quaternion
  84766. * @param q defines the source quaternion
  84767. * @returns a new quaternion as the inverted current quaternion
  84768. */
  84769. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  84770. /**
  84771. * Inverse a given quaternion
  84772. * @param q defines the source quaternion
  84773. * @param result the quaternion the result will be stored in
  84774. * @returns the result quaternion
  84775. */
  84776. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  84777. /**
  84778. * Creates an identity quaternion
  84779. * @returns the identity quaternion
  84780. */
  84781. static Identity(): Quaternion;
  84782. /**
  84783. * Gets a boolean indicating if the given quaternion is identity
  84784. * @param quaternion defines the quaternion to check
  84785. * @returns true if the quaternion is identity
  84786. */
  84787. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  84788. /**
  84789. * Creates a quaternion from a rotation around an axis
  84790. * @param axis defines the axis to use
  84791. * @param angle defines the angle to use
  84792. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  84793. */
  84794. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  84795. /**
  84796. * Creates a rotation around an axis and stores it into the given quaternion
  84797. * @param axis defines the axis to use
  84798. * @param angle defines the angle to use
  84799. * @param result defines the target quaternion
  84800. * @returns the target quaternion
  84801. */
  84802. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  84803. /**
  84804. * Creates a new quaternion from data stored into an array
  84805. * @param array defines the data source
  84806. * @param offset defines the offset in the source array where the data starts
  84807. * @returns a new quaternion
  84808. */
  84809. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  84810. /**
  84811. * Updates the given quaternion "result" from the starting index of the given array.
  84812. * @param array the array to pull values from
  84813. * @param offset the offset into the array to start at
  84814. * @param result the quaternion to store the result in
  84815. */
  84816. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  84817. /**
  84818. * Create a quaternion from Euler rotation angles
  84819. * @param x Pitch
  84820. * @param y Yaw
  84821. * @param z Roll
  84822. * @returns the new Quaternion
  84823. */
  84824. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  84825. /**
  84826. * Updates a quaternion from Euler rotation angles
  84827. * @param x Pitch
  84828. * @param y Yaw
  84829. * @param z Roll
  84830. * @param result the quaternion to store the result
  84831. * @returns the updated quaternion
  84832. */
  84833. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  84834. /**
  84835. * Create a quaternion from Euler rotation vector
  84836. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84837. * @returns the new Quaternion
  84838. */
  84839. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  84840. /**
  84841. * Updates a quaternion from Euler rotation vector
  84842. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84843. * @param result the quaternion to store the result
  84844. * @returns the updated quaternion
  84845. */
  84846. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  84847. /**
  84848. * Creates a new quaternion from the given Euler float angles (y, x, z)
  84849. * @param yaw defines the rotation around Y axis
  84850. * @param pitch defines the rotation around X axis
  84851. * @param roll defines the rotation around Z axis
  84852. * @returns the new quaternion
  84853. */
  84854. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  84855. /**
  84856. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  84857. * @param yaw defines the rotation around Y axis
  84858. * @param pitch defines the rotation around X axis
  84859. * @param roll defines the rotation around Z axis
  84860. * @param result defines the target quaternion
  84861. */
  84862. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  84863. /**
  84864. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  84865. * @param alpha defines the rotation around first axis
  84866. * @param beta defines the rotation around second axis
  84867. * @param gamma defines the rotation around third axis
  84868. * @returns the new quaternion
  84869. */
  84870. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  84871. /**
  84872. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  84873. * @param alpha defines the rotation around first axis
  84874. * @param beta defines the rotation around second axis
  84875. * @param gamma defines the rotation around third axis
  84876. * @param result defines the target quaternion
  84877. */
  84878. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  84879. /**
  84880. * 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)
  84881. * @param axis1 defines the first axis
  84882. * @param axis2 defines the second axis
  84883. * @param axis3 defines the third axis
  84884. * @returns the new quaternion
  84885. */
  84886. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  84887. /**
  84888. * 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
  84889. * @param axis1 defines the first axis
  84890. * @param axis2 defines the second axis
  84891. * @param axis3 defines the third axis
  84892. * @param ref defines the target quaternion
  84893. */
  84894. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  84895. /**
  84896. * Interpolates between two quaternions
  84897. * @param left defines first quaternion
  84898. * @param right defines second quaternion
  84899. * @param amount defines the gradient to use
  84900. * @returns the new interpolated quaternion
  84901. */
  84902. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84903. /**
  84904. * Interpolates between two quaternions and stores it into a target quaternion
  84905. * @param left defines first quaternion
  84906. * @param right defines second quaternion
  84907. * @param amount defines the gradient to use
  84908. * @param result defines the target quaternion
  84909. */
  84910. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  84911. /**
  84912. * Interpolate between two quaternions using Hermite interpolation
  84913. * @param value1 defines first quaternion
  84914. * @param tangent1 defines the incoming tangent
  84915. * @param value2 defines second quaternion
  84916. * @param tangent2 defines the outgoing tangent
  84917. * @param amount defines the target quaternion
  84918. * @returns the new interpolated quaternion
  84919. */
  84920. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84921. }
  84922. /**
  84923. * Class used to store matrix data (4x4)
  84924. */
  84925. export class Matrix {
  84926. /**
  84927. * Gets the precision of matrix computations
  84928. */
  84929. static get Use64Bits(): boolean;
  84930. private static _updateFlagSeed;
  84931. private static _identityReadOnly;
  84932. private _isIdentity;
  84933. private _isIdentityDirty;
  84934. private _isIdentity3x2;
  84935. private _isIdentity3x2Dirty;
  84936. /**
  84937. * Gets the update flag of the matrix which is an unique number for the matrix.
  84938. * It will be incremented every time the matrix data change.
  84939. * You can use it to speed the comparison between two versions of the same matrix.
  84940. */
  84941. updateFlag: number;
  84942. private readonly _m;
  84943. /**
  84944. * Gets the internal data of the matrix
  84945. */
  84946. get m(): DeepImmutable<Float32Array | Array<number>>;
  84947. /** @hidden */
  84948. _markAsUpdated(): void;
  84949. /** @hidden */
  84950. private _updateIdentityStatus;
  84951. /**
  84952. * Creates an empty matrix (filled with zeros)
  84953. */
  84954. constructor();
  84955. /**
  84956. * Check if the current matrix is identity
  84957. * @returns true is the matrix is the identity matrix
  84958. */
  84959. isIdentity(): boolean;
  84960. /**
  84961. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  84962. * @returns true is the matrix is the identity matrix
  84963. */
  84964. isIdentityAs3x2(): boolean;
  84965. /**
  84966. * Gets the determinant of the matrix
  84967. * @returns the matrix determinant
  84968. */
  84969. determinant(): number;
  84970. /**
  84971. * Returns the matrix as a Float32Array or Array<number>
  84972. * @returns the matrix underlying array
  84973. */
  84974. toArray(): DeepImmutable<Float32Array | Array<number>>;
  84975. /**
  84976. * Returns the matrix as a Float32Array or Array<number>
  84977. * @returns the matrix underlying array.
  84978. */
  84979. asArray(): DeepImmutable<Float32Array | Array<number>>;
  84980. /**
  84981. * Inverts the current matrix in place
  84982. * @returns the current inverted matrix
  84983. */
  84984. invert(): Matrix;
  84985. /**
  84986. * Sets all the matrix elements to zero
  84987. * @returns the current matrix
  84988. */
  84989. reset(): Matrix;
  84990. /**
  84991. * Adds the current matrix with a second one
  84992. * @param other defines the matrix to add
  84993. * @returns a new matrix as the addition of the current matrix and the given one
  84994. */
  84995. add(other: DeepImmutable<Matrix>): Matrix;
  84996. /**
  84997. * Sets the given matrix "result" to the addition of the current matrix and the given one
  84998. * @param other defines the matrix to add
  84999. * @param result defines the target matrix
  85000. * @returns the current matrix
  85001. */
  85002. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  85003. /**
  85004. * Adds in place the given matrix to the current matrix
  85005. * @param other defines the second operand
  85006. * @returns the current updated matrix
  85007. */
  85008. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  85009. /**
  85010. * Sets the given matrix to the current inverted Matrix
  85011. * @param other defines the target matrix
  85012. * @returns the unmodified current matrix
  85013. */
  85014. invertToRef(other: Matrix): Matrix;
  85015. /**
  85016. * add a value at the specified position in the current Matrix
  85017. * @param index the index of the value within the matrix. between 0 and 15.
  85018. * @param value the value to be added
  85019. * @returns the current updated matrix
  85020. */
  85021. addAtIndex(index: number, value: number): Matrix;
  85022. /**
  85023. * mutiply the specified position in the current Matrix by a value
  85024. * @param index the index of the value within the matrix. between 0 and 15.
  85025. * @param value the value to be added
  85026. * @returns the current updated matrix
  85027. */
  85028. multiplyAtIndex(index: number, value: number): Matrix;
  85029. /**
  85030. * Inserts the translation vector (using 3 floats) in the current matrix
  85031. * @param x defines the 1st component of the translation
  85032. * @param y defines the 2nd component of the translation
  85033. * @param z defines the 3rd component of the translation
  85034. * @returns the current updated matrix
  85035. */
  85036. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  85037. /**
  85038. * Adds the translation vector (using 3 floats) in the current matrix
  85039. * @param x defines the 1st component of the translation
  85040. * @param y defines the 2nd component of the translation
  85041. * @param z defines the 3rd component of the translation
  85042. * @returns the current updated matrix
  85043. */
  85044. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  85045. /**
  85046. * Inserts the translation vector in the current matrix
  85047. * @param vector3 defines the translation to insert
  85048. * @returns the current updated matrix
  85049. */
  85050. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  85051. /**
  85052. * Gets the translation value of the current matrix
  85053. * @returns a new Vector3 as the extracted translation from the matrix
  85054. */
  85055. getTranslation(): Vector3;
  85056. /**
  85057. * Fill a Vector3 with the extracted translation from the matrix
  85058. * @param result defines the Vector3 where to store the translation
  85059. * @returns the current matrix
  85060. */
  85061. getTranslationToRef(result: Vector3): Matrix;
  85062. /**
  85063. * Remove rotation and scaling part from the matrix
  85064. * @returns the updated matrix
  85065. */
  85066. removeRotationAndScaling(): Matrix;
  85067. /**
  85068. * Multiply two matrices
  85069. * @param other defines the second operand
  85070. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  85071. */
  85072. multiply(other: DeepImmutable<Matrix>): Matrix;
  85073. /**
  85074. * Copy the current matrix from the given one
  85075. * @param other defines the source matrix
  85076. * @returns the current updated matrix
  85077. */
  85078. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  85079. /**
  85080. * Populates the given array from the starting index with the current matrix values
  85081. * @param array defines the target array
  85082. * @param offset defines the offset in the target array where to start storing values
  85083. * @returns the current matrix
  85084. */
  85085. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  85086. /**
  85087. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  85088. * @param other defines the second operand
  85089. * @param result defines the matrix where to store the multiplication
  85090. * @returns the current matrix
  85091. */
  85092. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  85093. /**
  85094. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  85095. * @param other defines the second operand
  85096. * @param result defines the array where to store the multiplication
  85097. * @param offset defines the offset in the target array where to start storing values
  85098. * @returns the current matrix
  85099. */
  85100. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  85101. /**
  85102. * Check equality between this matrix and a second one
  85103. * @param value defines the second matrix to compare
  85104. * @returns true is the current matrix and the given one values are strictly equal
  85105. */
  85106. equals(value: DeepImmutable<Matrix>): boolean;
  85107. /**
  85108. * Clone the current matrix
  85109. * @returns a new matrix from the current matrix
  85110. */
  85111. clone(): Matrix;
  85112. /**
  85113. * Returns the name of the current matrix class
  85114. * @returns the string "Matrix"
  85115. */
  85116. getClassName(): string;
  85117. /**
  85118. * Gets the hash code of the current matrix
  85119. * @returns the hash code
  85120. */
  85121. getHashCode(): number;
  85122. /**
  85123. * Decomposes the current Matrix into a translation, rotation and scaling components
  85124. * @param scale defines the scale vector3 given as a reference to update
  85125. * @param rotation defines the rotation quaternion given as a reference to update
  85126. * @param translation defines the translation vector3 given as a reference to update
  85127. * @returns true if operation was successful
  85128. */
  85129. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  85130. /**
  85131. * Gets specific row of the matrix
  85132. * @param index defines the number of the row to get
  85133. * @returns the index-th row of the current matrix as a new Vector4
  85134. */
  85135. getRow(index: number): Nullable<Vector4>;
  85136. /**
  85137. * Sets the index-th row of the current matrix to the vector4 values
  85138. * @param index defines the number of the row to set
  85139. * @param row defines the target vector4
  85140. * @returns the updated current matrix
  85141. */
  85142. setRow(index: number, row: Vector4): Matrix;
  85143. /**
  85144. * Compute the transpose of the matrix
  85145. * @returns the new transposed matrix
  85146. */
  85147. transpose(): Matrix;
  85148. /**
  85149. * Compute the transpose of the matrix and store it in a given matrix
  85150. * @param result defines the target matrix
  85151. * @returns the current matrix
  85152. */
  85153. transposeToRef(result: Matrix): Matrix;
  85154. /**
  85155. * Sets the index-th row of the current matrix with the given 4 x float values
  85156. * @param index defines the row index
  85157. * @param x defines the x component to set
  85158. * @param y defines the y component to set
  85159. * @param z defines the z component to set
  85160. * @param w defines the w component to set
  85161. * @returns the updated current matrix
  85162. */
  85163. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  85164. /**
  85165. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  85166. * @param scale defines the scale factor
  85167. * @returns a new matrix
  85168. */
  85169. scale(scale: number): Matrix;
  85170. /**
  85171. * Scale the current matrix values by a factor to a given result matrix
  85172. * @param scale defines the scale factor
  85173. * @param result defines the matrix to store the result
  85174. * @returns the current matrix
  85175. */
  85176. scaleToRef(scale: number, result: Matrix): Matrix;
  85177. /**
  85178. * Scale the current matrix values by a factor and add the result to a given matrix
  85179. * @param scale defines the scale factor
  85180. * @param result defines the Matrix to store the result
  85181. * @returns the current matrix
  85182. */
  85183. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  85184. /**
  85185. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  85186. * @param ref matrix to store the result
  85187. */
  85188. toNormalMatrix(ref: Matrix): void;
  85189. /**
  85190. * Gets only rotation part of the current matrix
  85191. * @returns a new matrix sets to the extracted rotation matrix from the current one
  85192. */
  85193. getRotationMatrix(): Matrix;
  85194. /**
  85195. * Extracts the rotation matrix from the current one and sets it as the given "result"
  85196. * @param result defines the target matrix to store data to
  85197. * @returns the current matrix
  85198. */
  85199. getRotationMatrixToRef(result: Matrix): Matrix;
  85200. /**
  85201. * Toggles model matrix from being right handed to left handed in place and vice versa
  85202. */
  85203. toggleModelMatrixHandInPlace(): void;
  85204. /**
  85205. * Toggles projection matrix from being right handed to left handed in place and vice versa
  85206. */
  85207. toggleProjectionMatrixHandInPlace(): void;
  85208. /**
  85209. * Creates a matrix from an array
  85210. * @param array defines the source array
  85211. * @param offset defines an offset in the source array
  85212. * @returns a new Matrix set from the starting index of the given array
  85213. */
  85214. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  85215. /**
  85216. * Copy the content of an array into a given matrix
  85217. * @param array defines the source array
  85218. * @param offset defines an offset in the source array
  85219. * @param result defines the target matrix
  85220. */
  85221. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  85222. /**
  85223. * Stores an array into a matrix after having multiplied each component by a given factor
  85224. * @param array defines the source array
  85225. * @param offset defines the offset in the source array
  85226. * @param scale defines the scaling factor
  85227. * @param result defines the target matrix
  85228. */
  85229. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  85230. /**
  85231. * Gets an identity matrix that must not be updated
  85232. */
  85233. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  85234. /**
  85235. * Stores a list of values (16) inside a given matrix
  85236. * @param initialM11 defines 1st value of 1st row
  85237. * @param initialM12 defines 2nd value of 1st row
  85238. * @param initialM13 defines 3rd value of 1st row
  85239. * @param initialM14 defines 4th value of 1st row
  85240. * @param initialM21 defines 1st value of 2nd row
  85241. * @param initialM22 defines 2nd value of 2nd row
  85242. * @param initialM23 defines 3rd value of 2nd row
  85243. * @param initialM24 defines 4th value of 2nd row
  85244. * @param initialM31 defines 1st value of 3rd row
  85245. * @param initialM32 defines 2nd value of 3rd row
  85246. * @param initialM33 defines 3rd value of 3rd row
  85247. * @param initialM34 defines 4th value of 3rd row
  85248. * @param initialM41 defines 1st value of 4th row
  85249. * @param initialM42 defines 2nd value of 4th row
  85250. * @param initialM43 defines 3rd value of 4th row
  85251. * @param initialM44 defines 4th value of 4th row
  85252. * @param result defines the target matrix
  85253. */
  85254. 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;
  85255. /**
  85256. * Creates new matrix from a list of values (16)
  85257. * @param initialM11 defines 1st value of 1st row
  85258. * @param initialM12 defines 2nd value of 1st row
  85259. * @param initialM13 defines 3rd value of 1st row
  85260. * @param initialM14 defines 4th value of 1st row
  85261. * @param initialM21 defines 1st value of 2nd row
  85262. * @param initialM22 defines 2nd value of 2nd row
  85263. * @param initialM23 defines 3rd value of 2nd row
  85264. * @param initialM24 defines 4th value of 2nd row
  85265. * @param initialM31 defines 1st value of 3rd row
  85266. * @param initialM32 defines 2nd value of 3rd row
  85267. * @param initialM33 defines 3rd value of 3rd row
  85268. * @param initialM34 defines 4th value of 3rd row
  85269. * @param initialM41 defines 1st value of 4th row
  85270. * @param initialM42 defines 2nd value of 4th row
  85271. * @param initialM43 defines 3rd value of 4th row
  85272. * @param initialM44 defines 4th value of 4th row
  85273. * @returns the new matrix
  85274. */
  85275. 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;
  85276. /**
  85277. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85278. * @param scale defines the scale vector3
  85279. * @param rotation defines the rotation quaternion
  85280. * @param translation defines the translation vector3
  85281. * @returns a new matrix
  85282. */
  85283. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  85284. /**
  85285. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85286. * @param scale defines the scale vector3
  85287. * @param rotation defines the rotation quaternion
  85288. * @param translation defines the translation vector3
  85289. * @param result defines the target matrix
  85290. */
  85291. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  85292. /**
  85293. * Creates a new identity matrix
  85294. * @returns a new identity matrix
  85295. */
  85296. static Identity(): Matrix;
  85297. /**
  85298. * Creates a new identity matrix and stores the result in a given matrix
  85299. * @param result defines the target matrix
  85300. */
  85301. static IdentityToRef(result: Matrix): void;
  85302. /**
  85303. * Creates a new zero matrix
  85304. * @returns a new zero matrix
  85305. */
  85306. static Zero(): Matrix;
  85307. /**
  85308. * Creates a new rotation matrix for "angle" radians around the X axis
  85309. * @param angle defines the angle (in radians) to use
  85310. * @return the new matrix
  85311. */
  85312. static RotationX(angle: number): Matrix;
  85313. /**
  85314. * Creates a new matrix as the invert of a given matrix
  85315. * @param source defines the source matrix
  85316. * @returns the new matrix
  85317. */
  85318. static Invert(source: DeepImmutable<Matrix>): Matrix;
  85319. /**
  85320. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  85321. * @param angle defines the angle (in radians) to use
  85322. * @param result defines the target matrix
  85323. */
  85324. static RotationXToRef(angle: number, result: Matrix): void;
  85325. /**
  85326. * Creates a new rotation matrix for "angle" radians around the Y axis
  85327. * @param angle defines the angle (in radians) to use
  85328. * @return the new matrix
  85329. */
  85330. static RotationY(angle: number): Matrix;
  85331. /**
  85332. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  85333. * @param angle defines the angle (in radians) to use
  85334. * @param result defines the target matrix
  85335. */
  85336. static RotationYToRef(angle: number, result: Matrix): void;
  85337. /**
  85338. * Creates a new rotation matrix for "angle" radians around the Z axis
  85339. * @param angle defines the angle (in radians) to use
  85340. * @return the new matrix
  85341. */
  85342. static RotationZ(angle: number): Matrix;
  85343. /**
  85344. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  85345. * @param angle defines the angle (in radians) to use
  85346. * @param result defines the target matrix
  85347. */
  85348. static RotationZToRef(angle: number, result: Matrix): void;
  85349. /**
  85350. * Creates a new rotation matrix for "angle" radians around the given axis
  85351. * @param axis defines the axis to use
  85352. * @param angle defines the angle (in radians) to use
  85353. * @return the new matrix
  85354. */
  85355. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  85356. /**
  85357. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  85358. * @param axis defines the axis to use
  85359. * @param angle defines the angle (in radians) to use
  85360. * @param result defines the target matrix
  85361. */
  85362. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  85363. /**
  85364. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  85365. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  85366. * @param from defines the vector to align
  85367. * @param to defines the vector to align to
  85368. * @param result defines the target matrix
  85369. */
  85370. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  85371. /**
  85372. * Creates a rotation matrix
  85373. * @param yaw defines the yaw angle in radians (Y axis)
  85374. * @param pitch defines the pitch angle in radians (X axis)
  85375. * @param roll defines the roll angle in radians (Z axis)
  85376. * @returns the new rotation matrix
  85377. */
  85378. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  85379. /**
  85380. * Creates a rotation matrix and stores it in a given matrix
  85381. * @param yaw defines the yaw angle in radians (Y axis)
  85382. * @param pitch defines the pitch angle in radians (X axis)
  85383. * @param roll defines the roll angle in radians (Z axis)
  85384. * @param result defines the target matrix
  85385. */
  85386. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  85387. /**
  85388. * Creates a scaling matrix
  85389. * @param x defines the scale factor on X axis
  85390. * @param y defines the scale factor on Y axis
  85391. * @param z defines the scale factor on Z axis
  85392. * @returns the new matrix
  85393. */
  85394. static Scaling(x: number, y: number, z: number): Matrix;
  85395. /**
  85396. * Creates a scaling matrix and stores it in a given matrix
  85397. * @param x defines the scale factor on X axis
  85398. * @param y defines the scale factor on Y axis
  85399. * @param z defines the scale factor on Z axis
  85400. * @param result defines the target matrix
  85401. */
  85402. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  85403. /**
  85404. * Creates a translation matrix
  85405. * @param x defines the translation on X axis
  85406. * @param y defines the translation on Y axis
  85407. * @param z defines the translationon Z axis
  85408. * @returns the new matrix
  85409. */
  85410. static Translation(x: number, y: number, z: number): Matrix;
  85411. /**
  85412. * Creates a translation matrix and stores it in a given matrix
  85413. * @param x defines the translation on X axis
  85414. * @param y defines the translation on Y axis
  85415. * @param z defines the translationon Z axis
  85416. * @param result defines the target matrix
  85417. */
  85418. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  85419. /**
  85420. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85421. * @param startValue defines the start value
  85422. * @param endValue defines the end value
  85423. * @param gradient defines the gradient factor
  85424. * @returns the new matrix
  85425. */
  85426. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85427. /**
  85428. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85429. * @param startValue defines the start value
  85430. * @param endValue defines the end value
  85431. * @param gradient defines the gradient factor
  85432. * @param result defines the Matrix object where to store data
  85433. */
  85434. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85435. /**
  85436. * Builds a new matrix whose values are computed by:
  85437. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85438. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85439. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85440. * @param startValue defines the first matrix
  85441. * @param endValue defines the second matrix
  85442. * @param gradient defines the gradient between the two matrices
  85443. * @returns the new matrix
  85444. */
  85445. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85446. /**
  85447. * Update a matrix to values which are computed by:
  85448. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85449. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85450. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85451. * @param startValue defines the first matrix
  85452. * @param endValue defines the second matrix
  85453. * @param gradient defines the gradient between the two matrices
  85454. * @param result defines the target matrix
  85455. */
  85456. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85457. /**
  85458. * 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"
  85459. * This function works in left handed mode
  85460. * @param eye defines the final position of the entity
  85461. * @param target defines where the entity should look at
  85462. * @param up defines the up vector for the entity
  85463. * @returns the new matrix
  85464. */
  85465. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85466. /**
  85467. * 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".
  85468. * This function works in left handed mode
  85469. * @param eye defines the final position of the entity
  85470. * @param target defines where the entity should look at
  85471. * @param up defines the up vector for the entity
  85472. * @param result defines the target matrix
  85473. */
  85474. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85475. /**
  85476. * 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"
  85477. * This function works in right handed mode
  85478. * @param eye defines the final position of the entity
  85479. * @param target defines where the entity should look at
  85480. * @param up defines the up vector for the entity
  85481. * @returns the new matrix
  85482. */
  85483. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85484. /**
  85485. * 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".
  85486. * This function works in right handed mode
  85487. * @param eye defines the final position of the entity
  85488. * @param target defines where the entity should look at
  85489. * @param up defines the up vector for the entity
  85490. * @param result defines the target matrix
  85491. */
  85492. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85493. /**
  85494. * Create a left-handed orthographic projection matrix
  85495. * @param width defines the viewport width
  85496. * @param height defines the viewport height
  85497. * @param znear defines the near clip plane
  85498. * @param zfar defines the far clip plane
  85499. * @returns a new matrix as a left-handed orthographic projection matrix
  85500. */
  85501. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85502. /**
  85503. * Store a left-handed orthographic projection to a given matrix
  85504. * @param width defines the viewport width
  85505. * @param height defines the viewport height
  85506. * @param znear defines the near clip plane
  85507. * @param zfar defines the far clip plane
  85508. * @param result defines the target matrix
  85509. */
  85510. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  85511. /**
  85512. * Create a left-handed orthographic projection matrix
  85513. * @param left defines the viewport left coordinate
  85514. * @param right defines the viewport right coordinate
  85515. * @param bottom defines the viewport bottom coordinate
  85516. * @param top defines the viewport top coordinate
  85517. * @param znear defines the near clip plane
  85518. * @param zfar defines the far clip plane
  85519. * @returns a new matrix as a left-handed orthographic projection matrix
  85520. */
  85521. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85522. /**
  85523. * Stores a left-handed orthographic projection into a given matrix
  85524. * @param left defines the viewport left coordinate
  85525. * @param right defines the viewport right coordinate
  85526. * @param bottom defines the viewport bottom coordinate
  85527. * @param top defines the viewport top coordinate
  85528. * @param znear defines the near clip plane
  85529. * @param zfar defines the far clip plane
  85530. * @param result defines the target matrix
  85531. */
  85532. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85533. /**
  85534. * Creates a right-handed orthographic projection matrix
  85535. * @param left defines the viewport left coordinate
  85536. * @param right defines the viewport right coordinate
  85537. * @param bottom defines the viewport bottom coordinate
  85538. * @param top defines the viewport top coordinate
  85539. * @param znear defines the near clip plane
  85540. * @param zfar defines the far clip plane
  85541. * @returns a new matrix as a right-handed orthographic projection matrix
  85542. */
  85543. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85544. /**
  85545. * Stores a right-handed orthographic projection into a given matrix
  85546. * @param left defines the viewport left coordinate
  85547. * @param right defines the viewport right coordinate
  85548. * @param bottom defines the viewport bottom coordinate
  85549. * @param top defines the viewport top coordinate
  85550. * @param znear defines the near clip plane
  85551. * @param zfar defines the far clip plane
  85552. * @param result defines the target matrix
  85553. */
  85554. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85555. /**
  85556. * Creates a left-handed perspective projection matrix
  85557. * @param width defines the viewport width
  85558. * @param height defines the viewport height
  85559. * @param znear defines the near clip plane
  85560. * @param zfar defines the far clip plane
  85561. * @returns a new matrix as a left-handed perspective projection matrix
  85562. */
  85563. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85564. /**
  85565. * Creates a left-handed perspective projection matrix
  85566. * @param fov defines the horizontal field of view
  85567. * @param aspect defines the aspect ratio
  85568. * @param znear defines the near clip plane
  85569. * @param zfar defines the far clip plane
  85570. * @returns a new matrix as a left-handed perspective projection matrix
  85571. */
  85572. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85573. /**
  85574. * Stores a left-handed perspective projection into a given matrix
  85575. * @param fov defines the horizontal field of view
  85576. * @param aspect defines the aspect ratio
  85577. * @param znear defines the near clip plane
  85578. * @param zfar defines the far clip plane
  85579. * @param result defines the target matrix
  85580. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85581. */
  85582. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85583. /**
  85584. * Stores a left-handed perspective projection into a given matrix with depth reversed
  85585. * @param fov defines the horizontal field of view
  85586. * @param aspect defines the aspect ratio
  85587. * @param znear defines the near clip plane
  85588. * @param zfar not used as infinity is used as far clip
  85589. * @param result defines the target matrix
  85590. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85591. */
  85592. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85593. /**
  85594. * Creates a right-handed perspective projection matrix
  85595. * @param fov defines the horizontal field of view
  85596. * @param aspect defines the aspect ratio
  85597. * @param znear defines the near clip plane
  85598. * @param zfar defines the far clip plane
  85599. * @returns a new matrix as a right-handed perspective projection matrix
  85600. */
  85601. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85602. /**
  85603. * Stores a right-handed perspective projection into a given matrix
  85604. * @param fov defines the horizontal field of view
  85605. * @param aspect defines the aspect ratio
  85606. * @param znear defines the near clip plane
  85607. * @param zfar defines the far clip plane
  85608. * @param result defines the target matrix
  85609. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85610. */
  85611. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85612. /**
  85613. * Stores a right-handed perspective projection into a given matrix
  85614. * @param fov defines the horizontal field of view
  85615. * @param aspect defines the aspect ratio
  85616. * @param znear defines the near clip plane
  85617. * @param zfar not used as infinity is used as far clip
  85618. * @param result defines the target matrix
  85619. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85620. */
  85621. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85622. /**
  85623. * Stores a perspective projection for WebVR info a given matrix
  85624. * @param fov defines the field of view
  85625. * @param znear defines the near clip plane
  85626. * @param zfar defines the far clip plane
  85627. * @param result defines the target matrix
  85628. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  85629. */
  85630. static PerspectiveFovWebVRToRef(fov: {
  85631. upDegrees: number;
  85632. downDegrees: number;
  85633. leftDegrees: number;
  85634. rightDegrees: number;
  85635. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  85636. /**
  85637. * Computes a complete transformation matrix
  85638. * @param viewport defines the viewport to use
  85639. * @param world defines the world matrix
  85640. * @param view defines the view matrix
  85641. * @param projection defines the projection matrix
  85642. * @param zmin defines the near clip plane
  85643. * @param zmax defines the far clip plane
  85644. * @returns the transformation matrix
  85645. */
  85646. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  85647. /**
  85648. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  85649. * @param matrix defines the matrix to use
  85650. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  85651. */
  85652. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85653. /**
  85654. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  85655. * @param matrix defines the matrix to use
  85656. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  85657. */
  85658. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85659. /**
  85660. * Compute the transpose of a given matrix
  85661. * @param matrix defines the matrix to transpose
  85662. * @returns the new matrix
  85663. */
  85664. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  85665. /**
  85666. * Compute the transpose of a matrix and store it in a target matrix
  85667. * @param matrix defines the matrix to transpose
  85668. * @param result defines the target matrix
  85669. */
  85670. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  85671. /**
  85672. * Computes a reflection matrix from a plane
  85673. * @param plane defines the reflection plane
  85674. * @returns a new matrix
  85675. */
  85676. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  85677. /**
  85678. * Computes a reflection matrix from a plane
  85679. * @param plane defines the reflection plane
  85680. * @param result defines the target matrix
  85681. */
  85682. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  85683. /**
  85684. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  85685. * @param xaxis defines the value of the 1st axis
  85686. * @param yaxis defines the value of the 2nd axis
  85687. * @param zaxis defines the value of the 3rd axis
  85688. * @param result defines the target matrix
  85689. */
  85690. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  85691. /**
  85692. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  85693. * @param quat defines the quaternion to use
  85694. * @param result defines the target matrix
  85695. */
  85696. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  85697. }
  85698. /**
  85699. * @hidden
  85700. */
  85701. export class TmpVectors {
  85702. static Vector2: Vector2[];
  85703. static Vector3: Vector3[];
  85704. static Vector4: Vector4[];
  85705. static Quaternion: Quaternion[];
  85706. static Matrix: Matrix[];
  85707. }
  85708. }
  85709. declare module BABYLON {
  85710. /**
  85711. * Defines potential orientation for back face culling
  85712. */
  85713. export enum Orientation {
  85714. /**
  85715. * Clockwise
  85716. */
  85717. CW = 0,
  85718. /** Counter clockwise */
  85719. CCW = 1
  85720. }
  85721. /** Class used to represent a Bezier curve */
  85722. export class BezierCurve {
  85723. /**
  85724. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  85725. * @param t defines the time
  85726. * @param x1 defines the left coordinate on X axis
  85727. * @param y1 defines the left coordinate on Y axis
  85728. * @param x2 defines the right coordinate on X axis
  85729. * @param y2 defines the right coordinate on Y axis
  85730. * @returns the interpolated value
  85731. */
  85732. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  85733. }
  85734. /**
  85735. * Defines angle representation
  85736. */
  85737. export class Angle {
  85738. private _radians;
  85739. /**
  85740. * Creates an Angle object of "radians" radians (float).
  85741. * @param radians the angle in radians
  85742. */
  85743. constructor(radians: number);
  85744. /**
  85745. * Get value in degrees
  85746. * @returns the Angle value in degrees (float)
  85747. */
  85748. degrees(): number;
  85749. /**
  85750. * Get value in radians
  85751. * @returns the Angle value in radians (float)
  85752. */
  85753. radians(): number;
  85754. /**
  85755. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  85756. * @param a defines first point as the origin
  85757. * @param b defines point
  85758. * @returns a new Angle
  85759. */
  85760. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  85761. /**
  85762. * Gets a new Angle object from the given float in radians
  85763. * @param radians defines the angle value in radians
  85764. * @returns a new Angle
  85765. */
  85766. static FromRadians(radians: number): Angle;
  85767. /**
  85768. * Gets a new Angle object from the given float in degrees
  85769. * @param degrees defines the angle value in degrees
  85770. * @returns a new Angle
  85771. */
  85772. static FromDegrees(degrees: number): Angle;
  85773. }
  85774. /**
  85775. * This represents an arc in a 2d space.
  85776. */
  85777. export class Arc2 {
  85778. /** Defines the start point of the arc */
  85779. startPoint: Vector2;
  85780. /** Defines the mid point of the arc */
  85781. midPoint: Vector2;
  85782. /** Defines the end point of the arc */
  85783. endPoint: Vector2;
  85784. /**
  85785. * Defines the center point of the arc.
  85786. */
  85787. centerPoint: Vector2;
  85788. /**
  85789. * Defines the radius of the arc.
  85790. */
  85791. radius: number;
  85792. /**
  85793. * Defines the angle of the arc (from mid point to end point).
  85794. */
  85795. angle: Angle;
  85796. /**
  85797. * Defines the start angle of the arc (from start point to middle point).
  85798. */
  85799. startAngle: Angle;
  85800. /**
  85801. * Defines the orientation of the arc (clock wise/counter clock wise).
  85802. */
  85803. orientation: Orientation;
  85804. /**
  85805. * Creates an Arc object from the three given points : start, middle and end.
  85806. * @param startPoint Defines the start point of the arc
  85807. * @param midPoint Defines the midlle point of the arc
  85808. * @param endPoint Defines the end point of the arc
  85809. */
  85810. constructor(
  85811. /** Defines the start point of the arc */
  85812. startPoint: Vector2,
  85813. /** Defines the mid point of the arc */
  85814. midPoint: Vector2,
  85815. /** Defines the end point of the arc */
  85816. endPoint: Vector2);
  85817. }
  85818. /**
  85819. * Represents a 2D path made up of multiple 2D points
  85820. */
  85821. export class Path2 {
  85822. private _points;
  85823. private _length;
  85824. /**
  85825. * If the path start and end point are the same
  85826. */
  85827. closed: boolean;
  85828. /**
  85829. * Creates a Path2 object from the starting 2D coordinates x and y.
  85830. * @param x the starting points x value
  85831. * @param y the starting points y value
  85832. */
  85833. constructor(x: number, y: number);
  85834. /**
  85835. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  85836. * @param x the added points x value
  85837. * @param y the added points y value
  85838. * @returns the updated Path2.
  85839. */
  85840. addLineTo(x: number, y: number): Path2;
  85841. /**
  85842. * 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.
  85843. * @param midX middle point x value
  85844. * @param midY middle point y value
  85845. * @param endX end point x value
  85846. * @param endY end point y value
  85847. * @param numberOfSegments (default: 36)
  85848. * @returns the updated Path2.
  85849. */
  85850. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  85851. /**
  85852. * Closes the Path2.
  85853. * @returns the Path2.
  85854. */
  85855. close(): Path2;
  85856. /**
  85857. * Gets the sum of the distance between each sequential point in the path
  85858. * @returns the Path2 total length (float).
  85859. */
  85860. length(): number;
  85861. /**
  85862. * Gets the points which construct the path
  85863. * @returns the Path2 internal array of points.
  85864. */
  85865. getPoints(): Vector2[];
  85866. /**
  85867. * Retreives the point at the distance aways from the starting point
  85868. * @param normalizedLengthPosition the length along the path to retreive the point from
  85869. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  85870. */
  85871. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  85872. /**
  85873. * Creates a new path starting from an x and y position
  85874. * @param x starting x value
  85875. * @param y starting y value
  85876. * @returns a new Path2 starting at the coordinates (x, y).
  85877. */
  85878. static StartingAt(x: number, y: number): Path2;
  85879. }
  85880. /**
  85881. * Represents a 3D path made up of multiple 3D points
  85882. */
  85883. export class Path3D {
  85884. /**
  85885. * an array of Vector3, the curve axis of the Path3D
  85886. */
  85887. path: Vector3[];
  85888. private _curve;
  85889. private _distances;
  85890. private _tangents;
  85891. private _normals;
  85892. private _binormals;
  85893. private _raw;
  85894. private _alignTangentsWithPath;
  85895. private readonly _pointAtData;
  85896. /**
  85897. * new Path3D(path, normal, raw)
  85898. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  85899. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  85900. * @param path an array of Vector3, the curve axis of the Path3D
  85901. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  85902. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  85903. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  85904. */
  85905. constructor(
  85906. /**
  85907. * an array of Vector3, the curve axis of the Path3D
  85908. */
  85909. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  85910. /**
  85911. * Returns the Path3D array of successive Vector3 designing its curve.
  85912. * @returns the Path3D array of successive Vector3 designing its curve.
  85913. */
  85914. getCurve(): Vector3[];
  85915. /**
  85916. * Returns the Path3D array of successive Vector3 designing its curve.
  85917. * @returns the Path3D array of successive Vector3 designing its curve.
  85918. */
  85919. getPoints(): Vector3[];
  85920. /**
  85921. * @returns the computed length (float) of the path.
  85922. */
  85923. length(): number;
  85924. /**
  85925. * Returns an array populated with tangent vectors on each Path3D curve point.
  85926. * @returns an array populated with tangent vectors on each Path3D curve point.
  85927. */
  85928. getTangents(): Vector3[];
  85929. /**
  85930. * Returns an array populated with normal vectors on each Path3D curve point.
  85931. * @returns an array populated with normal vectors on each Path3D curve point.
  85932. */
  85933. getNormals(): Vector3[];
  85934. /**
  85935. * Returns an array populated with binormal vectors on each Path3D curve point.
  85936. * @returns an array populated with binormal vectors on each Path3D curve point.
  85937. */
  85938. getBinormals(): Vector3[];
  85939. /**
  85940. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  85941. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  85942. */
  85943. getDistances(): number[];
  85944. /**
  85945. * Returns an interpolated point along this path
  85946. * @param position the position of the point along this path, from 0.0 to 1.0
  85947. * @returns a new Vector3 as the point
  85948. */
  85949. getPointAt(position: number): Vector3;
  85950. /**
  85951. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85952. * @param position the position of the point along this path, from 0.0 to 1.0
  85953. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  85954. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  85955. */
  85956. getTangentAt(position: number, interpolated?: boolean): Vector3;
  85957. /**
  85958. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85959. * @param position the position of the point along this path, from 0.0 to 1.0
  85960. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  85961. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  85962. */
  85963. getNormalAt(position: number, interpolated?: boolean): Vector3;
  85964. /**
  85965. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  85966. * @param position the position of the point along this path, from 0.0 to 1.0
  85967. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  85968. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  85969. */
  85970. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  85971. /**
  85972. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  85973. * @param position the position of the point along this path, from 0.0 to 1.0
  85974. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  85975. */
  85976. getDistanceAt(position: number): number;
  85977. /**
  85978. * Returns the array index of the previous point of an interpolated point along this path
  85979. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85980. * @returns the array index
  85981. */
  85982. getPreviousPointIndexAt(position: number): number;
  85983. /**
  85984. * 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)
  85985. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85986. * @returns the sub position
  85987. */
  85988. getSubPositionAt(position: number): number;
  85989. /**
  85990. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  85991. * @param target the vector of which to get the closest position to
  85992. * @returns the position of the closest virtual point on this path to the target vector
  85993. */
  85994. getClosestPositionTo(target: Vector3): number;
  85995. /**
  85996. * Returns a sub path (slice) of this path
  85997. * @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
  85998. * @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
  85999. * @returns a sub path (slice) of this path
  86000. */
  86001. slice(start?: number, end?: number): Path3D;
  86002. /**
  86003. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  86004. * @param path path which all values are copied into the curves points
  86005. * @param firstNormal which should be projected onto the curve
  86006. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  86007. * @returns the same object updated.
  86008. */
  86009. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  86010. private _compute;
  86011. private _getFirstNonNullVector;
  86012. private _getLastNonNullVector;
  86013. private _normalVector;
  86014. /**
  86015. * Updates the point at data for an interpolated point along this curve
  86016. * @param position the position of the point along this curve, from 0.0 to 1.0
  86017. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  86018. * @returns the (updated) point at data
  86019. */
  86020. private _updatePointAtData;
  86021. /**
  86022. * Updates the point at data from the specified parameters
  86023. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  86024. * @param point the interpolated point
  86025. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  86026. */
  86027. private _setPointAtData;
  86028. /**
  86029. * Updates the point at interpolation matrix for the tangents, normals and binormals
  86030. */
  86031. private _updateInterpolationMatrix;
  86032. }
  86033. /**
  86034. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  86035. * A Curve3 is designed from a series of successive Vector3.
  86036. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  86037. */
  86038. export class Curve3 {
  86039. private _points;
  86040. private _length;
  86041. /**
  86042. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  86043. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  86044. * @param v1 (Vector3) the control point
  86045. * @param v2 (Vector3) the end point of the Quadratic Bezier
  86046. * @param nbPoints (integer) the wanted number of points in the curve
  86047. * @returns the created Curve3
  86048. */
  86049. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86050. /**
  86051. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  86052. * @param v0 (Vector3) the origin point of the Cubic Bezier
  86053. * @param v1 (Vector3) the first control point
  86054. * @param v2 (Vector3) the second control point
  86055. * @param v3 (Vector3) the end point of the Cubic Bezier
  86056. * @param nbPoints (integer) the wanted number of points in the curve
  86057. * @returns the created Curve3
  86058. */
  86059. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86060. /**
  86061. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  86062. * @param p1 (Vector3) the origin point of the Hermite Spline
  86063. * @param t1 (Vector3) the tangent vector at the origin point
  86064. * @param p2 (Vector3) the end point of the Hermite Spline
  86065. * @param t2 (Vector3) the tangent vector at the end point
  86066. * @param nbPoints (integer) the wanted number of points in the curve
  86067. * @returns the created Curve3
  86068. */
  86069. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86070. /**
  86071. * Returns a Curve3 object along a CatmullRom Spline curve :
  86072. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  86073. * @param nbPoints (integer) the wanted number of points between each curve control points
  86074. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  86075. * @returns the created Curve3
  86076. */
  86077. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  86078. /**
  86079. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  86080. * A Curve3 is designed from a series of successive Vector3.
  86081. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  86082. * @param points points which make up the curve
  86083. */
  86084. constructor(points: Vector3[]);
  86085. /**
  86086. * @returns the Curve3 stored array of successive Vector3
  86087. */
  86088. getPoints(): Vector3[];
  86089. /**
  86090. * @returns the computed length (float) of the curve.
  86091. */
  86092. length(): number;
  86093. /**
  86094. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  86095. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  86096. * curveA and curveB keep unchanged.
  86097. * @param curve the curve to continue from this curve
  86098. * @returns the newly constructed curve
  86099. */
  86100. continue(curve: DeepImmutable<Curve3>): Curve3;
  86101. private _computeLength;
  86102. }
  86103. }
  86104. declare module BABYLON {
  86105. /**
  86106. * This represents the main contract an easing function should follow.
  86107. * Easing functions are used throughout the animation system.
  86108. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86109. */
  86110. export interface IEasingFunction {
  86111. /**
  86112. * Given an input gradient between 0 and 1, this returns the corrseponding value
  86113. * of the easing function.
  86114. * The link below provides some of the most common examples of easing functions.
  86115. * @see https://easings.net/
  86116. * @param gradient Defines the value between 0 and 1 we want the easing value for
  86117. * @returns the corresponding value on the curve defined by the easing function
  86118. */
  86119. ease(gradient: number): number;
  86120. }
  86121. /**
  86122. * Base class used for every default easing function.
  86123. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86124. */
  86125. export class EasingFunction implements IEasingFunction {
  86126. /**
  86127. * Interpolation follows the mathematical formula associated with the easing function.
  86128. */
  86129. static readonly EASINGMODE_EASEIN: number;
  86130. /**
  86131. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  86132. */
  86133. static readonly EASINGMODE_EASEOUT: number;
  86134. /**
  86135. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  86136. */
  86137. static readonly EASINGMODE_EASEINOUT: number;
  86138. private _easingMode;
  86139. /**
  86140. * Sets the easing mode of the current function.
  86141. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  86142. */
  86143. setEasingMode(easingMode: number): void;
  86144. /**
  86145. * Gets the current easing mode.
  86146. * @returns the easing mode
  86147. */
  86148. getEasingMode(): number;
  86149. /**
  86150. * @hidden
  86151. */
  86152. easeInCore(gradient: number): number;
  86153. /**
  86154. * Given an input gradient between 0 and 1, this returns the corresponding value
  86155. * of the easing function.
  86156. * @param gradient Defines the value between 0 and 1 we want the easing value for
  86157. * @returns the corresponding value on the curve defined by the easing function
  86158. */
  86159. ease(gradient: number): number;
  86160. }
  86161. /**
  86162. * Easing function with a circle shape (see link below).
  86163. * @see https://easings.net/#easeInCirc
  86164. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86165. */
  86166. export class CircleEase extends EasingFunction implements IEasingFunction {
  86167. /** @hidden */
  86168. easeInCore(gradient: number): number;
  86169. }
  86170. /**
  86171. * Easing function with a ease back shape (see link below).
  86172. * @see https://easings.net/#easeInBack
  86173. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86174. */
  86175. export class BackEase extends EasingFunction implements IEasingFunction {
  86176. /** Defines the amplitude of the function */
  86177. amplitude: number;
  86178. /**
  86179. * Instantiates a back ease easing
  86180. * @see https://easings.net/#easeInBack
  86181. * @param amplitude Defines the amplitude of the function
  86182. */
  86183. constructor(
  86184. /** Defines the amplitude of the function */
  86185. amplitude?: number);
  86186. /** @hidden */
  86187. easeInCore(gradient: number): number;
  86188. }
  86189. /**
  86190. * Easing function with a bouncing shape (see link below).
  86191. * @see https://easings.net/#easeInBounce
  86192. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86193. */
  86194. export class BounceEase extends EasingFunction implements IEasingFunction {
  86195. /** Defines the number of bounces */
  86196. bounces: number;
  86197. /** Defines the amplitude of the bounce */
  86198. bounciness: number;
  86199. /**
  86200. * Instantiates a bounce easing
  86201. * @see https://easings.net/#easeInBounce
  86202. * @param bounces Defines the number of bounces
  86203. * @param bounciness Defines the amplitude of the bounce
  86204. */
  86205. constructor(
  86206. /** Defines the number of bounces */
  86207. bounces?: number,
  86208. /** Defines the amplitude of the bounce */
  86209. bounciness?: number);
  86210. /** @hidden */
  86211. easeInCore(gradient: number): number;
  86212. }
  86213. /**
  86214. * Easing function with a power of 3 shape (see link below).
  86215. * @see https://easings.net/#easeInCubic
  86216. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86217. */
  86218. export class CubicEase extends EasingFunction implements IEasingFunction {
  86219. /** @hidden */
  86220. easeInCore(gradient: number): number;
  86221. }
  86222. /**
  86223. * Easing function with an elastic shape (see link below).
  86224. * @see https://easings.net/#easeInElastic
  86225. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86226. */
  86227. export class ElasticEase extends EasingFunction implements IEasingFunction {
  86228. /** Defines the number of oscillations*/
  86229. oscillations: number;
  86230. /** Defines the amplitude of the oscillations*/
  86231. springiness: number;
  86232. /**
  86233. * Instantiates an elastic easing function
  86234. * @see https://easings.net/#easeInElastic
  86235. * @param oscillations Defines the number of oscillations
  86236. * @param springiness Defines the amplitude of the oscillations
  86237. */
  86238. constructor(
  86239. /** Defines the number of oscillations*/
  86240. oscillations?: number,
  86241. /** Defines the amplitude of the oscillations*/
  86242. springiness?: number);
  86243. /** @hidden */
  86244. easeInCore(gradient: number): number;
  86245. }
  86246. /**
  86247. * Easing function with an exponential shape (see link below).
  86248. * @see https://easings.net/#easeInExpo
  86249. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86250. */
  86251. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  86252. /** Defines the exponent of the function */
  86253. exponent: number;
  86254. /**
  86255. * Instantiates an exponential easing function
  86256. * @see https://easings.net/#easeInExpo
  86257. * @param exponent Defines the exponent of the function
  86258. */
  86259. constructor(
  86260. /** Defines the exponent of the function */
  86261. exponent?: number);
  86262. /** @hidden */
  86263. easeInCore(gradient: number): number;
  86264. }
  86265. /**
  86266. * Easing function with a power shape (see link below).
  86267. * @see https://easings.net/#easeInQuad
  86268. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86269. */
  86270. export class PowerEase extends EasingFunction implements IEasingFunction {
  86271. /** Defines the power of the function */
  86272. power: number;
  86273. /**
  86274. * Instantiates an power base easing function
  86275. * @see https://easings.net/#easeInQuad
  86276. * @param power Defines the power of the function
  86277. */
  86278. constructor(
  86279. /** Defines the power of the function */
  86280. power?: number);
  86281. /** @hidden */
  86282. easeInCore(gradient: number): number;
  86283. }
  86284. /**
  86285. * Easing function with a power of 2 shape (see link below).
  86286. * @see https://easings.net/#easeInQuad
  86287. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86288. */
  86289. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  86290. /** @hidden */
  86291. easeInCore(gradient: number): number;
  86292. }
  86293. /**
  86294. * Easing function with a power of 4 shape (see link below).
  86295. * @see https://easings.net/#easeInQuart
  86296. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86297. */
  86298. export class QuarticEase extends EasingFunction implements IEasingFunction {
  86299. /** @hidden */
  86300. easeInCore(gradient: number): number;
  86301. }
  86302. /**
  86303. * Easing function with a power of 5 shape (see link below).
  86304. * @see https://easings.net/#easeInQuint
  86305. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86306. */
  86307. export class QuinticEase extends EasingFunction implements IEasingFunction {
  86308. /** @hidden */
  86309. easeInCore(gradient: number): number;
  86310. }
  86311. /**
  86312. * Easing function with a sin shape (see link below).
  86313. * @see https://easings.net/#easeInSine
  86314. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86315. */
  86316. export class SineEase extends EasingFunction implements IEasingFunction {
  86317. /** @hidden */
  86318. easeInCore(gradient: number): number;
  86319. }
  86320. /**
  86321. * Easing function with a bezier shape (see link below).
  86322. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86323. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86324. */
  86325. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  86326. /** Defines the x component of the start tangent in the bezier curve */
  86327. x1: number;
  86328. /** Defines the y component of the start tangent in the bezier curve */
  86329. y1: number;
  86330. /** Defines the x component of the end tangent in the bezier curve */
  86331. x2: number;
  86332. /** Defines the y component of the end tangent in the bezier curve */
  86333. y2: number;
  86334. /**
  86335. * Instantiates a bezier function
  86336. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86337. * @param x1 Defines the x component of the start tangent in the bezier curve
  86338. * @param y1 Defines the y component of the start tangent in the bezier curve
  86339. * @param x2 Defines the x component of the end tangent in the bezier curve
  86340. * @param y2 Defines the y component of the end tangent in the bezier curve
  86341. */
  86342. constructor(
  86343. /** Defines the x component of the start tangent in the bezier curve */
  86344. x1?: number,
  86345. /** Defines the y component of the start tangent in the bezier curve */
  86346. y1?: number,
  86347. /** Defines the x component of the end tangent in the bezier curve */
  86348. x2?: number,
  86349. /** Defines the y component of the end tangent in the bezier curve */
  86350. y2?: number);
  86351. /** @hidden */
  86352. easeInCore(gradient: number): number;
  86353. }
  86354. }
  86355. declare module BABYLON {
  86356. /**
  86357. * Class used to hold a RBG color
  86358. */
  86359. export class Color3 {
  86360. /**
  86361. * Defines the red component (between 0 and 1, default is 0)
  86362. */
  86363. r: number;
  86364. /**
  86365. * Defines the green component (between 0 and 1, default is 0)
  86366. */
  86367. g: number;
  86368. /**
  86369. * Defines the blue component (between 0 and 1, default is 0)
  86370. */
  86371. b: number;
  86372. /**
  86373. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  86374. * @param r defines the red component (between 0 and 1, default is 0)
  86375. * @param g defines the green component (between 0 and 1, default is 0)
  86376. * @param b defines the blue component (between 0 and 1, default is 0)
  86377. */
  86378. constructor(
  86379. /**
  86380. * Defines the red component (between 0 and 1, default is 0)
  86381. */
  86382. r?: number,
  86383. /**
  86384. * Defines the green component (between 0 and 1, default is 0)
  86385. */
  86386. g?: number,
  86387. /**
  86388. * Defines the blue component (between 0 and 1, default is 0)
  86389. */
  86390. b?: number);
  86391. /**
  86392. * Creates a string with the Color3 current values
  86393. * @returns the string representation of the Color3 object
  86394. */
  86395. toString(): string;
  86396. /**
  86397. * Returns the string "Color3"
  86398. * @returns "Color3"
  86399. */
  86400. getClassName(): string;
  86401. /**
  86402. * Compute the Color3 hash code
  86403. * @returns an unique number that can be used to hash Color3 objects
  86404. */
  86405. getHashCode(): number;
  86406. /**
  86407. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  86408. * @param array defines the array where to store the r,g,b components
  86409. * @param index defines an optional index in the target array to define where to start storing values
  86410. * @returns the current Color3 object
  86411. */
  86412. toArray(array: FloatArray, index?: number): Color3;
  86413. /**
  86414. * Update the current color with values stored in an array from the starting index of the given array
  86415. * @param array defines the source array
  86416. * @param offset defines an offset in the source array
  86417. * @returns the current Color3 object
  86418. */
  86419. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86420. /**
  86421. * Returns a new Color4 object from the current Color3 and the given alpha
  86422. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  86423. * @returns a new Color4 object
  86424. */
  86425. toColor4(alpha?: number): Color4;
  86426. /**
  86427. * Returns a new array populated with 3 numeric elements : red, green and blue values
  86428. * @returns the new array
  86429. */
  86430. asArray(): number[];
  86431. /**
  86432. * Returns the luminance value
  86433. * @returns a float value
  86434. */
  86435. toLuminance(): number;
  86436. /**
  86437. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  86438. * @param otherColor defines the second operand
  86439. * @returns the new Color3 object
  86440. */
  86441. multiply(otherColor: DeepImmutable<Color3>): Color3;
  86442. /**
  86443. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  86444. * @param otherColor defines the second operand
  86445. * @param result defines the Color3 object where to store the result
  86446. * @returns the current Color3
  86447. */
  86448. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86449. /**
  86450. * Determines equality between Color3 objects
  86451. * @param otherColor defines the second operand
  86452. * @returns true if the rgb values are equal to the given ones
  86453. */
  86454. equals(otherColor: DeepImmutable<Color3>): boolean;
  86455. /**
  86456. * Determines equality between the current Color3 object and a set of r,b,g values
  86457. * @param r defines the red component to check
  86458. * @param g defines the green component to check
  86459. * @param b defines the blue component to check
  86460. * @returns true if the rgb values are equal to the given ones
  86461. */
  86462. equalsFloats(r: number, g: number, b: number): boolean;
  86463. /**
  86464. * Multiplies in place each rgb value by scale
  86465. * @param scale defines the scaling factor
  86466. * @returns the updated Color3
  86467. */
  86468. scale(scale: number): Color3;
  86469. /**
  86470. * Multiplies the rgb values by scale and stores the result into "result"
  86471. * @param scale defines the scaling factor
  86472. * @param result defines the Color3 object where to store the result
  86473. * @returns the unmodified current Color3
  86474. */
  86475. scaleToRef(scale: number, result: Color3): Color3;
  86476. /**
  86477. * Scale the current Color3 values by a factor and add the result to a given Color3
  86478. * @param scale defines the scale factor
  86479. * @param result defines color to store the result into
  86480. * @returns the unmodified current Color3
  86481. */
  86482. scaleAndAddToRef(scale: number, result: Color3): Color3;
  86483. /**
  86484. * Clamps the rgb values by the min and max values and stores the result into "result"
  86485. * @param min defines minimum clamping value (default is 0)
  86486. * @param max defines maximum clamping value (default is 1)
  86487. * @param result defines color to store the result into
  86488. * @returns the original Color3
  86489. */
  86490. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  86491. /**
  86492. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  86493. * @param otherColor defines the second operand
  86494. * @returns the new Color3
  86495. */
  86496. add(otherColor: DeepImmutable<Color3>): Color3;
  86497. /**
  86498. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  86499. * @param otherColor defines the second operand
  86500. * @param result defines Color3 object to store the result into
  86501. * @returns the unmodified current Color3
  86502. */
  86503. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86504. /**
  86505. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  86506. * @param otherColor defines the second operand
  86507. * @returns the new Color3
  86508. */
  86509. subtract(otherColor: DeepImmutable<Color3>): Color3;
  86510. /**
  86511. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  86512. * @param otherColor defines the second operand
  86513. * @param result defines Color3 object to store the result into
  86514. * @returns the unmodified current Color3
  86515. */
  86516. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86517. /**
  86518. * Copy the current object
  86519. * @returns a new Color3 copied the current one
  86520. */
  86521. clone(): Color3;
  86522. /**
  86523. * Copies the rgb values from the source in the current Color3
  86524. * @param source defines the source Color3 object
  86525. * @returns the updated Color3 object
  86526. */
  86527. copyFrom(source: DeepImmutable<Color3>): Color3;
  86528. /**
  86529. * Updates the Color3 rgb values from the given floats
  86530. * @param r defines the red component to read from
  86531. * @param g defines the green component to read from
  86532. * @param b defines the blue component to read from
  86533. * @returns the current Color3 object
  86534. */
  86535. copyFromFloats(r: number, g: number, b: number): Color3;
  86536. /**
  86537. * Updates the Color3 rgb values from the given floats
  86538. * @param r defines the red component to read from
  86539. * @param g defines the green component to read from
  86540. * @param b defines the blue component to read from
  86541. * @returns the current Color3 object
  86542. */
  86543. set(r: number, g: number, b: number): Color3;
  86544. /**
  86545. * Compute the Color3 hexadecimal code as a string
  86546. * @returns a string containing the hexadecimal representation of the Color3 object
  86547. */
  86548. toHexString(): string;
  86549. /**
  86550. * Computes a new Color3 converted from the current one to linear space
  86551. * @returns a new Color3 object
  86552. */
  86553. toLinearSpace(): Color3;
  86554. /**
  86555. * Converts current color in rgb space to HSV values
  86556. * @returns a new color3 representing the HSV values
  86557. */
  86558. toHSV(): Color3;
  86559. /**
  86560. * Converts current color in rgb space to HSV values
  86561. * @param result defines the Color3 where to store the HSV values
  86562. */
  86563. toHSVToRef(result: Color3): void;
  86564. /**
  86565. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  86566. * @param convertedColor defines the Color3 object where to store the linear space version
  86567. * @returns the unmodified Color3
  86568. */
  86569. toLinearSpaceToRef(convertedColor: Color3): Color3;
  86570. /**
  86571. * Computes a new Color3 converted from the current one to gamma space
  86572. * @returns a new Color3 object
  86573. */
  86574. toGammaSpace(): Color3;
  86575. /**
  86576. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  86577. * @param convertedColor defines the Color3 object where to store the gamma space version
  86578. * @returns the unmodified Color3
  86579. */
  86580. toGammaSpaceToRef(convertedColor: Color3): Color3;
  86581. private static _BlackReadOnly;
  86582. /**
  86583. * Convert Hue, saturation and value to a Color3 (RGB)
  86584. * @param hue defines the hue
  86585. * @param saturation defines the saturation
  86586. * @param value defines the value
  86587. * @param result defines the Color3 where to store the RGB values
  86588. */
  86589. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  86590. /**
  86591. * Creates a new Color3 from the string containing valid hexadecimal values
  86592. * @param hex defines a string containing valid hexadecimal values
  86593. * @returns a new Color3 object
  86594. */
  86595. static FromHexString(hex: string): Color3;
  86596. /**
  86597. * Creates a new Color3 from the starting index of the given array
  86598. * @param array defines the source array
  86599. * @param offset defines an offset in the source array
  86600. * @returns a new Color3 object
  86601. */
  86602. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86603. /**
  86604. * Creates a new Color3 from the starting index element of the given array
  86605. * @param array defines the source array to read from
  86606. * @param offset defines the offset in the source array
  86607. * @param result defines the target Color3 object
  86608. */
  86609. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86610. /**
  86611. * Creates a new Color3 from integer values (< 256)
  86612. * @param r defines the red component to read from (value between 0 and 255)
  86613. * @param g defines the green component to read from (value between 0 and 255)
  86614. * @param b defines the blue component to read from (value between 0 and 255)
  86615. * @returns a new Color3 object
  86616. */
  86617. static FromInts(r: number, g: number, b: number): Color3;
  86618. /**
  86619. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86620. * @param start defines the start Color3 value
  86621. * @param end defines the end Color3 value
  86622. * @param amount defines the gradient value between start and end
  86623. * @returns a new Color3 object
  86624. */
  86625. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  86626. /**
  86627. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86628. * @param left defines the start value
  86629. * @param right defines the end value
  86630. * @param amount defines the gradient factor
  86631. * @param result defines the Color3 object where to store the result
  86632. */
  86633. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  86634. /**
  86635. * Returns a Color3 value containing a red color
  86636. * @returns a new Color3 object
  86637. */
  86638. static Red(): Color3;
  86639. /**
  86640. * Returns a Color3 value containing a green color
  86641. * @returns a new Color3 object
  86642. */
  86643. static Green(): Color3;
  86644. /**
  86645. * Returns a Color3 value containing a blue color
  86646. * @returns a new Color3 object
  86647. */
  86648. static Blue(): Color3;
  86649. /**
  86650. * Returns a Color3 value containing a black color
  86651. * @returns a new Color3 object
  86652. */
  86653. static Black(): Color3;
  86654. /**
  86655. * Gets a Color3 value containing a black color that must not be updated
  86656. */
  86657. static get BlackReadOnly(): DeepImmutable<Color3>;
  86658. /**
  86659. * Returns a Color3 value containing a white color
  86660. * @returns a new Color3 object
  86661. */
  86662. static White(): Color3;
  86663. /**
  86664. * Returns a Color3 value containing a purple color
  86665. * @returns a new Color3 object
  86666. */
  86667. static Purple(): Color3;
  86668. /**
  86669. * Returns a Color3 value containing a magenta color
  86670. * @returns a new Color3 object
  86671. */
  86672. static Magenta(): Color3;
  86673. /**
  86674. * Returns a Color3 value containing a yellow color
  86675. * @returns a new Color3 object
  86676. */
  86677. static Yellow(): Color3;
  86678. /**
  86679. * Returns a Color3 value containing a gray color
  86680. * @returns a new Color3 object
  86681. */
  86682. static Gray(): Color3;
  86683. /**
  86684. * Returns a Color3 value containing a teal color
  86685. * @returns a new Color3 object
  86686. */
  86687. static Teal(): Color3;
  86688. /**
  86689. * Returns a Color3 value containing a random color
  86690. * @returns a new Color3 object
  86691. */
  86692. static Random(): Color3;
  86693. }
  86694. /**
  86695. * Class used to hold a RBGA color
  86696. */
  86697. export class Color4 {
  86698. /**
  86699. * Defines the red component (between 0 and 1, default is 0)
  86700. */
  86701. r: number;
  86702. /**
  86703. * Defines the green component (between 0 and 1, default is 0)
  86704. */
  86705. g: number;
  86706. /**
  86707. * Defines the blue component (between 0 and 1, default is 0)
  86708. */
  86709. b: number;
  86710. /**
  86711. * Defines the alpha component (between 0 and 1, default is 1)
  86712. */
  86713. a: number;
  86714. /**
  86715. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  86716. * @param r defines the red component (between 0 and 1, default is 0)
  86717. * @param g defines the green component (between 0 and 1, default is 0)
  86718. * @param b defines the blue component (between 0 and 1, default is 0)
  86719. * @param a defines the alpha component (between 0 and 1, default is 1)
  86720. */
  86721. constructor(
  86722. /**
  86723. * Defines the red component (between 0 and 1, default is 0)
  86724. */
  86725. r?: number,
  86726. /**
  86727. * Defines the green component (between 0 and 1, default is 0)
  86728. */
  86729. g?: number,
  86730. /**
  86731. * Defines the blue component (between 0 and 1, default is 0)
  86732. */
  86733. b?: number,
  86734. /**
  86735. * Defines the alpha component (between 0 and 1, default is 1)
  86736. */
  86737. a?: number);
  86738. /**
  86739. * Adds in place the given Color4 values to the current Color4 object
  86740. * @param right defines the second operand
  86741. * @returns the current updated Color4 object
  86742. */
  86743. addInPlace(right: DeepImmutable<Color4>): Color4;
  86744. /**
  86745. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  86746. * @returns the new array
  86747. */
  86748. asArray(): number[];
  86749. /**
  86750. * Stores from the starting index in the given array the Color4 successive values
  86751. * @param array defines the array where to store the r,g,b components
  86752. * @param index defines an optional index in the target array to define where to start storing values
  86753. * @returns the current Color4 object
  86754. */
  86755. toArray(array: number[], index?: number): Color4;
  86756. /**
  86757. * Update the current color with values stored in an array from the starting index of the given array
  86758. * @param array defines the source array
  86759. * @param offset defines an offset in the source array
  86760. * @returns the current Color4 object
  86761. */
  86762. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86763. /**
  86764. * Determines equality between Color4 objects
  86765. * @param otherColor defines the second operand
  86766. * @returns true if the rgba values are equal to the given ones
  86767. */
  86768. equals(otherColor: DeepImmutable<Color4>): boolean;
  86769. /**
  86770. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  86771. * @param right defines the second operand
  86772. * @returns a new Color4 object
  86773. */
  86774. add(right: DeepImmutable<Color4>): Color4;
  86775. /**
  86776. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  86777. * @param right defines the second operand
  86778. * @returns a new Color4 object
  86779. */
  86780. subtract(right: DeepImmutable<Color4>): Color4;
  86781. /**
  86782. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  86783. * @param right defines the second operand
  86784. * @param result defines the Color4 object where to store the result
  86785. * @returns the current Color4 object
  86786. */
  86787. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  86788. /**
  86789. * Creates a new Color4 with the current Color4 values multiplied by scale
  86790. * @param scale defines the scaling factor to apply
  86791. * @returns a new Color4 object
  86792. */
  86793. scale(scale: number): Color4;
  86794. /**
  86795. * Multiplies the current Color4 values by scale and stores the result in "result"
  86796. * @param scale defines the scaling factor to apply
  86797. * @param result defines the Color4 object where to store the result
  86798. * @returns the current unmodified Color4
  86799. */
  86800. scaleToRef(scale: number, result: Color4): Color4;
  86801. /**
  86802. * Scale the current Color4 values by a factor and add the result to a given Color4
  86803. * @param scale defines the scale factor
  86804. * @param result defines the Color4 object where to store the result
  86805. * @returns the unmodified current Color4
  86806. */
  86807. scaleAndAddToRef(scale: number, result: Color4): Color4;
  86808. /**
  86809. * Clamps the rgb values by the min and max values and stores the result into "result"
  86810. * @param min defines minimum clamping value (default is 0)
  86811. * @param max defines maximum clamping value (default is 1)
  86812. * @param result defines color to store the result into.
  86813. * @returns the cuurent Color4
  86814. */
  86815. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  86816. /**
  86817. * Multipy an Color4 value by another and return a new Color4 object
  86818. * @param color defines the Color4 value to multiply by
  86819. * @returns a new Color4 object
  86820. */
  86821. multiply(color: Color4): Color4;
  86822. /**
  86823. * Multipy a Color4 value by another and push the result in a reference value
  86824. * @param color defines the Color4 value to multiply by
  86825. * @param result defines the Color4 to fill the result in
  86826. * @returns the result Color4
  86827. */
  86828. multiplyToRef(color: Color4, result: Color4): Color4;
  86829. /**
  86830. * Creates a string with the Color4 current values
  86831. * @returns the string representation of the Color4 object
  86832. */
  86833. toString(): string;
  86834. /**
  86835. * Returns the string "Color4"
  86836. * @returns "Color4"
  86837. */
  86838. getClassName(): string;
  86839. /**
  86840. * Compute the Color4 hash code
  86841. * @returns an unique number that can be used to hash Color4 objects
  86842. */
  86843. getHashCode(): number;
  86844. /**
  86845. * Creates a new Color4 copied from the current one
  86846. * @returns a new Color4 object
  86847. */
  86848. clone(): Color4;
  86849. /**
  86850. * Copies the given Color4 values into the current one
  86851. * @param source defines the source Color4 object
  86852. * @returns the current updated Color4 object
  86853. */
  86854. copyFrom(source: Color4): Color4;
  86855. /**
  86856. * Copies the given float values into the current one
  86857. * @param r defines the red component to read from
  86858. * @param g defines the green component to read from
  86859. * @param b defines the blue component to read from
  86860. * @param a defines the alpha component to read from
  86861. * @returns the current updated Color4 object
  86862. */
  86863. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  86864. /**
  86865. * Copies the given float values into the current one
  86866. * @param r defines the red component to read from
  86867. * @param g defines the green component to read from
  86868. * @param b defines the blue component to read from
  86869. * @param a defines the alpha component to read from
  86870. * @returns the current updated Color4 object
  86871. */
  86872. set(r: number, g: number, b: number, a: number): Color4;
  86873. /**
  86874. * Compute the Color4 hexadecimal code as a string
  86875. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  86876. * @returns a string containing the hexadecimal representation of the Color4 object
  86877. */
  86878. toHexString(returnAsColor3?: boolean): string;
  86879. /**
  86880. * Computes a new Color4 converted from the current one to linear space
  86881. * @returns a new Color4 object
  86882. */
  86883. toLinearSpace(): Color4;
  86884. /**
  86885. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  86886. * @param convertedColor defines the Color4 object where to store the linear space version
  86887. * @returns the unmodified Color4
  86888. */
  86889. toLinearSpaceToRef(convertedColor: Color4): Color4;
  86890. /**
  86891. * Computes a new Color4 converted from the current one to gamma space
  86892. * @returns a new Color4 object
  86893. */
  86894. toGammaSpace(): Color4;
  86895. /**
  86896. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  86897. * @param convertedColor defines the Color4 object where to store the gamma space version
  86898. * @returns the unmodified Color4
  86899. */
  86900. toGammaSpaceToRef(convertedColor: Color4): Color4;
  86901. /**
  86902. * Creates a new Color4 from the string containing valid hexadecimal values
  86903. * @param hex defines a string containing valid hexadecimal values
  86904. * @returns a new Color4 object
  86905. */
  86906. static FromHexString(hex: string): Color4;
  86907. /**
  86908. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86909. * @param left defines the start value
  86910. * @param right defines the end value
  86911. * @param amount defines the gradient factor
  86912. * @returns a new Color4 object
  86913. */
  86914. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  86915. /**
  86916. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86917. * @param left defines the start value
  86918. * @param right defines the end value
  86919. * @param amount defines the gradient factor
  86920. * @param result defines the Color4 object where to store data
  86921. */
  86922. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  86923. /**
  86924. * Creates a new Color4 from a Color3 and an alpha value
  86925. * @param color3 defines the source Color3 to read from
  86926. * @param alpha defines the alpha component (1.0 by default)
  86927. * @returns a new Color4 object
  86928. */
  86929. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  86930. /**
  86931. * Creates a new Color4 from the starting index element of the given array
  86932. * @param array defines the source array to read from
  86933. * @param offset defines the offset in the source array
  86934. * @returns a new Color4 object
  86935. */
  86936. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86937. /**
  86938. * Creates a new Color4 from the starting index element of the given array
  86939. * @param array defines the source array to read from
  86940. * @param offset defines the offset in the source array
  86941. * @param result defines the target Color4 object
  86942. */
  86943. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  86944. /**
  86945. * Creates a new Color3 from integer values (< 256)
  86946. * @param r defines the red component to read from (value between 0 and 255)
  86947. * @param g defines the green component to read from (value between 0 and 255)
  86948. * @param b defines the blue component to read from (value between 0 and 255)
  86949. * @param a defines the alpha component to read from (value between 0 and 255)
  86950. * @returns a new Color3 object
  86951. */
  86952. static FromInts(r: number, g: number, b: number, a: number): Color4;
  86953. /**
  86954. * Check the content of a given array and convert it to an array containing RGBA data
  86955. * If the original array was already containing count * 4 values then it is returned directly
  86956. * @param colors defines the array to check
  86957. * @param count defines the number of RGBA data to expect
  86958. * @returns an array containing count * 4 values (RGBA)
  86959. */
  86960. static CheckColors4(colors: number[], count: number): number[];
  86961. }
  86962. /**
  86963. * @hidden
  86964. */
  86965. export class TmpColors {
  86966. static Color3: Color3[];
  86967. static Color4: Color4[];
  86968. }
  86969. }
  86970. declare module BABYLON {
  86971. /**
  86972. * Defines an interface which represents an animation key frame
  86973. */
  86974. export interface IAnimationKey {
  86975. /**
  86976. * Frame of the key frame
  86977. */
  86978. frame: number;
  86979. /**
  86980. * Value at the specifies key frame
  86981. */
  86982. value: any;
  86983. /**
  86984. * The input tangent for the cubic hermite spline
  86985. */
  86986. inTangent?: any;
  86987. /**
  86988. * The output tangent for the cubic hermite spline
  86989. */
  86990. outTangent?: any;
  86991. /**
  86992. * The animation interpolation type
  86993. */
  86994. interpolation?: AnimationKeyInterpolation;
  86995. }
  86996. /**
  86997. * Enum for the animation key frame interpolation type
  86998. */
  86999. export enum AnimationKeyInterpolation {
  87000. /**
  87001. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  87002. */
  87003. STEP = 1
  87004. }
  87005. }
  87006. declare module BABYLON {
  87007. /**
  87008. * Represents the range of an animation
  87009. */
  87010. export class AnimationRange {
  87011. /**The name of the animation range**/
  87012. name: string;
  87013. /**The starting frame of the animation */
  87014. from: number;
  87015. /**The ending frame of the animation*/
  87016. to: number;
  87017. /**
  87018. * Initializes the range of an animation
  87019. * @param name The name of the animation range
  87020. * @param from The starting frame of the animation
  87021. * @param to The ending frame of the animation
  87022. */
  87023. constructor(
  87024. /**The name of the animation range**/
  87025. name: string,
  87026. /**The starting frame of the animation */
  87027. from: number,
  87028. /**The ending frame of the animation*/
  87029. to: number);
  87030. /**
  87031. * Makes a copy of the animation range
  87032. * @returns A copy of the animation range
  87033. */
  87034. clone(): AnimationRange;
  87035. }
  87036. }
  87037. declare module BABYLON {
  87038. /**
  87039. * Composed of a frame, and an action function
  87040. */
  87041. export class AnimationEvent {
  87042. /** The frame for which the event is triggered **/
  87043. frame: number;
  87044. /** The event to perform when triggered **/
  87045. action: (currentFrame: number) => void;
  87046. /** Specifies if the event should be triggered only once**/
  87047. onlyOnce?: boolean | undefined;
  87048. /**
  87049. * Specifies if the animation event is done
  87050. */
  87051. isDone: boolean;
  87052. /**
  87053. * Initializes the animation event
  87054. * @param frame The frame for which the event is triggered
  87055. * @param action The event to perform when triggered
  87056. * @param onlyOnce Specifies if the event should be triggered only once
  87057. */
  87058. constructor(
  87059. /** The frame for which the event is triggered **/
  87060. frame: number,
  87061. /** The event to perform when triggered **/
  87062. action: (currentFrame: number) => void,
  87063. /** Specifies if the event should be triggered only once**/
  87064. onlyOnce?: boolean | undefined);
  87065. /** @hidden */
  87066. _clone(): AnimationEvent;
  87067. }
  87068. }
  87069. declare module BABYLON {
  87070. /**
  87071. * Interface used to define a behavior
  87072. */
  87073. export interface Behavior<T> {
  87074. /** gets or sets behavior's name */
  87075. name: string;
  87076. /**
  87077. * Function called when the behavior needs to be initialized (after attaching it to a target)
  87078. */
  87079. init(): void;
  87080. /**
  87081. * Called when the behavior is attached to a target
  87082. * @param target defines the target where the behavior is attached to
  87083. */
  87084. attach(target: T): void;
  87085. /**
  87086. * Called when the behavior is detached from its target
  87087. */
  87088. detach(): void;
  87089. }
  87090. /**
  87091. * Interface implemented by classes supporting behaviors
  87092. */
  87093. export interface IBehaviorAware<T> {
  87094. /**
  87095. * Attach a behavior
  87096. * @param behavior defines the behavior to attach
  87097. * @returns the current host
  87098. */
  87099. addBehavior(behavior: Behavior<T>): T;
  87100. /**
  87101. * Remove a behavior from the current object
  87102. * @param behavior defines the behavior to detach
  87103. * @returns the current host
  87104. */
  87105. removeBehavior(behavior: Behavior<T>): T;
  87106. /**
  87107. * Gets a behavior using its name to search
  87108. * @param name defines the name to search
  87109. * @returns the behavior or null if not found
  87110. */
  87111. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  87112. }
  87113. }
  87114. declare module BABYLON {
  87115. /**
  87116. * Defines an array and its length.
  87117. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  87118. */
  87119. export interface ISmartArrayLike<T> {
  87120. /**
  87121. * The data of the array.
  87122. */
  87123. data: Array<T>;
  87124. /**
  87125. * The active length of the array.
  87126. */
  87127. length: number;
  87128. }
  87129. /**
  87130. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87131. */
  87132. export class SmartArray<T> implements ISmartArrayLike<T> {
  87133. /**
  87134. * The full set of data from the array.
  87135. */
  87136. data: Array<T>;
  87137. /**
  87138. * The active length of the array.
  87139. */
  87140. length: number;
  87141. protected _id: number;
  87142. /**
  87143. * Instantiates a Smart Array.
  87144. * @param capacity defines the default capacity of the array.
  87145. */
  87146. constructor(capacity: number);
  87147. /**
  87148. * Pushes a value at the end of the active data.
  87149. * @param value defines the object to push in the array.
  87150. */
  87151. push(value: T): void;
  87152. /**
  87153. * Iterates over the active data and apply the lambda to them.
  87154. * @param func defines the action to apply on each value.
  87155. */
  87156. forEach(func: (content: T) => void): void;
  87157. /**
  87158. * Sorts the full sets of data.
  87159. * @param compareFn defines the comparison function to apply.
  87160. */
  87161. sort(compareFn: (a: T, b: T) => number): void;
  87162. /**
  87163. * Resets the active data to an empty array.
  87164. */
  87165. reset(): void;
  87166. /**
  87167. * Releases all the data from the array as well as the array.
  87168. */
  87169. dispose(): void;
  87170. /**
  87171. * Concats the active data with a given array.
  87172. * @param array defines the data to concatenate with.
  87173. */
  87174. concat(array: any): void;
  87175. /**
  87176. * Returns the position of a value in the active data.
  87177. * @param value defines the value to find the index for
  87178. * @returns the index if found in the active data otherwise -1
  87179. */
  87180. indexOf(value: T): number;
  87181. /**
  87182. * Returns whether an element is part of the active data.
  87183. * @param value defines the value to look for
  87184. * @returns true if found in the active data otherwise false
  87185. */
  87186. contains(value: T): boolean;
  87187. private static _GlobalId;
  87188. }
  87189. /**
  87190. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87191. * The data in this array can only be present once
  87192. */
  87193. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  87194. private _duplicateId;
  87195. /**
  87196. * Pushes a value at the end of the active data.
  87197. * THIS DOES NOT PREVENT DUPPLICATE DATA
  87198. * @param value defines the object to push in the array.
  87199. */
  87200. push(value: T): void;
  87201. /**
  87202. * Pushes a value at the end of the active data.
  87203. * If the data is already present, it won t be added again
  87204. * @param value defines the object to push in the array.
  87205. * @returns true if added false if it was already present
  87206. */
  87207. pushNoDuplicate(value: T): boolean;
  87208. /**
  87209. * Resets the active data to an empty array.
  87210. */
  87211. reset(): void;
  87212. /**
  87213. * Concats the active data with a given array.
  87214. * This ensures no dupplicate will be present in the result.
  87215. * @param array defines the data to concatenate with.
  87216. */
  87217. concatWithNoDuplicate(array: any): void;
  87218. }
  87219. }
  87220. declare module BABYLON {
  87221. /**
  87222. * @ignore
  87223. * This is a list of all the different input types that are available in the application.
  87224. * Fo instance: ArcRotateCameraGamepadInput...
  87225. */
  87226. export var CameraInputTypes: {};
  87227. /**
  87228. * This is the contract to implement in order to create a new input class.
  87229. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  87230. */
  87231. export interface ICameraInput<TCamera extends Camera> {
  87232. /**
  87233. * Defines the camera the input is attached to.
  87234. */
  87235. camera: Nullable<TCamera>;
  87236. /**
  87237. * Gets the class name of the current intput.
  87238. * @returns the class name
  87239. */
  87240. getClassName(): string;
  87241. /**
  87242. * Get the friendly name associated with the input class.
  87243. * @returns the input friendly name
  87244. */
  87245. getSimpleName(): string;
  87246. /**
  87247. * Attach the input controls to a specific dom element to get the input from.
  87248. * @param element Defines the element the controls should be listened from
  87249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87250. */
  87251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87252. /**
  87253. * Detach the current controls from the specified dom element.
  87254. * @param element Defines the element to stop listening the inputs from
  87255. */
  87256. detachControl(element: Nullable<HTMLElement>): void;
  87257. /**
  87258. * Update the current camera state depending on the inputs that have been used this frame.
  87259. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87260. */
  87261. checkInputs?: () => void;
  87262. }
  87263. /**
  87264. * Represents a map of input types to input instance or input index to input instance.
  87265. */
  87266. export interface CameraInputsMap<TCamera extends Camera> {
  87267. /**
  87268. * Accessor to the input by input type.
  87269. */
  87270. [name: string]: ICameraInput<TCamera>;
  87271. /**
  87272. * Accessor to the input by input index.
  87273. */
  87274. [idx: number]: ICameraInput<TCamera>;
  87275. }
  87276. /**
  87277. * This represents the input manager used within a camera.
  87278. * It helps dealing with all the different kind of input attached to a camera.
  87279. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87280. */
  87281. export class CameraInputsManager<TCamera extends Camera> {
  87282. /**
  87283. * Defines the list of inputs attahed to the camera.
  87284. */
  87285. attached: CameraInputsMap<TCamera>;
  87286. /**
  87287. * Defines the dom element the camera is collecting inputs from.
  87288. * This is null if the controls have not been attached.
  87289. */
  87290. attachedElement: Nullable<HTMLElement>;
  87291. /**
  87292. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87293. */
  87294. noPreventDefault: boolean;
  87295. /**
  87296. * Defined the camera the input manager belongs to.
  87297. */
  87298. camera: TCamera;
  87299. /**
  87300. * Update the current camera state depending on the inputs that have been used this frame.
  87301. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87302. */
  87303. checkInputs: () => void;
  87304. /**
  87305. * Instantiate a new Camera Input Manager.
  87306. * @param camera Defines the camera the input manager blongs to
  87307. */
  87308. constructor(camera: TCamera);
  87309. /**
  87310. * Add an input method to a camera
  87311. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87312. * @param input camera input method
  87313. */
  87314. add(input: ICameraInput<TCamera>): void;
  87315. /**
  87316. * Remove a specific input method from a camera
  87317. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  87318. * @param inputToRemove camera input method
  87319. */
  87320. remove(inputToRemove: ICameraInput<TCamera>): void;
  87321. /**
  87322. * Remove a specific input type from a camera
  87323. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  87324. * @param inputType the type of the input to remove
  87325. */
  87326. removeByType(inputType: string): void;
  87327. private _addCheckInputs;
  87328. /**
  87329. * Attach the input controls to the currently attached dom element to listen the events from.
  87330. * @param input Defines the input to attach
  87331. */
  87332. attachInput(input: ICameraInput<TCamera>): void;
  87333. /**
  87334. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  87335. * @param element Defines the dom element to collect the events from
  87336. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87337. */
  87338. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  87339. /**
  87340. * Detach the current manager inputs controls from a specific dom element.
  87341. * @param element Defines the dom element to collect the events from
  87342. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  87343. */
  87344. detachElement(element: HTMLElement, disconnect?: boolean): void;
  87345. /**
  87346. * Rebuild the dynamic inputCheck function from the current list of
  87347. * defined inputs in the manager.
  87348. */
  87349. rebuildInputCheck(): void;
  87350. /**
  87351. * Remove all attached input methods from a camera
  87352. */
  87353. clear(): void;
  87354. /**
  87355. * Serialize the current input manager attached to a camera.
  87356. * This ensures than once parsed,
  87357. * the input associated to the camera will be identical to the current ones
  87358. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  87359. */
  87360. serialize(serializedCamera: any): void;
  87361. /**
  87362. * Parses an input manager serialized JSON to restore the previous list of inputs
  87363. * and states associated to a camera.
  87364. * @param parsedCamera Defines the JSON to parse
  87365. */
  87366. parse(parsedCamera: any): void;
  87367. }
  87368. }
  87369. declare module BABYLON {
  87370. /**
  87371. * Class used to store data that will be store in GPU memory
  87372. */
  87373. export class Buffer {
  87374. private _engine;
  87375. private _buffer;
  87376. /** @hidden */
  87377. _data: Nullable<DataArray>;
  87378. private _updatable;
  87379. private _instanced;
  87380. private _divisor;
  87381. /**
  87382. * Gets the byte stride.
  87383. */
  87384. readonly byteStride: number;
  87385. /**
  87386. * Constructor
  87387. * @param engine the engine
  87388. * @param data the data to use for this buffer
  87389. * @param updatable whether the data is updatable
  87390. * @param stride the stride (optional)
  87391. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87392. * @param instanced whether the buffer is instanced (optional)
  87393. * @param useBytes set to true if the stride in in bytes (optional)
  87394. * @param divisor sets an optional divisor for instances (1 by default)
  87395. */
  87396. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  87397. /**
  87398. * Create a new VertexBuffer based on the current buffer
  87399. * @param kind defines the vertex buffer kind (position, normal, etc.)
  87400. * @param offset defines offset in the buffer (0 by default)
  87401. * @param size defines the size in floats of attributes (position is 3 for instance)
  87402. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  87403. * @param instanced defines if the vertex buffer contains indexed data
  87404. * @param useBytes defines if the offset and stride are in bytes *
  87405. * @param divisor sets an optional divisor for instances (1 by default)
  87406. * @returns the new vertex buffer
  87407. */
  87408. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  87409. /**
  87410. * Gets a boolean indicating if the Buffer is updatable?
  87411. * @returns true if the buffer is updatable
  87412. */
  87413. isUpdatable(): boolean;
  87414. /**
  87415. * Gets current buffer's data
  87416. * @returns a DataArray or null
  87417. */
  87418. getData(): Nullable<DataArray>;
  87419. /**
  87420. * Gets underlying native buffer
  87421. * @returns underlying native buffer
  87422. */
  87423. getBuffer(): Nullable<DataBuffer>;
  87424. /**
  87425. * Gets the stride in float32 units (i.e. byte stride / 4).
  87426. * May not be an integer if the byte stride is not divisible by 4.
  87427. * @returns the stride in float32 units
  87428. * @deprecated Please use byteStride instead.
  87429. */
  87430. getStrideSize(): number;
  87431. /**
  87432. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87433. * @param data defines the data to store
  87434. */
  87435. create(data?: Nullable<DataArray>): void;
  87436. /** @hidden */
  87437. _rebuild(): void;
  87438. /**
  87439. * Update current buffer data
  87440. * @param data defines the data to store
  87441. */
  87442. update(data: DataArray): void;
  87443. /**
  87444. * Updates the data directly.
  87445. * @param data the new data
  87446. * @param offset the new offset
  87447. * @param vertexCount the vertex count (optional)
  87448. * @param useBytes set to true if the offset is in bytes
  87449. */
  87450. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  87451. /**
  87452. * Release all resources
  87453. */
  87454. dispose(): void;
  87455. }
  87456. /**
  87457. * Specialized buffer used to store vertex data
  87458. */
  87459. export class VertexBuffer {
  87460. /** @hidden */
  87461. _buffer: Buffer;
  87462. private _kind;
  87463. private _size;
  87464. private _ownsBuffer;
  87465. private _instanced;
  87466. private _instanceDivisor;
  87467. /**
  87468. * The byte type.
  87469. */
  87470. static readonly BYTE: number;
  87471. /**
  87472. * The unsigned byte type.
  87473. */
  87474. static readonly UNSIGNED_BYTE: number;
  87475. /**
  87476. * The short type.
  87477. */
  87478. static readonly SHORT: number;
  87479. /**
  87480. * The unsigned short type.
  87481. */
  87482. static readonly UNSIGNED_SHORT: number;
  87483. /**
  87484. * The integer type.
  87485. */
  87486. static readonly INT: number;
  87487. /**
  87488. * The unsigned integer type.
  87489. */
  87490. static readonly UNSIGNED_INT: number;
  87491. /**
  87492. * The float type.
  87493. */
  87494. static readonly FLOAT: number;
  87495. /**
  87496. * Gets or sets the instance divisor when in instanced mode
  87497. */
  87498. get instanceDivisor(): number;
  87499. set instanceDivisor(value: number);
  87500. /**
  87501. * Gets the byte stride.
  87502. */
  87503. readonly byteStride: number;
  87504. /**
  87505. * Gets the byte offset.
  87506. */
  87507. readonly byteOffset: number;
  87508. /**
  87509. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  87510. */
  87511. readonly normalized: boolean;
  87512. /**
  87513. * Gets the data type of each component in the array.
  87514. */
  87515. readonly type: number;
  87516. /**
  87517. * Constructor
  87518. * @param engine the engine
  87519. * @param data the data to use for this vertex buffer
  87520. * @param kind the vertex buffer kind
  87521. * @param updatable whether the data is updatable
  87522. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87523. * @param stride the stride (optional)
  87524. * @param instanced whether the buffer is instanced (optional)
  87525. * @param offset the offset of the data (optional)
  87526. * @param size the number of components (optional)
  87527. * @param type the type of the component (optional)
  87528. * @param normalized whether the data contains normalized data (optional)
  87529. * @param useBytes set to true if stride and offset are in bytes (optional)
  87530. * @param divisor defines the instance divisor to use (1 by default)
  87531. */
  87532. 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);
  87533. /** @hidden */
  87534. _rebuild(): void;
  87535. /**
  87536. * Returns the kind of the VertexBuffer (string)
  87537. * @returns a string
  87538. */
  87539. getKind(): string;
  87540. /**
  87541. * Gets a boolean indicating if the VertexBuffer is updatable?
  87542. * @returns true if the buffer is updatable
  87543. */
  87544. isUpdatable(): boolean;
  87545. /**
  87546. * Gets current buffer's data
  87547. * @returns a DataArray or null
  87548. */
  87549. getData(): Nullable<DataArray>;
  87550. /**
  87551. * Gets underlying native buffer
  87552. * @returns underlying native buffer
  87553. */
  87554. getBuffer(): Nullable<DataBuffer>;
  87555. /**
  87556. * Gets the stride in float32 units (i.e. byte stride / 4).
  87557. * May not be an integer if the byte stride is not divisible by 4.
  87558. * @returns the stride in float32 units
  87559. * @deprecated Please use byteStride instead.
  87560. */
  87561. getStrideSize(): number;
  87562. /**
  87563. * Returns the offset as a multiple of the type byte length.
  87564. * @returns the offset in bytes
  87565. * @deprecated Please use byteOffset instead.
  87566. */
  87567. getOffset(): number;
  87568. /**
  87569. * Returns the number of components per vertex attribute (integer)
  87570. * @returns the size in float
  87571. */
  87572. getSize(): number;
  87573. /**
  87574. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  87575. * @returns true if this buffer is instanced
  87576. */
  87577. getIsInstanced(): boolean;
  87578. /**
  87579. * Returns the instancing divisor, zero for non-instanced (integer).
  87580. * @returns a number
  87581. */
  87582. getInstanceDivisor(): number;
  87583. /**
  87584. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87585. * @param data defines the data to store
  87586. */
  87587. create(data?: DataArray): void;
  87588. /**
  87589. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  87590. * This function will create a new buffer if the current one is not updatable
  87591. * @param data defines the data to store
  87592. */
  87593. update(data: DataArray): void;
  87594. /**
  87595. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  87596. * Returns the directly updated WebGLBuffer.
  87597. * @param data the new data
  87598. * @param offset the new offset
  87599. * @param useBytes set to true if the offset is in bytes
  87600. */
  87601. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  87602. /**
  87603. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  87604. */
  87605. dispose(): void;
  87606. /**
  87607. * Enumerates each value of this vertex buffer as numbers.
  87608. * @param count the number of values to enumerate
  87609. * @param callback the callback function called for each value
  87610. */
  87611. forEach(count: number, callback: (value: number, index: number) => void): void;
  87612. /**
  87613. * Positions
  87614. */
  87615. static readonly PositionKind: string;
  87616. /**
  87617. * Normals
  87618. */
  87619. static readonly NormalKind: string;
  87620. /**
  87621. * Tangents
  87622. */
  87623. static readonly TangentKind: string;
  87624. /**
  87625. * Texture coordinates
  87626. */
  87627. static readonly UVKind: string;
  87628. /**
  87629. * Texture coordinates 2
  87630. */
  87631. static readonly UV2Kind: string;
  87632. /**
  87633. * Texture coordinates 3
  87634. */
  87635. static readonly UV3Kind: string;
  87636. /**
  87637. * Texture coordinates 4
  87638. */
  87639. static readonly UV4Kind: string;
  87640. /**
  87641. * Texture coordinates 5
  87642. */
  87643. static readonly UV5Kind: string;
  87644. /**
  87645. * Texture coordinates 6
  87646. */
  87647. static readonly UV6Kind: string;
  87648. /**
  87649. * Colors
  87650. */
  87651. static readonly ColorKind: string;
  87652. /**
  87653. * Matrix indices (for bones)
  87654. */
  87655. static readonly MatricesIndicesKind: string;
  87656. /**
  87657. * Matrix weights (for bones)
  87658. */
  87659. static readonly MatricesWeightsKind: string;
  87660. /**
  87661. * Additional matrix indices (for bones)
  87662. */
  87663. static readonly MatricesIndicesExtraKind: string;
  87664. /**
  87665. * Additional matrix weights (for bones)
  87666. */
  87667. static readonly MatricesWeightsExtraKind: string;
  87668. /**
  87669. * Deduces the stride given a kind.
  87670. * @param kind The kind string to deduce
  87671. * @returns The deduced stride
  87672. */
  87673. static DeduceStride(kind: string): number;
  87674. /**
  87675. * Gets the byte length of the given type.
  87676. * @param type the type
  87677. * @returns the number of bytes
  87678. */
  87679. static GetTypeByteLength(type: number): number;
  87680. /**
  87681. * Enumerates each value of the given parameters as numbers.
  87682. * @param data the data to enumerate
  87683. * @param byteOffset the byte offset of the data
  87684. * @param byteStride the byte stride of the data
  87685. * @param componentCount the number of components per element
  87686. * @param componentType the type of the component
  87687. * @param count the number of values to enumerate
  87688. * @param normalized whether the data is normalized
  87689. * @param callback the callback function called for each value
  87690. */
  87691. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  87692. private static _GetFloatValue;
  87693. }
  87694. }
  87695. declare module BABYLON {
  87696. /**
  87697. * The options Interface for creating a Capsule Mesh
  87698. */
  87699. export interface ICreateCapsuleOptions {
  87700. /** The Orientation of the capsule. Default : Vector3.Up() */
  87701. orientation?: Vector3;
  87702. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  87703. subdivisions: number;
  87704. /** Number of cylindrical segments on the capsule. */
  87705. tessellation: number;
  87706. /** Height or Length of the capsule. */
  87707. height: number;
  87708. /** Radius of the capsule. */
  87709. radius: number;
  87710. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  87711. capSubdivisions: number;
  87712. /** Overwrite for the top radius. */
  87713. radiusTop?: number;
  87714. /** Overwrite for the bottom radius. */
  87715. radiusBottom?: number;
  87716. /** Overwrite for the top capSubdivisions. */
  87717. topCapSubdivisions?: number;
  87718. /** Overwrite for the bottom capSubdivisions. */
  87719. bottomCapSubdivisions?: number;
  87720. }
  87721. /**
  87722. * Class containing static functions to help procedurally build meshes
  87723. */
  87724. export class CapsuleBuilder {
  87725. /**
  87726. * Creates a capsule or a pill mesh
  87727. * @param name defines the name of the mesh
  87728. * @param options The constructors options.
  87729. * @param scene The scene the mesh is scoped to.
  87730. * @returns Capsule Mesh
  87731. */
  87732. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  87733. }
  87734. }
  87735. declare module BABYLON {
  87736. /**
  87737. * @hidden
  87738. */
  87739. export class IntersectionInfo {
  87740. bu: Nullable<number>;
  87741. bv: Nullable<number>;
  87742. distance: number;
  87743. faceId: number;
  87744. subMeshId: number;
  87745. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  87746. }
  87747. }
  87748. declare module BABYLON {
  87749. /**
  87750. * Class used to store bounding sphere information
  87751. */
  87752. export class BoundingSphere {
  87753. /**
  87754. * Gets the center of the bounding sphere in local space
  87755. */
  87756. readonly center: Vector3;
  87757. /**
  87758. * Radius of the bounding sphere in local space
  87759. */
  87760. radius: number;
  87761. /**
  87762. * Gets the center of the bounding sphere in world space
  87763. */
  87764. readonly centerWorld: Vector3;
  87765. /**
  87766. * Radius of the bounding sphere in world space
  87767. */
  87768. radiusWorld: number;
  87769. /**
  87770. * Gets the minimum vector in local space
  87771. */
  87772. readonly minimum: Vector3;
  87773. /**
  87774. * Gets the maximum vector in local space
  87775. */
  87776. readonly maximum: Vector3;
  87777. private _worldMatrix;
  87778. private static readonly TmpVector3;
  87779. /**
  87780. * Creates a new bounding sphere
  87781. * @param min defines the minimum vector (in local space)
  87782. * @param max defines the maximum vector (in local space)
  87783. * @param worldMatrix defines the new world matrix
  87784. */
  87785. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87786. /**
  87787. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  87788. * @param min defines the new minimum vector (in local space)
  87789. * @param max defines the new maximum vector (in local space)
  87790. * @param worldMatrix defines the new world matrix
  87791. */
  87792. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87793. /**
  87794. * Scale the current bounding sphere by applying a scale factor
  87795. * @param factor defines the scale factor to apply
  87796. * @returns the current bounding box
  87797. */
  87798. scale(factor: number): BoundingSphere;
  87799. /**
  87800. * Gets the world matrix of the bounding box
  87801. * @returns a matrix
  87802. */
  87803. getWorldMatrix(): DeepImmutable<Matrix>;
  87804. /** @hidden */
  87805. _update(worldMatrix: DeepImmutable<Matrix>): void;
  87806. /**
  87807. * Tests if the bounding sphere is intersecting the frustum planes
  87808. * @param frustumPlanes defines the frustum planes to test
  87809. * @returns true if there is an intersection
  87810. */
  87811. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87812. /**
  87813. * Tests if the bounding sphere center is in between the frustum planes.
  87814. * Used for optimistic fast inclusion.
  87815. * @param frustumPlanes defines the frustum planes to test
  87816. * @returns true if the sphere center is in between the frustum planes
  87817. */
  87818. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87819. /**
  87820. * Tests if a point is inside the bounding sphere
  87821. * @param point defines the point to test
  87822. * @returns true if the point is inside the bounding sphere
  87823. */
  87824. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87825. /**
  87826. * Checks if two sphere intersct
  87827. * @param sphere0 sphere 0
  87828. * @param sphere1 sphere 1
  87829. * @returns true if the speres intersect
  87830. */
  87831. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  87832. }
  87833. }
  87834. declare module BABYLON {
  87835. /**
  87836. * Class used to store bounding box information
  87837. */
  87838. export class BoundingBox implements ICullable {
  87839. /**
  87840. * Gets the 8 vectors representing the bounding box in local space
  87841. */
  87842. readonly vectors: Vector3[];
  87843. /**
  87844. * Gets the center of the bounding box in local space
  87845. */
  87846. readonly center: Vector3;
  87847. /**
  87848. * Gets the center of the bounding box in world space
  87849. */
  87850. readonly centerWorld: Vector3;
  87851. /**
  87852. * Gets the extend size in local space
  87853. */
  87854. readonly extendSize: Vector3;
  87855. /**
  87856. * Gets the extend size in world space
  87857. */
  87858. readonly extendSizeWorld: Vector3;
  87859. /**
  87860. * Gets the OBB (object bounding box) directions
  87861. */
  87862. readonly directions: Vector3[];
  87863. /**
  87864. * Gets the 8 vectors representing the bounding box in world space
  87865. */
  87866. readonly vectorsWorld: Vector3[];
  87867. /**
  87868. * Gets the minimum vector in world space
  87869. */
  87870. readonly minimumWorld: Vector3;
  87871. /**
  87872. * Gets the maximum vector in world space
  87873. */
  87874. readonly maximumWorld: Vector3;
  87875. /**
  87876. * Gets the minimum vector in local space
  87877. */
  87878. readonly minimum: Vector3;
  87879. /**
  87880. * Gets the maximum vector in local space
  87881. */
  87882. readonly maximum: Vector3;
  87883. private _worldMatrix;
  87884. private static readonly TmpVector3;
  87885. /**
  87886. * @hidden
  87887. */
  87888. _tag: number;
  87889. /**
  87890. * Creates a new bounding box
  87891. * @param min defines the minimum vector (in local space)
  87892. * @param max defines the maximum vector (in local space)
  87893. * @param worldMatrix defines the new world matrix
  87894. */
  87895. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87896. /**
  87897. * Recreates the entire bounding box from scratch as if we call the constructor in place
  87898. * @param min defines the new minimum vector (in local space)
  87899. * @param max defines the new maximum vector (in local space)
  87900. * @param worldMatrix defines the new world matrix
  87901. */
  87902. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87903. /**
  87904. * Scale the current bounding box by applying a scale factor
  87905. * @param factor defines the scale factor to apply
  87906. * @returns the current bounding box
  87907. */
  87908. scale(factor: number): BoundingBox;
  87909. /**
  87910. * Gets the world matrix of the bounding box
  87911. * @returns a matrix
  87912. */
  87913. getWorldMatrix(): DeepImmutable<Matrix>;
  87914. /** @hidden */
  87915. _update(world: DeepImmutable<Matrix>): void;
  87916. /**
  87917. * Tests if the bounding box is intersecting the frustum planes
  87918. * @param frustumPlanes defines the frustum planes to test
  87919. * @returns true if there is an intersection
  87920. */
  87921. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87922. /**
  87923. * Tests if the bounding box is entirely inside the frustum planes
  87924. * @param frustumPlanes defines the frustum planes to test
  87925. * @returns true if there is an inclusion
  87926. */
  87927. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87928. /**
  87929. * Tests if a point is inside the bounding box
  87930. * @param point defines the point to test
  87931. * @returns true if the point is inside the bounding box
  87932. */
  87933. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87934. /**
  87935. * Tests if the bounding box intersects with a bounding sphere
  87936. * @param sphere defines the sphere to test
  87937. * @returns true if there is an intersection
  87938. */
  87939. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  87940. /**
  87941. * Tests if the bounding box intersects with a box defined by a min and max vectors
  87942. * @param min defines the min vector to use
  87943. * @param max defines the max vector to use
  87944. * @returns true if there is an intersection
  87945. */
  87946. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  87947. /**
  87948. * Tests if two bounding boxes are intersections
  87949. * @param box0 defines the first box to test
  87950. * @param box1 defines the second box to test
  87951. * @returns true if there is an intersection
  87952. */
  87953. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  87954. /**
  87955. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  87956. * @param minPoint defines the minimum vector of the bounding box
  87957. * @param maxPoint defines the maximum vector of the bounding box
  87958. * @param sphereCenter defines the sphere center
  87959. * @param sphereRadius defines the sphere radius
  87960. * @returns true if there is an intersection
  87961. */
  87962. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  87963. /**
  87964. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  87965. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87966. * @param frustumPlanes defines the frustum planes to test
  87967. * @return true if there is an inclusion
  87968. */
  87969. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87970. /**
  87971. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  87972. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87973. * @param frustumPlanes defines the frustum planes to test
  87974. * @return true if there is an intersection
  87975. */
  87976. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87977. }
  87978. }
  87979. declare module BABYLON {
  87980. /** @hidden */
  87981. export class Collider {
  87982. /** Define if a collision was found */
  87983. collisionFound: boolean;
  87984. /**
  87985. * Define last intersection point in local space
  87986. */
  87987. intersectionPoint: Vector3;
  87988. /**
  87989. * Define last collided mesh
  87990. */
  87991. collidedMesh: Nullable<AbstractMesh>;
  87992. private _collisionPoint;
  87993. private _planeIntersectionPoint;
  87994. private _tempVector;
  87995. private _tempVector2;
  87996. private _tempVector3;
  87997. private _tempVector4;
  87998. private _edge;
  87999. private _baseToVertex;
  88000. private _destinationPoint;
  88001. private _slidePlaneNormal;
  88002. private _displacementVector;
  88003. /** @hidden */
  88004. _radius: Vector3;
  88005. /** @hidden */
  88006. _retry: number;
  88007. private _velocity;
  88008. private _basePoint;
  88009. private _epsilon;
  88010. /** @hidden */
  88011. _velocityWorldLength: number;
  88012. /** @hidden */
  88013. _basePointWorld: Vector3;
  88014. private _velocityWorld;
  88015. private _normalizedVelocity;
  88016. /** @hidden */
  88017. _initialVelocity: Vector3;
  88018. /** @hidden */
  88019. _initialPosition: Vector3;
  88020. private _nearestDistance;
  88021. private _collisionMask;
  88022. get collisionMask(): number;
  88023. set collisionMask(mask: number);
  88024. /**
  88025. * Gets the plane normal used to compute the sliding response (in local space)
  88026. */
  88027. get slidePlaneNormal(): Vector3;
  88028. /** @hidden */
  88029. _initialize(source: Vector3, dir: Vector3, e: number): void;
  88030. /** @hidden */
  88031. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  88032. /** @hidden */
  88033. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  88034. /** @hidden */
  88035. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88036. /** @hidden */
  88037. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88038. /** @hidden */
  88039. _getResponse(pos: Vector3, vel: Vector3): void;
  88040. }
  88041. }
  88042. declare module BABYLON {
  88043. /**
  88044. * Interface for cullable objects
  88045. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  88046. */
  88047. export interface ICullable {
  88048. /**
  88049. * Checks if the object or part of the object is in the frustum
  88050. * @param frustumPlanes Camera near/planes
  88051. * @returns true if the object is in frustum otherwise false
  88052. */
  88053. isInFrustum(frustumPlanes: Plane[]): boolean;
  88054. /**
  88055. * Checks if a cullable object (mesh...) is in the camera frustum
  88056. * Unlike isInFrustum this cheks the full bounding box
  88057. * @param frustumPlanes Camera near/planes
  88058. * @returns true if the object is in frustum otherwise false
  88059. */
  88060. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88061. }
  88062. /**
  88063. * Info for a bounding data of a mesh
  88064. */
  88065. export class BoundingInfo implements ICullable {
  88066. /**
  88067. * Bounding box for the mesh
  88068. */
  88069. readonly boundingBox: BoundingBox;
  88070. /**
  88071. * Bounding sphere for the mesh
  88072. */
  88073. readonly boundingSphere: BoundingSphere;
  88074. private _isLocked;
  88075. private static readonly TmpVector3;
  88076. /**
  88077. * Constructs bounding info
  88078. * @param minimum min vector of the bounding box/sphere
  88079. * @param maximum max vector of the bounding box/sphere
  88080. * @param worldMatrix defines the new world matrix
  88081. */
  88082. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88083. /**
  88084. * Recreates the entire bounding info from scratch as if we call the constructor in place
  88085. * @param min defines the new minimum vector (in local space)
  88086. * @param max defines the new maximum vector (in local space)
  88087. * @param worldMatrix defines the new world matrix
  88088. */
  88089. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88090. /**
  88091. * min vector of the bounding box/sphere
  88092. */
  88093. get minimum(): Vector3;
  88094. /**
  88095. * max vector of the bounding box/sphere
  88096. */
  88097. get maximum(): Vector3;
  88098. /**
  88099. * If the info is locked and won't be updated to avoid perf overhead
  88100. */
  88101. get isLocked(): boolean;
  88102. set isLocked(value: boolean);
  88103. /**
  88104. * Updates the bounding sphere and box
  88105. * @param world world matrix to be used to update
  88106. */
  88107. update(world: DeepImmutable<Matrix>): void;
  88108. /**
  88109. * Recreate the bounding info to be centered around a specific point given a specific extend.
  88110. * @param center New center of the bounding info
  88111. * @param extend New extend of the bounding info
  88112. * @returns the current bounding info
  88113. */
  88114. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  88115. /**
  88116. * Scale the current bounding info by applying a scale factor
  88117. * @param factor defines the scale factor to apply
  88118. * @returns the current bounding info
  88119. */
  88120. scale(factor: number): BoundingInfo;
  88121. /**
  88122. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  88123. * @param frustumPlanes defines the frustum to test
  88124. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  88125. * @returns true if the bounding info is in the frustum planes
  88126. */
  88127. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  88128. /**
  88129. * Gets the world distance between the min and max points of the bounding box
  88130. */
  88131. get diagonalLength(): number;
  88132. /**
  88133. * Checks if a cullable object (mesh...) is in the camera frustum
  88134. * Unlike isInFrustum this cheks the full bounding box
  88135. * @param frustumPlanes Camera near/planes
  88136. * @returns true if the object is in frustum otherwise false
  88137. */
  88138. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88139. /** @hidden */
  88140. _checkCollision(collider: Collider): boolean;
  88141. /**
  88142. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  88143. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88144. * @param point the point to check intersection with
  88145. * @returns if the point intersects
  88146. */
  88147. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88148. /**
  88149. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  88150. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88151. * @param boundingInfo the bounding info to check intersection with
  88152. * @param precise if the intersection should be done using OBB
  88153. * @returns if the bounding info intersects
  88154. */
  88155. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  88156. }
  88157. }
  88158. declare module BABYLON {
  88159. /**
  88160. * Extracts minimum and maximum values from a list of indexed positions
  88161. * @param positions defines the positions to use
  88162. * @param indices defines the indices to the positions
  88163. * @param indexStart defines the start index
  88164. * @param indexCount defines the end index
  88165. * @param bias defines bias value to add to the result
  88166. * @return minimum and maximum values
  88167. */
  88168. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  88169. minimum: Vector3;
  88170. maximum: Vector3;
  88171. };
  88172. /**
  88173. * Extracts minimum and maximum values from a list of positions
  88174. * @param positions defines the positions to use
  88175. * @param start defines the start index in the positions array
  88176. * @param count defines the number of positions to handle
  88177. * @param bias defines bias value to add to the result
  88178. * @param stride defines the stride size to use (distance between two positions in the positions array)
  88179. * @return minimum and maximum values
  88180. */
  88181. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  88182. minimum: Vector3;
  88183. maximum: Vector3;
  88184. };
  88185. }
  88186. declare module BABYLON {
  88187. /** @hidden */
  88188. export class WebGLDataBuffer extends DataBuffer {
  88189. private _buffer;
  88190. constructor(resource: WebGLBuffer);
  88191. get underlyingResource(): any;
  88192. }
  88193. }
  88194. declare module BABYLON {
  88195. /** @hidden */
  88196. export class WebGLPipelineContext implements IPipelineContext {
  88197. engine: ThinEngine;
  88198. program: Nullable<WebGLProgram>;
  88199. context?: WebGLRenderingContext;
  88200. vertexShader?: WebGLShader;
  88201. fragmentShader?: WebGLShader;
  88202. isParallelCompiled: boolean;
  88203. onCompiled?: () => void;
  88204. transformFeedback?: WebGLTransformFeedback | null;
  88205. vertexCompilationError: Nullable<string>;
  88206. fragmentCompilationError: Nullable<string>;
  88207. programLinkError: Nullable<string>;
  88208. programValidationError: Nullable<string>;
  88209. get isAsync(): boolean;
  88210. get isReady(): boolean;
  88211. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  88212. _getVertexShaderCode(): string | null;
  88213. _getFragmentShaderCode(): string | null;
  88214. }
  88215. }
  88216. declare module BABYLON {
  88217. interface ThinEngine {
  88218. /**
  88219. * Create an uniform buffer
  88220. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88221. * @param elements defines the content of the uniform buffer
  88222. * @returns the webGL uniform buffer
  88223. */
  88224. createUniformBuffer(elements: FloatArray): DataBuffer;
  88225. /**
  88226. * Create a dynamic uniform buffer
  88227. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88228. * @param elements defines the content of the uniform buffer
  88229. * @returns the webGL uniform buffer
  88230. */
  88231. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88232. /**
  88233. * Update an existing uniform buffer
  88234. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88235. * @param uniformBuffer defines the target uniform buffer
  88236. * @param elements defines the content to update
  88237. * @param offset defines the offset in the uniform buffer where update should start
  88238. * @param count defines the size of the data to update
  88239. */
  88240. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88241. /**
  88242. * Bind an uniform buffer to the current webGL context
  88243. * @param buffer defines the buffer to bind
  88244. */
  88245. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88246. /**
  88247. * Bind a buffer to the current webGL context at a given location
  88248. * @param buffer defines the buffer to bind
  88249. * @param location defines the index where to bind the buffer
  88250. */
  88251. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88252. /**
  88253. * Bind a specific block at a given index in a specific shader program
  88254. * @param pipelineContext defines the pipeline context to use
  88255. * @param blockName defines the block name
  88256. * @param index defines the index where to bind the block
  88257. */
  88258. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88259. }
  88260. }
  88261. declare module BABYLON {
  88262. /**
  88263. * Uniform buffer objects.
  88264. *
  88265. * Handles blocks of uniform on the GPU.
  88266. *
  88267. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88268. *
  88269. * For more information, please refer to :
  88270. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88271. */
  88272. export class UniformBuffer {
  88273. private _engine;
  88274. private _buffer;
  88275. private _data;
  88276. private _bufferData;
  88277. private _dynamic?;
  88278. private _uniformLocations;
  88279. private _uniformSizes;
  88280. private _uniformLocationPointer;
  88281. private _needSync;
  88282. private _noUBO;
  88283. private _currentEffect;
  88284. /** @hidden */
  88285. _alreadyBound: boolean;
  88286. private static _MAX_UNIFORM_SIZE;
  88287. private static _tempBuffer;
  88288. /**
  88289. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  88290. * This is dynamic to allow compat with webgl 1 and 2.
  88291. * You will need to pass the name of the uniform as well as the value.
  88292. */
  88293. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  88294. /**
  88295. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  88296. * This is dynamic to allow compat with webgl 1 and 2.
  88297. * You will need to pass the name of the uniform as well as the value.
  88298. */
  88299. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  88300. /**
  88301. * Lambda to Update a single float in a uniform buffer.
  88302. * This is dynamic to allow compat with webgl 1 and 2.
  88303. * You will need to pass the name of the uniform as well as the value.
  88304. */
  88305. updateFloat: (name: string, x: number) => void;
  88306. /**
  88307. * Lambda to Update a vec2 of float in a uniform buffer.
  88308. * This is dynamic to allow compat with webgl 1 and 2.
  88309. * You will need to pass the name of the uniform as well as the value.
  88310. */
  88311. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  88312. /**
  88313. * Lambda to Update a vec3 of float in a uniform buffer.
  88314. * This is dynamic to allow compat with webgl 1 and 2.
  88315. * You will need to pass the name of the uniform as well as the value.
  88316. */
  88317. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  88318. /**
  88319. * Lambda to Update a vec4 of float in a uniform buffer.
  88320. * This is dynamic to allow compat with webgl 1 and 2.
  88321. * You will need to pass the name of the uniform as well as the value.
  88322. */
  88323. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  88324. /**
  88325. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  88326. * This is dynamic to allow compat with webgl 1 and 2.
  88327. * You will need to pass the name of the uniform as well as the value.
  88328. */
  88329. updateMatrix: (name: string, mat: Matrix) => void;
  88330. /**
  88331. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  88332. * This is dynamic to allow compat with webgl 1 and 2.
  88333. * You will need to pass the name of the uniform as well as the value.
  88334. */
  88335. updateVector3: (name: string, vector: Vector3) => void;
  88336. /**
  88337. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  88338. * This is dynamic to allow compat with webgl 1 and 2.
  88339. * You will need to pass the name of the uniform as well as the value.
  88340. */
  88341. updateVector4: (name: string, vector: Vector4) => void;
  88342. /**
  88343. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  88344. * This is dynamic to allow compat with webgl 1 and 2.
  88345. * You will need to pass the name of the uniform as well as the value.
  88346. */
  88347. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  88348. /**
  88349. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  88350. * This is dynamic to allow compat with webgl 1 and 2.
  88351. * You will need to pass the name of the uniform as well as the value.
  88352. */
  88353. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  88354. /**
  88355. * Instantiates a new Uniform buffer objects.
  88356. *
  88357. * Handles blocks of uniform on the GPU.
  88358. *
  88359. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88360. *
  88361. * For more information, please refer to :
  88362. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88363. * @param engine Define the engine the buffer is associated with
  88364. * @param data Define the data contained in the buffer
  88365. * @param dynamic Define if the buffer is updatable
  88366. */
  88367. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  88368. /**
  88369. * Indicates if the buffer is using the WebGL2 UBO implementation,
  88370. * or just falling back on setUniformXXX calls.
  88371. */
  88372. get useUbo(): boolean;
  88373. /**
  88374. * Indicates if the WebGL underlying uniform buffer is in sync
  88375. * with the javascript cache data.
  88376. */
  88377. get isSync(): boolean;
  88378. /**
  88379. * Indicates if the WebGL underlying uniform buffer is dynamic.
  88380. * Also, a dynamic UniformBuffer will disable cache verification and always
  88381. * update the underlying WebGL uniform buffer to the GPU.
  88382. * @returns if Dynamic, otherwise false
  88383. */
  88384. isDynamic(): boolean;
  88385. /**
  88386. * The data cache on JS side.
  88387. * @returns the underlying data as a float array
  88388. */
  88389. getData(): Float32Array;
  88390. /**
  88391. * The underlying WebGL Uniform buffer.
  88392. * @returns the webgl buffer
  88393. */
  88394. getBuffer(): Nullable<DataBuffer>;
  88395. /**
  88396. * std140 layout specifies how to align data within an UBO structure.
  88397. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  88398. * for specs.
  88399. */
  88400. private _fillAlignment;
  88401. /**
  88402. * Adds an uniform in the buffer.
  88403. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  88404. * for the layout to be correct !
  88405. * @param name Name of the uniform, as used in the uniform block in the shader.
  88406. * @param size Data size, or data directly.
  88407. */
  88408. addUniform(name: string, size: number | number[]): void;
  88409. /**
  88410. * Adds a Matrix 4x4 to the uniform buffer.
  88411. * @param name Name of the uniform, as used in the uniform block in the shader.
  88412. * @param mat A 4x4 matrix.
  88413. */
  88414. addMatrix(name: string, mat: Matrix): void;
  88415. /**
  88416. * Adds a vec2 to the uniform buffer.
  88417. * @param name Name of the uniform, as used in the uniform block in the shader.
  88418. * @param x Define the x component value of the vec2
  88419. * @param y Define the y component value of the vec2
  88420. */
  88421. addFloat2(name: string, x: number, y: number): void;
  88422. /**
  88423. * Adds a vec3 to the uniform buffer.
  88424. * @param name Name of the uniform, as used in the uniform block in the shader.
  88425. * @param x Define the x component value of the vec3
  88426. * @param y Define the y component value of the vec3
  88427. * @param z Define the z component value of the vec3
  88428. */
  88429. addFloat3(name: string, x: number, y: number, z: number): void;
  88430. /**
  88431. * Adds a vec3 to the uniform buffer.
  88432. * @param name Name of the uniform, as used in the uniform block in the shader.
  88433. * @param color Define the vec3 from a Color
  88434. */
  88435. addColor3(name: string, color: Color3): void;
  88436. /**
  88437. * Adds a vec4 to the uniform buffer.
  88438. * @param name Name of the uniform, as used in the uniform block in the shader.
  88439. * @param color Define the rgb components from a Color
  88440. * @param alpha Define the a component of the vec4
  88441. */
  88442. addColor4(name: string, color: Color3, alpha: number): void;
  88443. /**
  88444. * Adds a vec3 to the uniform buffer.
  88445. * @param name Name of the uniform, as used in the uniform block in the shader.
  88446. * @param vector Define the vec3 components from a Vector
  88447. */
  88448. addVector3(name: string, vector: Vector3): void;
  88449. /**
  88450. * Adds a Matrix 3x3 to the uniform buffer.
  88451. * @param name Name of the uniform, as used in the uniform block in the shader.
  88452. */
  88453. addMatrix3x3(name: string): void;
  88454. /**
  88455. * Adds a Matrix 2x2 to the uniform buffer.
  88456. * @param name Name of the uniform, as used in the uniform block in the shader.
  88457. */
  88458. addMatrix2x2(name: string): void;
  88459. /**
  88460. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  88461. */
  88462. create(): void;
  88463. /** @hidden */
  88464. _rebuild(): void;
  88465. /**
  88466. * Updates the WebGL Uniform Buffer on the GPU.
  88467. * If the `dynamic` flag is set to true, no cache comparison is done.
  88468. * Otherwise, the buffer will be updated only if the cache differs.
  88469. */
  88470. update(): void;
  88471. /**
  88472. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  88473. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88474. * @param data Define the flattened data
  88475. * @param size Define the size of the data.
  88476. */
  88477. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  88478. private _valueCache;
  88479. private _cacheMatrix;
  88480. private _updateMatrix3x3ForUniform;
  88481. private _updateMatrix3x3ForEffect;
  88482. private _updateMatrix2x2ForEffect;
  88483. private _updateMatrix2x2ForUniform;
  88484. private _updateFloatForEffect;
  88485. private _updateFloatForUniform;
  88486. private _updateFloat2ForEffect;
  88487. private _updateFloat2ForUniform;
  88488. private _updateFloat3ForEffect;
  88489. private _updateFloat3ForUniform;
  88490. private _updateFloat4ForEffect;
  88491. private _updateFloat4ForUniform;
  88492. private _updateMatrixForEffect;
  88493. private _updateMatrixForUniform;
  88494. private _updateVector3ForEffect;
  88495. private _updateVector3ForUniform;
  88496. private _updateVector4ForEffect;
  88497. private _updateVector4ForUniform;
  88498. private _updateColor3ForEffect;
  88499. private _updateColor3ForUniform;
  88500. private _updateColor4ForEffect;
  88501. private _updateColor4ForUniform;
  88502. /**
  88503. * Sets a sampler uniform on the effect.
  88504. * @param name Define the name of the sampler.
  88505. * @param texture Define the texture to set in the sampler
  88506. */
  88507. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  88508. /**
  88509. * Directly updates the value of the uniform in the cache AND on the GPU.
  88510. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88511. * @param data Define the flattened data
  88512. */
  88513. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  88514. /**
  88515. * Binds this uniform buffer to an effect.
  88516. * @param effect Define the effect to bind the buffer to
  88517. * @param name Name of the uniform block in the shader.
  88518. */
  88519. bindToEffect(effect: Effect, name: string): void;
  88520. /**
  88521. * Disposes the uniform buffer.
  88522. */
  88523. dispose(): void;
  88524. }
  88525. }
  88526. declare module BABYLON {
  88527. /**
  88528. * Enum that determines the text-wrapping mode to use.
  88529. */
  88530. export enum InspectableType {
  88531. /**
  88532. * Checkbox for booleans
  88533. */
  88534. Checkbox = 0,
  88535. /**
  88536. * Sliders for numbers
  88537. */
  88538. Slider = 1,
  88539. /**
  88540. * Vector3
  88541. */
  88542. Vector3 = 2,
  88543. /**
  88544. * Quaternions
  88545. */
  88546. Quaternion = 3,
  88547. /**
  88548. * Color3
  88549. */
  88550. Color3 = 4,
  88551. /**
  88552. * String
  88553. */
  88554. String = 5
  88555. }
  88556. /**
  88557. * Interface used to define custom inspectable properties.
  88558. * This interface is used by the inspector to display custom property grids
  88559. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88560. */
  88561. export interface IInspectable {
  88562. /**
  88563. * Gets the label to display
  88564. */
  88565. label: string;
  88566. /**
  88567. * Gets the name of the property to edit
  88568. */
  88569. propertyName: string;
  88570. /**
  88571. * Gets the type of the editor to use
  88572. */
  88573. type: InspectableType;
  88574. /**
  88575. * Gets the minimum value of the property when using in "slider" mode
  88576. */
  88577. min?: number;
  88578. /**
  88579. * Gets the maximum value of the property when using in "slider" mode
  88580. */
  88581. max?: number;
  88582. /**
  88583. * Gets the setp to use when using in "slider" mode
  88584. */
  88585. step?: number;
  88586. }
  88587. }
  88588. declare module BABYLON {
  88589. /**
  88590. * Class used to provide helper for timing
  88591. */
  88592. export class TimingTools {
  88593. /**
  88594. * Polyfill for setImmediate
  88595. * @param action defines the action to execute after the current execution block
  88596. */
  88597. static SetImmediate(action: () => void): void;
  88598. }
  88599. }
  88600. declare module BABYLON {
  88601. /**
  88602. * Class used to enable instatition of objects by class name
  88603. */
  88604. export class InstantiationTools {
  88605. /**
  88606. * Use this object to register external classes like custom textures or material
  88607. * to allow the laoders to instantiate them
  88608. */
  88609. static RegisteredExternalClasses: {
  88610. [key: string]: Object;
  88611. };
  88612. /**
  88613. * Tries to instantiate a new object from a given class name
  88614. * @param className defines the class name to instantiate
  88615. * @returns the new object or null if the system was not able to do the instantiation
  88616. */
  88617. static Instantiate(className: string): any;
  88618. }
  88619. }
  88620. declare module BABYLON {
  88621. /**
  88622. * Define options used to create a depth texture
  88623. */
  88624. export class DepthTextureCreationOptions {
  88625. /** Specifies whether or not a stencil should be allocated in the texture */
  88626. generateStencil?: boolean;
  88627. /** Specifies whether or not bilinear filtering is enable on the texture */
  88628. bilinearFiltering?: boolean;
  88629. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  88630. comparisonFunction?: number;
  88631. /** Specifies if the created texture is a cube texture */
  88632. isCube?: boolean;
  88633. }
  88634. }
  88635. declare module BABYLON {
  88636. interface ThinEngine {
  88637. /**
  88638. * Creates a depth stencil cube texture.
  88639. * This is only available in WebGL 2.
  88640. * @param size The size of face edge in the cube texture.
  88641. * @param options The options defining the cube texture.
  88642. * @returns The cube texture
  88643. */
  88644. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  88645. /**
  88646. * Creates a cube texture
  88647. * @param rootUrl defines the url where the files to load is located
  88648. * @param scene defines the current scene
  88649. * @param files defines the list of files to load (1 per face)
  88650. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88651. * @param onLoad defines an optional callback raised when the texture is loaded
  88652. * @param onError defines an optional callback raised if there is an issue to load the texture
  88653. * @param format defines the format of the data
  88654. * @param forcedExtension defines the extension to use to pick the right loader
  88655. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88656. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88657. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88658. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88659. * @param loaderOptions options to be passed to the loader
  88660. * @returns the cube texture as an InternalTexture
  88661. */
  88662. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  88663. /**
  88664. * Creates a cube texture
  88665. * @param rootUrl defines the url where the files to load is located
  88666. * @param scene defines the current scene
  88667. * @param files defines the list of files to load (1 per face)
  88668. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88669. * @param onLoad defines an optional callback raised when the texture is loaded
  88670. * @param onError defines an optional callback raised if there is an issue to load the texture
  88671. * @param format defines the format of the data
  88672. * @param forcedExtension defines the extension to use to pick the right loader
  88673. * @returns the cube texture as an InternalTexture
  88674. */
  88675. 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;
  88676. /**
  88677. * Creates a cube texture
  88678. * @param rootUrl defines the url where the files to load is located
  88679. * @param scene defines the current scene
  88680. * @param files defines the list of files to load (1 per face)
  88681. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88682. * @param onLoad defines an optional callback raised when the texture is loaded
  88683. * @param onError defines an optional callback raised if there is an issue to load the texture
  88684. * @param format defines the format of the data
  88685. * @param forcedExtension defines the extension to use to pick the right loader
  88686. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88687. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88688. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88689. * @returns the cube texture as an InternalTexture
  88690. */
  88691. 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;
  88692. /** @hidden */
  88693. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  88694. /** @hidden */
  88695. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  88696. /** @hidden */
  88697. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88698. /** @hidden */
  88699. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88700. /**
  88701. * @hidden
  88702. */
  88703. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  88704. }
  88705. }
  88706. declare module BABYLON {
  88707. /**
  88708. * Class for creating a cube texture
  88709. */
  88710. export class CubeTexture extends BaseTexture {
  88711. private _delayedOnLoad;
  88712. /**
  88713. * Observable triggered once the texture has been loaded.
  88714. */
  88715. onLoadObservable: Observable<CubeTexture>;
  88716. /**
  88717. * The url of the texture
  88718. */
  88719. url: string;
  88720. /**
  88721. * Gets or sets the center of the bounding box associated with the cube texture.
  88722. * It must define where the camera used to render the texture was set
  88723. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88724. */
  88725. boundingBoxPosition: Vector3;
  88726. private _boundingBoxSize;
  88727. /**
  88728. * Gets or sets the size of the bounding box associated with the cube texture
  88729. * When defined, the cubemap will switch to local mode
  88730. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88731. * @example https://www.babylonjs-playground.com/#RNASML
  88732. */
  88733. set boundingBoxSize(value: Vector3);
  88734. /**
  88735. * Returns the bounding box size
  88736. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88737. */
  88738. get boundingBoxSize(): Vector3;
  88739. protected _rotationY: number;
  88740. /**
  88741. * Sets texture matrix rotation angle around Y axis in radians.
  88742. */
  88743. set rotationY(value: number);
  88744. /**
  88745. * Gets texture matrix rotation angle around Y axis radians.
  88746. */
  88747. get rotationY(): number;
  88748. /**
  88749. * Are mip maps generated for this texture or not.
  88750. */
  88751. get noMipmap(): boolean;
  88752. private _noMipmap;
  88753. private _files;
  88754. protected _forcedExtension: Nullable<string>;
  88755. private _extensions;
  88756. private _textureMatrix;
  88757. private _format;
  88758. private _createPolynomials;
  88759. private _loaderOptions;
  88760. /**
  88761. * Creates a cube texture from an array of image urls
  88762. * @param files defines an array of image urls
  88763. * @param scene defines the hosting scene
  88764. * @param noMipmap specifies if mip maps are not used
  88765. * @returns a cube texture
  88766. */
  88767. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  88768. /**
  88769. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  88770. * @param url defines the url of the prefiltered texture
  88771. * @param scene defines the scene the texture is attached to
  88772. * @param forcedExtension defines the extension of the file if different from the url
  88773. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88774. * @return the prefiltered texture
  88775. */
  88776. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  88777. /**
  88778. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  88779. * as prefiltered data.
  88780. * @param rootUrl defines the url of the texture or the root name of the six images
  88781. * @param null defines the scene or engine the texture is attached to
  88782. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  88783. * @param noMipmap defines if mipmaps should be created or not
  88784. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  88785. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  88786. * @param onError defines a callback triggered in case of error during load
  88787. * @param format defines the internal format to use for the texture once loaded
  88788. * @param prefiltered defines whether or not the texture is created from prefiltered data
  88789. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  88790. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88791. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88792. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88793. * @param loaderOptions options to be passed to the loader
  88794. * @return the cube texture
  88795. */
  88796. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  88797. /**
  88798. * Get the current class name of the texture useful for serialization or dynamic coding.
  88799. * @returns "CubeTexture"
  88800. */
  88801. getClassName(): string;
  88802. /**
  88803. * Update the url (and optional buffer) of this texture if url was null during construction.
  88804. * @param url the url of the texture
  88805. * @param forcedExtension defines the extension to use
  88806. * @param onLoad callback called when the texture is loaded (defaults to null)
  88807. * @param prefiltered Defines whether the updated texture is prefiltered or not
  88808. */
  88809. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  88810. /**
  88811. * Delays loading of the cube texture
  88812. * @param forcedExtension defines the extension to use
  88813. */
  88814. delayLoad(forcedExtension?: string): void;
  88815. /**
  88816. * Returns the reflection texture matrix
  88817. * @returns the reflection texture matrix
  88818. */
  88819. getReflectionTextureMatrix(): Matrix;
  88820. /**
  88821. * Sets the reflection texture matrix
  88822. * @param value Reflection texture matrix
  88823. */
  88824. setReflectionTextureMatrix(value: Matrix): void;
  88825. /**
  88826. * Parses text to create a cube texture
  88827. * @param parsedTexture define the serialized text to read from
  88828. * @param scene defines the hosting scene
  88829. * @param rootUrl defines the root url of the cube texture
  88830. * @returns a cube texture
  88831. */
  88832. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  88833. /**
  88834. * Makes a clone, or deep copy, of the cube texture
  88835. * @returns a new cube texture
  88836. */
  88837. clone(): CubeTexture;
  88838. }
  88839. }
  88840. declare module BABYLON {
  88841. /**
  88842. * Manages the defines for the Material
  88843. */
  88844. export class MaterialDefines {
  88845. /** @hidden */
  88846. protected _keys: string[];
  88847. private _isDirty;
  88848. /** @hidden */
  88849. _renderId: number;
  88850. /** @hidden */
  88851. _areLightsDirty: boolean;
  88852. /** @hidden */
  88853. _areLightsDisposed: boolean;
  88854. /** @hidden */
  88855. _areAttributesDirty: boolean;
  88856. /** @hidden */
  88857. _areTexturesDirty: boolean;
  88858. /** @hidden */
  88859. _areFresnelDirty: boolean;
  88860. /** @hidden */
  88861. _areMiscDirty: boolean;
  88862. /** @hidden */
  88863. _arePrePassDirty: boolean;
  88864. /** @hidden */
  88865. _areImageProcessingDirty: boolean;
  88866. /** @hidden */
  88867. _normals: boolean;
  88868. /** @hidden */
  88869. _uvs: boolean;
  88870. /** @hidden */
  88871. _needNormals: boolean;
  88872. /** @hidden */
  88873. _needUVs: boolean;
  88874. [id: string]: any;
  88875. /**
  88876. * Specifies if the material needs to be re-calculated
  88877. */
  88878. get isDirty(): boolean;
  88879. /**
  88880. * Marks the material to indicate that it has been re-calculated
  88881. */
  88882. markAsProcessed(): void;
  88883. /**
  88884. * Marks the material to indicate that it needs to be re-calculated
  88885. */
  88886. markAsUnprocessed(): void;
  88887. /**
  88888. * Marks the material to indicate all of its defines need to be re-calculated
  88889. */
  88890. markAllAsDirty(): void;
  88891. /**
  88892. * Marks the material to indicate that image processing needs to be re-calculated
  88893. */
  88894. markAsImageProcessingDirty(): void;
  88895. /**
  88896. * Marks the material to indicate the lights need to be re-calculated
  88897. * @param disposed Defines whether the light is dirty due to dispose or not
  88898. */
  88899. markAsLightDirty(disposed?: boolean): void;
  88900. /**
  88901. * Marks the attribute state as changed
  88902. */
  88903. markAsAttributesDirty(): void;
  88904. /**
  88905. * Marks the texture state as changed
  88906. */
  88907. markAsTexturesDirty(): void;
  88908. /**
  88909. * Marks the fresnel state as changed
  88910. */
  88911. markAsFresnelDirty(): void;
  88912. /**
  88913. * Marks the misc state as changed
  88914. */
  88915. markAsMiscDirty(): void;
  88916. /**
  88917. * Marks the prepass state as changed
  88918. */
  88919. markAsPrePassDirty(): void;
  88920. /**
  88921. * Rebuilds the material defines
  88922. */
  88923. rebuild(): void;
  88924. /**
  88925. * Specifies if two material defines are equal
  88926. * @param other - A material define instance to compare to
  88927. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  88928. */
  88929. isEqual(other: MaterialDefines): boolean;
  88930. /**
  88931. * Clones this instance's defines to another instance
  88932. * @param other - material defines to clone values to
  88933. */
  88934. cloneTo(other: MaterialDefines): void;
  88935. /**
  88936. * Resets the material define values
  88937. */
  88938. reset(): void;
  88939. /**
  88940. * Converts the material define values to a string
  88941. * @returns - String of material define information
  88942. */
  88943. toString(): string;
  88944. }
  88945. }
  88946. declare module BABYLON {
  88947. /**
  88948. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88949. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88950. * 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;
  88951. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88952. */
  88953. export class ColorCurves {
  88954. private _dirty;
  88955. private _tempColor;
  88956. private _globalCurve;
  88957. private _highlightsCurve;
  88958. private _midtonesCurve;
  88959. private _shadowsCurve;
  88960. private _positiveCurve;
  88961. private _negativeCurve;
  88962. private _globalHue;
  88963. private _globalDensity;
  88964. private _globalSaturation;
  88965. private _globalExposure;
  88966. /**
  88967. * Gets the global Hue value.
  88968. * 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).
  88969. */
  88970. get globalHue(): number;
  88971. /**
  88972. * Sets the global Hue value.
  88973. * 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).
  88974. */
  88975. set globalHue(value: number);
  88976. /**
  88977. * Gets the global Density value.
  88978. * 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.
  88979. * Values less than zero provide a filter of opposite hue.
  88980. */
  88981. get globalDensity(): number;
  88982. /**
  88983. * Sets the global Density value.
  88984. * 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.
  88985. * Values less than zero provide a filter of opposite hue.
  88986. */
  88987. set globalDensity(value: number);
  88988. /**
  88989. * Gets the global Saturation value.
  88990. * 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.
  88991. */
  88992. get globalSaturation(): number;
  88993. /**
  88994. * Sets the global Saturation value.
  88995. * 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.
  88996. */
  88997. set globalSaturation(value: number);
  88998. /**
  88999. * Gets the global Exposure value.
  89000. * 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.
  89001. */
  89002. get globalExposure(): number;
  89003. /**
  89004. * Sets the global Exposure value.
  89005. * 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.
  89006. */
  89007. set globalExposure(value: number);
  89008. private _highlightsHue;
  89009. private _highlightsDensity;
  89010. private _highlightsSaturation;
  89011. private _highlightsExposure;
  89012. /**
  89013. * Gets the highlights Hue value.
  89014. * 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).
  89015. */
  89016. get highlightsHue(): number;
  89017. /**
  89018. * Sets the highlights Hue value.
  89019. * 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).
  89020. */
  89021. set highlightsHue(value: number);
  89022. /**
  89023. * Gets the highlights Density value.
  89024. * 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.
  89025. * Values less than zero provide a filter of opposite hue.
  89026. */
  89027. get highlightsDensity(): number;
  89028. /**
  89029. * Sets the highlights Density value.
  89030. * 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.
  89031. * Values less than zero provide a filter of opposite hue.
  89032. */
  89033. set highlightsDensity(value: number);
  89034. /**
  89035. * Gets the highlights Saturation value.
  89036. * 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.
  89037. */
  89038. get highlightsSaturation(): number;
  89039. /**
  89040. * Sets the highlights Saturation value.
  89041. * 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.
  89042. */
  89043. set highlightsSaturation(value: number);
  89044. /**
  89045. * Gets the highlights Exposure value.
  89046. * 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.
  89047. */
  89048. get highlightsExposure(): number;
  89049. /**
  89050. * Sets the highlights Exposure value.
  89051. * 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.
  89052. */
  89053. set highlightsExposure(value: number);
  89054. private _midtonesHue;
  89055. private _midtonesDensity;
  89056. private _midtonesSaturation;
  89057. private _midtonesExposure;
  89058. /**
  89059. * Gets the midtones Hue value.
  89060. * 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).
  89061. */
  89062. get midtonesHue(): number;
  89063. /**
  89064. * Sets the midtones Hue value.
  89065. * 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).
  89066. */
  89067. set midtonesHue(value: number);
  89068. /**
  89069. * Gets the midtones Density value.
  89070. * 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.
  89071. * Values less than zero provide a filter of opposite hue.
  89072. */
  89073. get midtonesDensity(): number;
  89074. /**
  89075. * Sets the midtones Density value.
  89076. * 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.
  89077. * Values less than zero provide a filter of opposite hue.
  89078. */
  89079. set midtonesDensity(value: number);
  89080. /**
  89081. * Gets the midtones Saturation value.
  89082. * 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.
  89083. */
  89084. get midtonesSaturation(): number;
  89085. /**
  89086. * Sets the midtones Saturation value.
  89087. * 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.
  89088. */
  89089. set midtonesSaturation(value: number);
  89090. /**
  89091. * Gets the midtones Exposure value.
  89092. * 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.
  89093. */
  89094. get midtonesExposure(): number;
  89095. /**
  89096. * Sets the midtones Exposure value.
  89097. * 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.
  89098. */
  89099. set midtonesExposure(value: number);
  89100. private _shadowsHue;
  89101. private _shadowsDensity;
  89102. private _shadowsSaturation;
  89103. private _shadowsExposure;
  89104. /**
  89105. * Gets the shadows Hue value.
  89106. * 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).
  89107. */
  89108. get shadowsHue(): number;
  89109. /**
  89110. * Sets the shadows Hue value.
  89111. * 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).
  89112. */
  89113. set shadowsHue(value: number);
  89114. /**
  89115. * Gets the shadows Density value.
  89116. * 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.
  89117. * Values less than zero provide a filter of opposite hue.
  89118. */
  89119. get shadowsDensity(): number;
  89120. /**
  89121. * Sets the shadows Density value.
  89122. * 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.
  89123. * Values less than zero provide a filter of opposite hue.
  89124. */
  89125. set shadowsDensity(value: number);
  89126. /**
  89127. * Gets the shadows Saturation value.
  89128. * 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.
  89129. */
  89130. get shadowsSaturation(): number;
  89131. /**
  89132. * Sets the shadows Saturation value.
  89133. * 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.
  89134. */
  89135. set shadowsSaturation(value: number);
  89136. /**
  89137. * Gets the shadows Exposure value.
  89138. * 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.
  89139. */
  89140. get shadowsExposure(): number;
  89141. /**
  89142. * Sets the shadows Exposure value.
  89143. * 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.
  89144. */
  89145. set shadowsExposure(value: number);
  89146. /**
  89147. * Returns the class name
  89148. * @returns The class name
  89149. */
  89150. getClassName(): string;
  89151. /**
  89152. * Binds the color curves to the shader.
  89153. * @param colorCurves The color curve to bind
  89154. * @param effect The effect to bind to
  89155. * @param positiveUniform The positive uniform shader parameter
  89156. * @param neutralUniform The neutral uniform shader parameter
  89157. * @param negativeUniform The negative uniform shader parameter
  89158. */
  89159. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89160. /**
  89161. * Prepare the list of uniforms associated with the ColorCurves effects.
  89162. * @param uniformsList The list of uniforms used in the effect
  89163. */
  89164. static PrepareUniforms(uniformsList: string[]): void;
  89165. /**
  89166. * Returns color grading data based on a hue, density, saturation and exposure value.
  89167. * @param filterHue The hue of the color filter.
  89168. * @param filterDensity The density of the color filter.
  89169. * @param saturation The saturation.
  89170. * @param exposure The exposure.
  89171. * @param result The result data container.
  89172. */
  89173. private getColorGradingDataToRef;
  89174. /**
  89175. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89176. * @param value The input slider value in range [-100,100].
  89177. * @returns Adjusted value.
  89178. */
  89179. private static applyColorGradingSliderNonlinear;
  89180. /**
  89181. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89182. * @param hue The hue (H) input.
  89183. * @param saturation The saturation (S) input.
  89184. * @param brightness The brightness (B) input.
  89185. * @result An RGBA color represented as Vector4.
  89186. */
  89187. private static fromHSBToRef;
  89188. /**
  89189. * Returns a value clamped between min and max
  89190. * @param value The value to clamp
  89191. * @param min The minimum of value
  89192. * @param max The maximum of value
  89193. * @returns The clamped value.
  89194. */
  89195. private static clamp;
  89196. /**
  89197. * Clones the current color curve instance.
  89198. * @return The cloned curves
  89199. */
  89200. clone(): ColorCurves;
  89201. /**
  89202. * Serializes the current color curve instance to a json representation.
  89203. * @return a JSON representation
  89204. */
  89205. serialize(): any;
  89206. /**
  89207. * Parses the color curve from a json representation.
  89208. * @param source the JSON source to parse
  89209. * @return The parsed curves
  89210. */
  89211. static Parse(source: any): ColorCurves;
  89212. }
  89213. }
  89214. declare module BABYLON {
  89215. /**
  89216. * Interface to follow in your material defines to integrate easily the
  89217. * Image proccessing functions.
  89218. * @hidden
  89219. */
  89220. export interface IImageProcessingConfigurationDefines {
  89221. IMAGEPROCESSING: boolean;
  89222. VIGNETTE: boolean;
  89223. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89224. VIGNETTEBLENDMODEOPAQUE: boolean;
  89225. TONEMAPPING: boolean;
  89226. TONEMAPPING_ACES: boolean;
  89227. CONTRAST: boolean;
  89228. EXPOSURE: boolean;
  89229. COLORCURVES: boolean;
  89230. COLORGRADING: boolean;
  89231. COLORGRADING3D: boolean;
  89232. SAMPLER3DGREENDEPTH: boolean;
  89233. SAMPLER3DBGRMAP: boolean;
  89234. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89235. }
  89236. /**
  89237. * @hidden
  89238. */
  89239. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89240. IMAGEPROCESSING: boolean;
  89241. VIGNETTE: boolean;
  89242. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89243. VIGNETTEBLENDMODEOPAQUE: boolean;
  89244. TONEMAPPING: boolean;
  89245. TONEMAPPING_ACES: boolean;
  89246. CONTRAST: boolean;
  89247. COLORCURVES: boolean;
  89248. COLORGRADING: boolean;
  89249. COLORGRADING3D: boolean;
  89250. SAMPLER3DGREENDEPTH: boolean;
  89251. SAMPLER3DBGRMAP: boolean;
  89252. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89253. EXPOSURE: boolean;
  89254. constructor();
  89255. }
  89256. /**
  89257. * This groups together the common properties used for image processing either in direct forward pass
  89258. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89259. * or not.
  89260. */
  89261. export class ImageProcessingConfiguration {
  89262. /**
  89263. * Default tone mapping applied in BabylonJS.
  89264. */
  89265. static readonly TONEMAPPING_STANDARD: number;
  89266. /**
  89267. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89268. * to other engines rendering to increase portability.
  89269. */
  89270. static readonly TONEMAPPING_ACES: number;
  89271. /**
  89272. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89273. */
  89274. colorCurves: Nullable<ColorCurves>;
  89275. private _colorCurvesEnabled;
  89276. /**
  89277. * Gets wether the color curves effect is enabled.
  89278. */
  89279. get colorCurvesEnabled(): boolean;
  89280. /**
  89281. * Sets wether the color curves effect is enabled.
  89282. */
  89283. set colorCurvesEnabled(value: boolean);
  89284. private _colorGradingTexture;
  89285. /**
  89286. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89287. */
  89288. get colorGradingTexture(): Nullable<BaseTexture>;
  89289. /**
  89290. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89291. */
  89292. set colorGradingTexture(value: Nullable<BaseTexture>);
  89293. private _colorGradingEnabled;
  89294. /**
  89295. * Gets wether the color grading effect is enabled.
  89296. */
  89297. get colorGradingEnabled(): boolean;
  89298. /**
  89299. * Sets wether the color grading effect is enabled.
  89300. */
  89301. set colorGradingEnabled(value: boolean);
  89302. private _colorGradingWithGreenDepth;
  89303. /**
  89304. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89305. */
  89306. get colorGradingWithGreenDepth(): boolean;
  89307. /**
  89308. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89309. */
  89310. set colorGradingWithGreenDepth(value: boolean);
  89311. private _colorGradingBGR;
  89312. /**
  89313. * Gets wether the color grading texture contains BGR values.
  89314. */
  89315. get colorGradingBGR(): boolean;
  89316. /**
  89317. * Sets wether the color grading texture contains BGR values.
  89318. */
  89319. set colorGradingBGR(value: boolean);
  89320. /** @hidden */
  89321. _exposure: number;
  89322. /**
  89323. * Gets the Exposure used in the effect.
  89324. */
  89325. get exposure(): number;
  89326. /**
  89327. * Sets the Exposure used in the effect.
  89328. */
  89329. set exposure(value: number);
  89330. private _toneMappingEnabled;
  89331. /**
  89332. * Gets wether the tone mapping effect is enabled.
  89333. */
  89334. get toneMappingEnabled(): boolean;
  89335. /**
  89336. * Sets wether the tone mapping effect is enabled.
  89337. */
  89338. set toneMappingEnabled(value: boolean);
  89339. private _toneMappingType;
  89340. /**
  89341. * Gets the type of tone mapping effect.
  89342. */
  89343. get toneMappingType(): number;
  89344. /**
  89345. * Sets the type of tone mapping effect used in BabylonJS.
  89346. */
  89347. set toneMappingType(value: number);
  89348. protected _contrast: number;
  89349. /**
  89350. * Gets the contrast used in the effect.
  89351. */
  89352. get contrast(): number;
  89353. /**
  89354. * Sets the contrast used in the effect.
  89355. */
  89356. set contrast(value: number);
  89357. /**
  89358. * Vignette stretch size.
  89359. */
  89360. vignetteStretch: number;
  89361. /**
  89362. * Vignette centre X Offset.
  89363. */
  89364. vignetteCentreX: number;
  89365. /**
  89366. * Vignette centre Y Offset.
  89367. */
  89368. vignetteCentreY: number;
  89369. /**
  89370. * Vignette weight or intensity of the vignette effect.
  89371. */
  89372. vignetteWeight: number;
  89373. /**
  89374. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89375. * if vignetteEnabled is set to true.
  89376. */
  89377. vignetteColor: Color4;
  89378. /**
  89379. * Camera field of view used by the Vignette effect.
  89380. */
  89381. vignetteCameraFov: number;
  89382. private _vignetteBlendMode;
  89383. /**
  89384. * Gets the vignette blend mode allowing different kind of effect.
  89385. */
  89386. get vignetteBlendMode(): number;
  89387. /**
  89388. * Sets the vignette blend mode allowing different kind of effect.
  89389. */
  89390. set vignetteBlendMode(value: number);
  89391. private _vignetteEnabled;
  89392. /**
  89393. * Gets wether the vignette effect is enabled.
  89394. */
  89395. get vignetteEnabled(): boolean;
  89396. /**
  89397. * Sets wether the vignette effect is enabled.
  89398. */
  89399. set vignetteEnabled(value: boolean);
  89400. private _applyByPostProcess;
  89401. /**
  89402. * Gets wether the image processing is applied through a post process or not.
  89403. */
  89404. get applyByPostProcess(): boolean;
  89405. /**
  89406. * Sets wether the image processing is applied through a post process or not.
  89407. */
  89408. set applyByPostProcess(value: boolean);
  89409. private _isEnabled;
  89410. /**
  89411. * Gets wether the image processing is enabled or not.
  89412. */
  89413. get isEnabled(): boolean;
  89414. /**
  89415. * Sets wether the image processing is enabled or not.
  89416. */
  89417. set isEnabled(value: boolean);
  89418. /**
  89419. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89420. */
  89421. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89422. /**
  89423. * Method called each time the image processing information changes requires to recompile the effect.
  89424. */
  89425. protected _updateParameters(): void;
  89426. /**
  89427. * Gets the current class name.
  89428. * @return "ImageProcessingConfiguration"
  89429. */
  89430. getClassName(): string;
  89431. /**
  89432. * Prepare the list of uniforms associated with the Image Processing effects.
  89433. * @param uniforms The list of uniforms used in the effect
  89434. * @param defines the list of defines currently in use
  89435. */
  89436. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89437. /**
  89438. * Prepare the list of samplers associated with the Image Processing effects.
  89439. * @param samplersList The list of uniforms used in the effect
  89440. * @param defines the list of defines currently in use
  89441. */
  89442. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89443. /**
  89444. * Prepare the list of defines associated to the shader.
  89445. * @param defines the list of defines to complete
  89446. * @param forPostProcess Define if we are currently in post process mode or not
  89447. */
  89448. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89449. /**
  89450. * Returns true if all the image processing information are ready.
  89451. * @returns True if ready, otherwise, false
  89452. */
  89453. isReady(): boolean;
  89454. /**
  89455. * Binds the image processing to the shader.
  89456. * @param effect The effect to bind to
  89457. * @param overrideAspectRatio Override the aspect ratio of the effect
  89458. */
  89459. bind(effect: Effect, overrideAspectRatio?: number): void;
  89460. /**
  89461. * Clones the current image processing instance.
  89462. * @return The cloned image processing
  89463. */
  89464. clone(): ImageProcessingConfiguration;
  89465. /**
  89466. * Serializes the current image processing instance to a json representation.
  89467. * @return a JSON representation
  89468. */
  89469. serialize(): any;
  89470. /**
  89471. * Parses the image processing from a json representation.
  89472. * @param source the JSON source to parse
  89473. * @return The parsed image processing
  89474. */
  89475. static Parse(source: any): ImageProcessingConfiguration;
  89476. private static _VIGNETTEMODE_MULTIPLY;
  89477. private static _VIGNETTEMODE_OPAQUE;
  89478. /**
  89479. * Used to apply the vignette as a mix with the pixel color.
  89480. */
  89481. static get VIGNETTEMODE_MULTIPLY(): number;
  89482. /**
  89483. * Used to apply the vignette as a replacement of the pixel color.
  89484. */
  89485. static get VIGNETTEMODE_OPAQUE(): number;
  89486. }
  89487. }
  89488. declare module BABYLON {
  89489. /** @hidden */
  89490. export var postprocessVertexShader: {
  89491. name: string;
  89492. shader: string;
  89493. };
  89494. }
  89495. declare module BABYLON {
  89496. /**
  89497. * Type used to define a render target texture size (either with a number or with a rect width and height)
  89498. */
  89499. export type RenderTargetTextureSize = number | {
  89500. width: number;
  89501. height: number;
  89502. layers?: number;
  89503. };
  89504. interface ThinEngine {
  89505. /**
  89506. * Creates a new render target texture
  89507. * @param size defines the size of the texture
  89508. * @param options defines the options used to create the texture
  89509. * @returns a new render target texture stored in an InternalTexture
  89510. */
  89511. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  89512. /**
  89513. * Creates a depth stencil texture.
  89514. * This is only available in WebGL 2 or with the depth texture extension available.
  89515. * @param size The size of face edge in the texture.
  89516. * @param options The options defining the texture.
  89517. * @returns The texture
  89518. */
  89519. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89520. /** @hidden */
  89521. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89522. }
  89523. }
  89524. declare module BABYLON {
  89525. /**
  89526. * Defines the kind of connection point for node based material
  89527. */
  89528. export enum NodeMaterialBlockConnectionPointTypes {
  89529. /** Float */
  89530. Float = 1,
  89531. /** Int */
  89532. Int = 2,
  89533. /** Vector2 */
  89534. Vector2 = 4,
  89535. /** Vector3 */
  89536. Vector3 = 8,
  89537. /** Vector4 */
  89538. Vector4 = 16,
  89539. /** Color3 */
  89540. Color3 = 32,
  89541. /** Color4 */
  89542. Color4 = 64,
  89543. /** Matrix */
  89544. Matrix = 128,
  89545. /** Custom object */
  89546. Object = 256,
  89547. /** Detect type based on connection */
  89548. AutoDetect = 1024,
  89549. /** Output type that will be defined by input type */
  89550. BasedOnInput = 2048
  89551. }
  89552. }
  89553. declare module BABYLON {
  89554. /**
  89555. * Enum used to define the target of a block
  89556. */
  89557. export enum NodeMaterialBlockTargets {
  89558. /** Vertex shader */
  89559. Vertex = 1,
  89560. /** Fragment shader */
  89561. Fragment = 2,
  89562. /** Neutral */
  89563. Neutral = 4,
  89564. /** Vertex and Fragment */
  89565. VertexAndFragment = 3
  89566. }
  89567. }
  89568. declare module BABYLON {
  89569. /**
  89570. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  89571. */
  89572. export enum NodeMaterialBlockConnectionPointMode {
  89573. /** Value is an uniform */
  89574. Uniform = 0,
  89575. /** Value is a mesh attribute */
  89576. Attribute = 1,
  89577. /** Value is a varying between vertex and fragment shaders */
  89578. Varying = 2,
  89579. /** Mode is undefined */
  89580. Undefined = 3
  89581. }
  89582. }
  89583. declare module BABYLON {
  89584. /**
  89585. * Enum used to define system values e.g. values automatically provided by the system
  89586. */
  89587. export enum NodeMaterialSystemValues {
  89588. /** World */
  89589. World = 1,
  89590. /** View */
  89591. View = 2,
  89592. /** Projection */
  89593. Projection = 3,
  89594. /** ViewProjection */
  89595. ViewProjection = 4,
  89596. /** WorldView */
  89597. WorldView = 5,
  89598. /** WorldViewProjection */
  89599. WorldViewProjection = 6,
  89600. /** CameraPosition */
  89601. CameraPosition = 7,
  89602. /** Fog Color */
  89603. FogColor = 8,
  89604. /** Delta time */
  89605. DeltaTime = 9
  89606. }
  89607. }
  89608. declare module BABYLON {
  89609. /** Defines supported spaces */
  89610. export enum Space {
  89611. /** Local (object) space */
  89612. LOCAL = 0,
  89613. /** World space */
  89614. WORLD = 1,
  89615. /** Bone space */
  89616. BONE = 2
  89617. }
  89618. /** Defines the 3 main axes */
  89619. export class Axis {
  89620. /** X axis */
  89621. static X: Vector3;
  89622. /** Y axis */
  89623. static Y: Vector3;
  89624. /** Z axis */
  89625. static Z: Vector3;
  89626. }
  89627. }
  89628. declare module BABYLON {
  89629. /**
  89630. * Represents a camera frustum
  89631. */
  89632. export class Frustum {
  89633. /**
  89634. * Gets the planes representing the frustum
  89635. * @param transform matrix to be applied to the returned planes
  89636. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  89637. */
  89638. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  89639. /**
  89640. * Gets the near frustum plane transformed by the transform matrix
  89641. * @param transform transformation matrix to be applied to the resulting frustum plane
  89642. * @param frustumPlane the resuling frustum plane
  89643. */
  89644. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89645. /**
  89646. * Gets the far frustum plane transformed by the transform matrix
  89647. * @param transform transformation matrix to be applied to the resulting frustum plane
  89648. * @param frustumPlane the resuling frustum plane
  89649. */
  89650. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89651. /**
  89652. * Gets the left frustum plane transformed by the transform matrix
  89653. * @param transform transformation matrix to be applied to the resulting frustum plane
  89654. * @param frustumPlane the resuling frustum plane
  89655. */
  89656. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89657. /**
  89658. * Gets the right frustum plane transformed by the transform matrix
  89659. * @param transform transformation matrix to be applied to the resulting frustum plane
  89660. * @param frustumPlane the resuling frustum plane
  89661. */
  89662. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89663. /**
  89664. * Gets the top frustum plane transformed by the transform matrix
  89665. * @param transform transformation matrix to be applied to the resulting frustum plane
  89666. * @param frustumPlane the resuling frustum plane
  89667. */
  89668. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89669. /**
  89670. * Gets the bottom frustum plane transformed by the transform matrix
  89671. * @param transform transformation matrix to be applied to the resulting frustum plane
  89672. * @param frustumPlane the resuling frustum plane
  89673. */
  89674. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89675. /**
  89676. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  89677. * @param transform transformation matrix to be applied to the resulting frustum planes
  89678. * @param frustumPlanes the resuling frustum planes
  89679. */
  89680. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  89681. }
  89682. }
  89683. declare module BABYLON {
  89684. /**
  89685. * Interface for the size containing width and height
  89686. */
  89687. export interface ISize {
  89688. /**
  89689. * Width
  89690. */
  89691. width: number;
  89692. /**
  89693. * Heighht
  89694. */
  89695. height: number;
  89696. }
  89697. /**
  89698. * Size containing widht and height
  89699. */
  89700. export class Size implements ISize {
  89701. /**
  89702. * Width
  89703. */
  89704. width: number;
  89705. /**
  89706. * Height
  89707. */
  89708. height: number;
  89709. /**
  89710. * Creates a Size object from the given width and height (floats).
  89711. * @param width width of the new size
  89712. * @param height height of the new size
  89713. */
  89714. constructor(width: number, height: number);
  89715. /**
  89716. * Returns a string with the Size width and height
  89717. * @returns a string with the Size width and height
  89718. */
  89719. toString(): string;
  89720. /**
  89721. * "Size"
  89722. * @returns the string "Size"
  89723. */
  89724. getClassName(): string;
  89725. /**
  89726. * Returns the Size hash code.
  89727. * @returns a hash code for a unique width and height
  89728. */
  89729. getHashCode(): number;
  89730. /**
  89731. * Updates the current size from the given one.
  89732. * @param src the given size
  89733. */
  89734. copyFrom(src: Size): void;
  89735. /**
  89736. * Updates in place the current Size from the given floats.
  89737. * @param width width of the new size
  89738. * @param height height of the new size
  89739. * @returns the updated Size.
  89740. */
  89741. copyFromFloats(width: number, height: number): Size;
  89742. /**
  89743. * Updates in place the current Size from the given floats.
  89744. * @param width width to set
  89745. * @param height height to set
  89746. * @returns the updated Size.
  89747. */
  89748. set(width: number, height: number): Size;
  89749. /**
  89750. * Multiplies the width and height by numbers
  89751. * @param w factor to multiple the width by
  89752. * @param h factor to multiple the height by
  89753. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  89754. */
  89755. multiplyByFloats(w: number, h: number): Size;
  89756. /**
  89757. * Clones the size
  89758. * @returns a new Size copied from the given one.
  89759. */
  89760. clone(): Size;
  89761. /**
  89762. * True if the current Size and the given one width and height are strictly equal.
  89763. * @param other the other size to compare against
  89764. * @returns True if the current Size and the given one width and height are strictly equal.
  89765. */
  89766. equals(other: Size): boolean;
  89767. /**
  89768. * The surface of the Size : width * height (float).
  89769. */
  89770. get surface(): number;
  89771. /**
  89772. * Create a new size of zero
  89773. * @returns a new Size set to (0.0, 0.0)
  89774. */
  89775. static Zero(): Size;
  89776. /**
  89777. * Sums the width and height of two sizes
  89778. * @param otherSize size to add to this size
  89779. * @returns a new Size set as the addition result of the current Size and the given one.
  89780. */
  89781. add(otherSize: Size): Size;
  89782. /**
  89783. * Subtracts the width and height of two
  89784. * @param otherSize size to subtract to this size
  89785. * @returns a new Size set as the subtraction result of the given one from the current Size.
  89786. */
  89787. subtract(otherSize: Size): Size;
  89788. /**
  89789. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  89790. * @param start starting size to lerp between
  89791. * @param end end size to lerp between
  89792. * @param amount amount to lerp between the start and end values
  89793. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  89794. */
  89795. static Lerp(start: Size, end: Size, amount: number): Size;
  89796. }
  89797. }
  89798. declare module BABYLON {
  89799. /**
  89800. * Contains position and normal vectors for a vertex
  89801. */
  89802. export class PositionNormalVertex {
  89803. /** the position of the vertex (defaut: 0,0,0) */
  89804. position: Vector3;
  89805. /** the normal of the vertex (defaut: 0,1,0) */
  89806. normal: Vector3;
  89807. /**
  89808. * Creates a PositionNormalVertex
  89809. * @param position the position of the vertex (defaut: 0,0,0)
  89810. * @param normal the normal of the vertex (defaut: 0,1,0)
  89811. */
  89812. constructor(
  89813. /** the position of the vertex (defaut: 0,0,0) */
  89814. position?: Vector3,
  89815. /** the normal of the vertex (defaut: 0,1,0) */
  89816. normal?: Vector3);
  89817. /**
  89818. * Clones the PositionNormalVertex
  89819. * @returns the cloned PositionNormalVertex
  89820. */
  89821. clone(): PositionNormalVertex;
  89822. }
  89823. /**
  89824. * Contains position, normal and uv vectors for a vertex
  89825. */
  89826. export class PositionNormalTextureVertex {
  89827. /** the position of the vertex (defaut: 0,0,0) */
  89828. position: Vector3;
  89829. /** the normal of the vertex (defaut: 0,1,0) */
  89830. normal: Vector3;
  89831. /** the uv of the vertex (default: 0,0) */
  89832. uv: Vector2;
  89833. /**
  89834. * Creates a PositionNormalTextureVertex
  89835. * @param position the position of the vertex (defaut: 0,0,0)
  89836. * @param normal the normal of the vertex (defaut: 0,1,0)
  89837. * @param uv the uv of the vertex (default: 0,0)
  89838. */
  89839. constructor(
  89840. /** the position of the vertex (defaut: 0,0,0) */
  89841. position?: Vector3,
  89842. /** the normal of the vertex (defaut: 0,1,0) */
  89843. normal?: Vector3,
  89844. /** the uv of the vertex (default: 0,0) */
  89845. uv?: Vector2);
  89846. /**
  89847. * Clones the PositionNormalTextureVertex
  89848. * @returns the cloned PositionNormalTextureVertex
  89849. */
  89850. clone(): PositionNormalTextureVertex;
  89851. }
  89852. }
  89853. declare module BABYLON {
  89854. /**
  89855. * Enum defining the type of animations supported by InputBlock
  89856. */
  89857. export enum AnimatedInputBlockTypes {
  89858. /** No animation */
  89859. None = 0,
  89860. /** Time based animation. Will only work for floats */
  89861. Time = 1
  89862. }
  89863. }
  89864. declare module BABYLON {
  89865. /**
  89866. * Interface describing all the common properties and methods a shadow light needs to implement.
  89867. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  89868. * as well as binding the different shadow properties to the effects.
  89869. */
  89870. export interface IShadowLight extends Light {
  89871. /**
  89872. * The light id in the scene (used in scene.findLighById for instance)
  89873. */
  89874. id: string;
  89875. /**
  89876. * The position the shdow will be casted from.
  89877. */
  89878. position: Vector3;
  89879. /**
  89880. * In 2d mode (needCube being false), the direction used to cast the shadow.
  89881. */
  89882. direction: Vector3;
  89883. /**
  89884. * The transformed position. Position of the light in world space taking parenting in account.
  89885. */
  89886. transformedPosition: Vector3;
  89887. /**
  89888. * The transformed direction. Direction of the light in world space taking parenting in account.
  89889. */
  89890. transformedDirection: Vector3;
  89891. /**
  89892. * The friendly name of the light in the scene.
  89893. */
  89894. name: string;
  89895. /**
  89896. * Defines the shadow projection clipping minimum z value.
  89897. */
  89898. shadowMinZ: number;
  89899. /**
  89900. * Defines the shadow projection clipping maximum z value.
  89901. */
  89902. shadowMaxZ: number;
  89903. /**
  89904. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89905. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89906. */
  89907. computeTransformedInformation(): boolean;
  89908. /**
  89909. * Gets the scene the light belongs to.
  89910. * @returns The scene
  89911. */
  89912. getScene(): Scene;
  89913. /**
  89914. * Callback defining a custom Projection Matrix Builder.
  89915. * This can be used to override the default projection matrix computation.
  89916. */
  89917. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89918. /**
  89919. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89920. * @param matrix The materix to updated with the projection information
  89921. * @param viewMatrix The transform matrix of the light
  89922. * @param renderList The list of mesh to render in the map
  89923. * @returns The current light
  89924. */
  89925. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89926. /**
  89927. * Gets the current depth scale used in ESM.
  89928. * @returns The scale
  89929. */
  89930. getDepthScale(): number;
  89931. /**
  89932. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89933. * @returns true if a cube texture needs to be use
  89934. */
  89935. needCube(): boolean;
  89936. /**
  89937. * Detects if the projection matrix requires to be recomputed this frame.
  89938. * @returns true if it requires to be recomputed otherwise, false.
  89939. */
  89940. needProjectionMatrixCompute(): boolean;
  89941. /**
  89942. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89943. */
  89944. forceProjectionMatrixCompute(): void;
  89945. /**
  89946. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89947. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89948. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89949. */
  89950. getShadowDirection(faceIndex?: number): Vector3;
  89951. /**
  89952. * Gets the minZ used for shadow according to both the scene and the light.
  89953. * @param activeCamera The camera we are returning the min for
  89954. * @returns the depth min z
  89955. */
  89956. getDepthMinZ(activeCamera: Camera): number;
  89957. /**
  89958. * Gets the maxZ used for shadow according to both the scene and the light.
  89959. * @param activeCamera The camera we are returning the max for
  89960. * @returns the depth max z
  89961. */
  89962. getDepthMaxZ(activeCamera: Camera): number;
  89963. }
  89964. /**
  89965. * Base implementation IShadowLight
  89966. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  89967. */
  89968. export abstract class ShadowLight extends Light implements IShadowLight {
  89969. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  89970. protected _position: Vector3;
  89971. protected _setPosition(value: Vector3): void;
  89972. /**
  89973. * Sets the position the shadow will be casted from. Also use as the light position for both
  89974. * point and spot lights.
  89975. */
  89976. get position(): Vector3;
  89977. /**
  89978. * Sets the position the shadow will be casted from. Also use as the light position for both
  89979. * point and spot lights.
  89980. */
  89981. set position(value: Vector3);
  89982. protected _direction: Vector3;
  89983. protected _setDirection(value: Vector3): void;
  89984. /**
  89985. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  89986. * Also use as the light direction on spot and directional lights.
  89987. */
  89988. get direction(): Vector3;
  89989. /**
  89990. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  89991. * Also use as the light direction on spot and directional lights.
  89992. */
  89993. set direction(value: Vector3);
  89994. protected _shadowMinZ: number;
  89995. /**
  89996. * Gets the shadow projection clipping minimum z value.
  89997. */
  89998. get shadowMinZ(): number;
  89999. /**
  90000. * Sets the shadow projection clipping minimum z value.
  90001. */
  90002. set shadowMinZ(value: number);
  90003. protected _shadowMaxZ: number;
  90004. /**
  90005. * Sets the shadow projection clipping maximum z value.
  90006. */
  90007. get shadowMaxZ(): number;
  90008. /**
  90009. * Gets the shadow projection clipping maximum z value.
  90010. */
  90011. set shadowMaxZ(value: number);
  90012. /**
  90013. * Callback defining a custom Projection Matrix Builder.
  90014. * This can be used to override the default projection matrix computation.
  90015. */
  90016. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  90017. /**
  90018. * The transformed position. Position of the light in world space taking parenting in account.
  90019. */
  90020. transformedPosition: Vector3;
  90021. /**
  90022. * The transformed direction. Direction of the light in world space taking parenting in account.
  90023. */
  90024. transformedDirection: Vector3;
  90025. private _needProjectionMatrixCompute;
  90026. /**
  90027. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90028. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90029. */
  90030. computeTransformedInformation(): boolean;
  90031. /**
  90032. * Return the depth scale used for the shadow map.
  90033. * @returns the depth scale.
  90034. */
  90035. getDepthScale(): number;
  90036. /**
  90037. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90038. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90039. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90040. */
  90041. getShadowDirection(faceIndex?: number): Vector3;
  90042. /**
  90043. * Returns the ShadowLight absolute position in the World.
  90044. * @returns the position vector in world space
  90045. */
  90046. getAbsolutePosition(): Vector3;
  90047. /**
  90048. * Sets the ShadowLight direction toward the passed target.
  90049. * @param target The point to target in local space
  90050. * @returns the updated ShadowLight direction
  90051. */
  90052. setDirectionToTarget(target: Vector3): Vector3;
  90053. /**
  90054. * Returns the light rotation in euler definition.
  90055. * @returns the x y z rotation in local space.
  90056. */
  90057. getRotation(): Vector3;
  90058. /**
  90059. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90060. * @returns true if a cube texture needs to be use
  90061. */
  90062. needCube(): boolean;
  90063. /**
  90064. * Detects if the projection matrix requires to be recomputed this frame.
  90065. * @returns true if it requires to be recomputed otherwise, false.
  90066. */
  90067. needProjectionMatrixCompute(): boolean;
  90068. /**
  90069. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90070. */
  90071. forceProjectionMatrixCompute(): void;
  90072. /** @hidden */
  90073. _initCache(): void;
  90074. /** @hidden */
  90075. _isSynchronized(): boolean;
  90076. /**
  90077. * Computes the world matrix of the node
  90078. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90079. * @returns the world matrix
  90080. */
  90081. computeWorldMatrix(force?: boolean): Matrix;
  90082. /**
  90083. * Gets the minZ used for shadow according to both the scene and the light.
  90084. * @param activeCamera The camera we are returning the min for
  90085. * @returns the depth min z
  90086. */
  90087. getDepthMinZ(activeCamera: Camera): number;
  90088. /**
  90089. * Gets the maxZ used for shadow according to both the scene and the light.
  90090. * @param activeCamera The camera we are returning the max for
  90091. * @returns the depth max z
  90092. */
  90093. getDepthMaxZ(activeCamera: Camera): number;
  90094. /**
  90095. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90096. * @param matrix The materix to updated with the projection information
  90097. * @param viewMatrix The transform matrix of the light
  90098. * @param renderList The list of mesh to render in the map
  90099. * @returns The current light
  90100. */
  90101. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90102. }
  90103. }
  90104. declare module BABYLON {
  90105. /** @hidden */
  90106. export var packingFunctions: {
  90107. name: string;
  90108. shader: string;
  90109. };
  90110. }
  90111. declare module BABYLON {
  90112. /** @hidden */
  90113. export var bayerDitherFunctions: {
  90114. name: string;
  90115. shader: string;
  90116. };
  90117. }
  90118. declare module BABYLON {
  90119. /** @hidden */
  90120. export var shadowMapFragmentDeclaration: {
  90121. name: string;
  90122. shader: string;
  90123. };
  90124. }
  90125. declare module BABYLON {
  90126. /** @hidden */
  90127. export var clipPlaneFragmentDeclaration: {
  90128. name: string;
  90129. shader: string;
  90130. };
  90131. }
  90132. declare module BABYLON {
  90133. /** @hidden */
  90134. export var clipPlaneFragment: {
  90135. name: string;
  90136. shader: string;
  90137. };
  90138. }
  90139. declare module BABYLON {
  90140. /** @hidden */
  90141. export var shadowMapFragment: {
  90142. name: string;
  90143. shader: string;
  90144. };
  90145. }
  90146. declare module BABYLON {
  90147. /** @hidden */
  90148. export var shadowMapPixelShader: {
  90149. name: string;
  90150. shader: string;
  90151. };
  90152. }
  90153. declare module BABYLON {
  90154. /** @hidden */
  90155. export var bonesDeclaration: {
  90156. name: string;
  90157. shader: string;
  90158. };
  90159. }
  90160. declare module BABYLON {
  90161. /** @hidden */
  90162. export var morphTargetsVertexGlobalDeclaration: {
  90163. name: string;
  90164. shader: string;
  90165. };
  90166. }
  90167. declare module BABYLON {
  90168. /** @hidden */
  90169. export var morphTargetsVertexDeclaration: {
  90170. name: string;
  90171. shader: string;
  90172. };
  90173. }
  90174. declare module BABYLON {
  90175. /** @hidden */
  90176. export var instancesDeclaration: {
  90177. name: string;
  90178. shader: string;
  90179. };
  90180. }
  90181. declare module BABYLON {
  90182. /** @hidden */
  90183. export var helperFunctions: {
  90184. name: string;
  90185. shader: string;
  90186. };
  90187. }
  90188. declare module BABYLON {
  90189. /** @hidden */
  90190. export var shadowMapVertexDeclaration: {
  90191. name: string;
  90192. shader: string;
  90193. };
  90194. }
  90195. declare module BABYLON {
  90196. /** @hidden */
  90197. export var clipPlaneVertexDeclaration: {
  90198. name: string;
  90199. shader: string;
  90200. };
  90201. }
  90202. declare module BABYLON {
  90203. /** @hidden */
  90204. export var morphTargetsVertex: {
  90205. name: string;
  90206. shader: string;
  90207. };
  90208. }
  90209. declare module BABYLON {
  90210. /** @hidden */
  90211. export var instancesVertex: {
  90212. name: string;
  90213. shader: string;
  90214. };
  90215. }
  90216. declare module BABYLON {
  90217. /** @hidden */
  90218. export var bonesVertex: {
  90219. name: string;
  90220. shader: string;
  90221. };
  90222. }
  90223. declare module BABYLON {
  90224. /** @hidden */
  90225. export var shadowMapVertexNormalBias: {
  90226. name: string;
  90227. shader: string;
  90228. };
  90229. }
  90230. declare module BABYLON {
  90231. /** @hidden */
  90232. export var shadowMapVertexMetric: {
  90233. name: string;
  90234. shader: string;
  90235. };
  90236. }
  90237. declare module BABYLON {
  90238. /** @hidden */
  90239. export var clipPlaneVertex: {
  90240. name: string;
  90241. shader: string;
  90242. };
  90243. }
  90244. declare module BABYLON {
  90245. /** @hidden */
  90246. export var shadowMapVertexShader: {
  90247. name: string;
  90248. shader: string;
  90249. };
  90250. }
  90251. declare module BABYLON {
  90252. /** @hidden */
  90253. export var depthBoxBlurPixelShader: {
  90254. name: string;
  90255. shader: string;
  90256. };
  90257. }
  90258. declare module BABYLON {
  90259. /** @hidden */
  90260. export var shadowMapFragmentSoftTransparentShadow: {
  90261. name: string;
  90262. shader: string;
  90263. };
  90264. }
  90265. declare module BABYLON {
  90266. /**
  90267. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  90268. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  90269. */
  90270. export class EffectFallbacks implements IEffectFallbacks {
  90271. private _defines;
  90272. private _currentRank;
  90273. private _maxRank;
  90274. private _mesh;
  90275. /**
  90276. * Removes the fallback from the bound mesh.
  90277. */
  90278. unBindMesh(): void;
  90279. /**
  90280. * Adds a fallback on the specified property.
  90281. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90282. * @param define The name of the define in the shader
  90283. */
  90284. addFallback(rank: number, define: string): void;
  90285. /**
  90286. * Sets the mesh to use CPU skinning when needing to fallback.
  90287. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90288. * @param mesh The mesh to use the fallbacks.
  90289. */
  90290. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  90291. /**
  90292. * Checks to see if more fallbacks are still availible.
  90293. */
  90294. get hasMoreFallbacks(): boolean;
  90295. /**
  90296. * Removes the defines that should be removed when falling back.
  90297. * @param currentDefines defines the current define statements for the shader.
  90298. * @param effect defines the current effect we try to compile
  90299. * @returns The resulting defines with defines of the current rank removed.
  90300. */
  90301. reduce(currentDefines: string, effect: Effect): string;
  90302. }
  90303. }
  90304. declare module BABYLON {
  90305. /**
  90306. * Interface used to define Action
  90307. */
  90308. export interface IAction {
  90309. /**
  90310. * Trigger for the action
  90311. */
  90312. trigger: number;
  90313. /** Options of the trigger */
  90314. triggerOptions: any;
  90315. /**
  90316. * Gets the trigger parameters
  90317. * @returns the trigger parameters
  90318. */
  90319. getTriggerParameter(): any;
  90320. /**
  90321. * Internal only - executes current action event
  90322. * @hidden
  90323. */
  90324. _executeCurrent(evt?: ActionEvent): void;
  90325. /**
  90326. * Serialize placeholder for child classes
  90327. * @param parent of child
  90328. * @returns the serialized object
  90329. */
  90330. serialize(parent: any): any;
  90331. /**
  90332. * Internal only
  90333. * @hidden
  90334. */
  90335. _prepare(): void;
  90336. /**
  90337. * Internal only - manager for action
  90338. * @hidden
  90339. */
  90340. _actionManager: Nullable<AbstractActionManager>;
  90341. /**
  90342. * Adds action to chain of actions, may be a DoNothingAction
  90343. * @param action defines the next action to execute
  90344. * @returns The action passed in
  90345. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90346. */
  90347. then(action: IAction): IAction;
  90348. }
  90349. /**
  90350. * The action to be carried out following a trigger
  90351. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90352. */
  90353. export class Action implements IAction {
  90354. /** the trigger, with or without parameters, for the action */
  90355. triggerOptions: any;
  90356. /**
  90357. * Trigger for the action
  90358. */
  90359. trigger: number;
  90360. /**
  90361. * Internal only - manager for action
  90362. * @hidden
  90363. */
  90364. _actionManager: ActionManager;
  90365. private _nextActiveAction;
  90366. private _child;
  90367. private _condition?;
  90368. private _triggerParameter;
  90369. /**
  90370. * An event triggered prior to action being executed.
  90371. */
  90372. onBeforeExecuteObservable: Observable<Action>;
  90373. /**
  90374. * Creates a new Action
  90375. * @param triggerOptions the trigger, with or without parameters, for the action
  90376. * @param condition an optional determinant of action
  90377. */
  90378. constructor(
  90379. /** the trigger, with or without parameters, for the action */
  90380. triggerOptions: any, condition?: Condition);
  90381. /**
  90382. * Internal only
  90383. * @hidden
  90384. */
  90385. _prepare(): void;
  90386. /**
  90387. * Gets the trigger parameters
  90388. * @returns the trigger parameters
  90389. */
  90390. getTriggerParameter(): any;
  90391. /**
  90392. * Internal only - executes current action event
  90393. * @hidden
  90394. */
  90395. _executeCurrent(evt?: ActionEvent): void;
  90396. /**
  90397. * Execute placeholder for child classes
  90398. * @param evt optional action event
  90399. */
  90400. execute(evt?: ActionEvent): void;
  90401. /**
  90402. * Skips to next active action
  90403. */
  90404. skipToNextActiveAction(): void;
  90405. /**
  90406. * Adds action to chain of actions, may be a DoNothingAction
  90407. * @param action defines the next action to execute
  90408. * @returns The action passed in
  90409. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90410. */
  90411. then(action: Action): Action;
  90412. /**
  90413. * Internal only
  90414. * @hidden
  90415. */
  90416. _getProperty(propertyPath: string): string;
  90417. /**
  90418. * Internal only
  90419. * @hidden
  90420. */
  90421. _getEffectiveTarget(target: any, propertyPath: string): any;
  90422. /**
  90423. * Serialize placeholder for child classes
  90424. * @param parent of child
  90425. * @returns the serialized object
  90426. */
  90427. serialize(parent: any): any;
  90428. /**
  90429. * Internal only called by serialize
  90430. * @hidden
  90431. */
  90432. protected _serialize(serializedAction: any, parent?: any): any;
  90433. /**
  90434. * Internal only
  90435. * @hidden
  90436. */
  90437. static _SerializeValueAsString: (value: any) => string;
  90438. /**
  90439. * Internal only
  90440. * @hidden
  90441. */
  90442. static _GetTargetProperty: (target: Scene | Node) => {
  90443. name: string;
  90444. targetType: string;
  90445. value: string;
  90446. };
  90447. }
  90448. }
  90449. declare module BABYLON {
  90450. /**
  90451. * A Condition applied to an Action
  90452. */
  90453. export class Condition {
  90454. /**
  90455. * Internal only - manager for action
  90456. * @hidden
  90457. */
  90458. _actionManager: ActionManager;
  90459. /**
  90460. * Internal only
  90461. * @hidden
  90462. */
  90463. _evaluationId: number;
  90464. /**
  90465. * Internal only
  90466. * @hidden
  90467. */
  90468. _currentResult: boolean;
  90469. /**
  90470. * Creates a new Condition
  90471. * @param actionManager the manager of the action the condition is applied to
  90472. */
  90473. constructor(actionManager: ActionManager);
  90474. /**
  90475. * Check if the current condition is valid
  90476. * @returns a boolean
  90477. */
  90478. isValid(): boolean;
  90479. /**
  90480. * Internal only
  90481. * @hidden
  90482. */
  90483. _getProperty(propertyPath: string): string;
  90484. /**
  90485. * Internal only
  90486. * @hidden
  90487. */
  90488. _getEffectiveTarget(target: any, propertyPath: string): any;
  90489. /**
  90490. * Serialize placeholder for child classes
  90491. * @returns the serialized object
  90492. */
  90493. serialize(): any;
  90494. /**
  90495. * Internal only
  90496. * @hidden
  90497. */
  90498. protected _serialize(serializedCondition: any): any;
  90499. }
  90500. /**
  90501. * Defines specific conditional operators as extensions of Condition
  90502. */
  90503. export class ValueCondition extends Condition {
  90504. /** path to specify the property of the target the conditional operator uses */
  90505. propertyPath: string;
  90506. /** the value compared by the conditional operator against the current value of the property */
  90507. value: any;
  90508. /** the conditional operator, default ValueCondition.IsEqual */
  90509. operator: number;
  90510. /**
  90511. * Internal only
  90512. * @hidden
  90513. */
  90514. private static _IsEqual;
  90515. /**
  90516. * Internal only
  90517. * @hidden
  90518. */
  90519. private static _IsDifferent;
  90520. /**
  90521. * Internal only
  90522. * @hidden
  90523. */
  90524. private static _IsGreater;
  90525. /**
  90526. * Internal only
  90527. * @hidden
  90528. */
  90529. private static _IsLesser;
  90530. /**
  90531. * returns the number for IsEqual
  90532. */
  90533. static get IsEqual(): number;
  90534. /**
  90535. * Returns the number for IsDifferent
  90536. */
  90537. static get IsDifferent(): number;
  90538. /**
  90539. * Returns the number for IsGreater
  90540. */
  90541. static get IsGreater(): number;
  90542. /**
  90543. * Returns the number for IsLesser
  90544. */
  90545. static get IsLesser(): number;
  90546. /**
  90547. * Internal only The action manager for the condition
  90548. * @hidden
  90549. */
  90550. _actionManager: ActionManager;
  90551. /**
  90552. * Internal only
  90553. * @hidden
  90554. */
  90555. private _target;
  90556. /**
  90557. * Internal only
  90558. * @hidden
  90559. */
  90560. private _effectiveTarget;
  90561. /**
  90562. * Internal only
  90563. * @hidden
  90564. */
  90565. private _property;
  90566. /**
  90567. * Creates a new ValueCondition
  90568. * @param actionManager manager for the action the condition applies to
  90569. * @param target for the action
  90570. * @param propertyPath path to specify the property of the target the conditional operator uses
  90571. * @param value the value compared by the conditional operator against the current value of the property
  90572. * @param operator the conditional operator, default ValueCondition.IsEqual
  90573. */
  90574. constructor(actionManager: ActionManager, target: any,
  90575. /** path to specify the property of the target the conditional operator uses */
  90576. propertyPath: string,
  90577. /** the value compared by the conditional operator against the current value of the property */
  90578. value: any,
  90579. /** the conditional operator, default ValueCondition.IsEqual */
  90580. operator?: number);
  90581. /**
  90582. * Compares the given value with the property value for the specified conditional operator
  90583. * @returns the result of the comparison
  90584. */
  90585. isValid(): boolean;
  90586. /**
  90587. * Serialize the ValueCondition into a JSON compatible object
  90588. * @returns serialization object
  90589. */
  90590. serialize(): any;
  90591. /**
  90592. * Gets the name of the conditional operator for the ValueCondition
  90593. * @param operator the conditional operator
  90594. * @returns the name
  90595. */
  90596. static GetOperatorName(operator: number): string;
  90597. }
  90598. /**
  90599. * Defines a predicate condition as an extension of Condition
  90600. */
  90601. export class PredicateCondition extends Condition {
  90602. /** defines the predicate function used to validate the condition */
  90603. predicate: () => boolean;
  90604. /**
  90605. * Internal only - manager for action
  90606. * @hidden
  90607. */
  90608. _actionManager: ActionManager;
  90609. /**
  90610. * Creates a new PredicateCondition
  90611. * @param actionManager manager for the action the condition applies to
  90612. * @param predicate defines the predicate function used to validate the condition
  90613. */
  90614. constructor(actionManager: ActionManager,
  90615. /** defines the predicate function used to validate the condition */
  90616. predicate: () => boolean);
  90617. /**
  90618. * @returns the validity of the predicate condition
  90619. */
  90620. isValid(): boolean;
  90621. }
  90622. /**
  90623. * Defines a state condition as an extension of Condition
  90624. */
  90625. export class StateCondition extends Condition {
  90626. /** Value to compare with target state */
  90627. value: string;
  90628. /**
  90629. * Internal only - manager for action
  90630. * @hidden
  90631. */
  90632. _actionManager: ActionManager;
  90633. /**
  90634. * Internal only
  90635. * @hidden
  90636. */
  90637. private _target;
  90638. /**
  90639. * Creates a new StateCondition
  90640. * @param actionManager manager for the action the condition applies to
  90641. * @param target of the condition
  90642. * @param value to compare with target state
  90643. */
  90644. constructor(actionManager: ActionManager, target: any,
  90645. /** Value to compare with target state */
  90646. value: string);
  90647. /**
  90648. * Gets a boolean indicating if the current condition is met
  90649. * @returns the validity of the state
  90650. */
  90651. isValid(): boolean;
  90652. /**
  90653. * Serialize the StateCondition into a JSON compatible object
  90654. * @returns serialization object
  90655. */
  90656. serialize(): any;
  90657. }
  90658. }
  90659. declare module BABYLON {
  90660. /**
  90661. * This defines an action responsible to toggle a boolean once triggered.
  90662. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90663. */
  90664. export class SwitchBooleanAction extends Action {
  90665. /**
  90666. * The path to the boolean property in the target object
  90667. */
  90668. propertyPath: string;
  90669. private _target;
  90670. private _effectiveTarget;
  90671. private _property;
  90672. /**
  90673. * Instantiate the action
  90674. * @param triggerOptions defines the trigger options
  90675. * @param target defines the object containing the boolean
  90676. * @param propertyPath defines the path to the boolean property in the target object
  90677. * @param condition defines the trigger related conditions
  90678. */
  90679. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90680. /** @hidden */
  90681. _prepare(): void;
  90682. /**
  90683. * Execute the action toggle the boolean value.
  90684. */
  90685. execute(): void;
  90686. /**
  90687. * Serializes the actions and its related information.
  90688. * @param parent defines the object to serialize in
  90689. * @returns the serialized object
  90690. */
  90691. serialize(parent: any): any;
  90692. }
  90693. /**
  90694. * This defines an action responsible to set a the state field of the target
  90695. * to a desired value once triggered.
  90696. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90697. */
  90698. export class SetStateAction extends Action {
  90699. /**
  90700. * The value to store in the state field.
  90701. */
  90702. value: string;
  90703. private _target;
  90704. /**
  90705. * Instantiate the action
  90706. * @param triggerOptions defines the trigger options
  90707. * @param target defines the object containing the state property
  90708. * @param value defines the value to store in the state field
  90709. * @param condition defines the trigger related conditions
  90710. */
  90711. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90712. /**
  90713. * Execute the action and store the value on the target state property.
  90714. */
  90715. execute(): void;
  90716. /**
  90717. * Serializes the actions and its related information.
  90718. * @param parent defines the object to serialize in
  90719. * @returns the serialized object
  90720. */
  90721. serialize(parent: any): any;
  90722. }
  90723. /**
  90724. * This defines an action responsible to set a property of the target
  90725. * to a desired value once triggered.
  90726. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90727. */
  90728. export class SetValueAction extends Action {
  90729. /**
  90730. * The path of the property to set in the target.
  90731. */
  90732. propertyPath: string;
  90733. /**
  90734. * The value to set in the property
  90735. */
  90736. value: any;
  90737. private _target;
  90738. private _effectiveTarget;
  90739. private _property;
  90740. /**
  90741. * Instantiate the action
  90742. * @param triggerOptions defines the trigger options
  90743. * @param target defines the object containing the property
  90744. * @param propertyPath defines the path of the property to set in the target
  90745. * @param value defines the value to set in the property
  90746. * @param condition defines the trigger related conditions
  90747. */
  90748. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90749. /** @hidden */
  90750. _prepare(): void;
  90751. /**
  90752. * Execute the action and set the targetted property to the desired value.
  90753. */
  90754. execute(): void;
  90755. /**
  90756. * Serializes the actions and its related information.
  90757. * @param parent defines the object to serialize in
  90758. * @returns the serialized object
  90759. */
  90760. serialize(parent: any): any;
  90761. }
  90762. /**
  90763. * This defines an action responsible to increment the target value
  90764. * to a desired value once triggered.
  90765. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90766. */
  90767. export class IncrementValueAction extends Action {
  90768. /**
  90769. * The path of the property to increment in the target.
  90770. */
  90771. propertyPath: string;
  90772. /**
  90773. * The value we should increment the property by.
  90774. */
  90775. value: any;
  90776. private _target;
  90777. private _effectiveTarget;
  90778. private _property;
  90779. /**
  90780. * Instantiate the action
  90781. * @param triggerOptions defines the trigger options
  90782. * @param target defines the object containing the property
  90783. * @param propertyPath defines the path of the property to increment in the target
  90784. * @param value defines the value value we should increment the property by
  90785. * @param condition defines the trigger related conditions
  90786. */
  90787. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90788. /** @hidden */
  90789. _prepare(): void;
  90790. /**
  90791. * Execute the action and increment the target of the value amount.
  90792. */
  90793. execute(): void;
  90794. /**
  90795. * Serializes the actions and its related information.
  90796. * @param parent defines the object to serialize in
  90797. * @returns the serialized object
  90798. */
  90799. serialize(parent: any): any;
  90800. }
  90801. /**
  90802. * This defines an action responsible to start an animation once triggered.
  90803. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90804. */
  90805. export class PlayAnimationAction extends Action {
  90806. /**
  90807. * Where the animation should start (animation frame)
  90808. */
  90809. from: number;
  90810. /**
  90811. * Where the animation should stop (animation frame)
  90812. */
  90813. to: number;
  90814. /**
  90815. * Define if the animation should loop or stop after the first play.
  90816. */
  90817. loop?: boolean;
  90818. private _target;
  90819. /**
  90820. * Instantiate the action
  90821. * @param triggerOptions defines the trigger options
  90822. * @param target defines the target animation or animation name
  90823. * @param from defines from where the animation should start (animation frame)
  90824. * @param end defines where the animation should stop (animation frame)
  90825. * @param loop defines if the animation should loop or stop after the first play
  90826. * @param condition defines the trigger related conditions
  90827. */
  90828. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90829. /** @hidden */
  90830. _prepare(): void;
  90831. /**
  90832. * Execute the action and play the animation.
  90833. */
  90834. execute(): void;
  90835. /**
  90836. * Serializes the actions and its related information.
  90837. * @param parent defines the object to serialize in
  90838. * @returns the serialized object
  90839. */
  90840. serialize(parent: any): any;
  90841. }
  90842. /**
  90843. * This defines an action responsible to stop an animation once triggered.
  90844. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90845. */
  90846. export class StopAnimationAction extends Action {
  90847. private _target;
  90848. /**
  90849. * Instantiate the action
  90850. * @param triggerOptions defines the trigger options
  90851. * @param target defines the target animation or animation name
  90852. * @param condition defines the trigger related conditions
  90853. */
  90854. constructor(triggerOptions: any, target: any, condition?: Condition);
  90855. /** @hidden */
  90856. _prepare(): void;
  90857. /**
  90858. * Execute the action and stop the animation.
  90859. */
  90860. execute(): void;
  90861. /**
  90862. * Serializes the actions and its related information.
  90863. * @param parent defines the object to serialize in
  90864. * @returns the serialized object
  90865. */
  90866. serialize(parent: any): any;
  90867. }
  90868. /**
  90869. * This defines an action responsible that does nothing once triggered.
  90870. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90871. */
  90872. export class DoNothingAction extends Action {
  90873. /**
  90874. * Instantiate the action
  90875. * @param triggerOptions defines the trigger options
  90876. * @param condition defines the trigger related conditions
  90877. */
  90878. constructor(triggerOptions?: any, condition?: Condition);
  90879. /**
  90880. * Execute the action and do nothing.
  90881. */
  90882. execute(): void;
  90883. /**
  90884. * Serializes the actions and its related information.
  90885. * @param parent defines the object to serialize in
  90886. * @returns the serialized object
  90887. */
  90888. serialize(parent: any): any;
  90889. }
  90890. /**
  90891. * This defines an action responsible to trigger several actions once triggered.
  90892. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90893. */
  90894. export class CombineAction extends Action {
  90895. /**
  90896. * The list of aggregated animations to run.
  90897. */
  90898. children: Action[];
  90899. /**
  90900. * Instantiate the action
  90901. * @param triggerOptions defines the trigger options
  90902. * @param children defines the list of aggregated animations to run
  90903. * @param condition defines the trigger related conditions
  90904. */
  90905. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90906. /** @hidden */
  90907. _prepare(): void;
  90908. /**
  90909. * Execute the action and executes all the aggregated actions.
  90910. */
  90911. execute(evt: ActionEvent): void;
  90912. /**
  90913. * Serializes the actions and its related information.
  90914. * @param parent defines the object to serialize in
  90915. * @returns the serialized object
  90916. */
  90917. serialize(parent: any): any;
  90918. }
  90919. /**
  90920. * This defines an action responsible to run code (external event) once triggered.
  90921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90922. */
  90923. export class ExecuteCodeAction extends Action {
  90924. /**
  90925. * The callback function to run.
  90926. */
  90927. func: (evt: ActionEvent) => void;
  90928. /**
  90929. * Instantiate the action
  90930. * @param triggerOptions defines the trigger options
  90931. * @param func defines the callback function to run
  90932. * @param condition defines the trigger related conditions
  90933. */
  90934. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90935. /**
  90936. * Execute the action and run the attached code.
  90937. */
  90938. execute(evt: ActionEvent): void;
  90939. }
  90940. /**
  90941. * This defines an action responsible to set the parent property of the target once triggered.
  90942. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90943. */
  90944. export class SetParentAction extends Action {
  90945. private _parent;
  90946. private _target;
  90947. /**
  90948. * Instantiate the action
  90949. * @param triggerOptions defines the trigger options
  90950. * @param target defines the target containing the parent property
  90951. * @param parent defines from where the animation should start (animation frame)
  90952. * @param condition defines the trigger related conditions
  90953. */
  90954. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90955. /** @hidden */
  90956. _prepare(): void;
  90957. /**
  90958. * Execute the action and set the parent property.
  90959. */
  90960. execute(): void;
  90961. /**
  90962. * Serializes the actions and its related information.
  90963. * @param parent defines the object to serialize in
  90964. * @returns the serialized object
  90965. */
  90966. serialize(parent: any): any;
  90967. }
  90968. }
  90969. declare module BABYLON {
  90970. /**
  90971. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90972. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90973. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90974. */
  90975. export class ActionManager extends AbstractActionManager {
  90976. /**
  90977. * Nothing
  90978. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90979. */
  90980. static readonly NothingTrigger: number;
  90981. /**
  90982. * On pick
  90983. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90984. */
  90985. static readonly OnPickTrigger: number;
  90986. /**
  90987. * On left pick
  90988. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90989. */
  90990. static readonly OnLeftPickTrigger: number;
  90991. /**
  90992. * On right pick
  90993. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90994. */
  90995. static readonly OnRightPickTrigger: number;
  90996. /**
  90997. * On center pick
  90998. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90999. */
  91000. static readonly OnCenterPickTrigger: number;
  91001. /**
  91002. * On pick down
  91003. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91004. */
  91005. static readonly OnPickDownTrigger: number;
  91006. /**
  91007. * On double pick
  91008. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91009. */
  91010. static readonly OnDoublePickTrigger: number;
  91011. /**
  91012. * On pick up
  91013. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91014. */
  91015. static readonly OnPickUpTrigger: number;
  91016. /**
  91017. * On pick out.
  91018. * This trigger will only be raised if you also declared a OnPickDown
  91019. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91020. */
  91021. static readonly OnPickOutTrigger: number;
  91022. /**
  91023. * On long press
  91024. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91025. */
  91026. static readonly OnLongPressTrigger: number;
  91027. /**
  91028. * On pointer over
  91029. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91030. */
  91031. static readonly OnPointerOverTrigger: number;
  91032. /**
  91033. * On pointer out
  91034. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91035. */
  91036. static readonly OnPointerOutTrigger: number;
  91037. /**
  91038. * On every frame
  91039. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91040. */
  91041. static readonly OnEveryFrameTrigger: number;
  91042. /**
  91043. * On intersection enter
  91044. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91045. */
  91046. static readonly OnIntersectionEnterTrigger: number;
  91047. /**
  91048. * On intersection exit
  91049. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91050. */
  91051. static readonly OnIntersectionExitTrigger: number;
  91052. /**
  91053. * On key down
  91054. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91055. */
  91056. static readonly OnKeyDownTrigger: number;
  91057. /**
  91058. * On key up
  91059. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91060. */
  91061. static readonly OnKeyUpTrigger: number;
  91062. private _scene;
  91063. /**
  91064. * Creates a new action manager
  91065. * @param scene defines the hosting scene
  91066. */
  91067. constructor(scene: Scene);
  91068. /**
  91069. * Releases all associated resources
  91070. */
  91071. dispose(): void;
  91072. /**
  91073. * Gets hosting scene
  91074. * @returns the hosting scene
  91075. */
  91076. getScene(): Scene;
  91077. /**
  91078. * Does this action manager handles actions of any of the given triggers
  91079. * @param triggers defines the triggers to be tested
  91080. * @return a boolean indicating whether one (or more) of the triggers is handled
  91081. */
  91082. hasSpecificTriggers(triggers: number[]): boolean;
  91083. /**
  91084. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91085. * speed.
  91086. * @param triggerA defines the trigger to be tested
  91087. * @param triggerB defines the trigger to be tested
  91088. * @return a boolean indicating whether one (or more) of the triggers is handled
  91089. */
  91090. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91091. /**
  91092. * Does this action manager handles actions of a given trigger
  91093. * @param trigger defines the trigger to be tested
  91094. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91095. * @return whether the trigger is handled
  91096. */
  91097. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91098. /**
  91099. * Does this action manager has pointer triggers
  91100. */
  91101. get hasPointerTriggers(): boolean;
  91102. /**
  91103. * Does this action manager has pick triggers
  91104. */
  91105. get hasPickTriggers(): boolean;
  91106. /**
  91107. * Registers an action to this action manager
  91108. * @param action defines the action to be registered
  91109. * @return the action amended (prepared) after registration
  91110. */
  91111. registerAction(action: IAction): Nullable<IAction>;
  91112. /**
  91113. * Unregisters an action to this action manager
  91114. * @param action defines the action to be unregistered
  91115. * @return a boolean indicating whether the action has been unregistered
  91116. */
  91117. unregisterAction(action: IAction): Boolean;
  91118. /**
  91119. * Process a specific trigger
  91120. * @param trigger defines the trigger to process
  91121. * @param evt defines the event details to be processed
  91122. */
  91123. processTrigger(trigger: number, evt?: IActionEvent): void;
  91124. /** @hidden */
  91125. _getEffectiveTarget(target: any, propertyPath: string): any;
  91126. /** @hidden */
  91127. _getProperty(propertyPath: string): string;
  91128. /**
  91129. * Serialize this manager to a JSON object
  91130. * @param name defines the property name to store this manager
  91131. * @returns a JSON representation of this manager
  91132. */
  91133. serialize(name: string): any;
  91134. /**
  91135. * Creates a new ActionManager from a JSON data
  91136. * @param parsedActions defines the JSON data to read from
  91137. * @param object defines the hosting mesh
  91138. * @param scene defines the hosting scene
  91139. */
  91140. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91141. /**
  91142. * Get a trigger name by index
  91143. * @param trigger defines the trigger index
  91144. * @returns a trigger name
  91145. */
  91146. static GetTriggerName(trigger: number): string;
  91147. }
  91148. }
  91149. declare module BABYLON {
  91150. /**
  91151. * Class used to represent a sprite
  91152. * @see https://doc.babylonjs.com/babylon101/sprites
  91153. */
  91154. export class Sprite implements IAnimatable {
  91155. /** defines the name */
  91156. name: string;
  91157. /** Gets or sets the current world position */
  91158. position: Vector3;
  91159. /** Gets or sets the main color */
  91160. color: Color4;
  91161. /** Gets or sets the width */
  91162. width: number;
  91163. /** Gets or sets the height */
  91164. height: number;
  91165. /** Gets or sets rotation angle */
  91166. angle: number;
  91167. /** Gets or sets the cell index in the sprite sheet */
  91168. cellIndex: number;
  91169. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91170. cellRef: string;
  91171. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91172. invertU: boolean;
  91173. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91174. invertV: boolean;
  91175. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91176. disposeWhenFinishedAnimating: boolean;
  91177. /** Gets the list of attached animations */
  91178. animations: Nullable<Array<Animation>>;
  91179. /** Gets or sets a boolean indicating if the sprite can be picked */
  91180. isPickable: boolean;
  91181. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  91182. useAlphaForPicking: boolean;
  91183. /** @hidden */
  91184. _xOffset: number;
  91185. /** @hidden */
  91186. _yOffset: number;
  91187. /** @hidden */
  91188. _xSize: number;
  91189. /** @hidden */
  91190. _ySize: number;
  91191. /**
  91192. * Gets or sets the associated action manager
  91193. */
  91194. actionManager: Nullable<ActionManager>;
  91195. /**
  91196. * An event triggered when the control has been disposed
  91197. */
  91198. onDisposeObservable: Observable<Sprite>;
  91199. private _animationStarted;
  91200. private _loopAnimation;
  91201. private _fromIndex;
  91202. private _toIndex;
  91203. private _delay;
  91204. private _direction;
  91205. private _manager;
  91206. private _time;
  91207. private _onAnimationEnd;
  91208. /**
  91209. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91210. */
  91211. isVisible: boolean;
  91212. /**
  91213. * Gets or sets the sprite size
  91214. */
  91215. get size(): number;
  91216. set size(value: number);
  91217. /**
  91218. * Returns a boolean indicating if the animation is started
  91219. */
  91220. get animationStarted(): boolean;
  91221. /**
  91222. * Gets or sets the unique id of the sprite
  91223. */
  91224. uniqueId: number;
  91225. /**
  91226. * Gets the manager of this sprite
  91227. */
  91228. get manager(): ISpriteManager;
  91229. /**
  91230. * Creates a new Sprite
  91231. * @param name defines the name
  91232. * @param manager defines the manager
  91233. */
  91234. constructor(
  91235. /** defines the name */
  91236. name: string, manager: ISpriteManager);
  91237. /**
  91238. * Returns the string "Sprite"
  91239. * @returns "Sprite"
  91240. */
  91241. getClassName(): string;
  91242. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  91243. get fromIndex(): number;
  91244. set fromIndex(value: number);
  91245. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  91246. get toIndex(): number;
  91247. set toIndex(value: number);
  91248. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  91249. get loopAnimation(): boolean;
  91250. set loopAnimation(value: boolean);
  91251. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  91252. get delay(): number;
  91253. set delay(value: number);
  91254. /**
  91255. * Starts an animation
  91256. * @param from defines the initial key
  91257. * @param to defines the end key
  91258. * @param loop defines if the animation must loop
  91259. * @param delay defines the start delay (in ms)
  91260. * @param onAnimationEnd defines a callback to call when animation ends
  91261. */
  91262. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  91263. /** Stops current animation (if any) */
  91264. stopAnimation(): void;
  91265. /** @hidden */
  91266. _animate(deltaTime: number): void;
  91267. /** Release associated resources */
  91268. dispose(): void;
  91269. /**
  91270. * Serializes the sprite to a JSON object
  91271. * @returns the JSON object
  91272. */
  91273. serialize(): any;
  91274. /**
  91275. * Parses a JSON object to create a new sprite
  91276. * @param parsedSprite The JSON object to parse
  91277. * @param manager defines the hosting manager
  91278. * @returns the new sprite
  91279. */
  91280. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  91281. }
  91282. }
  91283. declare module BABYLON {
  91284. /**
  91285. * Information about the result of picking within a scene
  91286. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91287. */
  91288. export class PickingInfo {
  91289. /** @hidden */
  91290. _pickingUnavailable: boolean;
  91291. /**
  91292. * If the pick collided with an object
  91293. */
  91294. hit: boolean;
  91295. /**
  91296. * Distance away where the pick collided
  91297. */
  91298. distance: number;
  91299. /**
  91300. * The location of pick collision
  91301. */
  91302. pickedPoint: Nullable<Vector3>;
  91303. /**
  91304. * The mesh corresponding the the pick collision
  91305. */
  91306. pickedMesh: Nullable<AbstractMesh>;
  91307. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91308. bu: number;
  91309. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91310. bv: number;
  91311. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91312. faceId: number;
  91313. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91314. subMeshFaceId: number;
  91315. /** Id of the the submesh that was picked */
  91316. subMeshId: number;
  91317. /** If a sprite was picked, this will be the sprite the pick collided with */
  91318. pickedSprite: Nullable<Sprite>;
  91319. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  91320. thinInstanceIndex: number;
  91321. /**
  91322. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91323. */
  91324. originMesh: Nullable<AbstractMesh>;
  91325. /**
  91326. * The ray that was used to perform the picking.
  91327. */
  91328. ray: Nullable<Ray>;
  91329. /**
  91330. * Gets the normal correspodning to the face the pick collided with
  91331. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91332. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91333. * @returns The normal correspodning to the face the pick collided with
  91334. */
  91335. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91336. /**
  91337. * Gets the texture coordinates of where the pick occured
  91338. * @returns the vector containing the coordnates of the texture
  91339. */
  91340. getTextureCoordinates(): Nullable<Vector2>;
  91341. }
  91342. }
  91343. declare module BABYLON {
  91344. /**
  91345. * Class representing a ray with position and direction
  91346. */
  91347. export class Ray {
  91348. /** origin point */
  91349. origin: Vector3;
  91350. /** direction */
  91351. direction: Vector3;
  91352. /** length of the ray */
  91353. length: number;
  91354. private static readonly _TmpVector3;
  91355. private _tmpRay;
  91356. /**
  91357. * Creates a new ray
  91358. * @param origin origin point
  91359. * @param direction direction
  91360. * @param length length of the ray
  91361. */
  91362. constructor(
  91363. /** origin point */
  91364. origin: Vector3,
  91365. /** direction */
  91366. direction: Vector3,
  91367. /** length of the ray */
  91368. length?: number);
  91369. /**
  91370. * Checks if the ray intersects a box
  91371. * This does not account for the ray lenght by design to improve perfs.
  91372. * @param minimum bound of the box
  91373. * @param maximum bound of the box
  91374. * @param intersectionTreshold extra extend to be added to the box in all direction
  91375. * @returns if the box was hit
  91376. */
  91377. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  91378. /**
  91379. * Checks if the ray intersects a box
  91380. * This does not account for the ray lenght by design to improve perfs.
  91381. * @param box the bounding box to check
  91382. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91383. * @returns if the box was hit
  91384. */
  91385. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  91386. /**
  91387. * If the ray hits a sphere
  91388. * @param sphere the bounding sphere to check
  91389. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  91390. * @returns true if it hits the sphere
  91391. */
  91392. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  91393. /**
  91394. * If the ray hits a triange
  91395. * @param vertex0 triangle vertex
  91396. * @param vertex1 triangle vertex
  91397. * @param vertex2 triangle vertex
  91398. * @returns intersection information if hit
  91399. */
  91400. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  91401. /**
  91402. * Checks if ray intersects a plane
  91403. * @param plane the plane to check
  91404. * @returns the distance away it was hit
  91405. */
  91406. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  91407. /**
  91408. * Calculate the intercept of a ray on a given axis
  91409. * @param axis to check 'x' | 'y' | 'z'
  91410. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  91411. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  91412. */
  91413. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  91414. /**
  91415. * Checks if ray intersects a mesh
  91416. * @param mesh the mesh to check
  91417. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91418. * @returns picking info of the intersecton
  91419. */
  91420. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  91421. /**
  91422. * Checks if ray intersects a mesh
  91423. * @param meshes the meshes to check
  91424. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91425. * @param results array to store result in
  91426. * @returns Array of picking infos
  91427. */
  91428. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  91429. private _comparePickingInfo;
  91430. private static smallnum;
  91431. private static rayl;
  91432. /**
  91433. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  91434. * @param sega the first point of the segment to test the intersection against
  91435. * @param segb the second point of the segment to test the intersection against
  91436. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  91437. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  91438. */
  91439. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  91440. /**
  91441. * Update the ray from viewport position
  91442. * @param x position
  91443. * @param y y position
  91444. * @param viewportWidth viewport width
  91445. * @param viewportHeight viewport height
  91446. * @param world world matrix
  91447. * @param view view matrix
  91448. * @param projection projection matrix
  91449. * @returns this ray updated
  91450. */
  91451. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91452. /**
  91453. * Creates a ray with origin and direction of 0,0,0
  91454. * @returns the new ray
  91455. */
  91456. static Zero(): Ray;
  91457. /**
  91458. * Creates a new ray from screen space and viewport
  91459. * @param x position
  91460. * @param y y position
  91461. * @param viewportWidth viewport width
  91462. * @param viewportHeight viewport height
  91463. * @param world world matrix
  91464. * @param view view matrix
  91465. * @param projection projection matrix
  91466. * @returns new ray
  91467. */
  91468. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91469. /**
  91470. * 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
  91471. * transformed to the given world matrix.
  91472. * @param origin The origin point
  91473. * @param end The end point
  91474. * @param world a matrix to transform the ray to. Default is the identity matrix.
  91475. * @returns the new ray
  91476. */
  91477. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  91478. /**
  91479. * Transforms a ray by a matrix
  91480. * @param ray ray to transform
  91481. * @param matrix matrix to apply
  91482. * @returns the resulting new ray
  91483. */
  91484. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  91485. /**
  91486. * Transforms a ray by a matrix
  91487. * @param ray ray to transform
  91488. * @param matrix matrix to apply
  91489. * @param result ray to store result in
  91490. */
  91491. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  91492. /**
  91493. * Unproject a ray from screen space to object space
  91494. * @param sourceX defines the screen space x coordinate to use
  91495. * @param sourceY defines the screen space y coordinate to use
  91496. * @param viewportWidth defines the current width of the viewport
  91497. * @param viewportHeight defines the current height of the viewport
  91498. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  91499. * @param view defines the view matrix to use
  91500. * @param projection defines the projection matrix to use
  91501. */
  91502. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  91503. }
  91504. /**
  91505. * Type used to define predicate used to select faces when a mesh intersection is detected
  91506. */
  91507. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  91508. interface Scene {
  91509. /** @hidden */
  91510. _tempPickingRay: Nullable<Ray>;
  91511. /** @hidden */
  91512. _cachedRayForTransform: Ray;
  91513. /** @hidden */
  91514. _pickWithRayInverseMatrix: Matrix;
  91515. /** @hidden */
  91516. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91517. /** @hidden */
  91518. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91519. /** @hidden */
  91520. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91521. }
  91522. }
  91523. declare module BABYLON {
  91524. /**
  91525. * Groups all the scene component constants in one place to ease maintenance.
  91526. * @hidden
  91527. */
  91528. export class SceneComponentConstants {
  91529. static readonly NAME_EFFECTLAYER: string;
  91530. static readonly NAME_LAYER: string;
  91531. static readonly NAME_LENSFLARESYSTEM: string;
  91532. static readonly NAME_BOUNDINGBOXRENDERER: string;
  91533. static readonly NAME_PARTICLESYSTEM: string;
  91534. static readonly NAME_GAMEPAD: string;
  91535. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  91536. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  91537. static readonly NAME_PREPASSRENDERER: string;
  91538. static readonly NAME_DEPTHRENDERER: string;
  91539. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  91540. static readonly NAME_SPRITE: string;
  91541. static readonly NAME_SUBSURFACE: string;
  91542. static readonly NAME_OUTLINERENDERER: string;
  91543. static readonly NAME_PROCEDURALTEXTURE: string;
  91544. static readonly NAME_SHADOWGENERATOR: string;
  91545. static readonly NAME_OCTREE: string;
  91546. static readonly NAME_PHYSICSENGINE: string;
  91547. static readonly NAME_AUDIO: string;
  91548. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  91549. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91550. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  91551. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91552. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  91553. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  91554. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  91555. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  91556. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  91557. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  91558. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  91559. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  91560. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  91561. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  91562. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  91563. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  91564. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  91565. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  91566. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  91567. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  91568. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  91569. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  91570. static readonly STEP_AFTERRENDER_AUDIO: number;
  91571. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  91572. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  91573. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  91574. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  91575. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  91576. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  91577. static readonly STEP_POINTERMOVE_SPRITE: number;
  91578. static readonly STEP_POINTERDOWN_SPRITE: number;
  91579. static readonly STEP_POINTERUP_SPRITE: number;
  91580. }
  91581. /**
  91582. * This represents a scene component.
  91583. *
  91584. * This is used to decouple the dependency the scene is having on the different workloads like
  91585. * layers, post processes...
  91586. */
  91587. export interface ISceneComponent {
  91588. /**
  91589. * The name of the component. Each component must have a unique name.
  91590. */
  91591. name: string;
  91592. /**
  91593. * The scene the component belongs to.
  91594. */
  91595. scene: Scene;
  91596. /**
  91597. * Register the component to one instance of a scene.
  91598. */
  91599. register(): void;
  91600. /**
  91601. * Rebuilds the elements related to this component in case of
  91602. * context lost for instance.
  91603. */
  91604. rebuild(): void;
  91605. /**
  91606. * Disposes the component and the associated ressources.
  91607. */
  91608. dispose(): void;
  91609. }
  91610. /**
  91611. * This represents a SERIALIZABLE scene component.
  91612. *
  91613. * This extends Scene Component to add Serialization methods on top.
  91614. */
  91615. export interface ISceneSerializableComponent extends ISceneComponent {
  91616. /**
  91617. * Adds all the elements from the container to the scene
  91618. * @param container the container holding the elements
  91619. */
  91620. addFromContainer(container: AbstractScene): void;
  91621. /**
  91622. * Removes all the elements in the container from the scene
  91623. * @param container contains the elements to remove
  91624. * @param dispose if the removed element should be disposed (default: false)
  91625. */
  91626. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91627. /**
  91628. * Serializes the component data to the specified json object
  91629. * @param serializationObject The object to serialize to
  91630. */
  91631. serialize(serializationObject: any): void;
  91632. }
  91633. /**
  91634. * Strong typing of a Mesh related stage step action
  91635. */
  91636. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91637. /**
  91638. * Strong typing of a Evaluate Sub Mesh related stage step action
  91639. */
  91640. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91641. /**
  91642. * Strong typing of a pre active Mesh related stage step action
  91643. */
  91644. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  91645. /**
  91646. * Strong typing of a Camera related stage step action
  91647. */
  91648. export type CameraStageAction = (camera: Camera) => void;
  91649. /**
  91650. * Strong typing of a Camera Frame buffer related stage step action
  91651. */
  91652. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91653. /**
  91654. * Strong typing of a Render Target related stage step action
  91655. */
  91656. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91657. /**
  91658. * Strong typing of a RenderingGroup related stage step action
  91659. */
  91660. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91661. /**
  91662. * Strong typing of a Mesh Render related stage step action
  91663. */
  91664. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91665. /**
  91666. * Strong typing of a simple stage step action
  91667. */
  91668. export type SimpleStageAction = () => void;
  91669. /**
  91670. * Strong typing of a render target action.
  91671. */
  91672. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  91673. /**
  91674. * Strong typing of a pointer move action.
  91675. */
  91676. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  91677. /**
  91678. * Strong typing of a pointer up/down action.
  91679. */
  91680. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  91681. /**
  91682. * Representation of a stage in the scene (Basically a list of ordered steps)
  91683. * @hidden
  91684. */
  91685. export class Stage<T extends Function> extends Array<{
  91686. index: number;
  91687. component: ISceneComponent;
  91688. action: T;
  91689. }> {
  91690. /**
  91691. * Hide ctor from the rest of the world.
  91692. * @param items The items to add.
  91693. */
  91694. private constructor();
  91695. /**
  91696. * Creates a new Stage.
  91697. * @returns A new instance of a Stage
  91698. */
  91699. static Create<T extends Function>(): Stage<T>;
  91700. /**
  91701. * Registers a step in an ordered way in the targeted stage.
  91702. * @param index Defines the position to register the step in
  91703. * @param component Defines the component attached to the step
  91704. * @param action Defines the action to launch during the step
  91705. */
  91706. registerStep(index: number, component: ISceneComponent, action: T): void;
  91707. /**
  91708. * Clears all the steps from the stage.
  91709. */
  91710. clear(): void;
  91711. }
  91712. }
  91713. declare module BABYLON {
  91714. interface Scene {
  91715. /** @hidden */
  91716. _pointerOverSprite: Nullable<Sprite>;
  91717. /** @hidden */
  91718. _pickedDownSprite: Nullable<Sprite>;
  91719. /** @hidden */
  91720. _tempSpritePickingRay: Nullable<Ray>;
  91721. /**
  91722. * All of the sprite managers added to this scene
  91723. * @see https://doc.babylonjs.com/babylon101/sprites
  91724. */
  91725. spriteManagers: Array<ISpriteManager>;
  91726. /**
  91727. * An event triggered when sprites rendering is about to start
  91728. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91729. */
  91730. onBeforeSpritesRenderingObservable: Observable<Scene>;
  91731. /**
  91732. * An event triggered when sprites rendering is done
  91733. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91734. */
  91735. onAfterSpritesRenderingObservable: Observable<Scene>;
  91736. /** @hidden */
  91737. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91738. /** Launch a ray to try to pick a sprite in the scene
  91739. * @param x position on screen
  91740. * @param y position on screen
  91741. * @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
  91742. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91743. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91744. * @returns a PickingInfo
  91745. */
  91746. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91747. /** Use the given ray to pick a sprite in the scene
  91748. * @param ray The ray (in world space) to use to pick meshes
  91749. * @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
  91750. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91751. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91752. * @returns a PickingInfo
  91753. */
  91754. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91755. /** @hidden */
  91756. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91757. /** Launch a ray to try to pick sprites in the scene
  91758. * @param x position on screen
  91759. * @param y position on screen
  91760. * @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
  91761. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91762. * @returns a PickingInfo array
  91763. */
  91764. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91765. /** Use the given ray to pick sprites in the scene
  91766. * @param ray The ray (in world space) to use to pick meshes
  91767. * @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
  91768. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91769. * @returns a PickingInfo array
  91770. */
  91771. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91772. /**
  91773. * Force the sprite under the pointer
  91774. * @param sprite defines the sprite to use
  91775. */
  91776. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  91777. /**
  91778. * Gets the sprite under the pointer
  91779. * @returns a Sprite or null if no sprite is under the pointer
  91780. */
  91781. getPointerOverSprite(): Nullable<Sprite>;
  91782. }
  91783. /**
  91784. * Defines the sprite scene component responsible to manage sprites
  91785. * in a given scene.
  91786. */
  91787. export class SpriteSceneComponent implements ISceneComponent {
  91788. /**
  91789. * The component name helpfull to identify the component in the list of scene components.
  91790. */
  91791. readonly name: string;
  91792. /**
  91793. * The scene the component belongs to.
  91794. */
  91795. scene: Scene;
  91796. /** @hidden */
  91797. private _spritePredicate;
  91798. /**
  91799. * Creates a new instance of the component for the given scene
  91800. * @param scene Defines the scene to register the component in
  91801. */
  91802. constructor(scene: Scene);
  91803. /**
  91804. * Registers the component in a given scene
  91805. */
  91806. register(): void;
  91807. /**
  91808. * Rebuilds the elements related to this component in case of
  91809. * context lost for instance.
  91810. */
  91811. rebuild(): void;
  91812. /**
  91813. * Disposes the component and the associated ressources.
  91814. */
  91815. dispose(): void;
  91816. private _pickSpriteButKeepRay;
  91817. private _pointerMove;
  91818. private _pointerDown;
  91819. private _pointerUp;
  91820. }
  91821. }
  91822. declare module BABYLON {
  91823. /** @hidden */
  91824. export var fogFragmentDeclaration: {
  91825. name: string;
  91826. shader: string;
  91827. };
  91828. }
  91829. declare module BABYLON {
  91830. /** @hidden */
  91831. export var fogFragment: {
  91832. name: string;
  91833. shader: string;
  91834. };
  91835. }
  91836. declare module BABYLON {
  91837. /** @hidden */
  91838. export var imageProcessingCompatibility: {
  91839. name: string;
  91840. shader: string;
  91841. };
  91842. }
  91843. declare module BABYLON {
  91844. /** @hidden */
  91845. export var spritesPixelShader: {
  91846. name: string;
  91847. shader: string;
  91848. };
  91849. }
  91850. declare module BABYLON {
  91851. /** @hidden */
  91852. export var fogVertexDeclaration: {
  91853. name: string;
  91854. shader: string;
  91855. };
  91856. }
  91857. declare module BABYLON {
  91858. /** @hidden */
  91859. export var spritesVertexShader: {
  91860. name: string;
  91861. shader: string;
  91862. };
  91863. }
  91864. declare module BABYLON {
  91865. /**
  91866. * Defines the minimum interface to fullfil in order to be a sprite manager.
  91867. */
  91868. export interface ISpriteManager extends IDisposable {
  91869. /**
  91870. * Gets manager's name
  91871. */
  91872. name: string;
  91873. /**
  91874. * Restricts the camera to viewing objects with the same layerMask.
  91875. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  91876. */
  91877. layerMask: number;
  91878. /**
  91879. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91880. */
  91881. isPickable: boolean;
  91882. /**
  91883. * Gets the hosting scene
  91884. */
  91885. scene: Scene;
  91886. /**
  91887. * Specifies the rendering group id for this mesh (0 by default)
  91888. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91889. */
  91890. renderingGroupId: number;
  91891. /**
  91892. * Defines the list of sprites managed by the manager.
  91893. */
  91894. sprites: Array<Sprite>;
  91895. /**
  91896. * Gets or sets the spritesheet texture
  91897. */
  91898. texture: Texture;
  91899. /** Defines the default width of a cell in the spritesheet */
  91900. cellWidth: number;
  91901. /** Defines the default height of a cell in the spritesheet */
  91902. cellHeight: number;
  91903. /**
  91904. * Tests the intersection of a sprite with a specific ray.
  91905. * @param ray The ray we are sending to test the collision
  91906. * @param camera The camera space we are sending rays in
  91907. * @param predicate A predicate allowing excluding sprites from the list of object to test
  91908. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91909. * @returns picking info or null.
  91910. */
  91911. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91912. /**
  91913. * Intersects the sprites with a ray
  91914. * @param ray defines the ray to intersect with
  91915. * @param camera defines the current active camera
  91916. * @param predicate defines a predicate used to select candidate sprites
  91917. * @returns null if no hit or a PickingInfo array
  91918. */
  91919. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91920. /**
  91921. * Renders the list of sprites on screen.
  91922. */
  91923. render(): void;
  91924. }
  91925. /**
  91926. * Class used to manage multiple sprites on the same spritesheet
  91927. * @see https://doc.babylonjs.com/babylon101/sprites
  91928. */
  91929. export class SpriteManager implements ISpriteManager {
  91930. /** defines the manager's name */
  91931. name: string;
  91932. /** Define the Url to load snippets */
  91933. static SnippetUrl: string;
  91934. /** Snippet ID if the manager was created from the snippet server */
  91935. snippetId: string;
  91936. /** Gets the list of sprites */
  91937. sprites: Sprite[];
  91938. /** Gets or sets the rendering group id (0 by default) */
  91939. renderingGroupId: number;
  91940. /** Gets or sets camera layer mask */
  91941. layerMask: number;
  91942. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  91943. fogEnabled: boolean;
  91944. /** Gets or sets a boolean indicating if the sprites are pickable */
  91945. isPickable: boolean;
  91946. /** Defines the default width of a cell in the spritesheet */
  91947. cellWidth: number;
  91948. /** Defines the default height of a cell in the spritesheet */
  91949. cellHeight: number;
  91950. /** Associative array from JSON sprite data file */
  91951. private _cellData;
  91952. /** Array of sprite names from JSON sprite data file */
  91953. private _spriteMap;
  91954. /** True when packed cell data from JSON file is ready*/
  91955. private _packedAndReady;
  91956. private _textureContent;
  91957. private _useInstancing;
  91958. /**
  91959. * An event triggered when the manager is disposed.
  91960. */
  91961. onDisposeObservable: Observable<SpriteManager>;
  91962. private _onDisposeObserver;
  91963. /**
  91964. * Callback called when the manager is disposed
  91965. */
  91966. set onDispose(callback: () => void);
  91967. private _capacity;
  91968. private _fromPacked;
  91969. private _spriteTexture;
  91970. private _epsilon;
  91971. private _scene;
  91972. private _vertexData;
  91973. private _buffer;
  91974. private _vertexBuffers;
  91975. private _spriteBuffer;
  91976. private _indexBuffer;
  91977. private _effectBase;
  91978. private _effectFog;
  91979. private _vertexBufferSize;
  91980. /**
  91981. * Gets or sets the unique id of the sprite
  91982. */
  91983. uniqueId: number;
  91984. /**
  91985. * Gets the array of sprites
  91986. */
  91987. get children(): Sprite[];
  91988. /**
  91989. * Gets the hosting scene
  91990. */
  91991. get scene(): Scene;
  91992. /**
  91993. * Gets the capacity of the manager
  91994. */
  91995. get capacity(): number;
  91996. /**
  91997. * Gets or sets the spritesheet texture
  91998. */
  91999. get texture(): Texture;
  92000. set texture(value: Texture);
  92001. private _blendMode;
  92002. /**
  92003. * Blend mode use to render the particle, it can be any of
  92004. * the static Constants.ALPHA_x properties provided in this class.
  92005. * Default value is Constants.ALPHA_COMBINE
  92006. */
  92007. get blendMode(): number;
  92008. set blendMode(blendMode: number);
  92009. /** Disables writing to the depth buffer when rendering the sprites.
  92010. * It can be handy to disable depth writing when using textures without alpha channel
  92011. * and setting some specific blend modes.
  92012. */
  92013. disableDepthWrite: boolean;
  92014. /**
  92015. * Creates a new sprite manager
  92016. * @param name defines the manager's name
  92017. * @param imgUrl defines the sprite sheet url
  92018. * @param capacity defines the maximum allowed number of sprites
  92019. * @param cellSize defines the size of a sprite cell
  92020. * @param scene defines the hosting scene
  92021. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  92022. * @param samplingMode defines the smapling mode to use with spritesheet
  92023. * @param fromPacked set to false; do not alter
  92024. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  92025. */
  92026. constructor(
  92027. /** defines the manager's name */
  92028. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  92029. /**
  92030. * Returns the string "SpriteManager"
  92031. * @returns "SpriteManager"
  92032. */
  92033. getClassName(): string;
  92034. private _makePacked;
  92035. private _appendSpriteVertex;
  92036. private _checkTextureAlpha;
  92037. /**
  92038. * Intersects the sprites with a ray
  92039. * @param ray defines the ray to intersect with
  92040. * @param camera defines the current active camera
  92041. * @param predicate defines a predicate used to select candidate sprites
  92042. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  92043. * @returns null if no hit or a PickingInfo
  92044. */
  92045. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  92046. /**
  92047. * Intersects the sprites with a ray
  92048. * @param ray defines the ray to intersect with
  92049. * @param camera defines the current active camera
  92050. * @param predicate defines a predicate used to select candidate sprites
  92051. * @returns null if no hit or a PickingInfo array
  92052. */
  92053. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  92054. /**
  92055. * Render all child sprites
  92056. */
  92057. render(): void;
  92058. /**
  92059. * Release associated resources
  92060. */
  92061. dispose(): void;
  92062. /**
  92063. * Serializes the sprite manager to a JSON object
  92064. * @param serializeTexture defines if the texture must be serialized as well
  92065. * @returns the JSON object
  92066. */
  92067. serialize(serializeTexture?: boolean): any;
  92068. /**
  92069. * Parses a JSON object to create a new sprite manager.
  92070. * @param parsedManager The JSON object to parse
  92071. * @param scene The scene to create the sprite managerin
  92072. * @param rootUrl The root url to use to load external dependencies like texture
  92073. * @returns the new sprite manager
  92074. */
  92075. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  92076. /**
  92077. * Creates a sprite manager from a snippet saved in a remote file
  92078. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  92079. * @param url defines the url to load from
  92080. * @param scene defines the hosting scene
  92081. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92082. * @returns a promise that will resolve to the new sprite manager
  92083. */
  92084. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  92085. /**
  92086. * Creates a sprite manager from a snippet saved by the sprite editor
  92087. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  92088. * @param scene defines the hosting scene
  92089. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92090. * @returns a promise that will resolve to the new sprite manager
  92091. */
  92092. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  92093. }
  92094. }
  92095. declare module BABYLON {
  92096. /** Interface used by value gradients (color, factor, ...) */
  92097. export interface IValueGradient {
  92098. /**
  92099. * Gets or sets the gradient value (between 0 and 1)
  92100. */
  92101. gradient: number;
  92102. }
  92103. /** Class used to store color4 gradient */
  92104. export class ColorGradient implements IValueGradient {
  92105. /**
  92106. * Gets or sets the gradient value (between 0 and 1)
  92107. */
  92108. gradient: number;
  92109. /**
  92110. * Gets or sets first associated color
  92111. */
  92112. color1: Color4;
  92113. /**
  92114. * Gets or sets second associated color
  92115. */
  92116. color2?: Color4 | undefined;
  92117. /**
  92118. * Creates a new color4 gradient
  92119. * @param gradient gets or sets the gradient value (between 0 and 1)
  92120. * @param color1 gets or sets first associated color
  92121. * @param color2 gets or sets first second color
  92122. */
  92123. constructor(
  92124. /**
  92125. * Gets or sets the gradient value (between 0 and 1)
  92126. */
  92127. gradient: number,
  92128. /**
  92129. * Gets or sets first associated color
  92130. */
  92131. color1: Color4,
  92132. /**
  92133. * Gets or sets second associated color
  92134. */
  92135. color2?: Color4 | undefined);
  92136. /**
  92137. * Will get a color picked randomly between color1 and color2.
  92138. * If color2 is undefined then color1 will be used
  92139. * @param result defines the target Color4 to store the result in
  92140. */
  92141. getColorToRef(result: Color4): void;
  92142. }
  92143. /** Class used to store color 3 gradient */
  92144. export class Color3Gradient implements IValueGradient {
  92145. /**
  92146. * Gets or sets the gradient value (between 0 and 1)
  92147. */
  92148. gradient: number;
  92149. /**
  92150. * Gets or sets the associated color
  92151. */
  92152. color: Color3;
  92153. /**
  92154. * Creates a new color3 gradient
  92155. * @param gradient gets or sets the gradient value (between 0 and 1)
  92156. * @param color gets or sets associated color
  92157. */
  92158. constructor(
  92159. /**
  92160. * Gets or sets the gradient value (between 0 and 1)
  92161. */
  92162. gradient: number,
  92163. /**
  92164. * Gets or sets the associated color
  92165. */
  92166. color: Color3);
  92167. }
  92168. /** Class used to store factor gradient */
  92169. export class FactorGradient implements IValueGradient {
  92170. /**
  92171. * Gets or sets the gradient value (between 0 and 1)
  92172. */
  92173. gradient: number;
  92174. /**
  92175. * Gets or sets first associated factor
  92176. */
  92177. factor1: number;
  92178. /**
  92179. * Gets or sets second associated factor
  92180. */
  92181. factor2?: number | undefined;
  92182. /**
  92183. * Creates a new factor gradient
  92184. * @param gradient gets or sets the gradient value (between 0 and 1)
  92185. * @param factor1 gets or sets first associated factor
  92186. * @param factor2 gets or sets second associated factor
  92187. */
  92188. constructor(
  92189. /**
  92190. * Gets or sets the gradient value (between 0 and 1)
  92191. */
  92192. gradient: number,
  92193. /**
  92194. * Gets or sets first associated factor
  92195. */
  92196. factor1: number,
  92197. /**
  92198. * Gets or sets second associated factor
  92199. */
  92200. factor2?: number | undefined);
  92201. /**
  92202. * Will get a number picked randomly between factor1 and factor2.
  92203. * If factor2 is undefined then factor1 will be used
  92204. * @returns the picked number
  92205. */
  92206. getFactor(): number;
  92207. }
  92208. /**
  92209. * Helper used to simplify some generic gradient tasks
  92210. */
  92211. export class GradientHelper {
  92212. /**
  92213. * Gets the current gradient from an array of IValueGradient
  92214. * @param ratio defines the current ratio to get
  92215. * @param gradients defines the array of IValueGradient
  92216. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  92217. */
  92218. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  92219. }
  92220. }
  92221. declare module BABYLON {
  92222. interface ThinEngine {
  92223. /**
  92224. * Creates a raw texture
  92225. * @param data defines the data to store in the texture
  92226. * @param width defines the width of the texture
  92227. * @param height defines the height of the texture
  92228. * @param format defines the format of the data
  92229. * @param generateMipMaps defines if the engine should generate the mip levels
  92230. * @param invertY defines if data must be stored with Y axis inverted
  92231. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  92232. * @param compression defines the compression used (null by default)
  92233. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92234. * @returns the raw texture inside an InternalTexture
  92235. */
  92236. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  92237. /**
  92238. * Update a raw texture
  92239. * @param texture defines the texture to update
  92240. * @param data defines the data to store in the texture
  92241. * @param format defines the format of the data
  92242. * @param invertY defines if data must be stored with Y axis inverted
  92243. */
  92244. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92245. /**
  92246. * Update a raw texture
  92247. * @param texture defines the texture to update
  92248. * @param data defines the data to store in the texture
  92249. * @param format defines the format of the data
  92250. * @param invertY defines if data must be stored with Y axis inverted
  92251. * @param compression defines the compression used (null by default)
  92252. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92253. */
  92254. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  92255. /**
  92256. * Creates a new raw cube texture
  92257. * @param data defines the array of data to use to create each face
  92258. * @param size defines the size of the textures
  92259. * @param format defines the format of the data
  92260. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92261. * @param generateMipMaps defines if the engine should generate the mip levels
  92262. * @param invertY defines if data must be stored with Y axis inverted
  92263. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92264. * @param compression defines the compression used (null by default)
  92265. * @returns the cube texture as an InternalTexture
  92266. */
  92267. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  92268. /**
  92269. * Update a raw cube texture
  92270. * @param texture defines the texture to udpdate
  92271. * @param data defines the data to store
  92272. * @param format defines the data format
  92273. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92274. * @param invertY defines if data must be stored with Y axis inverted
  92275. */
  92276. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  92277. /**
  92278. * Update a raw cube texture
  92279. * @param texture defines the texture to udpdate
  92280. * @param data defines the data to store
  92281. * @param format defines the data format
  92282. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92283. * @param invertY defines if data must be stored with Y axis inverted
  92284. * @param compression defines the compression used (null by default)
  92285. */
  92286. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  92287. /**
  92288. * Update a raw cube texture
  92289. * @param texture defines the texture to udpdate
  92290. * @param data defines the data to store
  92291. * @param format defines the data format
  92292. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92293. * @param invertY defines if data must be stored with Y axis inverted
  92294. * @param compression defines the compression used (null by default)
  92295. * @param level defines which level of the texture to update
  92296. */
  92297. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  92298. /**
  92299. * Creates a new raw cube texture from a specified url
  92300. * @param url defines the url where the data is located
  92301. * @param scene defines the current scene
  92302. * @param size defines the size of the textures
  92303. * @param format defines the format of the data
  92304. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92305. * @param noMipmap defines if the engine should avoid generating the mip levels
  92306. * @param callback defines a callback used to extract texture data from loaded data
  92307. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92308. * @param onLoad defines a callback called when texture is loaded
  92309. * @param onError defines a callback called if there is an error
  92310. * @returns the cube texture as an InternalTexture
  92311. */
  92312. 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;
  92313. /**
  92314. * Creates a new raw cube texture from a specified url
  92315. * @param url defines the url where the data is located
  92316. * @param scene defines the current scene
  92317. * @param size defines the size of the textures
  92318. * @param format defines the format of the data
  92319. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92320. * @param noMipmap defines if the engine should avoid generating the mip levels
  92321. * @param callback defines a callback used to extract texture data from loaded data
  92322. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92323. * @param onLoad defines a callback called when texture is loaded
  92324. * @param onError defines a callback called if there is an error
  92325. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92326. * @param invertY defines if data must be stored with Y axis inverted
  92327. * @returns the cube texture as an InternalTexture
  92328. */
  92329. 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;
  92330. /**
  92331. * Creates a new raw 3D texture
  92332. * @param data defines the data used to create the texture
  92333. * @param width defines the width of the texture
  92334. * @param height defines the height of the texture
  92335. * @param depth defines the depth of the texture
  92336. * @param format defines the format of the texture
  92337. * @param generateMipMaps defines if the engine must generate mip levels
  92338. * @param invertY defines if data must be stored with Y axis inverted
  92339. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92340. * @param compression defines the compressed used (can be null)
  92341. * @param textureType defines the compressed used (can be null)
  92342. * @returns a new raw 3D texture (stored in an InternalTexture)
  92343. */
  92344. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92345. /**
  92346. * Update a raw 3D texture
  92347. * @param texture defines the texture to update
  92348. * @param data defines the data to store
  92349. * @param format defines the data format
  92350. * @param invertY defines if data must be stored with Y axis inverted
  92351. */
  92352. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92353. /**
  92354. * Update a raw 3D texture
  92355. * @param texture defines the texture to update
  92356. * @param data defines the data to store
  92357. * @param format defines the data format
  92358. * @param invertY defines if data must be stored with Y axis inverted
  92359. * @param compression defines the used compression (can be null)
  92360. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92361. */
  92362. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92363. /**
  92364. * Creates a new raw 2D array texture
  92365. * @param data defines the data used to create the texture
  92366. * @param width defines the width of the texture
  92367. * @param height defines the height of the texture
  92368. * @param depth defines the number of layers of the texture
  92369. * @param format defines the format of the texture
  92370. * @param generateMipMaps defines if the engine must generate mip levels
  92371. * @param invertY defines if data must be stored with Y axis inverted
  92372. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92373. * @param compression defines the compressed used (can be null)
  92374. * @param textureType defines the compressed used (can be null)
  92375. * @returns a new raw 2D array texture (stored in an InternalTexture)
  92376. */
  92377. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92378. /**
  92379. * Update a raw 2D array texture
  92380. * @param texture defines the texture to update
  92381. * @param data defines the data to store
  92382. * @param format defines the data format
  92383. * @param invertY defines if data must be stored with Y axis inverted
  92384. */
  92385. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92386. /**
  92387. * Update a raw 2D array texture
  92388. * @param texture defines the texture to update
  92389. * @param data defines the data to store
  92390. * @param format defines the data format
  92391. * @param invertY defines if data must be stored with Y axis inverted
  92392. * @param compression defines the used compression (can be null)
  92393. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92394. */
  92395. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92396. }
  92397. }
  92398. declare module BABYLON {
  92399. /**
  92400. * Raw texture can help creating a texture directly from an array of data.
  92401. * This can be super useful if you either get the data from an uncompressed source or
  92402. * if you wish to create your texture pixel by pixel.
  92403. */
  92404. export class RawTexture extends Texture {
  92405. /**
  92406. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92407. */
  92408. format: number;
  92409. /**
  92410. * Instantiates a new RawTexture.
  92411. * Raw texture can help creating a texture directly from an array of data.
  92412. * This can be super useful if you either get the data from an uncompressed source or
  92413. * if you wish to create your texture pixel by pixel.
  92414. * @param data define the array of data to use to create the texture
  92415. * @param width define the width of the texture
  92416. * @param height define the height of the texture
  92417. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92418. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92419. * @param generateMipMaps define whether mip maps should be generated or not
  92420. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92421. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92422. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92423. */
  92424. constructor(data: ArrayBufferView, width: number, height: number,
  92425. /**
  92426. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92427. */
  92428. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  92429. /**
  92430. * Updates the texture underlying data.
  92431. * @param data Define the new data of the texture
  92432. */
  92433. update(data: ArrayBufferView): void;
  92434. /**
  92435. * Creates a luminance texture from some data.
  92436. * @param data Define the texture data
  92437. * @param width Define the width of the texture
  92438. * @param height Define the height of the texture
  92439. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92440. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92441. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92442. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92443. * @returns the luminance texture
  92444. */
  92445. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92446. /**
  92447. * Creates a luminance alpha texture from some data.
  92448. * @param data Define the texture data
  92449. * @param width Define the width of the texture
  92450. * @param height Define the height of the texture
  92451. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92452. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92453. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92454. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92455. * @returns the luminance alpha texture
  92456. */
  92457. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92458. /**
  92459. * Creates an alpha texture from some data.
  92460. * @param data Define the texture data
  92461. * @param width Define the width of the texture
  92462. * @param height Define the height of the texture
  92463. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92464. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92465. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92466. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92467. * @returns the alpha texture
  92468. */
  92469. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92470. /**
  92471. * Creates a RGB texture from some data.
  92472. * @param data Define the texture data
  92473. * @param width Define the width of the texture
  92474. * @param height Define the height of the texture
  92475. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92476. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92477. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92478. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92479. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92480. * @returns the RGB alpha texture
  92481. */
  92482. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92483. /**
  92484. * Creates a RGBA texture from some data.
  92485. * @param data Define the texture data
  92486. * @param width Define the width of the texture
  92487. * @param height Define the height of the texture
  92488. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92489. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92490. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92491. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92492. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92493. * @returns the RGBA texture
  92494. */
  92495. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92496. /**
  92497. * Creates a R texture from some data.
  92498. * @param data Define the texture data
  92499. * @param width Define the width of the texture
  92500. * @param height Define the height of the texture
  92501. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92502. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92503. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92504. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92505. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92506. * @returns the R texture
  92507. */
  92508. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92509. }
  92510. }
  92511. declare module BABYLON {
  92512. interface ThinEngine {
  92513. /**
  92514. * Update a dynamic index buffer
  92515. * @param indexBuffer defines the target index buffer
  92516. * @param indices defines the data to update
  92517. * @param offset defines the offset in the target index buffer where update should start
  92518. */
  92519. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  92520. /**
  92521. * Updates a dynamic vertex buffer.
  92522. * @param vertexBuffer the vertex buffer to update
  92523. * @param data the data used to update the vertex buffer
  92524. * @param byteOffset the byte offset of the data
  92525. * @param byteLength the byte length of the data
  92526. */
  92527. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  92528. }
  92529. }
  92530. declare module BABYLON {
  92531. interface AbstractScene {
  92532. /**
  92533. * The list of procedural textures added to the scene
  92534. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92535. */
  92536. proceduralTextures: Array<ProceduralTexture>;
  92537. }
  92538. /**
  92539. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  92540. * in a given scene.
  92541. */
  92542. export class ProceduralTextureSceneComponent implements ISceneComponent {
  92543. /**
  92544. * The component name helpfull to identify the component in the list of scene components.
  92545. */
  92546. readonly name: string;
  92547. /**
  92548. * The scene the component belongs to.
  92549. */
  92550. scene: Scene;
  92551. /**
  92552. * Creates a new instance of the component for the given scene
  92553. * @param scene Defines the scene to register the component in
  92554. */
  92555. constructor(scene: Scene);
  92556. /**
  92557. * Registers the component in a given scene
  92558. */
  92559. register(): void;
  92560. /**
  92561. * Rebuilds the elements related to this component in case of
  92562. * context lost for instance.
  92563. */
  92564. rebuild(): void;
  92565. /**
  92566. * Disposes the component and the associated ressources.
  92567. */
  92568. dispose(): void;
  92569. private _beforeClear;
  92570. }
  92571. }
  92572. declare module BABYLON {
  92573. interface ThinEngine {
  92574. /**
  92575. * Creates a new render target cube texture
  92576. * @param size defines the size of the texture
  92577. * @param options defines the options used to create the texture
  92578. * @returns a new render target cube texture stored in an InternalTexture
  92579. */
  92580. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  92581. }
  92582. }
  92583. declare module BABYLON {
  92584. /** @hidden */
  92585. export var proceduralVertexShader: {
  92586. name: string;
  92587. shader: string;
  92588. };
  92589. }
  92590. declare module BABYLON {
  92591. /**
  92592. * 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.
  92593. * This is the base class of any Procedural texture and contains most of the shareable code.
  92594. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92595. */
  92596. export class ProceduralTexture extends Texture {
  92597. /**
  92598. * Define if the texture is enabled or not (disabled texture will not render)
  92599. */
  92600. isEnabled: boolean;
  92601. /**
  92602. * Define if the texture must be cleared before rendering (default is true)
  92603. */
  92604. autoClear: boolean;
  92605. /**
  92606. * Callback called when the texture is generated
  92607. */
  92608. onGenerated: () => void;
  92609. /**
  92610. * Event raised when the texture is generated
  92611. */
  92612. onGeneratedObservable: Observable<ProceduralTexture>;
  92613. /**
  92614. * Event raised before the texture is generated
  92615. */
  92616. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  92617. /**
  92618. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  92619. */
  92620. nodeMaterialSource: Nullable<NodeMaterial>;
  92621. /** @hidden */
  92622. _generateMipMaps: boolean;
  92623. /** @hidden **/
  92624. _effect: Effect;
  92625. /** @hidden */
  92626. _textures: {
  92627. [key: string]: Texture;
  92628. };
  92629. /** @hidden */
  92630. protected _fallbackTexture: Nullable<Texture>;
  92631. private _size;
  92632. private _currentRefreshId;
  92633. private _frameId;
  92634. private _refreshRate;
  92635. private _vertexBuffers;
  92636. private _indexBuffer;
  92637. private _uniforms;
  92638. private _samplers;
  92639. private _fragment;
  92640. private _floats;
  92641. private _ints;
  92642. private _floatsArrays;
  92643. private _colors3;
  92644. private _colors4;
  92645. private _vectors2;
  92646. private _vectors3;
  92647. private _matrices;
  92648. private _fallbackTextureUsed;
  92649. private _fullEngine;
  92650. private _cachedDefines;
  92651. private _contentUpdateId;
  92652. private _contentData;
  92653. /**
  92654. * Instantiates a new procedural texture.
  92655. * 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.
  92656. * This is the base class of any Procedural texture and contains most of the shareable code.
  92657. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92658. * @param name Define the name of the texture
  92659. * @param size Define the size of the texture to create
  92660. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  92661. * @param scene Define the scene the texture belongs to
  92662. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  92663. * @param generateMipMaps Define if the texture should creates mip maps or not
  92664. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  92665. * @param textureType The FBO internal texture type
  92666. */
  92667. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  92668. /**
  92669. * The effect that is created when initializing the post process.
  92670. * @returns The created effect corresponding the the postprocess.
  92671. */
  92672. getEffect(): Effect;
  92673. /**
  92674. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  92675. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  92676. */
  92677. getContent(): Nullable<ArrayBufferView>;
  92678. private _createIndexBuffer;
  92679. /** @hidden */
  92680. _rebuild(): void;
  92681. /**
  92682. * Resets the texture in order to recreate its associated resources.
  92683. * This can be called in case of context loss
  92684. */
  92685. reset(): void;
  92686. protected _getDefines(): string;
  92687. /**
  92688. * Is the texture ready to be used ? (rendered at least once)
  92689. * @returns true if ready, otherwise, false.
  92690. */
  92691. isReady(): boolean;
  92692. /**
  92693. * Resets the refresh counter of the texture and start bak from scratch.
  92694. * Could be useful to regenerate the texture if it is setup to render only once.
  92695. */
  92696. resetRefreshCounter(): void;
  92697. /**
  92698. * Set the fragment shader to use in order to render the texture.
  92699. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  92700. */
  92701. setFragment(fragment: any): void;
  92702. /**
  92703. * Define the refresh rate of the texture or the rendering frequency.
  92704. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92705. */
  92706. get refreshRate(): number;
  92707. set refreshRate(value: number);
  92708. /** @hidden */
  92709. _shouldRender(): boolean;
  92710. /**
  92711. * Get the size the texture is rendering at.
  92712. * @returns the size (on cube texture it is always squared)
  92713. */
  92714. getRenderSize(): RenderTargetTextureSize;
  92715. /**
  92716. * Resize the texture to new value.
  92717. * @param size Define the new size the texture should have
  92718. * @param generateMipMaps Define whether the new texture should create mip maps
  92719. */
  92720. resize(size: number, generateMipMaps: boolean): void;
  92721. private _checkUniform;
  92722. /**
  92723. * Set a texture in the shader program used to render.
  92724. * @param name Define the name of the uniform samplers as defined in the shader
  92725. * @param texture Define the texture to bind to this sampler
  92726. * @return the texture itself allowing "fluent" like uniform updates
  92727. */
  92728. setTexture(name: string, texture: Texture): ProceduralTexture;
  92729. /**
  92730. * Set a float in the shader.
  92731. * @param name Define the name of the uniform as defined in the shader
  92732. * @param value Define the value to give to the uniform
  92733. * @return the texture itself allowing "fluent" like uniform updates
  92734. */
  92735. setFloat(name: string, value: number): ProceduralTexture;
  92736. /**
  92737. * Set a int in the shader.
  92738. * @param name Define the name of the uniform as defined in the shader
  92739. * @param value Define the value to give to the uniform
  92740. * @return the texture itself allowing "fluent" like uniform updates
  92741. */
  92742. setInt(name: string, value: number): ProceduralTexture;
  92743. /**
  92744. * Set an array of floats in the shader.
  92745. * @param name Define the name of the uniform as defined in the shader
  92746. * @param value Define the value to give to the uniform
  92747. * @return the texture itself allowing "fluent" like uniform updates
  92748. */
  92749. setFloats(name: string, value: number[]): ProceduralTexture;
  92750. /**
  92751. * Set a vec3 in the shader from a Color3.
  92752. * @param name Define the name of the uniform as defined in the shader
  92753. * @param value Define the value to give to the uniform
  92754. * @return the texture itself allowing "fluent" like uniform updates
  92755. */
  92756. setColor3(name: string, value: Color3): ProceduralTexture;
  92757. /**
  92758. * Set a vec4 in the shader from a Color4.
  92759. * @param name Define the name of the uniform as defined in the shader
  92760. * @param value Define the value to give to the uniform
  92761. * @return the texture itself allowing "fluent" like uniform updates
  92762. */
  92763. setColor4(name: string, value: Color4): ProceduralTexture;
  92764. /**
  92765. * Set a vec2 in the shader from a Vector2.
  92766. * @param name Define the name of the uniform as defined in the shader
  92767. * @param value Define the value to give to the uniform
  92768. * @return the texture itself allowing "fluent" like uniform updates
  92769. */
  92770. setVector2(name: string, value: Vector2): ProceduralTexture;
  92771. /**
  92772. * Set a vec3 in the shader from a Vector3.
  92773. * @param name Define the name of the uniform as defined in the shader
  92774. * @param value Define the value to give to the uniform
  92775. * @return the texture itself allowing "fluent" like uniform updates
  92776. */
  92777. setVector3(name: string, value: Vector3): ProceduralTexture;
  92778. /**
  92779. * Set a mat4 in the shader from a MAtrix.
  92780. * @param name Define the name of the uniform as defined in the shader
  92781. * @param value Define the value to give to the uniform
  92782. * @return the texture itself allowing "fluent" like uniform updates
  92783. */
  92784. setMatrix(name: string, value: Matrix): ProceduralTexture;
  92785. /**
  92786. * Render the texture to its associated render target.
  92787. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  92788. */
  92789. render(useCameraPostProcess?: boolean): void;
  92790. /**
  92791. * Clone the texture.
  92792. * @returns the cloned texture
  92793. */
  92794. clone(): ProceduralTexture;
  92795. /**
  92796. * Dispose the texture and release its asoociated resources.
  92797. */
  92798. dispose(): void;
  92799. }
  92800. }
  92801. declare module BABYLON {
  92802. /**
  92803. * This represents the base class for particle system in Babylon.
  92804. * 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.
  92805. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92806. * @example https://doc.babylonjs.com/babylon101/particles
  92807. */
  92808. export class BaseParticleSystem {
  92809. /**
  92810. * Source color is added to the destination color without alpha affecting the result
  92811. */
  92812. static BLENDMODE_ONEONE: number;
  92813. /**
  92814. * Blend current color and particle color using particle’s alpha
  92815. */
  92816. static BLENDMODE_STANDARD: number;
  92817. /**
  92818. * Add current color and particle color multiplied by particle’s alpha
  92819. */
  92820. static BLENDMODE_ADD: number;
  92821. /**
  92822. * Multiply current color with particle color
  92823. */
  92824. static BLENDMODE_MULTIPLY: number;
  92825. /**
  92826. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  92827. */
  92828. static BLENDMODE_MULTIPLYADD: number;
  92829. /**
  92830. * List of animations used by the particle system.
  92831. */
  92832. animations: Animation[];
  92833. /**
  92834. * Gets or sets the unique id of the particle system
  92835. */
  92836. uniqueId: number;
  92837. /**
  92838. * The id of the Particle system.
  92839. */
  92840. id: string;
  92841. /**
  92842. * The friendly name of the Particle system.
  92843. */
  92844. name: string;
  92845. /**
  92846. * Snippet ID if the particle system was created from the snippet server
  92847. */
  92848. snippetId: string;
  92849. /**
  92850. * The rendering group used by the Particle system to chose when to render.
  92851. */
  92852. renderingGroupId: number;
  92853. /**
  92854. * The emitter represents the Mesh or position we are attaching the particle system to.
  92855. */
  92856. emitter: Nullable<AbstractMesh | Vector3>;
  92857. /**
  92858. * The maximum number of particles to emit per frame
  92859. */
  92860. emitRate: number;
  92861. /**
  92862. * If you want to launch only a few particles at once, that can be done, as well.
  92863. */
  92864. manualEmitCount: number;
  92865. /**
  92866. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92867. */
  92868. updateSpeed: number;
  92869. /**
  92870. * The amount of time the particle system is running (depends of the overall update speed).
  92871. */
  92872. targetStopDuration: number;
  92873. /**
  92874. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92875. */
  92876. disposeOnStop: boolean;
  92877. /**
  92878. * Minimum power of emitting particles.
  92879. */
  92880. minEmitPower: number;
  92881. /**
  92882. * Maximum power of emitting particles.
  92883. */
  92884. maxEmitPower: number;
  92885. /**
  92886. * Minimum life time of emitting particles.
  92887. */
  92888. minLifeTime: number;
  92889. /**
  92890. * Maximum life time of emitting particles.
  92891. */
  92892. maxLifeTime: number;
  92893. /**
  92894. * Minimum Size of emitting particles.
  92895. */
  92896. minSize: number;
  92897. /**
  92898. * Maximum Size of emitting particles.
  92899. */
  92900. maxSize: number;
  92901. /**
  92902. * Minimum scale of emitting particles on X axis.
  92903. */
  92904. minScaleX: number;
  92905. /**
  92906. * Maximum scale of emitting particles on X axis.
  92907. */
  92908. maxScaleX: number;
  92909. /**
  92910. * Minimum scale of emitting particles on Y axis.
  92911. */
  92912. minScaleY: number;
  92913. /**
  92914. * Maximum scale of emitting particles on Y axis.
  92915. */
  92916. maxScaleY: number;
  92917. /**
  92918. * Gets or sets the minimal initial rotation in radians.
  92919. */
  92920. minInitialRotation: number;
  92921. /**
  92922. * Gets or sets the maximal initial rotation in radians.
  92923. */
  92924. maxInitialRotation: number;
  92925. /**
  92926. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92927. */
  92928. minAngularSpeed: number;
  92929. /**
  92930. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92931. */
  92932. maxAngularSpeed: number;
  92933. /**
  92934. * The texture used to render each particle. (this can be a spritesheet)
  92935. */
  92936. particleTexture: Nullable<BaseTexture>;
  92937. /**
  92938. * The layer mask we are rendering the particles through.
  92939. */
  92940. layerMask: number;
  92941. /**
  92942. * This can help using your own shader to render the particle system.
  92943. * The according effect will be created
  92944. */
  92945. customShader: any;
  92946. /**
  92947. * By default particle system starts as soon as they are created. This prevents the
  92948. * automatic start to happen and let you decide when to start emitting particles.
  92949. */
  92950. preventAutoStart: boolean;
  92951. private _noiseTexture;
  92952. /**
  92953. * Gets or sets a texture used to add random noise to particle positions
  92954. */
  92955. get noiseTexture(): Nullable<ProceduralTexture>;
  92956. set noiseTexture(value: Nullable<ProceduralTexture>);
  92957. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92958. noiseStrength: Vector3;
  92959. /**
  92960. * Callback triggered when the particle animation is ending.
  92961. */
  92962. onAnimationEnd: Nullable<() => void>;
  92963. /**
  92964. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  92965. */
  92966. blendMode: number;
  92967. /**
  92968. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  92969. * to override the particles.
  92970. */
  92971. forceDepthWrite: boolean;
  92972. /** 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 */
  92973. preWarmCycles: number;
  92974. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  92975. preWarmStepOffset: number;
  92976. /**
  92977. * 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)
  92978. */
  92979. spriteCellChangeSpeed: number;
  92980. /**
  92981. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92982. */
  92983. startSpriteCellID: number;
  92984. /**
  92985. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92986. */
  92987. endSpriteCellID: number;
  92988. /**
  92989. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92990. */
  92991. spriteCellWidth: number;
  92992. /**
  92993. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92994. */
  92995. spriteCellHeight: number;
  92996. /**
  92997. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92998. */
  92999. spriteRandomStartCell: boolean;
  93000. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  93001. translationPivot: Vector2;
  93002. /** @hidden */
  93003. protected _isAnimationSheetEnabled: boolean;
  93004. /**
  93005. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  93006. */
  93007. beginAnimationOnStart: boolean;
  93008. /**
  93009. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  93010. */
  93011. beginAnimationFrom: number;
  93012. /**
  93013. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  93014. */
  93015. beginAnimationTo: number;
  93016. /**
  93017. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  93018. */
  93019. beginAnimationLoop: boolean;
  93020. /**
  93021. * Gets or sets a world offset applied to all particles
  93022. */
  93023. worldOffset: Vector3;
  93024. /**
  93025. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  93026. */
  93027. get isAnimationSheetEnabled(): boolean;
  93028. set isAnimationSheetEnabled(value: boolean);
  93029. /**
  93030. * Get hosting scene
  93031. * @returns the scene
  93032. */
  93033. getScene(): Nullable<Scene>;
  93034. /**
  93035. * You can use gravity if you want to give an orientation to your particles.
  93036. */
  93037. gravity: Vector3;
  93038. protected _colorGradients: Nullable<Array<ColorGradient>>;
  93039. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  93040. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  93041. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  93042. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  93043. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  93044. protected _dragGradients: Nullable<Array<FactorGradient>>;
  93045. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  93046. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  93047. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  93048. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  93049. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  93050. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  93051. /**
  93052. * Defines the delay in milliseconds before starting the system (0 by default)
  93053. */
  93054. startDelay: number;
  93055. /**
  93056. * Gets the current list of drag gradients.
  93057. * You must use addDragGradient and removeDragGradient to udpate this list
  93058. * @returns the list of drag gradients
  93059. */
  93060. getDragGradients(): Nullable<Array<FactorGradient>>;
  93061. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  93062. limitVelocityDamping: number;
  93063. /**
  93064. * Gets the current list of limit velocity gradients.
  93065. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  93066. * @returns the list of limit velocity gradients
  93067. */
  93068. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  93069. /**
  93070. * Gets the current list of color gradients.
  93071. * You must use addColorGradient and removeColorGradient to udpate this list
  93072. * @returns the list of color gradients
  93073. */
  93074. getColorGradients(): Nullable<Array<ColorGradient>>;
  93075. /**
  93076. * Gets the current list of size gradients.
  93077. * You must use addSizeGradient and removeSizeGradient to udpate this list
  93078. * @returns the list of size gradients
  93079. */
  93080. getSizeGradients(): Nullable<Array<FactorGradient>>;
  93081. /**
  93082. * Gets the current list of color remap gradients.
  93083. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  93084. * @returns the list of color remap gradients
  93085. */
  93086. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  93087. /**
  93088. * Gets the current list of alpha remap gradients.
  93089. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  93090. * @returns the list of alpha remap gradients
  93091. */
  93092. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  93093. /**
  93094. * Gets the current list of life time gradients.
  93095. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  93096. * @returns the list of life time gradients
  93097. */
  93098. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  93099. /**
  93100. * Gets the current list of angular speed gradients.
  93101. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  93102. * @returns the list of angular speed gradients
  93103. */
  93104. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  93105. /**
  93106. * Gets the current list of velocity gradients.
  93107. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  93108. * @returns the list of velocity gradients
  93109. */
  93110. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  93111. /**
  93112. * Gets the current list of start size gradients.
  93113. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  93114. * @returns the list of start size gradients
  93115. */
  93116. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  93117. /**
  93118. * Gets the current list of emit rate gradients.
  93119. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  93120. * @returns the list of emit rate gradients
  93121. */
  93122. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  93123. /**
  93124. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93125. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93126. */
  93127. get direction1(): Vector3;
  93128. set direction1(value: Vector3);
  93129. /**
  93130. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93131. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93132. */
  93133. get direction2(): Vector3;
  93134. set direction2(value: Vector3);
  93135. /**
  93136. * 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.
  93137. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93138. */
  93139. get minEmitBox(): Vector3;
  93140. set minEmitBox(value: Vector3);
  93141. /**
  93142. * 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.
  93143. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93144. */
  93145. get maxEmitBox(): Vector3;
  93146. set maxEmitBox(value: Vector3);
  93147. /**
  93148. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  93149. */
  93150. color1: Color4;
  93151. /**
  93152. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  93153. */
  93154. color2: Color4;
  93155. /**
  93156. * Color the particle will have at the end of its lifetime
  93157. */
  93158. colorDead: Color4;
  93159. /**
  93160. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  93161. */
  93162. textureMask: Color4;
  93163. /**
  93164. * The particle emitter type defines the emitter used by the particle system.
  93165. * It can be for example box, sphere, or cone...
  93166. */
  93167. particleEmitterType: IParticleEmitterType;
  93168. /** @hidden */
  93169. _isSubEmitter: boolean;
  93170. /**
  93171. * Gets or sets the billboard mode to use when isBillboardBased = true.
  93172. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  93173. */
  93174. billboardMode: number;
  93175. protected _isBillboardBased: boolean;
  93176. /**
  93177. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  93178. */
  93179. get isBillboardBased(): boolean;
  93180. set isBillboardBased(value: boolean);
  93181. /**
  93182. * The scene the particle system belongs to.
  93183. */
  93184. protected _scene: Nullable<Scene>;
  93185. /**
  93186. * The engine the particle system belongs to.
  93187. */
  93188. protected _engine: ThinEngine;
  93189. /**
  93190. * Local cache of defines for image processing.
  93191. */
  93192. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  93193. /**
  93194. * Default configuration related to image processing available in the standard Material.
  93195. */
  93196. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  93197. /**
  93198. * Gets the image processing configuration used either in this material.
  93199. */
  93200. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  93201. /**
  93202. * Sets the Default image processing configuration used either in the this material.
  93203. *
  93204. * If sets to null, the scene one is in use.
  93205. */
  93206. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  93207. /**
  93208. * Attaches a new image processing configuration to the Standard Material.
  93209. * @param configuration
  93210. */
  93211. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  93212. /** @hidden */
  93213. protected _reset(): void;
  93214. /** @hidden */
  93215. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  93216. /**
  93217. * Instantiates a particle system.
  93218. * 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.
  93219. * @param name The name of the particle system
  93220. */
  93221. constructor(name: string);
  93222. /**
  93223. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  93224. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93225. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93226. * @returns the emitter
  93227. */
  93228. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  93229. /**
  93230. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  93231. * @param radius The radius of the hemisphere to emit from
  93232. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93233. * @returns the emitter
  93234. */
  93235. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  93236. /**
  93237. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93238. * @param radius The radius of the sphere to emit from
  93239. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93240. * @returns the emitter
  93241. */
  93242. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  93243. /**
  93244. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93245. * @param radius The radius of the sphere to emit from
  93246. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93247. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93248. * @returns the emitter
  93249. */
  93250. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  93251. /**
  93252. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93253. * @param radius The radius of the emission cylinder
  93254. * @param height The height of the emission cylinder
  93255. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93256. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93257. * @returns the emitter
  93258. */
  93259. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  93260. /**
  93261. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93262. * @param radius The radius of the cylinder to emit from
  93263. * @param height The height of the emission cylinder
  93264. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93265. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93266. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93267. * @returns the emitter
  93268. */
  93269. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  93270. /**
  93271. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93272. * @param radius The radius of the cone to emit from
  93273. * @param angle The base angle of the cone
  93274. * @returns the emitter
  93275. */
  93276. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  93277. /**
  93278. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93279. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93280. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93281. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93282. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93283. * @returns the emitter
  93284. */
  93285. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93286. }
  93287. }
  93288. declare module BABYLON {
  93289. /**
  93290. * Type of sub emitter
  93291. */
  93292. export enum SubEmitterType {
  93293. /**
  93294. * Attached to the particle over it's lifetime
  93295. */
  93296. ATTACHED = 0,
  93297. /**
  93298. * Created when the particle dies
  93299. */
  93300. END = 1
  93301. }
  93302. /**
  93303. * Sub emitter class used to emit particles from an existing particle
  93304. */
  93305. export class SubEmitter {
  93306. /**
  93307. * the particle system to be used by the sub emitter
  93308. */
  93309. particleSystem: ParticleSystem;
  93310. /**
  93311. * Type of the submitter (Default: END)
  93312. */
  93313. type: SubEmitterType;
  93314. /**
  93315. * 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)
  93316. * Note: This only is supported when using an emitter of type Mesh
  93317. */
  93318. inheritDirection: boolean;
  93319. /**
  93320. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  93321. */
  93322. inheritedVelocityAmount: number;
  93323. /**
  93324. * Creates a sub emitter
  93325. * @param particleSystem the particle system to be used by the sub emitter
  93326. */
  93327. constructor(
  93328. /**
  93329. * the particle system to be used by the sub emitter
  93330. */
  93331. particleSystem: ParticleSystem);
  93332. /**
  93333. * Clones the sub emitter
  93334. * @returns the cloned sub emitter
  93335. */
  93336. clone(): SubEmitter;
  93337. /**
  93338. * Serialize current object to a JSON object
  93339. * @returns the serialized object
  93340. */
  93341. serialize(): any;
  93342. /** @hidden */
  93343. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  93344. /**
  93345. * Creates a new SubEmitter from a serialized JSON version
  93346. * @param serializationObject defines the JSON object to read from
  93347. * @param sceneOrEngine defines the hosting scene or the hosting engine
  93348. * @param rootUrl defines the rootUrl for data loading
  93349. * @returns a new SubEmitter
  93350. */
  93351. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  93352. /** Release associated resources */
  93353. dispose(): void;
  93354. }
  93355. }
  93356. declare module BABYLON {
  93357. /** @hidden */
  93358. export var imageProcessingDeclaration: {
  93359. name: string;
  93360. shader: string;
  93361. };
  93362. }
  93363. declare module BABYLON {
  93364. /** @hidden */
  93365. export var imageProcessingFunctions: {
  93366. name: string;
  93367. shader: string;
  93368. };
  93369. }
  93370. declare module BABYLON {
  93371. /** @hidden */
  93372. export var particlesPixelShader: {
  93373. name: string;
  93374. shader: string;
  93375. };
  93376. }
  93377. declare module BABYLON {
  93378. /** @hidden */
  93379. export var particlesVertexShader: {
  93380. name: string;
  93381. shader: string;
  93382. };
  93383. }
  93384. declare module BABYLON {
  93385. /**
  93386. * Interface used to define entities containing multiple clip planes
  93387. */
  93388. export interface IClipPlanesHolder {
  93389. /**
  93390. * Gets or sets the active clipplane 1
  93391. */
  93392. clipPlane: Nullable<Plane>;
  93393. /**
  93394. * Gets or sets the active clipplane 2
  93395. */
  93396. clipPlane2: Nullable<Plane>;
  93397. /**
  93398. * Gets or sets the active clipplane 3
  93399. */
  93400. clipPlane3: Nullable<Plane>;
  93401. /**
  93402. * Gets or sets the active clipplane 4
  93403. */
  93404. clipPlane4: Nullable<Plane>;
  93405. /**
  93406. * Gets or sets the active clipplane 5
  93407. */
  93408. clipPlane5: Nullable<Plane>;
  93409. /**
  93410. * Gets or sets the active clipplane 6
  93411. */
  93412. clipPlane6: Nullable<Plane>;
  93413. }
  93414. }
  93415. declare module BABYLON {
  93416. /**
  93417. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  93418. *
  93419. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  93420. *
  93421. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  93422. */
  93423. export class ThinMaterialHelper {
  93424. /**
  93425. * Binds the clip plane information from the holder to the effect.
  93426. * @param effect The effect we are binding the data to
  93427. * @param holder The entity containing the clip plane information
  93428. */
  93429. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  93430. }
  93431. }
  93432. declare module BABYLON {
  93433. interface ThinEngine {
  93434. /**
  93435. * Sets alpha constants used by some alpha blending modes
  93436. * @param r defines the red component
  93437. * @param g defines the green component
  93438. * @param b defines the blue component
  93439. * @param a defines the alpha component
  93440. */
  93441. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  93442. /**
  93443. * Sets the current alpha mode
  93444. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  93445. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  93446. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93447. */
  93448. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  93449. /**
  93450. * Gets the current alpha mode
  93451. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93452. * @returns the current alpha mode
  93453. */
  93454. getAlphaMode(): number;
  93455. /**
  93456. * Sets the current alpha equation
  93457. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  93458. */
  93459. setAlphaEquation(equation: number): void;
  93460. /**
  93461. * Gets the current alpha equation.
  93462. * @returns the current alpha equation
  93463. */
  93464. getAlphaEquation(): number;
  93465. }
  93466. }
  93467. declare module BABYLON {
  93468. /**
  93469. * This represents a particle system in Babylon.
  93470. * 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.
  93471. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  93472. * @example https://doc.babylonjs.com/babylon101/particles
  93473. */
  93474. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  93475. /**
  93476. * Billboard mode will only apply to Y axis
  93477. */
  93478. static readonly BILLBOARDMODE_Y: number;
  93479. /**
  93480. * Billboard mode will apply to all axes
  93481. */
  93482. static readonly BILLBOARDMODE_ALL: number;
  93483. /**
  93484. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  93485. */
  93486. static readonly BILLBOARDMODE_STRETCHED: number;
  93487. /**
  93488. * This function can be defined to provide custom update for active particles.
  93489. * This function will be called instead of regular update (age, position, color, etc.).
  93490. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  93491. */
  93492. updateFunction: (particles: Particle[]) => void;
  93493. private _emitterWorldMatrix;
  93494. /**
  93495. * This function can be defined to specify initial direction for every new particle.
  93496. * It by default use the emitterType defined function
  93497. */
  93498. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93499. /**
  93500. * This function can be defined to specify initial position for every new particle.
  93501. * It by default use the emitterType defined function
  93502. */
  93503. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93504. /**
  93505. * @hidden
  93506. */
  93507. _inheritedVelocityOffset: Vector3;
  93508. /**
  93509. * An event triggered when the system is disposed
  93510. */
  93511. onDisposeObservable: Observable<IParticleSystem>;
  93512. /**
  93513. * An event triggered when the system is stopped
  93514. */
  93515. onStoppedObservable: Observable<IParticleSystem>;
  93516. private _onDisposeObserver;
  93517. /**
  93518. * Sets a callback that will be triggered when the system is disposed
  93519. */
  93520. set onDispose(callback: () => void);
  93521. private _particles;
  93522. private _epsilon;
  93523. private _capacity;
  93524. private _stockParticles;
  93525. private _newPartsExcess;
  93526. private _vertexData;
  93527. private _vertexBuffer;
  93528. private _vertexBuffers;
  93529. private _spriteBuffer;
  93530. private _indexBuffer;
  93531. private _effect;
  93532. private _customEffect;
  93533. private _cachedDefines;
  93534. private _scaledColorStep;
  93535. private _colorDiff;
  93536. private _scaledDirection;
  93537. private _scaledGravity;
  93538. private _currentRenderId;
  93539. private _alive;
  93540. private _useInstancing;
  93541. private _vertexArrayObject;
  93542. private _started;
  93543. private _stopped;
  93544. private _actualFrame;
  93545. private _scaledUpdateSpeed;
  93546. private _vertexBufferSize;
  93547. /** @hidden */
  93548. _currentEmitRateGradient: Nullable<FactorGradient>;
  93549. /** @hidden */
  93550. _currentEmitRate1: number;
  93551. /** @hidden */
  93552. _currentEmitRate2: number;
  93553. /** @hidden */
  93554. _currentStartSizeGradient: Nullable<FactorGradient>;
  93555. /** @hidden */
  93556. _currentStartSize1: number;
  93557. /** @hidden */
  93558. _currentStartSize2: number;
  93559. private readonly _rawTextureWidth;
  93560. private _rampGradientsTexture;
  93561. private _useRampGradients;
  93562. /** Gets or sets a matrix to use to compute projection */
  93563. defaultProjectionMatrix: Matrix;
  93564. /** Gets or sets a matrix to use to compute view */
  93565. defaultViewMatrix: Matrix;
  93566. /** Gets or sets a boolean indicating that ramp gradients must be used
  93567. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93568. */
  93569. get useRampGradients(): boolean;
  93570. set useRampGradients(value: boolean);
  93571. /**
  93572. * 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.
  93573. * 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: [])
  93574. */
  93575. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  93576. private _subEmitters;
  93577. /**
  93578. * @hidden
  93579. * If the particle systems emitter should be disposed when the particle system is disposed
  93580. */
  93581. _disposeEmitterOnDispose: boolean;
  93582. /**
  93583. * The current active Sub-systems, this property is used by the root particle system only.
  93584. */
  93585. activeSubSystems: Array<ParticleSystem>;
  93586. /**
  93587. * Specifies if the particles are updated in emitter local space or world space
  93588. */
  93589. isLocal: boolean;
  93590. private _rootParticleSystem;
  93591. /**
  93592. * Gets the current list of active particles
  93593. */
  93594. get particles(): Particle[];
  93595. /**
  93596. * Gets the number of particles active at the same time.
  93597. * @returns The number of active particles.
  93598. */
  93599. getActiveCount(): number;
  93600. /**
  93601. * Returns the string "ParticleSystem"
  93602. * @returns a string containing the class name
  93603. */
  93604. getClassName(): string;
  93605. /**
  93606. * Gets a boolean indicating that the system is stopping
  93607. * @returns true if the system is currently stopping
  93608. */
  93609. isStopping(): boolean;
  93610. /**
  93611. * Gets the custom effect used to render the particles
  93612. * @param blendMode Blend mode for which the effect should be retrieved
  93613. * @returns The effect
  93614. */
  93615. getCustomEffect(blendMode?: number): Nullable<Effect>;
  93616. /**
  93617. * Sets the custom effect used to render the particles
  93618. * @param effect The effect to set
  93619. * @param blendMode Blend mode for which the effect should be set
  93620. */
  93621. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  93622. /** @hidden */
  93623. private _onBeforeDrawParticlesObservable;
  93624. /**
  93625. * Observable that will be called just before the particles are drawn
  93626. */
  93627. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  93628. /**
  93629. * Gets the name of the particle vertex shader
  93630. */
  93631. get vertexShaderName(): string;
  93632. /**
  93633. * Instantiates a particle system.
  93634. * 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.
  93635. * @param name The name of the particle system
  93636. * @param capacity The max number of particles alive at the same time
  93637. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  93638. * @param customEffect a custom effect used to change the way particles are rendered by default
  93639. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  93640. * @param epsilon Offset used to render the particles
  93641. */
  93642. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  93643. private _addFactorGradient;
  93644. private _removeFactorGradient;
  93645. /**
  93646. * Adds a new life time gradient
  93647. * @param gradient defines the gradient to use (between 0 and 1)
  93648. * @param factor defines the life time factor to affect to the specified gradient
  93649. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93650. * @returns the current particle system
  93651. */
  93652. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93653. /**
  93654. * Remove a specific life time gradient
  93655. * @param gradient defines the gradient to remove
  93656. * @returns the current particle system
  93657. */
  93658. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93659. /**
  93660. * Adds a new size gradient
  93661. * @param gradient defines the gradient to use (between 0 and 1)
  93662. * @param factor defines the size factor to affect to the specified gradient
  93663. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93664. * @returns the current particle system
  93665. */
  93666. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93667. /**
  93668. * Remove a specific size gradient
  93669. * @param gradient defines the gradient to remove
  93670. * @returns the current particle system
  93671. */
  93672. removeSizeGradient(gradient: number): IParticleSystem;
  93673. /**
  93674. * Adds a new color remap gradient
  93675. * @param gradient defines the gradient to use (between 0 and 1)
  93676. * @param min defines the color remap minimal range
  93677. * @param max defines the color remap maximal range
  93678. * @returns the current particle system
  93679. */
  93680. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93681. /**
  93682. * Remove a specific color remap gradient
  93683. * @param gradient defines the gradient to remove
  93684. * @returns the current particle system
  93685. */
  93686. removeColorRemapGradient(gradient: number): IParticleSystem;
  93687. /**
  93688. * Adds a new alpha remap gradient
  93689. * @param gradient defines the gradient to use (between 0 and 1)
  93690. * @param min defines the alpha remap minimal range
  93691. * @param max defines the alpha remap maximal range
  93692. * @returns the current particle system
  93693. */
  93694. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93695. /**
  93696. * Remove a specific alpha remap gradient
  93697. * @param gradient defines the gradient to remove
  93698. * @returns the current particle system
  93699. */
  93700. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  93701. /**
  93702. * Adds a new angular speed gradient
  93703. * @param gradient defines the gradient to use (between 0 and 1)
  93704. * @param factor defines the angular speed to affect to the specified gradient
  93705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93706. * @returns the current particle system
  93707. */
  93708. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93709. /**
  93710. * Remove a specific angular speed gradient
  93711. * @param gradient defines the gradient to remove
  93712. * @returns the current particle system
  93713. */
  93714. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93715. /**
  93716. * Adds a new velocity gradient
  93717. * @param gradient defines the gradient to use (between 0 and 1)
  93718. * @param factor defines the velocity to affect to the specified gradient
  93719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93720. * @returns the current particle system
  93721. */
  93722. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93723. /**
  93724. * Remove a specific velocity gradient
  93725. * @param gradient defines the gradient to remove
  93726. * @returns the current particle system
  93727. */
  93728. removeVelocityGradient(gradient: number): IParticleSystem;
  93729. /**
  93730. * Adds a new limit velocity gradient
  93731. * @param gradient defines the gradient to use (between 0 and 1)
  93732. * @param factor defines the limit velocity value to affect to the specified gradient
  93733. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93734. * @returns the current particle system
  93735. */
  93736. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93737. /**
  93738. * Remove a specific limit velocity gradient
  93739. * @param gradient defines the gradient to remove
  93740. * @returns the current particle system
  93741. */
  93742. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93743. /**
  93744. * Adds a new drag gradient
  93745. * @param gradient defines the gradient to use (between 0 and 1)
  93746. * @param factor defines the drag value to affect to the specified gradient
  93747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93748. * @returns the current particle system
  93749. */
  93750. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93751. /**
  93752. * Remove a specific drag gradient
  93753. * @param gradient defines the gradient to remove
  93754. * @returns the current particle system
  93755. */
  93756. removeDragGradient(gradient: number): IParticleSystem;
  93757. /**
  93758. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93759. * @param gradient defines the gradient to use (between 0 and 1)
  93760. * @param factor defines the emit rate value to affect to the specified gradient
  93761. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93762. * @returns the current particle system
  93763. */
  93764. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93765. /**
  93766. * Remove a specific emit rate gradient
  93767. * @param gradient defines the gradient to remove
  93768. * @returns the current particle system
  93769. */
  93770. removeEmitRateGradient(gradient: number): IParticleSystem;
  93771. /**
  93772. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93773. * @param gradient defines the gradient to use (between 0 and 1)
  93774. * @param factor defines the start size value to affect to the specified gradient
  93775. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93776. * @returns the current particle system
  93777. */
  93778. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93779. /**
  93780. * Remove a specific start size gradient
  93781. * @param gradient defines the gradient to remove
  93782. * @returns the current particle system
  93783. */
  93784. removeStartSizeGradient(gradient: number): IParticleSystem;
  93785. private _createRampGradientTexture;
  93786. /**
  93787. * Gets the current list of ramp gradients.
  93788. * You must use addRampGradient and removeRampGradient to udpate this list
  93789. * @returns the list of ramp gradients
  93790. */
  93791. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93792. /** Force the system to rebuild all gradients that need to be resync */
  93793. forceRefreshGradients(): void;
  93794. private _syncRampGradientTexture;
  93795. /**
  93796. * Adds a new ramp gradient used to remap particle colors
  93797. * @param gradient defines the gradient to use (between 0 and 1)
  93798. * @param color defines the color to affect to the specified gradient
  93799. * @returns the current particle system
  93800. */
  93801. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  93802. /**
  93803. * Remove a specific ramp gradient
  93804. * @param gradient defines the gradient to remove
  93805. * @returns the current particle system
  93806. */
  93807. removeRampGradient(gradient: number): ParticleSystem;
  93808. /**
  93809. * Adds a new color gradient
  93810. * @param gradient defines the gradient to use (between 0 and 1)
  93811. * @param color1 defines the color to affect to the specified gradient
  93812. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93813. * @returns this particle system
  93814. */
  93815. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93816. /**
  93817. * Remove a specific color gradient
  93818. * @param gradient defines the gradient to remove
  93819. * @returns this particle system
  93820. */
  93821. removeColorGradient(gradient: number): IParticleSystem;
  93822. private _fetchR;
  93823. protected _reset(): void;
  93824. private _resetEffect;
  93825. private _createVertexBuffers;
  93826. private _createIndexBuffer;
  93827. /**
  93828. * Gets the maximum number of particles active at the same time.
  93829. * @returns The max number of active particles.
  93830. */
  93831. getCapacity(): number;
  93832. /**
  93833. * Gets whether there are still active particles in the system.
  93834. * @returns True if it is alive, otherwise false.
  93835. */
  93836. isAlive(): boolean;
  93837. /**
  93838. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93839. * @returns True if it has been started, otherwise false.
  93840. */
  93841. isStarted(): boolean;
  93842. private _prepareSubEmitterInternalArray;
  93843. /**
  93844. * Starts the particle system and begins to emit
  93845. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  93846. */
  93847. start(delay?: number): void;
  93848. /**
  93849. * Stops the particle system.
  93850. * @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.
  93851. */
  93852. stop(stopSubEmitters?: boolean): void;
  93853. /**
  93854. * Remove all active particles
  93855. */
  93856. reset(): void;
  93857. /**
  93858. * @hidden (for internal use only)
  93859. */
  93860. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  93861. /**
  93862. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  93863. * Its lifetime will start back at 0.
  93864. */
  93865. recycleParticle: (particle: Particle) => void;
  93866. private _stopSubEmitters;
  93867. private _createParticle;
  93868. private _removeFromRoot;
  93869. private _emitFromParticle;
  93870. private _update;
  93871. /** @hidden */
  93872. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  93873. /** @hidden */
  93874. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  93875. /**
  93876. * Fill the defines array according to the current settings of the particle system
  93877. * @param defines Array to be updated
  93878. * @param blendMode blend mode to take into account when updating the array
  93879. */
  93880. fillDefines(defines: Array<string>, blendMode: number): void;
  93881. /**
  93882. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93883. * @param uniforms Uniforms array to fill
  93884. * @param attributes Attributes array to fill
  93885. * @param samplers Samplers array to fill
  93886. */
  93887. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93888. /** @hidden */
  93889. private _getEffect;
  93890. /**
  93891. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  93892. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  93893. */
  93894. animate(preWarmOnly?: boolean): void;
  93895. private _appendParticleVertices;
  93896. /**
  93897. * Rebuilds the particle system.
  93898. */
  93899. rebuild(): void;
  93900. /**
  93901. * Is this system ready to be used/rendered
  93902. * @return true if the system is ready
  93903. */
  93904. isReady(): boolean;
  93905. private _render;
  93906. /**
  93907. * Renders the particle system in its current state.
  93908. * @returns the current number of particles
  93909. */
  93910. render(): number;
  93911. /**
  93912. * Disposes the particle system and free the associated resources
  93913. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93914. */
  93915. dispose(disposeTexture?: boolean): void;
  93916. /**
  93917. * Clones the particle system.
  93918. * @param name The name of the cloned object
  93919. * @param newEmitter The new emitter to use
  93920. * @returns the cloned particle system
  93921. */
  93922. clone(name: string, newEmitter: any): ParticleSystem;
  93923. /**
  93924. * Serializes the particle system to a JSON object
  93925. * @param serializeTexture defines if the texture must be serialized as well
  93926. * @returns the JSON object
  93927. */
  93928. serialize(serializeTexture?: boolean): any;
  93929. /** @hidden */
  93930. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  93931. /** @hidden */
  93932. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  93933. /**
  93934. * Parses a JSON object to create a particle system.
  93935. * @param parsedParticleSystem The JSON object to parse
  93936. * @param sceneOrEngine The scene or the engine to create the particle system in
  93937. * @param rootUrl The root url to use to load external dependencies like texture
  93938. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  93939. * @returns the Parsed particle system
  93940. */
  93941. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  93942. }
  93943. }
  93944. declare module BABYLON {
  93945. /**
  93946. * A particle represents one of the element emitted by a particle system.
  93947. * This is mainly define by its coordinates, direction, velocity and age.
  93948. */
  93949. export class Particle {
  93950. /**
  93951. * The particle system the particle belongs to.
  93952. */
  93953. particleSystem: ParticleSystem;
  93954. private static _Count;
  93955. /**
  93956. * Unique ID of the particle
  93957. */
  93958. id: number;
  93959. /**
  93960. * The world position of the particle in the scene.
  93961. */
  93962. position: Vector3;
  93963. /**
  93964. * The world direction of the particle in the scene.
  93965. */
  93966. direction: Vector3;
  93967. /**
  93968. * The color of the particle.
  93969. */
  93970. color: Color4;
  93971. /**
  93972. * The color change of the particle per step.
  93973. */
  93974. colorStep: Color4;
  93975. /**
  93976. * Defines how long will the life of the particle be.
  93977. */
  93978. lifeTime: number;
  93979. /**
  93980. * The current age of the particle.
  93981. */
  93982. age: number;
  93983. /**
  93984. * The current size of the particle.
  93985. */
  93986. size: number;
  93987. /**
  93988. * The current scale of the particle.
  93989. */
  93990. scale: Vector2;
  93991. /**
  93992. * The current angle of the particle.
  93993. */
  93994. angle: number;
  93995. /**
  93996. * Defines how fast is the angle changing.
  93997. */
  93998. angularSpeed: number;
  93999. /**
  94000. * Defines the cell index used by the particle to be rendered from a sprite.
  94001. */
  94002. cellIndex: number;
  94003. /**
  94004. * The information required to support color remapping
  94005. */
  94006. remapData: Vector4;
  94007. /** @hidden */
  94008. _randomCellOffset?: number;
  94009. /** @hidden */
  94010. _initialDirection: Nullable<Vector3>;
  94011. /** @hidden */
  94012. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  94013. /** @hidden */
  94014. _initialStartSpriteCellID: number;
  94015. /** @hidden */
  94016. _initialEndSpriteCellID: number;
  94017. /** @hidden */
  94018. _currentColorGradient: Nullable<ColorGradient>;
  94019. /** @hidden */
  94020. _currentColor1: Color4;
  94021. /** @hidden */
  94022. _currentColor2: Color4;
  94023. /** @hidden */
  94024. _currentSizeGradient: Nullable<FactorGradient>;
  94025. /** @hidden */
  94026. _currentSize1: number;
  94027. /** @hidden */
  94028. _currentSize2: number;
  94029. /** @hidden */
  94030. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  94031. /** @hidden */
  94032. _currentAngularSpeed1: number;
  94033. /** @hidden */
  94034. _currentAngularSpeed2: number;
  94035. /** @hidden */
  94036. _currentVelocityGradient: Nullable<FactorGradient>;
  94037. /** @hidden */
  94038. _currentVelocity1: number;
  94039. /** @hidden */
  94040. _currentVelocity2: number;
  94041. /** @hidden */
  94042. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  94043. /** @hidden */
  94044. _currentLimitVelocity1: number;
  94045. /** @hidden */
  94046. _currentLimitVelocity2: number;
  94047. /** @hidden */
  94048. _currentDragGradient: Nullable<FactorGradient>;
  94049. /** @hidden */
  94050. _currentDrag1: number;
  94051. /** @hidden */
  94052. _currentDrag2: number;
  94053. /** @hidden */
  94054. _randomNoiseCoordinates1: Vector3;
  94055. /** @hidden */
  94056. _randomNoiseCoordinates2: Vector3;
  94057. /** @hidden */
  94058. _localPosition?: Vector3;
  94059. /**
  94060. * Creates a new instance Particle
  94061. * @param particleSystem the particle system the particle belongs to
  94062. */
  94063. constructor(
  94064. /**
  94065. * The particle system the particle belongs to.
  94066. */
  94067. particleSystem: ParticleSystem);
  94068. private updateCellInfoFromSystem;
  94069. /**
  94070. * Defines how the sprite cell index is updated for the particle
  94071. */
  94072. updateCellIndex(): void;
  94073. /** @hidden */
  94074. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  94075. /** @hidden */
  94076. _inheritParticleInfoToSubEmitters(): void;
  94077. /** @hidden */
  94078. _reset(): void;
  94079. /**
  94080. * Copy the properties of particle to another one.
  94081. * @param other the particle to copy the information to.
  94082. */
  94083. copyTo(other: Particle): void;
  94084. }
  94085. }
  94086. declare module BABYLON {
  94087. /**
  94088. * Particle emitter represents a volume emitting particles.
  94089. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  94090. */
  94091. export interface IParticleEmitterType {
  94092. /**
  94093. * Called by the particle System when the direction is computed for the created particle.
  94094. * @param worldMatrix is the world matrix of the particle system
  94095. * @param directionToUpdate is the direction vector to update with the result
  94096. * @param particle is the particle we are computed the direction for
  94097. * @param isLocal defines if the direction should be set in local space
  94098. */
  94099. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94100. /**
  94101. * Called by the particle System when the position is computed for the created particle.
  94102. * @param worldMatrix is the world matrix of the particle system
  94103. * @param positionToUpdate is the position vector to update with the result
  94104. * @param particle is the particle we are computed the position for
  94105. * @param isLocal defines if the position should be set in local space
  94106. */
  94107. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94108. /**
  94109. * Clones the current emitter and returns a copy of it
  94110. * @returns the new emitter
  94111. */
  94112. clone(): IParticleEmitterType;
  94113. /**
  94114. * Called by the GPUParticleSystem to setup the update shader
  94115. * @param effect defines the update shader
  94116. */
  94117. applyToShader(effect: Effect): void;
  94118. /**
  94119. * Returns a string to use to update the GPU particles update shader
  94120. * @returns the effect defines string
  94121. */
  94122. getEffectDefines(): string;
  94123. /**
  94124. * Returns a string representing the class name
  94125. * @returns a string containing the class name
  94126. */
  94127. getClassName(): string;
  94128. /**
  94129. * Serializes the particle system to a JSON object.
  94130. * @returns the JSON object
  94131. */
  94132. serialize(): any;
  94133. /**
  94134. * Parse properties from a JSON object
  94135. * @param serializationObject defines the JSON object
  94136. * @param scene defines the hosting scene
  94137. */
  94138. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94139. }
  94140. }
  94141. declare module BABYLON {
  94142. /**
  94143. * Particle emitter emitting particles from the inside of a box.
  94144. * It emits the particles randomly between 2 given directions.
  94145. */
  94146. export class BoxParticleEmitter implements IParticleEmitterType {
  94147. /**
  94148. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94149. */
  94150. direction1: Vector3;
  94151. /**
  94152. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94153. */
  94154. direction2: Vector3;
  94155. /**
  94156. * 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.
  94157. */
  94158. minEmitBox: Vector3;
  94159. /**
  94160. * 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.
  94161. */
  94162. maxEmitBox: Vector3;
  94163. /**
  94164. * Creates a new instance BoxParticleEmitter
  94165. */
  94166. constructor();
  94167. /**
  94168. * Called by the particle System when the direction is computed for the created particle.
  94169. * @param worldMatrix is the world matrix of the particle system
  94170. * @param directionToUpdate is the direction vector to update with the result
  94171. * @param particle is the particle we are computed the direction for
  94172. * @param isLocal defines if the direction should be set in local space
  94173. */
  94174. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94175. /**
  94176. * Called by the particle System when the position is computed for the created particle.
  94177. * @param worldMatrix is the world matrix of the particle system
  94178. * @param positionToUpdate is the position vector to update with the result
  94179. * @param particle is the particle we are computed the position for
  94180. * @param isLocal defines if the position should be set in local space
  94181. */
  94182. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94183. /**
  94184. * Clones the current emitter and returns a copy of it
  94185. * @returns the new emitter
  94186. */
  94187. clone(): BoxParticleEmitter;
  94188. /**
  94189. * Called by the GPUParticleSystem to setup the update shader
  94190. * @param effect defines the update shader
  94191. */
  94192. applyToShader(effect: Effect): void;
  94193. /**
  94194. * Returns a string to use to update the GPU particles update shader
  94195. * @returns a string containng the defines string
  94196. */
  94197. getEffectDefines(): string;
  94198. /**
  94199. * Returns the string "BoxParticleEmitter"
  94200. * @returns a string containing the class name
  94201. */
  94202. getClassName(): string;
  94203. /**
  94204. * Serializes the particle system to a JSON object.
  94205. * @returns the JSON object
  94206. */
  94207. serialize(): any;
  94208. /**
  94209. * Parse properties from a JSON object
  94210. * @param serializationObject defines the JSON object
  94211. */
  94212. parse(serializationObject: any): void;
  94213. }
  94214. }
  94215. declare module BABYLON {
  94216. /**
  94217. * Particle emitter emitting particles from the inside of a cone.
  94218. * It emits the particles alongside the cone volume from the base to the particle.
  94219. * The emission direction might be randomized.
  94220. */
  94221. export class ConeParticleEmitter implements IParticleEmitterType {
  94222. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94223. directionRandomizer: number;
  94224. private _radius;
  94225. private _angle;
  94226. private _height;
  94227. /**
  94228. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  94229. */
  94230. radiusRange: number;
  94231. /**
  94232. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  94233. */
  94234. heightRange: number;
  94235. /**
  94236. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  94237. */
  94238. emitFromSpawnPointOnly: boolean;
  94239. /**
  94240. * Gets or sets the radius of the emission cone
  94241. */
  94242. get radius(): number;
  94243. set radius(value: number);
  94244. /**
  94245. * Gets or sets the angle of the emission cone
  94246. */
  94247. get angle(): number;
  94248. set angle(value: number);
  94249. private _buildHeight;
  94250. /**
  94251. * Creates a new instance ConeParticleEmitter
  94252. * @param radius the radius of the emission cone (1 by default)
  94253. * @param angle the cone base angle (PI by default)
  94254. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  94255. */
  94256. constructor(radius?: number, angle?: number,
  94257. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94258. directionRandomizer?: number);
  94259. /**
  94260. * Called by the particle System when the direction is computed for the created particle.
  94261. * @param worldMatrix is the world matrix of the particle system
  94262. * @param directionToUpdate is the direction vector to update with the result
  94263. * @param particle is the particle we are computed the direction for
  94264. * @param isLocal defines if the direction should be set in local space
  94265. */
  94266. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94267. /**
  94268. * Called by the particle System when the position is computed for the created particle.
  94269. * @param worldMatrix is the world matrix of the particle system
  94270. * @param positionToUpdate is the position vector to update with the result
  94271. * @param particle is the particle we are computed the position for
  94272. * @param isLocal defines if the position should be set in local space
  94273. */
  94274. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94275. /**
  94276. * Clones the current emitter and returns a copy of it
  94277. * @returns the new emitter
  94278. */
  94279. clone(): ConeParticleEmitter;
  94280. /**
  94281. * Called by the GPUParticleSystem to setup the update shader
  94282. * @param effect defines the update shader
  94283. */
  94284. applyToShader(effect: Effect): void;
  94285. /**
  94286. * Returns a string to use to update the GPU particles update shader
  94287. * @returns a string containng the defines string
  94288. */
  94289. getEffectDefines(): string;
  94290. /**
  94291. * Returns the string "ConeParticleEmitter"
  94292. * @returns a string containing the class name
  94293. */
  94294. getClassName(): string;
  94295. /**
  94296. * Serializes the particle system to a JSON object.
  94297. * @returns the JSON object
  94298. */
  94299. serialize(): any;
  94300. /**
  94301. * Parse properties from a JSON object
  94302. * @param serializationObject defines the JSON object
  94303. */
  94304. parse(serializationObject: any): void;
  94305. }
  94306. }
  94307. declare module BABYLON {
  94308. /**
  94309. * Particle emitter emitting particles from the inside of a cylinder.
  94310. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  94311. */
  94312. export class CylinderParticleEmitter implements IParticleEmitterType {
  94313. /**
  94314. * The radius of the emission cylinder.
  94315. */
  94316. radius: number;
  94317. /**
  94318. * The height of the emission cylinder.
  94319. */
  94320. height: number;
  94321. /**
  94322. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94323. */
  94324. radiusRange: number;
  94325. /**
  94326. * How much to randomize the particle direction [0-1].
  94327. */
  94328. directionRandomizer: number;
  94329. /**
  94330. * Creates a new instance CylinderParticleEmitter
  94331. * @param radius the radius of the emission cylinder (1 by default)
  94332. * @param height the height of the emission cylinder (1 by default)
  94333. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94334. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94335. */
  94336. constructor(
  94337. /**
  94338. * The radius of the emission cylinder.
  94339. */
  94340. radius?: number,
  94341. /**
  94342. * The height of the emission cylinder.
  94343. */
  94344. height?: number,
  94345. /**
  94346. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94347. */
  94348. radiusRange?: number,
  94349. /**
  94350. * How much to randomize the particle direction [0-1].
  94351. */
  94352. directionRandomizer?: number);
  94353. /**
  94354. * Called by the particle System when the direction is computed for the created particle.
  94355. * @param worldMatrix is the world matrix of the particle system
  94356. * @param directionToUpdate is the direction vector to update with the result
  94357. * @param particle is the particle we are computed the direction for
  94358. * @param isLocal defines if the direction should be set in local space
  94359. */
  94360. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94361. /**
  94362. * Called by the particle System when the position is computed for the created particle.
  94363. * @param worldMatrix is the world matrix of the particle system
  94364. * @param positionToUpdate is the position vector to update with the result
  94365. * @param particle is the particle we are computed the position for
  94366. * @param isLocal defines if the position should be set in local space
  94367. */
  94368. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94369. /**
  94370. * Clones the current emitter and returns a copy of it
  94371. * @returns the new emitter
  94372. */
  94373. clone(): CylinderParticleEmitter;
  94374. /**
  94375. * Called by the GPUParticleSystem to setup the update shader
  94376. * @param effect defines the update shader
  94377. */
  94378. applyToShader(effect: Effect): void;
  94379. /**
  94380. * Returns a string to use to update the GPU particles update shader
  94381. * @returns a string containng the defines string
  94382. */
  94383. getEffectDefines(): string;
  94384. /**
  94385. * Returns the string "CylinderParticleEmitter"
  94386. * @returns a string containing the class name
  94387. */
  94388. getClassName(): string;
  94389. /**
  94390. * Serializes the particle system to a JSON object.
  94391. * @returns the JSON object
  94392. */
  94393. serialize(): any;
  94394. /**
  94395. * Parse properties from a JSON object
  94396. * @param serializationObject defines the JSON object
  94397. */
  94398. parse(serializationObject: any): void;
  94399. }
  94400. /**
  94401. * Particle emitter emitting particles from the inside of a cylinder.
  94402. * It emits the particles randomly between two vectors.
  94403. */
  94404. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  94405. /**
  94406. * The min limit of the emission direction.
  94407. */
  94408. direction1: Vector3;
  94409. /**
  94410. * The max limit of the emission direction.
  94411. */
  94412. direction2: Vector3;
  94413. /**
  94414. * Creates a new instance CylinderDirectedParticleEmitter
  94415. * @param radius the radius of the emission cylinder (1 by default)
  94416. * @param height the height of the emission cylinder (1 by default)
  94417. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94418. * @param direction1 the min limit of the emission direction (up vector by default)
  94419. * @param direction2 the max limit of the emission direction (up vector by default)
  94420. */
  94421. constructor(radius?: number, height?: number, radiusRange?: number,
  94422. /**
  94423. * The min limit of the emission direction.
  94424. */
  94425. direction1?: Vector3,
  94426. /**
  94427. * The max limit of the emission direction.
  94428. */
  94429. direction2?: Vector3);
  94430. /**
  94431. * Called by the particle System when the direction is computed for the created particle.
  94432. * @param worldMatrix is the world matrix of the particle system
  94433. * @param directionToUpdate is the direction vector to update with the result
  94434. * @param particle is the particle we are computed the direction for
  94435. */
  94436. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94437. /**
  94438. * Clones the current emitter and returns a copy of it
  94439. * @returns the new emitter
  94440. */
  94441. clone(): CylinderDirectedParticleEmitter;
  94442. /**
  94443. * Called by the GPUParticleSystem to setup the update shader
  94444. * @param effect defines the update shader
  94445. */
  94446. applyToShader(effect: Effect): void;
  94447. /**
  94448. * Returns a string to use to update the GPU particles update shader
  94449. * @returns a string containng the defines string
  94450. */
  94451. getEffectDefines(): string;
  94452. /**
  94453. * Returns the string "CylinderDirectedParticleEmitter"
  94454. * @returns a string containing the class name
  94455. */
  94456. getClassName(): string;
  94457. /**
  94458. * Serializes the particle system to a JSON object.
  94459. * @returns the JSON object
  94460. */
  94461. serialize(): any;
  94462. /**
  94463. * Parse properties from a JSON object
  94464. * @param serializationObject defines the JSON object
  94465. */
  94466. parse(serializationObject: any): void;
  94467. }
  94468. }
  94469. declare module BABYLON {
  94470. /**
  94471. * Particle emitter emitting particles from the inside of a hemisphere.
  94472. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  94473. */
  94474. export class HemisphericParticleEmitter implements IParticleEmitterType {
  94475. /**
  94476. * The radius of the emission hemisphere.
  94477. */
  94478. radius: number;
  94479. /**
  94480. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94481. */
  94482. radiusRange: number;
  94483. /**
  94484. * How much to randomize the particle direction [0-1].
  94485. */
  94486. directionRandomizer: number;
  94487. /**
  94488. * Creates a new instance HemisphericParticleEmitter
  94489. * @param radius the radius of the emission hemisphere (1 by default)
  94490. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94491. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94492. */
  94493. constructor(
  94494. /**
  94495. * The radius of the emission hemisphere.
  94496. */
  94497. radius?: number,
  94498. /**
  94499. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94500. */
  94501. radiusRange?: number,
  94502. /**
  94503. * How much to randomize the particle direction [0-1].
  94504. */
  94505. directionRandomizer?: number);
  94506. /**
  94507. * Called by the particle System when the direction is computed for the created particle.
  94508. * @param worldMatrix is the world matrix of the particle system
  94509. * @param directionToUpdate is the direction vector to update with the result
  94510. * @param particle is the particle we are computed the direction for
  94511. * @param isLocal defines if the direction should be set in local space
  94512. */
  94513. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94514. /**
  94515. * Called by the particle System when the position is computed for the created particle.
  94516. * @param worldMatrix is the world matrix of the particle system
  94517. * @param positionToUpdate is the position vector to update with the result
  94518. * @param particle is the particle we are computed the position for
  94519. * @param isLocal defines if the position should be set in local space
  94520. */
  94521. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94522. /**
  94523. * Clones the current emitter and returns a copy of it
  94524. * @returns the new emitter
  94525. */
  94526. clone(): HemisphericParticleEmitter;
  94527. /**
  94528. * Called by the GPUParticleSystem to setup the update shader
  94529. * @param effect defines the update shader
  94530. */
  94531. applyToShader(effect: Effect): void;
  94532. /**
  94533. * Returns a string to use to update the GPU particles update shader
  94534. * @returns a string containng the defines string
  94535. */
  94536. getEffectDefines(): string;
  94537. /**
  94538. * Returns the string "HemisphericParticleEmitter"
  94539. * @returns a string containing the class name
  94540. */
  94541. getClassName(): string;
  94542. /**
  94543. * Serializes the particle system to a JSON object.
  94544. * @returns the JSON object
  94545. */
  94546. serialize(): any;
  94547. /**
  94548. * Parse properties from a JSON object
  94549. * @param serializationObject defines the JSON object
  94550. */
  94551. parse(serializationObject: any): void;
  94552. }
  94553. }
  94554. declare module BABYLON {
  94555. /**
  94556. * Particle emitter emitting particles from a point.
  94557. * It emits the particles randomly between 2 given directions.
  94558. */
  94559. export class PointParticleEmitter implements IParticleEmitterType {
  94560. /**
  94561. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94562. */
  94563. direction1: Vector3;
  94564. /**
  94565. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94566. */
  94567. direction2: Vector3;
  94568. /**
  94569. * Creates a new instance PointParticleEmitter
  94570. */
  94571. constructor();
  94572. /**
  94573. * Called by the particle System when the direction is computed for the created particle.
  94574. * @param worldMatrix is the world matrix of the particle system
  94575. * @param directionToUpdate is the direction vector to update with the result
  94576. * @param particle is the particle we are computed the direction for
  94577. * @param isLocal defines if the direction should be set in local space
  94578. */
  94579. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94580. /**
  94581. * Called by the particle System when the position is computed for the created particle.
  94582. * @param worldMatrix is the world matrix of the particle system
  94583. * @param positionToUpdate is the position vector to update with the result
  94584. * @param particle is the particle we are computed the position for
  94585. * @param isLocal defines if the position should be set in local space
  94586. */
  94587. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94588. /**
  94589. * Clones the current emitter and returns a copy of it
  94590. * @returns the new emitter
  94591. */
  94592. clone(): PointParticleEmitter;
  94593. /**
  94594. * Called by the GPUParticleSystem to setup the update shader
  94595. * @param effect defines the update shader
  94596. */
  94597. applyToShader(effect: Effect): void;
  94598. /**
  94599. * Returns a string to use to update the GPU particles update shader
  94600. * @returns a string containng the defines string
  94601. */
  94602. getEffectDefines(): string;
  94603. /**
  94604. * Returns the string "PointParticleEmitter"
  94605. * @returns a string containing the class name
  94606. */
  94607. getClassName(): string;
  94608. /**
  94609. * Serializes the particle system to a JSON object.
  94610. * @returns the JSON object
  94611. */
  94612. serialize(): any;
  94613. /**
  94614. * Parse properties from a JSON object
  94615. * @param serializationObject defines the JSON object
  94616. */
  94617. parse(serializationObject: any): void;
  94618. }
  94619. }
  94620. declare module BABYLON {
  94621. /**
  94622. * Particle emitter emitting particles from the inside of a sphere.
  94623. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  94624. */
  94625. export class SphereParticleEmitter implements IParticleEmitterType {
  94626. /**
  94627. * The radius of the emission sphere.
  94628. */
  94629. radius: number;
  94630. /**
  94631. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94632. */
  94633. radiusRange: number;
  94634. /**
  94635. * How much to randomize the particle direction [0-1].
  94636. */
  94637. directionRandomizer: number;
  94638. /**
  94639. * Creates a new instance SphereParticleEmitter
  94640. * @param radius the radius of the emission sphere (1 by default)
  94641. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94642. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94643. */
  94644. constructor(
  94645. /**
  94646. * The radius of the emission sphere.
  94647. */
  94648. radius?: number,
  94649. /**
  94650. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94651. */
  94652. radiusRange?: number,
  94653. /**
  94654. * How much to randomize the particle direction [0-1].
  94655. */
  94656. directionRandomizer?: number);
  94657. /**
  94658. * Called by the particle System when the direction is computed for the created particle.
  94659. * @param worldMatrix is the world matrix of the particle system
  94660. * @param directionToUpdate is the direction vector to update with the result
  94661. * @param particle is the particle we are computed the direction for
  94662. * @param isLocal defines if the direction should be set in local space
  94663. */
  94664. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94665. /**
  94666. * Called by the particle System when the position is computed for the created particle.
  94667. * @param worldMatrix is the world matrix of the particle system
  94668. * @param positionToUpdate is the position vector to update with the result
  94669. * @param particle is the particle we are computed the position for
  94670. * @param isLocal defines if the position should be set in local space
  94671. */
  94672. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94673. /**
  94674. * Clones the current emitter and returns a copy of it
  94675. * @returns the new emitter
  94676. */
  94677. clone(): SphereParticleEmitter;
  94678. /**
  94679. * Called by the GPUParticleSystem to setup the update shader
  94680. * @param effect defines the update shader
  94681. */
  94682. applyToShader(effect: Effect): void;
  94683. /**
  94684. * Returns a string to use to update the GPU particles update shader
  94685. * @returns a string containng the defines string
  94686. */
  94687. getEffectDefines(): string;
  94688. /**
  94689. * Returns the string "SphereParticleEmitter"
  94690. * @returns a string containing the class name
  94691. */
  94692. getClassName(): string;
  94693. /**
  94694. * Serializes the particle system to a JSON object.
  94695. * @returns the JSON object
  94696. */
  94697. serialize(): any;
  94698. /**
  94699. * Parse properties from a JSON object
  94700. * @param serializationObject defines the JSON object
  94701. */
  94702. parse(serializationObject: any): void;
  94703. }
  94704. /**
  94705. * Particle emitter emitting particles from the inside of a sphere.
  94706. * It emits the particles randomly between two vectors.
  94707. */
  94708. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  94709. /**
  94710. * The min limit of the emission direction.
  94711. */
  94712. direction1: Vector3;
  94713. /**
  94714. * The max limit of the emission direction.
  94715. */
  94716. direction2: Vector3;
  94717. /**
  94718. * Creates a new instance SphereDirectedParticleEmitter
  94719. * @param radius the radius of the emission sphere (1 by default)
  94720. * @param direction1 the min limit of the emission direction (up vector by default)
  94721. * @param direction2 the max limit of the emission direction (up vector by default)
  94722. */
  94723. constructor(radius?: number,
  94724. /**
  94725. * The min limit of the emission direction.
  94726. */
  94727. direction1?: Vector3,
  94728. /**
  94729. * The max limit of the emission direction.
  94730. */
  94731. direction2?: Vector3);
  94732. /**
  94733. * Called by the particle System when the direction is computed for the created particle.
  94734. * @param worldMatrix is the world matrix of the particle system
  94735. * @param directionToUpdate is the direction vector to update with the result
  94736. * @param particle is the particle we are computed the direction for
  94737. */
  94738. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94739. /**
  94740. * Clones the current emitter and returns a copy of it
  94741. * @returns the new emitter
  94742. */
  94743. clone(): SphereDirectedParticleEmitter;
  94744. /**
  94745. * Called by the GPUParticleSystem to setup the update shader
  94746. * @param effect defines the update shader
  94747. */
  94748. applyToShader(effect: Effect): void;
  94749. /**
  94750. * Returns a string to use to update the GPU particles update shader
  94751. * @returns a string containng the defines string
  94752. */
  94753. getEffectDefines(): string;
  94754. /**
  94755. * Returns the string "SphereDirectedParticleEmitter"
  94756. * @returns a string containing the class name
  94757. */
  94758. getClassName(): string;
  94759. /**
  94760. * Serializes the particle system to a JSON object.
  94761. * @returns the JSON object
  94762. */
  94763. serialize(): any;
  94764. /**
  94765. * Parse properties from a JSON object
  94766. * @param serializationObject defines the JSON object
  94767. */
  94768. parse(serializationObject: any): void;
  94769. }
  94770. }
  94771. declare module BABYLON {
  94772. /**
  94773. * Particle emitter emitting particles from a custom list of positions.
  94774. */
  94775. export class CustomParticleEmitter implements IParticleEmitterType {
  94776. /**
  94777. * Gets or sets the position generator that will create the inital position of each particle.
  94778. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94779. */
  94780. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  94781. /**
  94782. * Gets or sets the destination generator that will create the final destination of each particle.
  94783. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94784. */
  94785. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  94786. /**
  94787. * Creates a new instance CustomParticleEmitter
  94788. */
  94789. constructor();
  94790. /**
  94791. * Called by the particle System when the direction is computed for the created particle.
  94792. * @param worldMatrix is the world matrix of the particle system
  94793. * @param directionToUpdate is the direction vector to update with the result
  94794. * @param particle is the particle we are computed the direction for
  94795. * @param isLocal defines if the direction should be set in local space
  94796. */
  94797. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94798. /**
  94799. * Called by the particle System when the position is computed for the created particle.
  94800. * @param worldMatrix is the world matrix of the particle system
  94801. * @param positionToUpdate is the position vector to update with the result
  94802. * @param particle is the particle we are computed the position for
  94803. * @param isLocal defines if the position should be set in local space
  94804. */
  94805. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94806. /**
  94807. * Clones the current emitter and returns a copy of it
  94808. * @returns the new emitter
  94809. */
  94810. clone(): CustomParticleEmitter;
  94811. /**
  94812. * Called by the GPUParticleSystem to setup the update shader
  94813. * @param effect defines the update shader
  94814. */
  94815. applyToShader(effect: Effect): void;
  94816. /**
  94817. * Returns a string to use to update the GPU particles update shader
  94818. * @returns a string containng the defines string
  94819. */
  94820. getEffectDefines(): string;
  94821. /**
  94822. * Returns the string "PointParticleEmitter"
  94823. * @returns a string containing the class name
  94824. */
  94825. getClassName(): string;
  94826. /**
  94827. * Serializes the particle system to a JSON object.
  94828. * @returns the JSON object
  94829. */
  94830. serialize(): any;
  94831. /**
  94832. * Parse properties from a JSON object
  94833. * @param serializationObject defines the JSON object
  94834. */
  94835. parse(serializationObject: any): void;
  94836. }
  94837. }
  94838. declare module BABYLON {
  94839. /**
  94840. * Particle emitter emitting particles from the inside of a box.
  94841. * It emits the particles randomly between 2 given directions.
  94842. */
  94843. export class MeshParticleEmitter implements IParticleEmitterType {
  94844. private _indices;
  94845. private _positions;
  94846. private _normals;
  94847. private _storedNormal;
  94848. private _mesh;
  94849. /**
  94850. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94851. */
  94852. direction1: Vector3;
  94853. /**
  94854. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94855. */
  94856. direction2: Vector3;
  94857. /**
  94858. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  94859. */
  94860. useMeshNormalsForDirection: boolean;
  94861. /** Defines the mesh to use as source */
  94862. get mesh(): Nullable<AbstractMesh>;
  94863. set mesh(value: Nullable<AbstractMesh>);
  94864. /**
  94865. * Creates a new instance MeshParticleEmitter
  94866. * @param mesh defines the mesh to use as source
  94867. */
  94868. constructor(mesh?: Nullable<AbstractMesh>);
  94869. /**
  94870. * Called by the particle System when the direction is computed for the created particle.
  94871. * @param worldMatrix is the world matrix of the particle system
  94872. * @param directionToUpdate is the direction vector to update with the result
  94873. * @param particle is the particle we are computed the direction for
  94874. * @param isLocal defines if the direction should be set in local space
  94875. */
  94876. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94877. /**
  94878. * Called by the particle System when the position is computed for the created particle.
  94879. * @param worldMatrix is the world matrix of the particle system
  94880. * @param positionToUpdate is the position vector to update with the result
  94881. * @param particle is the particle we are computed the position for
  94882. * @param isLocal defines if the position should be set in local space
  94883. */
  94884. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94885. /**
  94886. * Clones the current emitter and returns a copy of it
  94887. * @returns the new emitter
  94888. */
  94889. clone(): MeshParticleEmitter;
  94890. /**
  94891. * Called by the GPUParticleSystem to setup the update shader
  94892. * @param effect defines the update shader
  94893. */
  94894. applyToShader(effect: Effect): void;
  94895. /**
  94896. * Returns a string to use to update the GPU particles update shader
  94897. * @returns a string containng the defines string
  94898. */
  94899. getEffectDefines(): string;
  94900. /**
  94901. * Returns the string "BoxParticleEmitter"
  94902. * @returns a string containing the class name
  94903. */
  94904. getClassName(): string;
  94905. /**
  94906. * Serializes the particle system to a JSON object.
  94907. * @returns the JSON object
  94908. */
  94909. serialize(): any;
  94910. /**
  94911. * Parse properties from a JSON object
  94912. * @param serializationObject defines the JSON object
  94913. * @param scene defines the hosting scene
  94914. */
  94915. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94916. }
  94917. }
  94918. declare module BABYLON {
  94919. /**
  94920. * Interface representing a particle system in Babylon.js.
  94921. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  94922. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  94923. */
  94924. export interface IParticleSystem {
  94925. /**
  94926. * List of animations used by the particle system.
  94927. */
  94928. animations: Animation[];
  94929. /**
  94930. * The id of the Particle system.
  94931. */
  94932. id: string;
  94933. /**
  94934. * The name of the Particle system.
  94935. */
  94936. name: string;
  94937. /**
  94938. * The emitter represents the Mesh or position we are attaching the particle system to.
  94939. */
  94940. emitter: Nullable<AbstractMesh | Vector3>;
  94941. /**
  94942. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  94943. */
  94944. isBillboardBased: boolean;
  94945. /**
  94946. * The rendering group used by the Particle system to chose when to render.
  94947. */
  94948. renderingGroupId: number;
  94949. /**
  94950. * The layer mask we are rendering the particles through.
  94951. */
  94952. layerMask: number;
  94953. /**
  94954. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  94955. */
  94956. updateSpeed: number;
  94957. /**
  94958. * The amount of time the particle system is running (depends of the overall update speed).
  94959. */
  94960. targetStopDuration: number;
  94961. /**
  94962. * The texture used to render each particle. (this can be a spritesheet)
  94963. */
  94964. particleTexture: Nullable<BaseTexture>;
  94965. /**
  94966. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  94967. */
  94968. blendMode: number;
  94969. /**
  94970. * Minimum life time of emitting particles.
  94971. */
  94972. minLifeTime: number;
  94973. /**
  94974. * Maximum life time of emitting particles.
  94975. */
  94976. maxLifeTime: number;
  94977. /**
  94978. * Minimum Size of emitting particles.
  94979. */
  94980. minSize: number;
  94981. /**
  94982. * Maximum Size of emitting particles.
  94983. */
  94984. maxSize: number;
  94985. /**
  94986. * Minimum scale of emitting particles on X axis.
  94987. */
  94988. minScaleX: number;
  94989. /**
  94990. * Maximum scale of emitting particles on X axis.
  94991. */
  94992. maxScaleX: number;
  94993. /**
  94994. * Minimum scale of emitting particles on Y axis.
  94995. */
  94996. minScaleY: number;
  94997. /**
  94998. * Maximum scale of emitting particles on Y axis.
  94999. */
  95000. maxScaleY: number;
  95001. /**
  95002. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  95003. */
  95004. color1: Color4;
  95005. /**
  95006. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  95007. */
  95008. color2: Color4;
  95009. /**
  95010. * Color the particle will have at the end of its lifetime.
  95011. */
  95012. colorDead: Color4;
  95013. /**
  95014. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  95015. */
  95016. emitRate: number;
  95017. /**
  95018. * You can use gravity if you want to give an orientation to your particles.
  95019. */
  95020. gravity: Vector3;
  95021. /**
  95022. * Minimum power of emitting particles.
  95023. */
  95024. minEmitPower: number;
  95025. /**
  95026. * Maximum power of emitting particles.
  95027. */
  95028. maxEmitPower: number;
  95029. /**
  95030. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  95031. */
  95032. minAngularSpeed: number;
  95033. /**
  95034. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  95035. */
  95036. maxAngularSpeed: number;
  95037. /**
  95038. * Gets or sets the minimal initial rotation in radians.
  95039. */
  95040. minInitialRotation: number;
  95041. /**
  95042. * Gets or sets the maximal initial rotation in radians.
  95043. */
  95044. maxInitialRotation: number;
  95045. /**
  95046. * The particle emitter type defines the emitter used by the particle system.
  95047. * It can be for example box, sphere, or cone...
  95048. */
  95049. particleEmitterType: Nullable<IParticleEmitterType>;
  95050. /**
  95051. * Defines the delay in milliseconds before starting the system (0 by default)
  95052. */
  95053. startDelay: number;
  95054. /**
  95055. * 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
  95056. */
  95057. preWarmCycles: number;
  95058. /**
  95059. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  95060. */
  95061. preWarmStepOffset: number;
  95062. /**
  95063. * 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)
  95064. */
  95065. spriteCellChangeSpeed: number;
  95066. /**
  95067. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  95068. */
  95069. startSpriteCellID: number;
  95070. /**
  95071. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  95072. */
  95073. endSpriteCellID: number;
  95074. /**
  95075. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  95076. */
  95077. spriteCellWidth: number;
  95078. /**
  95079. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  95080. */
  95081. spriteCellHeight: number;
  95082. /**
  95083. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  95084. */
  95085. spriteRandomStartCell: boolean;
  95086. /**
  95087. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  95088. */
  95089. isAnimationSheetEnabled: boolean;
  95090. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  95091. translationPivot: Vector2;
  95092. /**
  95093. * Gets or sets a texture used to add random noise to particle positions
  95094. */
  95095. noiseTexture: Nullable<BaseTexture>;
  95096. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  95097. noiseStrength: Vector3;
  95098. /**
  95099. * Gets or sets the billboard mode to use when isBillboardBased = true.
  95100. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  95101. */
  95102. billboardMode: number;
  95103. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  95104. limitVelocityDamping: number;
  95105. /**
  95106. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  95107. */
  95108. beginAnimationOnStart: boolean;
  95109. /**
  95110. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  95111. */
  95112. beginAnimationFrom: number;
  95113. /**
  95114. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  95115. */
  95116. beginAnimationTo: number;
  95117. /**
  95118. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  95119. */
  95120. beginAnimationLoop: boolean;
  95121. /**
  95122. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  95123. */
  95124. disposeOnStop: boolean;
  95125. /**
  95126. * Specifies if the particles are updated in emitter local space or world space
  95127. */
  95128. isLocal: boolean;
  95129. /** Snippet ID if the particle system was created from the snippet server */
  95130. snippetId: string;
  95131. /** Gets or sets a matrix to use to compute projection */
  95132. defaultProjectionMatrix: Matrix;
  95133. /**
  95134. * Gets the maximum number of particles active at the same time.
  95135. * @returns The max number of active particles.
  95136. */
  95137. getCapacity(): number;
  95138. /**
  95139. * Gets the number of particles active at the same time.
  95140. * @returns The number of active particles.
  95141. */
  95142. getActiveCount(): number;
  95143. /**
  95144. * Gets if the system has been started. (Note: this will still be true after stop is called)
  95145. * @returns True if it has been started, otherwise false.
  95146. */
  95147. isStarted(): boolean;
  95148. /**
  95149. * Animates the particle system for this frame.
  95150. */
  95151. animate(): void;
  95152. /**
  95153. * Renders the particle system in its current state.
  95154. * @returns the current number of particles
  95155. */
  95156. render(): number;
  95157. /**
  95158. * Dispose the particle system and frees its associated resources.
  95159. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  95160. */
  95161. dispose(disposeTexture?: boolean): void;
  95162. /**
  95163. * An event triggered when the system is disposed
  95164. */
  95165. onDisposeObservable: Observable<IParticleSystem>;
  95166. /**
  95167. * An event triggered when the system is stopped
  95168. */
  95169. onStoppedObservable: Observable<IParticleSystem>;
  95170. /**
  95171. * Clones the particle system.
  95172. * @param name The name of the cloned object
  95173. * @param newEmitter The new emitter to use
  95174. * @returns the cloned particle system
  95175. */
  95176. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  95177. /**
  95178. * Serializes the particle system to a JSON object
  95179. * @param serializeTexture defines if the texture must be serialized as well
  95180. * @returns the JSON object
  95181. */
  95182. serialize(serializeTexture: boolean): any;
  95183. /**
  95184. * Rebuild the particle system
  95185. */
  95186. rebuild(): void;
  95187. /** Force the system to rebuild all gradients that need to be resync */
  95188. forceRefreshGradients(): void;
  95189. /**
  95190. * Starts the particle system and begins to emit
  95191. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  95192. */
  95193. start(delay?: number): void;
  95194. /**
  95195. * Stops the particle system.
  95196. */
  95197. stop(): void;
  95198. /**
  95199. * Remove all active particles
  95200. */
  95201. reset(): void;
  95202. /**
  95203. * Gets a boolean indicating that the system is stopping
  95204. * @returns true if the system is currently stopping
  95205. */
  95206. isStopping(): boolean;
  95207. /**
  95208. * Is this system ready to be used/rendered
  95209. * @return true if the system is ready
  95210. */
  95211. isReady(): boolean;
  95212. /**
  95213. * Returns the string "ParticleSystem"
  95214. * @returns a string containing the class name
  95215. */
  95216. getClassName(): string;
  95217. /**
  95218. * Gets the custom effect used to render the particles
  95219. * @param blendMode Blend mode for which the effect should be retrieved
  95220. * @returns The effect
  95221. */
  95222. getCustomEffect(blendMode: number): Nullable<Effect>;
  95223. /**
  95224. * Sets the custom effect used to render the particles
  95225. * @param effect The effect to set
  95226. * @param blendMode Blend mode for which the effect should be set
  95227. */
  95228. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  95229. /**
  95230. * Fill the defines array according to the current settings of the particle system
  95231. * @param defines Array to be updated
  95232. * @param blendMode blend mode to take into account when updating the array
  95233. */
  95234. fillDefines(defines: Array<string>, blendMode: number): void;
  95235. /**
  95236. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  95237. * @param uniforms Uniforms array to fill
  95238. * @param attributes Attributes array to fill
  95239. * @param samplers Samplers array to fill
  95240. */
  95241. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  95242. /**
  95243. * Observable that will be called just before the particles are drawn
  95244. */
  95245. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  95246. /**
  95247. * Gets the name of the particle vertex shader
  95248. */
  95249. vertexShaderName: string;
  95250. /**
  95251. * Adds a new color gradient
  95252. * @param gradient defines the gradient to use (between 0 and 1)
  95253. * @param color1 defines the color to affect to the specified gradient
  95254. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  95255. * @returns the current particle system
  95256. */
  95257. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  95258. /**
  95259. * Remove a specific color gradient
  95260. * @param gradient defines the gradient to remove
  95261. * @returns the current particle system
  95262. */
  95263. removeColorGradient(gradient: number): IParticleSystem;
  95264. /**
  95265. * Adds a new size gradient
  95266. * @param gradient defines the gradient to use (between 0 and 1)
  95267. * @param factor defines the size factor to affect to the specified gradient
  95268. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95269. * @returns the current particle system
  95270. */
  95271. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95272. /**
  95273. * Remove a specific size gradient
  95274. * @param gradient defines the gradient to remove
  95275. * @returns the current particle system
  95276. */
  95277. removeSizeGradient(gradient: number): IParticleSystem;
  95278. /**
  95279. * Gets the current list of color gradients.
  95280. * You must use addColorGradient and removeColorGradient to udpate this list
  95281. * @returns the list of color gradients
  95282. */
  95283. getColorGradients(): Nullable<Array<ColorGradient>>;
  95284. /**
  95285. * Gets the current list of size gradients.
  95286. * You must use addSizeGradient and removeSizeGradient to udpate this list
  95287. * @returns the list of size gradients
  95288. */
  95289. getSizeGradients(): Nullable<Array<FactorGradient>>;
  95290. /**
  95291. * Gets the current list of angular speed gradients.
  95292. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  95293. * @returns the list of angular speed gradients
  95294. */
  95295. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  95296. /**
  95297. * Adds a new angular speed gradient
  95298. * @param gradient defines the gradient to use (between 0 and 1)
  95299. * @param factor defines the angular speed to affect to the specified gradient
  95300. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95301. * @returns the current particle system
  95302. */
  95303. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95304. /**
  95305. * Remove a specific angular speed gradient
  95306. * @param gradient defines the gradient to remove
  95307. * @returns the current particle system
  95308. */
  95309. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  95310. /**
  95311. * Gets the current list of velocity gradients.
  95312. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  95313. * @returns the list of velocity gradients
  95314. */
  95315. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  95316. /**
  95317. * Adds a new velocity gradient
  95318. * @param gradient defines the gradient to use (between 0 and 1)
  95319. * @param factor defines the velocity to affect to the specified gradient
  95320. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95321. * @returns the current particle system
  95322. */
  95323. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95324. /**
  95325. * Remove a specific velocity gradient
  95326. * @param gradient defines the gradient to remove
  95327. * @returns the current particle system
  95328. */
  95329. removeVelocityGradient(gradient: number): IParticleSystem;
  95330. /**
  95331. * Gets the current list of limit velocity gradients.
  95332. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  95333. * @returns the list of limit velocity gradients
  95334. */
  95335. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  95336. /**
  95337. * Adds a new limit velocity gradient
  95338. * @param gradient defines the gradient to use (between 0 and 1)
  95339. * @param factor defines the limit velocity to affect to the specified gradient
  95340. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95341. * @returns the current particle system
  95342. */
  95343. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95344. /**
  95345. * Remove a specific limit velocity gradient
  95346. * @param gradient defines the gradient to remove
  95347. * @returns the current particle system
  95348. */
  95349. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  95350. /**
  95351. * Adds a new drag gradient
  95352. * @param gradient defines the gradient to use (between 0 and 1)
  95353. * @param factor defines the drag to affect to the specified gradient
  95354. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95355. * @returns the current particle system
  95356. */
  95357. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95358. /**
  95359. * Remove a specific drag gradient
  95360. * @param gradient defines the gradient to remove
  95361. * @returns the current particle system
  95362. */
  95363. removeDragGradient(gradient: number): IParticleSystem;
  95364. /**
  95365. * Gets the current list of drag gradients.
  95366. * You must use addDragGradient and removeDragGradient to udpate this list
  95367. * @returns the list of drag gradients
  95368. */
  95369. getDragGradients(): Nullable<Array<FactorGradient>>;
  95370. /**
  95371. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  95372. * @param gradient defines the gradient to use (between 0 and 1)
  95373. * @param factor defines the emit rate to affect to the specified gradient
  95374. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95375. * @returns the current particle system
  95376. */
  95377. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95378. /**
  95379. * Remove a specific emit rate gradient
  95380. * @param gradient defines the gradient to remove
  95381. * @returns the current particle system
  95382. */
  95383. removeEmitRateGradient(gradient: number): IParticleSystem;
  95384. /**
  95385. * Gets the current list of emit rate gradients.
  95386. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  95387. * @returns the list of emit rate gradients
  95388. */
  95389. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  95390. /**
  95391. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  95392. * @param gradient defines the gradient to use (between 0 and 1)
  95393. * @param factor defines the start size to affect to the specified gradient
  95394. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95395. * @returns the current particle system
  95396. */
  95397. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95398. /**
  95399. * Remove a specific start size gradient
  95400. * @param gradient defines the gradient to remove
  95401. * @returns the current particle system
  95402. */
  95403. removeStartSizeGradient(gradient: number): IParticleSystem;
  95404. /**
  95405. * Gets the current list of start size gradients.
  95406. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  95407. * @returns the list of start size gradients
  95408. */
  95409. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  95410. /**
  95411. * Adds a new life time gradient
  95412. * @param gradient defines the gradient to use (between 0 and 1)
  95413. * @param factor defines the life time factor to affect to the specified gradient
  95414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95415. * @returns the current particle system
  95416. */
  95417. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95418. /**
  95419. * Remove a specific life time gradient
  95420. * @param gradient defines the gradient to remove
  95421. * @returns the current particle system
  95422. */
  95423. removeLifeTimeGradient(gradient: number): IParticleSystem;
  95424. /**
  95425. * Gets the current list of life time gradients.
  95426. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  95427. * @returns the list of life time gradients
  95428. */
  95429. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  95430. /**
  95431. * Gets the current list of color gradients.
  95432. * You must use addColorGradient and removeColorGradient to udpate this list
  95433. * @returns the list of color gradients
  95434. */
  95435. getColorGradients(): Nullable<Array<ColorGradient>>;
  95436. /**
  95437. * Adds a new ramp gradient used to remap particle colors
  95438. * @param gradient defines the gradient to use (between 0 and 1)
  95439. * @param color defines the color to affect to the specified gradient
  95440. * @returns the current particle system
  95441. */
  95442. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  95443. /**
  95444. * Gets the current list of ramp gradients.
  95445. * You must use addRampGradient and removeRampGradient to udpate this list
  95446. * @returns the list of ramp gradients
  95447. */
  95448. getRampGradients(): Nullable<Array<Color3Gradient>>;
  95449. /** Gets or sets a boolean indicating that ramp gradients must be used
  95450. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  95451. */
  95452. useRampGradients: boolean;
  95453. /**
  95454. * Adds a new color remap gradient
  95455. * @param gradient defines the gradient to use (between 0 and 1)
  95456. * @param min defines the color remap minimal range
  95457. * @param max defines the color remap maximal range
  95458. * @returns the current particle system
  95459. */
  95460. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95461. /**
  95462. * Gets the current list of color remap gradients.
  95463. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  95464. * @returns the list of color remap gradients
  95465. */
  95466. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  95467. /**
  95468. * Adds a new alpha remap gradient
  95469. * @param gradient defines the gradient to use (between 0 and 1)
  95470. * @param min defines the alpha remap minimal range
  95471. * @param max defines the alpha remap maximal range
  95472. * @returns the current particle system
  95473. */
  95474. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95475. /**
  95476. * Gets the current list of alpha remap gradients.
  95477. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  95478. * @returns the list of alpha remap gradients
  95479. */
  95480. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  95481. /**
  95482. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  95483. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95484. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95485. * @returns the emitter
  95486. */
  95487. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  95488. /**
  95489. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  95490. * @param radius The radius of the hemisphere to emit from
  95491. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95492. * @returns the emitter
  95493. */
  95494. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  95495. /**
  95496. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  95497. * @param radius The radius of the sphere to emit from
  95498. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95499. * @returns the emitter
  95500. */
  95501. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  95502. /**
  95503. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  95504. * @param radius The radius of the sphere to emit from
  95505. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  95506. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  95507. * @returns the emitter
  95508. */
  95509. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95510. /**
  95511. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  95512. * @param radius The radius of the emission cylinder
  95513. * @param height The height of the emission cylinder
  95514. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  95515. * @param directionRandomizer How much to randomize the particle direction [0-1]
  95516. * @returns the emitter
  95517. */
  95518. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  95519. /**
  95520. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  95521. * @param radius The radius of the cylinder to emit from
  95522. * @param height The height of the emission cylinder
  95523. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  95524. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  95525. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  95526. * @returns the emitter
  95527. */
  95528. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95529. /**
  95530. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  95531. * @param radius The radius of the cone to emit from
  95532. * @param angle The base angle of the cone
  95533. * @returns the emitter
  95534. */
  95535. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  95536. /**
  95537. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  95538. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95539. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95540. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95541. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95542. * @returns the emitter
  95543. */
  95544. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  95545. /**
  95546. * Get hosting scene
  95547. * @returns the scene
  95548. */
  95549. getScene(): Nullable<Scene>;
  95550. }
  95551. }
  95552. declare module BABYLON {
  95553. /**
  95554. * 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.
  95555. * @see https://doc.babylonjs.com/how_to/transformnode
  95556. */
  95557. export class TransformNode extends Node {
  95558. /**
  95559. * Object will not rotate to face the camera
  95560. */
  95561. static BILLBOARDMODE_NONE: number;
  95562. /**
  95563. * Object will rotate to face the camera but only on the x axis
  95564. */
  95565. static BILLBOARDMODE_X: number;
  95566. /**
  95567. * Object will rotate to face the camera but only on the y axis
  95568. */
  95569. static BILLBOARDMODE_Y: number;
  95570. /**
  95571. * Object will rotate to face the camera but only on the z axis
  95572. */
  95573. static BILLBOARDMODE_Z: number;
  95574. /**
  95575. * Object will rotate to face the camera
  95576. */
  95577. static BILLBOARDMODE_ALL: number;
  95578. /**
  95579. * Object will rotate to face the camera's position instead of orientation
  95580. */
  95581. static BILLBOARDMODE_USE_POSITION: number;
  95582. private static _TmpRotation;
  95583. private static _TmpScaling;
  95584. private static _TmpTranslation;
  95585. private _forward;
  95586. private _forwardInverted;
  95587. private _up;
  95588. private _right;
  95589. private _rightInverted;
  95590. private _position;
  95591. private _rotation;
  95592. private _rotationQuaternion;
  95593. protected _scaling: Vector3;
  95594. protected _isDirty: boolean;
  95595. private _transformToBoneReferal;
  95596. private _isAbsoluteSynced;
  95597. private _billboardMode;
  95598. /**
  95599. * Gets or sets the billboard mode. Default is 0.
  95600. *
  95601. * | Value | Type | Description |
  95602. * | --- | --- | --- |
  95603. * | 0 | BILLBOARDMODE_NONE | |
  95604. * | 1 | BILLBOARDMODE_X | |
  95605. * | 2 | BILLBOARDMODE_Y | |
  95606. * | 4 | BILLBOARDMODE_Z | |
  95607. * | 7 | BILLBOARDMODE_ALL | |
  95608. *
  95609. */
  95610. get billboardMode(): number;
  95611. set billboardMode(value: number);
  95612. private _preserveParentRotationForBillboard;
  95613. /**
  95614. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  95615. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  95616. */
  95617. get preserveParentRotationForBillboard(): boolean;
  95618. set preserveParentRotationForBillboard(value: boolean);
  95619. /**
  95620. * 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
  95621. */
  95622. scalingDeterminant: number;
  95623. private _infiniteDistance;
  95624. /**
  95625. * Gets or sets the distance of the object to max, often used by skybox
  95626. */
  95627. get infiniteDistance(): boolean;
  95628. set infiniteDistance(value: boolean);
  95629. /**
  95630. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  95631. * By default the system will update normals to compensate
  95632. */
  95633. ignoreNonUniformScaling: boolean;
  95634. /**
  95635. * 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
  95636. */
  95637. reIntegrateRotationIntoRotationQuaternion: boolean;
  95638. /** @hidden */
  95639. _poseMatrix: Nullable<Matrix>;
  95640. /** @hidden */
  95641. _localMatrix: Matrix;
  95642. private _usePivotMatrix;
  95643. private _absolutePosition;
  95644. private _absoluteScaling;
  95645. private _absoluteRotationQuaternion;
  95646. private _pivotMatrix;
  95647. private _pivotMatrixInverse;
  95648. /** @hidden */
  95649. _postMultiplyPivotMatrix: boolean;
  95650. protected _isWorldMatrixFrozen: boolean;
  95651. /** @hidden */
  95652. _indexInSceneTransformNodesArray: number;
  95653. /**
  95654. * An event triggered after the world matrix is updated
  95655. */
  95656. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  95657. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  95658. /**
  95659. * Gets a string identifying the name of the class
  95660. * @returns "TransformNode" string
  95661. */
  95662. getClassName(): string;
  95663. /**
  95664. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  95665. */
  95666. get position(): Vector3;
  95667. set position(newPosition: Vector3);
  95668. /**
  95669. * 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)).
  95670. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  95671. */
  95672. get rotation(): Vector3;
  95673. set rotation(newRotation: Vector3);
  95674. /**
  95675. * 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)).
  95676. */
  95677. get scaling(): Vector3;
  95678. set scaling(newScaling: Vector3);
  95679. /**
  95680. * 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).
  95681. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  95682. */
  95683. get rotationQuaternion(): Nullable<Quaternion>;
  95684. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  95685. /**
  95686. * The forward direction of that transform in world space.
  95687. */
  95688. get forward(): Vector3;
  95689. /**
  95690. * The up direction of that transform in world space.
  95691. */
  95692. get up(): Vector3;
  95693. /**
  95694. * The right direction of that transform in world space.
  95695. */
  95696. get right(): Vector3;
  95697. /**
  95698. * Copies the parameter passed Matrix into the mesh Pose matrix.
  95699. * @param matrix the matrix to copy the pose from
  95700. * @returns this TransformNode.
  95701. */
  95702. updatePoseMatrix(matrix: Matrix): TransformNode;
  95703. /**
  95704. * Returns the mesh Pose matrix.
  95705. * @returns the pose matrix
  95706. */
  95707. getPoseMatrix(): Matrix;
  95708. /** @hidden */
  95709. _isSynchronized(): boolean;
  95710. /** @hidden */
  95711. _initCache(): void;
  95712. /**
  95713. * Flag the transform node as dirty (Forcing it to update everything)
  95714. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  95715. * @returns this transform node
  95716. */
  95717. markAsDirty(property: string): TransformNode;
  95718. /**
  95719. * Returns the current mesh absolute position.
  95720. * Returns a Vector3.
  95721. */
  95722. get absolutePosition(): Vector3;
  95723. /**
  95724. * Returns the current mesh absolute scaling.
  95725. * Returns a Vector3.
  95726. */
  95727. get absoluteScaling(): Vector3;
  95728. /**
  95729. * Returns the current mesh absolute rotation.
  95730. * Returns a Quaternion.
  95731. */
  95732. get absoluteRotationQuaternion(): Quaternion;
  95733. /**
  95734. * Sets a new matrix to apply before all other transformation
  95735. * @param matrix defines the transform matrix
  95736. * @returns the current TransformNode
  95737. */
  95738. setPreTransformMatrix(matrix: Matrix): TransformNode;
  95739. /**
  95740. * Sets a new pivot matrix to the current node
  95741. * @param matrix defines the new pivot matrix to use
  95742. * @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
  95743. * @returns the current TransformNode
  95744. */
  95745. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  95746. /**
  95747. * Returns the mesh pivot matrix.
  95748. * Default : Identity.
  95749. * @returns the matrix
  95750. */
  95751. getPivotMatrix(): Matrix;
  95752. /**
  95753. * Instantiate (when possible) or clone that node with its hierarchy
  95754. * @param newParent defines the new parent to use for the instance (or clone)
  95755. * @param options defines options to configure how copy is done
  95756. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  95757. * @returns an instance (or a clone) of the current node with its hiearchy
  95758. */
  95759. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95760. doNotInstantiate: boolean;
  95761. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95762. /**
  95763. * Prevents the World matrix to be computed any longer
  95764. * @param newWorldMatrix defines an optional matrix to use as world matrix
  95765. * @returns the TransformNode.
  95766. */
  95767. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  95768. /**
  95769. * Allows back the World matrix computation.
  95770. * @returns the TransformNode.
  95771. */
  95772. unfreezeWorldMatrix(): this;
  95773. /**
  95774. * True if the World matrix has been frozen.
  95775. */
  95776. get isWorldMatrixFrozen(): boolean;
  95777. /**
  95778. * Retuns the mesh absolute position in the World.
  95779. * @returns a Vector3.
  95780. */
  95781. getAbsolutePosition(): Vector3;
  95782. /**
  95783. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  95784. * @param absolutePosition the absolute position to set
  95785. * @returns the TransformNode.
  95786. */
  95787. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  95788. /**
  95789. * Sets the mesh position in its local space.
  95790. * @param vector3 the position to set in localspace
  95791. * @returns the TransformNode.
  95792. */
  95793. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  95794. /**
  95795. * Returns the mesh position in the local space from the current World matrix values.
  95796. * @returns a new Vector3.
  95797. */
  95798. getPositionExpressedInLocalSpace(): Vector3;
  95799. /**
  95800. * Translates the mesh along the passed Vector3 in its local space.
  95801. * @param vector3 the distance to translate in localspace
  95802. * @returns the TransformNode.
  95803. */
  95804. locallyTranslate(vector3: Vector3): TransformNode;
  95805. private static _lookAtVectorCache;
  95806. /**
  95807. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  95808. * @param targetPoint the position (must be in same space as current mesh) to look at
  95809. * @param yawCor optional yaw (y-axis) correction in radians
  95810. * @param pitchCor optional pitch (x-axis) correction in radians
  95811. * @param rollCor optional roll (z-axis) correction in radians
  95812. * @param space the choosen space of the target
  95813. * @returns the TransformNode.
  95814. */
  95815. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  95816. /**
  95817. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95818. * This Vector3 is expressed in the World space.
  95819. * @param localAxis axis to rotate
  95820. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95821. */
  95822. getDirection(localAxis: Vector3): Vector3;
  95823. /**
  95824. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  95825. * localAxis is expressed in the mesh local space.
  95826. * result is computed in the Wordl space from the mesh World matrix.
  95827. * @param localAxis axis to rotate
  95828. * @param result the resulting transformnode
  95829. * @returns this TransformNode.
  95830. */
  95831. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  95832. /**
  95833. * Sets this transform node rotation to the given local axis.
  95834. * @param localAxis the axis in local space
  95835. * @param yawCor optional yaw (y-axis) correction in radians
  95836. * @param pitchCor optional pitch (x-axis) correction in radians
  95837. * @param rollCor optional roll (z-axis) correction in radians
  95838. * @returns this TransformNode
  95839. */
  95840. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  95841. /**
  95842. * Sets a new pivot point to the current node
  95843. * @param point defines the new pivot point to use
  95844. * @param space defines if the point is in world or local space (local by default)
  95845. * @returns the current TransformNode
  95846. */
  95847. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  95848. /**
  95849. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  95850. * @returns the pivot point
  95851. */
  95852. getPivotPoint(): Vector3;
  95853. /**
  95854. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  95855. * @param result the vector3 to store the result
  95856. * @returns this TransformNode.
  95857. */
  95858. getPivotPointToRef(result: Vector3): TransformNode;
  95859. /**
  95860. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  95861. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  95862. */
  95863. getAbsolutePivotPoint(): Vector3;
  95864. /**
  95865. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  95866. * @param result vector3 to store the result
  95867. * @returns this TransformNode.
  95868. */
  95869. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  95870. /**
  95871. * Defines the passed node as the parent of the current node.
  95872. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  95873. * @see https://doc.babylonjs.com/how_to/parenting
  95874. * @param node the node ot set as the parent
  95875. * @returns this TransformNode.
  95876. */
  95877. setParent(node: Nullable<Node>): TransformNode;
  95878. private _nonUniformScaling;
  95879. /**
  95880. * True if the scaling property of this object is non uniform eg. (1,2,1)
  95881. */
  95882. get nonUniformScaling(): boolean;
  95883. /** @hidden */
  95884. _updateNonUniformScalingState(value: boolean): boolean;
  95885. /**
  95886. * Attach the current TransformNode to another TransformNode associated with a bone
  95887. * @param bone Bone affecting the TransformNode
  95888. * @param affectedTransformNode TransformNode associated with the bone
  95889. * @returns this object
  95890. */
  95891. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  95892. /**
  95893. * Detach the transform node if its associated with a bone
  95894. * @returns this object
  95895. */
  95896. detachFromBone(): TransformNode;
  95897. private static _rotationAxisCache;
  95898. /**
  95899. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  95900. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95901. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95902. * The passed axis is also normalized.
  95903. * @param axis the axis to rotate around
  95904. * @param amount the amount to rotate in radians
  95905. * @param space Space to rotate in (Default: local)
  95906. * @returns the TransformNode.
  95907. */
  95908. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  95909. /**
  95910. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  95911. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95912. * The passed axis is also normalized. .
  95913. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  95914. * @param point the point to rotate around
  95915. * @param axis the axis to rotate around
  95916. * @param amount the amount to rotate in radians
  95917. * @returns the TransformNode
  95918. */
  95919. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  95920. /**
  95921. * Translates the mesh along the axis vector for the passed distance in the given space.
  95922. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95923. * @param axis the axis to translate in
  95924. * @param distance the distance to translate
  95925. * @param space Space to rotate in (Default: local)
  95926. * @returns the TransformNode.
  95927. */
  95928. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  95929. /**
  95930. * Adds a rotation step to the mesh current rotation.
  95931. * x, y, z are Euler angles expressed in radians.
  95932. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  95933. * This means this rotation is made in the mesh local space only.
  95934. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  95935. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  95936. * ```javascript
  95937. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  95938. * ```
  95939. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  95940. * 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.
  95941. * @param x Rotation to add
  95942. * @param y Rotation to add
  95943. * @param z Rotation to add
  95944. * @returns the TransformNode.
  95945. */
  95946. addRotation(x: number, y: number, z: number): TransformNode;
  95947. /**
  95948. * @hidden
  95949. */
  95950. protected _getEffectiveParent(): Nullable<Node>;
  95951. /**
  95952. * Computes the world matrix of the node
  95953. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95954. * @returns the world matrix
  95955. */
  95956. computeWorldMatrix(force?: boolean): Matrix;
  95957. /**
  95958. * Resets this nodeTransform's local matrix to Matrix.Identity().
  95959. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  95960. */
  95961. resetLocalMatrix(independentOfChildren?: boolean): void;
  95962. protected _afterComputeWorldMatrix(): void;
  95963. /**
  95964. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95965. * @param func callback function to add
  95966. *
  95967. * @returns the TransformNode.
  95968. */
  95969. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95970. /**
  95971. * Removes a registered callback function.
  95972. * @param func callback function to remove
  95973. * @returns the TransformNode.
  95974. */
  95975. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95976. /**
  95977. * Gets the position of the current mesh in camera space
  95978. * @param camera defines the camera to use
  95979. * @returns a position
  95980. */
  95981. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  95982. /**
  95983. * Returns the distance from the mesh to the active camera
  95984. * @param camera defines the camera to use
  95985. * @returns the distance
  95986. */
  95987. getDistanceToCamera(camera?: Nullable<Camera>): number;
  95988. /**
  95989. * Clone the current transform node
  95990. * @param name Name of the new clone
  95991. * @param newParent New parent for the clone
  95992. * @param doNotCloneChildren Do not clone children hierarchy
  95993. * @returns the new transform node
  95994. */
  95995. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  95996. /**
  95997. * Serializes the objects information.
  95998. * @param currentSerializationObject defines the object to serialize in
  95999. * @returns the serialized object
  96000. */
  96001. serialize(currentSerializationObject?: any): any;
  96002. /**
  96003. * Returns a new TransformNode object parsed from the source provided.
  96004. * @param parsedTransformNode is the source.
  96005. * @param scene the scne the object belongs to
  96006. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  96007. * @returns a new TransformNode object parsed from the source provided.
  96008. */
  96009. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  96010. /**
  96011. * Get all child-transformNodes of this node
  96012. * @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
  96013. * @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
  96014. * @returns an array of TransformNode
  96015. */
  96016. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  96017. /**
  96018. * Releases resources associated with this transform node.
  96019. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96020. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96021. */
  96022. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96023. /**
  96024. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  96025. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  96026. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  96027. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  96028. * @returns the current mesh
  96029. */
  96030. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  96031. private _syncAbsoluteScalingAndRotation;
  96032. }
  96033. }
  96034. declare module BABYLON {
  96035. /**
  96036. * Class used to override all child animations of a given target
  96037. */
  96038. export class AnimationPropertiesOverride {
  96039. /**
  96040. * Gets or sets a value indicating if animation blending must be used
  96041. */
  96042. enableBlending: boolean;
  96043. /**
  96044. * Gets or sets the blending speed to use when enableBlending is true
  96045. */
  96046. blendingSpeed: number;
  96047. /**
  96048. * Gets or sets the default loop mode to use
  96049. */
  96050. loopMode: number;
  96051. }
  96052. }
  96053. declare module BABYLON {
  96054. /**
  96055. * Class used to store bone information
  96056. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96057. */
  96058. export class Bone extends Node {
  96059. /**
  96060. * defines the bone name
  96061. */
  96062. name: string;
  96063. private static _tmpVecs;
  96064. private static _tmpQuat;
  96065. private static _tmpMats;
  96066. /**
  96067. * Gets the list of child bones
  96068. */
  96069. children: Bone[];
  96070. /** Gets the animations associated with this bone */
  96071. animations: Animation[];
  96072. /**
  96073. * Gets or sets bone length
  96074. */
  96075. length: number;
  96076. /**
  96077. * @hidden Internal only
  96078. * Set this value to map this bone to a different index in the transform matrices
  96079. * Set this value to -1 to exclude the bone from the transform matrices
  96080. */
  96081. _index: Nullable<number>;
  96082. private _skeleton;
  96083. private _localMatrix;
  96084. private _restPose;
  96085. private _bindPose;
  96086. private _baseMatrix;
  96087. private _absoluteTransform;
  96088. private _invertedAbsoluteTransform;
  96089. private _parent;
  96090. private _scalingDeterminant;
  96091. private _worldTransform;
  96092. private _localScaling;
  96093. private _localRotation;
  96094. private _localPosition;
  96095. private _needToDecompose;
  96096. private _needToCompose;
  96097. /** @hidden */
  96098. _linkedTransformNode: Nullable<TransformNode>;
  96099. /** @hidden */
  96100. _waitingTransformNodeId: Nullable<string>;
  96101. /** @hidden */
  96102. get _matrix(): Matrix;
  96103. /** @hidden */
  96104. set _matrix(value: Matrix);
  96105. /**
  96106. * Create a new bone
  96107. * @param name defines the bone name
  96108. * @param skeleton defines the parent skeleton
  96109. * @param parentBone defines the parent (can be null if the bone is the root)
  96110. * @param localMatrix defines the local matrix
  96111. * @param restPose defines the rest pose matrix
  96112. * @param baseMatrix defines the base matrix
  96113. * @param index defines index of the bone in the hiearchy
  96114. */
  96115. constructor(
  96116. /**
  96117. * defines the bone name
  96118. */
  96119. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  96120. /**
  96121. * Gets the current object class name.
  96122. * @return the class name
  96123. */
  96124. getClassName(): string;
  96125. /**
  96126. * Gets the parent skeleton
  96127. * @returns a skeleton
  96128. */
  96129. getSkeleton(): Skeleton;
  96130. /**
  96131. * Gets parent bone
  96132. * @returns a bone or null if the bone is the root of the bone hierarchy
  96133. */
  96134. getParent(): Nullable<Bone>;
  96135. /**
  96136. * Returns an array containing the root bones
  96137. * @returns an array containing the root bones
  96138. */
  96139. getChildren(): Array<Bone>;
  96140. /**
  96141. * Gets the node index in matrix array generated for rendering
  96142. * @returns the node index
  96143. */
  96144. getIndex(): number;
  96145. /**
  96146. * Sets the parent bone
  96147. * @param parent defines the parent (can be null if the bone is the root)
  96148. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  96149. */
  96150. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  96151. /**
  96152. * Gets the local matrix
  96153. * @returns a matrix
  96154. */
  96155. getLocalMatrix(): Matrix;
  96156. /**
  96157. * Gets the base matrix (initial matrix which remains unchanged)
  96158. * @returns a matrix
  96159. */
  96160. getBaseMatrix(): Matrix;
  96161. /**
  96162. * Gets the rest pose matrix
  96163. * @returns a matrix
  96164. */
  96165. getRestPose(): Matrix;
  96166. /**
  96167. * Sets the rest pose matrix
  96168. * @param matrix the local-space rest pose to set for this bone
  96169. */
  96170. setRestPose(matrix: Matrix): void;
  96171. /**
  96172. * Gets the bind pose matrix
  96173. * @returns the bind pose matrix
  96174. */
  96175. getBindPose(): Matrix;
  96176. /**
  96177. * Sets the bind pose matrix
  96178. * @param matrix the local-space bind pose to set for this bone
  96179. */
  96180. setBindPose(matrix: Matrix): void;
  96181. /**
  96182. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  96183. */
  96184. getWorldMatrix(): Matrix;
  96185. /**
  96186. * Sets the local matrix to rest pose matrix
  96187. */
  96188. returnToRest(): void;
  96189. /**
  96190. * Gets the inverse of the absolute transform matrix.
  96191. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  96192. * @returns a matrix
  96193. */
  96194. getInvertedAbsoluteTransform(): Matrix;
  96195. /**
  96196. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  96197. * @returns a matrix
  96198. */
  96199. getAbsoluteTransform(): Matrix;
  96200. /**
  96201. * Links with the given transform node.
  96202. * The local matrix of this bone is copied from the transform node every frame.
  96203. * @param transformNode defines the transform node to link to
  96204. */
  96205. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  96206. /**
  96207. * Gets the node used to drive the bone's transformation
  96208. * @returns a transform node or null
  96209. */
  96210. getTransformNode(): Nullable<TransformNode>;
  96211. /** Gets or sets current position (in local space) */
  96212. get position(): Vector3;
  96213. set position(newPosition: Vector3);
  96214. /** Gets or sets current rotation (in local space) */
  96215. get rotation(): Vector3;
  96216. set rotation(newRotation: Vector3);
  96217. /** Gets or sets current rotation quaternion (in local space) */
  96218. get rotationQuaternion(): Quaternion;
  96219. set rotationQuaternion(newRotation: Quaternion);
  96220. /** Gets or sets current scaling (in local space) */
  96221. get scaling(): Vector3;
  96222. set scaling(newScaling: Vector3);
  96223. /**
  96224. * Gets the animation properties override
  96225. */
  96226. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96227. private _decompose;
  96228. private _compose;
  96229. /**
  96230. * Update the base and local matrices
  96231. * @param matrix defines the new base or local matrix
  96232. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  96233. * @param updateLocalMatrix defines if the local matrix should be updated
  96234. */
  96235. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  96236. /** @hidden */
  96237. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  96238. /**
  96239. * Flag the bone as dirty (Forcing it to update everything)
  96240. */
  96241. markAsDirty(): void;
  96242. /** @hidden */
  96243. _markAsDirtyAndCompose(): void;
  96244. private _markAsDirtyAndDecompose;
  96245. /**
  96246. * Translate the bone in local or world space
  96247. * @param vec The amount to translate the bone
  96248. * @param space The space that the translation is in
  96249. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96250. */
  96251. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96252. /**
  96253. * Set the postion of the bone in local or world space
  96254. * @param position The position to set the bone
  96255. * @param space The space that the position is in
  96256. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96257. */
  96258. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96259. /**
  96260. * Set the absolute position of the bone (world space)
  96261. * @param position The position to set the bone
  96262. * @param mesh The mesh that this bone is attached to
  96263. */
  96264. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  96265. /**
  96266. * Scale the bone on the x, y and z axes (in local space)
  96267. * @param x The amount to scale the bone on the x axis
  96268. * @param y The amount to scale the bone on the y axis
  96269. * @param z The amount to scale the bone on the z axis
  96270. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  96271. */
  96272. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  96273. /**
  96274. * Set the bone scaling in local space
  96275. * @param scale defines the scaling vector
  96276. */
  96277. setScale(scale: Vector3): void;
  96278. /**
  96279. * Gets the current scaling in local space
  96280. * @returns the current scaling vector
  96281. */
  96282. getScale(): Vector3;
  96283. /**
  96284. * Gets the current scaling in local space and stores it in a target vector
  96285. * @param result defines the target vector
  96286. */
  96287. getScaleToRef(result: Vector3): void;
  96288. /**
  96289. * Set the yaw, pitch, and roll of the bone in local or world space
  96290. * @param yaw The rotation of the bone on the y axis
  96291. * @param pitch The rotation of the bone on the x axis
  96292. * @param roll The rotation of the bone on the z axis
  96293. * @param space The space that the axes of rotation are in
  96294. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96295. */
  96296. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  96297. /**
  96298. * Add a rotation to the bone on an axis in local or world space
  96299. * @param axis The axis to rotate the bone on
  96300. * @param amount The amount to rotate the bone
  96301. * @param space The space that the axis is in
  96302. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96303. */
  96304. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  96305. /**
  96306. * Set the rotation of the bone to a particular axis angle in local or world space
  96307. * @param axis The axis to rotate the bone on
  96308. * @param angle The angle that the bone should be rotated to
  96309. * @param space The space that the axis is in
  96310. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96311. */
  96312. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  96313. /**
  96314. * Set the euler rotation of the bone in local or world space
  96315. * @param rotation The euler rotation that the bone should be set to
  96316. * @param space The space that the rotation is in
  96317. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96318. */
  96319. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96320. /**
  96321. * Set the quaternion rotation of the bone in local or world space
  96322. * @param quat The quaternion rotation that the bone should be set to
  96323. * @param space The space that the rotation is in
  96324. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96325. */
  96326. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  96327. /**
  96328. * Set the rotation matrix of the bone in local or world space
  96329. * @param rotMat The rotation matrix that the bone should be set to
  96330. * @param space The space that the rotation is in
  96331. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96332. */
  96333. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  96334. private _rotateWithMatrix;
  96335. private _getNegativeRotationToRef;
  96336. /**
  96337. * Get the position of the bone in local or world space
  96338. * @param space The space that the returned position is in
  96339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96340. * @returns The position of the bone
  96341. */
  96342. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96343. /**
  96344. * Copy the position of the bone to a vector3 in local or world space
  96345. * @param space The space that the returned position is in
  96346. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96347. * @param result The vector3 to copy the position to
  96348. */
  96349. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  96350. /**
  96351. * Get the absolute position of the bone (world space)
  96352. * @param mesh The mesh that this bone is attached to
  96353. * @returns The absolute position of the bone
  96354. */
  96355. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  96356. /**
  96357. * Copy the absolute position of the bone (world space) to the result param
  96358. * @param mesh The mesh that this bone is attached to
  96359. * @param result The vector3 to copy the absolute position to
  96360. */
  96361. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  96362. /**
  96363. * Compute the absolute transforms of this bone and its children
  96364. */
  96365. computeAbsoluteTransforms(): void;
  96366. /**
  96367. * Get the world direction from an axis that is in the local space of the bone
  96368. * @param localAxis The local direction that is used to compute the world direction
  96369. * @param mesh The mesh that this bone is attached to
  96370. * @returns The world direction
  96371. */
  96372. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96373. /**
  96374. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  96375. * @param localAxis The local direction that is used to compute the world direction
  96376. * @param mesh The mesh that this bone is attached to
  96377. * @param result The vector3 that the world direction will be copied to
  96378. */
  96379. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96380. /**
  96381. * Get the euler rotation of the bone in local or world space
  96382. * @param space The space that the rotation should be in
  96383. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96384. * @returns The euler rotation
  96385. */
  96386. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96387. /**
  96388. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  96389. * @param space The space that the rotation should be in
  96390. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96391. * @param result The vector3 that the rotation should be copied to
  96392. */
  96393. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96394. /**
  96395. * Get the quaternion rotation of the bone in either local or world space
  96396. * @param space The space that the rotation should be in
  96397. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96398. * @returns The quaternion rotation
  96399. */
  96400. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  96401. /**
  96402. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  96403. * @param space The space that the rotation should be in
  96404. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96405. * @param result The quaternion that the rotation should be copied to
  96406. */
  96407. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  96408. /**
  96409. * Get the rotation matrix of the bone in local or world space
  96410. * @param space The space that the rotation should be in
  96411. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96412. * @returns The rotation matrix
  96413. */
  96414. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  96415. /**
  96416. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  96417. * @param space The space that the rotation should be in
  96418. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96419. * @param result The quaternion that the rotation should be copied to
  96420. */
  96421. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  96422. /**
  96423. * Get the world position of a point that is in the local space of the bone
  96424. * @param position The local position
  96425. * @param mesh The mesh that this bone is attached to
  96426. * @returns The world position
  96427. */
  96428. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96429. /**
  96430. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  96431. * @param position The local position
  96432. * @param mesh The mesh that this bone is attached to
  96433. * @param result The vector3 that the world position should be copied to
  96434. */
  96435. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96436. /**
  96437. * Get the local position of a point that is in world space
  96438. * @param position The world position
  96439. * @param mesh The mesh that this bone is attached to
  96440. * @returns The local position
  96441. */
  96442. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96443. /**
  96444. * Get the local position of a point that is in world space and copy it to the result param
  96445. * @param position The world position
  96446. * @param mesh The mesh that this bone is attached to
  96447. * @param result The vector3 that the local position should be copied to
  96448. */
  96449. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96450. /**
  96451. * Set the current local matrix as the restPose for this bone.
  96452. */
  96453. setCurrentPoseAsRest(): void;
  96454. }
  96455. }
  96456. declare module BABYLON {
  96457. /**
  96458. * Defines a runtime animation
  96459. */
  96460. export class RuntimeAnimation {
  96461. private _events;
  96462. /**
  96463. * The current frame of the runtime animation
  96464. */
  96465. private _currentFrame;
  96466. /**
  96467. * The animation used by the runtime animation
  96468. */
  96469. private _animation;
  96470. /**
  96471. * The target of the runtime animation
  96472. */
  96473. private _target;
  96474. /**
  96475. * The initiating animatable
  96476. */
  96477. private _host;
  96478. /**
  96479. * The original value of the runtime animation
  96480. */
  96481. private _originalValue;
  96482. /**
  96483. * The original blend value of the runtime animation
  96484. */
  96485. private _originalBlendValue;
  96486. /**
  96487. * The offsets cache of the runtime animation
  96488. */
  96489. private _offsetsCache;
  96490. /**
  96491. * The high limits cache of the runtime animation
  96492. */
  96493. private _highLimitsCache;
  96494. /**
  96495. * Specifies if the runtime animation has been stopped
  96496. */
  96497. private _stopped;
  96498. /**
  96499. * The blending factor of the runtime animation
  96500. */
  96501. private _blendingFactor;
  96502. /**
  96503. * The BabylonJS scene
  96504. */
  96505. private _scene;
  96506. /**
  96507. * The current value of the runtime animation
  96508. */
  96509. private _currentValue;
  96510. /** @hidden */
  96511. _animationState: _IAnimationState;
  96512. /**
  96513. * The active target of the runtime animation
  96514. */
  96515. private _activeTargets;
  96516. private _currentActiveTarget;
  96517. private _directTarget;
  96518. /**
  96519. * The target path of the runtime animation
  96520. */
  96521. private _targetPath;
  96522. /**
  96523. * The weight of the runtime animation
  96524. */
  96525. private _weight;
  96526. /**
  96527. * The ratio offset of the runtime animation
  96528. */
  96529. private _ratioOffset;
  96530. /**
  96531. * The previous delay of the runtime animation
  96532. */
  96533. private _previousDelay;
  96534. /**
  96535. * The previous ratio of the runtime animation
  96536. */
  96537. private _previousRatio;
  96538. private _enableBlending;
  96539. private _keys;
  96540. private _minFrame;
  96541. private _maxFrame;
  96542. private _minValue;
  96543. private _maxValue;
  96544. private _targetIsArray;
  96545. /**
  96546. * Gets the current frame of the runtime animation
  96547. */
  96548. get currentFrame(): number;
  96549. /**
  96550. * Gets the weight of the runtime animation
  96551. */
  96552. get weight(): number;
  96553. /**
  96554. * Gets the current value of the runtime animation
  96555. */
  96556. get currentValue(): any;
  96557. /**
  96558. * Gets the target path of the runtime animation
  96559. */
  96560. get targetPath(): string;
  96561. /**
  96562. * Gets the actual target of the runtime animation
  96563. */
  96564. get target(): any;
  96565. /**
  96566. * Gets the additive state of the runtime animation
  96567. */
  96568. get isAdditive(): boolean;
  96569. /** @hidden */
  96570. _onLoop: () => void;
  96571. /**
  96572. * Create a new RuntimeAnimation object
  96573. * @param target defines the target of the animation
  96574. * @param animation defines the source animation object
  96575. * @param scene defines the hosting scene
  96576. * @param host defines the initiating Animatable
  96577. */
  96578. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  96579. private _preparePath;
  96580. /**
  96581. * Gets the animation from the runtime animation
  96582. */
  96583. get animation(): Animation;
  96584. /**
  96585. * Resets the runtime animation to the beginning
  96586. * @param restoreOriginal defines whether to restore the target property to the original value
  96587. */
  96588. reset(restoreOriginal?: boolean): void;
  96589. /**
  96590. * Specifies if the runtime animation is stopped
  96591. * @returns Boolean specifying if the runtime animation is stopped
  96592. */
  96593. isStopped(): boolean;
  96594. /**
  96595. * Disposes of the runtime animation
  96596. */
  96597. dispose(): void;
  96598. /**
  96599. * Apply the interpolated value to the target
  96600. * @param currentValue defines the value computed by the animation
  96601. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  96602. */
  96603. setValue(currentValue: any, weight: number): void;
  96604. private _getOriginalValues;
  96605. private _setValue;
  96606. /**
  96607. * Gets the loop pmode of the runtime animation
  96608. * @returns Loop Mode
  96609. */
  96610. private _getCorrectLoopMode;
  96611. /**
  96612. * Move the current animation to a given frame
  96613. * @param frame defines the frame to move to
  96614. */
  96615. goToFrame(frame: number): void;
  96616. /**
  96617. * @hidden Internal use only
  96618. */
  96619. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  96620. /**
  96621. * Execute the current animation
  96622. * @param delay defines the delay to add to the current frame
  96623. * @param from defines the lower bound of the animation range
  96624. * @param to defines the upper bound of the animation range
  96625. * @param loop defines if the current animation must loop
  96626. * @param speedRatio defines the current speed ratio
  96627. * @param weight defines the weight of the animation (default is -1 so no weight)
  96628. * @param onLoop optional callback called when animation loops
  96629. * @returns a boolean indicating if the animation is running
  96630. */
  96631. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  96632. }
  96633. }
  96634. declare module BABYLON {
  96635. /**
  96636. * Class used to store an actual running animation
  96637. */
  96638. export class Animatable {
  96639. /** defines the target object */
  96640. target: any;
  96641. /** defines the starting frame number (default is 0) */
  96642. fromFrame: number;
  96643. /** defines the ending frame number (default is 100) */
  96644. toFrame: number;
  96645. /** defines if the animation must loop (default is false) */
  96646. loopAnimation: boolean;
  96647. /** defines a callback to call when animation ends if it is not looping */
  96648. onAnimationEnd?: (() => void) | null | undefined;
  96649. /** defines a callback to call when animation loops */
  96650. onAnimationLoop?: (() => void) | null | undefined;
  96651. /** defines whether the animation should be evaluated additively */
  96652. isAdditive: boolean;
  96653. private _localDelayOffset;
  96654. private _pausedDelay;
  96655. private _runtimeAnimations;
  96656. private _paused;
  96657. private _scene;
  96658. private _speedRatio;
  96659. private _weight;
  96660. private _syncRoot;
  96661. /**
  96662. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  96663. * This will only apply for non looping animation (default is true)
  96664. */
  96665. disposeOnEnd: boolean;
  96666. /**
  96667. * Gets a boolean indicating if the animation has started
  96668. */
  96669. animationStarted: boolean;
  96670. /**
  96671. * Observer raised when the animation ends
  96672. */
  96673. onAnimationEndObservable: Observable<Animatable>;
  96674. /**
  96675. * Observer raised when the animation loops
  96676. */
  96677. onAnimationLoopObservable: Observable<Animatable>;
  96678. /**
  96679. * Gets the root Animatable used to synchronize and normalize animations
  96680. */
  96681. get syncRoot(): Nullable<Animatable>;
  96682. /**
  96683. * Gets the current frame of the first RuntimeAnimation
  96684. * Used to synchronize Animatables
  96685. */
  96686. get masterFrame(): number;
  96687. /**
  96688. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  96689. */
  96690. get weight(): number;
  96691. set weight(value: number);
  96692. /**
  96693. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  96694. */
  96695. get speedRatio(): number;
  96696. set speedRatio(value: number);
  96697. /**
  96698. * Creates a new Animatable
  96699. * @param scene defines the hosting scene
  96700. * @param target defines the target object
  96701. * @param fromFrame defines the starting frame number (default is 0)
  96702. * @param toFrame defines the ending frame number (default is 100)
  96703. * @param loopAnimation defines if the animation must loop (default is false)
  96704. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  96705. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  96706. * @param animations defines a group of animation to add to the new Animatable
  96707. * @param onAnimationLoop defines a callback to call when animation loops
  96708. * @param isAdditive defines whether the animation should be evaluated additively
  96709. */
  96710. constructor(scene: Scene,
  96711. /** defines the target object */
  96712. target: any,
  96713. /** defines the starting frame number (default is 0) */
  96714. fromFrame?: number,
  96715. /** defines the ending frame number (default is 100) */
  96716. toFrame?: number,
  96717. /** defines if the animation must loop (default is false) */
  96718. loopAnimation?: boolean, speedRatio?: number,
  96719. /** defines a callback to call when animation ends if it is not looping */
  96720. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  96721. /** defines a callback to call when animation loops */
  96722. onAnimationLoop?: (() => void) | null | undefined,
  96723. /** defines whether the animation should be evaluated additively */
  96724. isAdditive?: boolean);
  96725. /**
  96726. * Synchronize and normalize current Animatable with a source Animatable
  96727. * This is useful when using animation weights and when animations are not of the same length
  96728. * @param root defines the root Animatable to synchronize with
  96729. * @returns the current Animatable
  96730. */
  96731. syncWith(root: Animatable): Animatable;
  96732. /**
  96733. * Gets the list of runtime animations
  96734. * @returns an array of RuntimeAnimation
  96735. */
  96736. getAnimations(): RuntimeAnimation[];
  96737. /**
  96738. * Adds more animations to the current animatable
  96739. * @param target defines the target of the animations
  96740. * @param animations defines the new animations to add
  96741. */
  96742. appendAnimations(target: any, animations: Animation[]): void;
  96743. /**
  96744. * Gets the source animation for a specific property
  96745. * @param property defines the propertyu to look for
  96746. * @returns null or the source animation for the given property
  96747. */
  96748. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  96749. /**
  96750. * Gets the runtime animation for a specific property
  96751. * @param property defines the propertyu to look for
  96752. * @returns null or the runtime animation for the given property
  96753. */
  96754. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  96755. /**
  96756. * Resets the animatable to its original state
  96757. */
  96758. reset(): void;
  96759. /**
  96760. * Allows the animatable to blend with current running animations
  96761. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96762. * @param blendingSpeed defines the blending speed to use
  96763. */
  96764. enableBlending(blendingSpeed: number): void;
  96765. /**
  96766. * Disable animation blending
  96767. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96768. */
  96769. disableBlending(): void;
  96770. /**
  96771. * Jump directly to a given frame
  96772. * @param frame defines the frame to jump to
  96773. */
  96774. goToFrame(frame: number): void;
  96775. /**
  96776. * Pause the animation
  96777. */
  96778. pause(): void;
  96779. /**
  96780. * Restart the animation
  96781. */
  96782. restart(): void;
  96783. private _raiseOnAnimationEnd;
  96784. /**
  96785. * Stop and delete the current animation
  96786. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  96787. * @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)
  96788. */
  96789. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  96790. /**
  96791. * Wait asynchronously for the animation to end
  96792. * @returns a promise which will be fullfilled when the animation ends
  96793. */
  96794. waitAsync(): Promise<Animatable>;
  96795. /** @hidden */
  96796. _animate(delay: number): boolean;
  96797. }
  96798. interface Scene {
  96799. /** @hidden */
  96800. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  96801. /** @hidden */
  96802. _processLateAnimationBindingsForMatrices(holder: {
  96803. totalWeight: number;
  96804. totalAdditiveWeight: number;
  96805. animations: RuntimeAnimation[];
  96806. additiveAnimations: RuntimeAnimation[];
  96807. originalValue: Matrix;
  96808. }): any;
  96809. /** @hidden */
  96810. _processLateAnimationBindingsForQuaternions(holder: {
  96811. totalWeight: number;
  96812. totalAdditiveWeight: number;
  96813. animations: RuntimeAnimation[];
  96814. additiveAnimations: RuntimeAnimation[];
  96815. originalValue: Quaternion;
  96816. }, refQuaternion: Quaternion): Quaternion;
  96817. /** @hidden */
  96818. _processLateAnimationBindings(): void;
  96819. /**
  96820. * Will start the animation sequence of a given target
  96821. * @param target defines the target
  96822. * @param from defines from which frame should animation start
  96823. * @param to defines until which frame should animation run.
  96824. * @param weight defines the weight to apply to the animation (1.0 by default)
  96825. * @param loop defines if the animation loops
  96826. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96827. * @param onAnimationEnd defines the function to be executed when the animation ends
  96828. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96829. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96830. * @param onAnimationLoop defines the callback to call when an animation loops
  96831. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96832. * @returns the animatable object created for this animation
  96833. */
  96834. 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;
  96835. /**
  96836. * Will start the animation sequence of a given target
  96837. * @param target defines the target
  96838. * @param from defines from which frame should animation start
  96839. * @param to defines until which frame should animation run.
  96840. * @param loop defines if the animation loops
  96841. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96842. * @param onAnimationEnd defines the function to be executed when the animation ends
  96843. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96844. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96845. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  96846. * @param onAnimationLoop defines the callback to call when an animation loops
  96847. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96848. * @returns the animatable object created for this animation
  96849. */
  96850. 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;
  96851. /**
  96852. * Will start the animation sequence of a given target and its hierarchy
  96853. * @param target defines the target
  96854. * @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.
  96855. * @param from defines from which frame should animation start
  96856. * @param to defines until which frame should animation run.
  96857. * @param loop defines if the animation loops
  96858. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96859. * @param onAnimationEnd defines the function to be executed when the animation ends
  96860. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96861. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96862. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96863. * @param onAnimationLoop defines the callback to call when an animation loops
  96864. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96865. * @returns the list of created animatables
  96866. */
  96867. 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[];
  96868. /**
  96869. * Begin a new animation on a given node
  96870. * @param target defines the target where the animation will take place
  96871. * @param animations defines the list of animations to start
  96872. * @param from defines the initial value
  96873. * @param to defines the final value
  96874. * @param loop defines if you want animation to loop (off by default)
  96875. * @param speedRatio defines the speed ratio to apply to all animations
  96876. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96877. * @param onAnimationLoop defines the callback to call when an animation loops
  96878. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96879. * @returns the list of created animatables
  96880. */
  96881. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  96882. /**
  96883. * Begin a new animation on a given node and its hierarchy
  96884. * @param target defines the root node where the animation will take place
  96885. * @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.
  96886. * @param animations defines the list of animations to start
  96887. * @param from defines the initial value
  96888. * @param to defines the final value
  96889. * @param loop defines if you want animation to loop (off by default)
  96890. * @param speedRatio defines the speed ratio to apply to all animations
  96891. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96892. * @param onAnimationLoop defines the callback to call when an animation loops
  96893. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96894. * @returns the list of animatables created for all nodes
  96895. */
  96896. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  96897. /**
  96898. * Gets the animatable associated with a specific target
  96899. * @param target defines the target of the animatable
  96900. * @returns the required animatable if found
  96901. */
  96902. getAnimatableByTarget(target: any): Nullable<Animatable>;
  96903. /**
  96904. * Gets all animatables associated with a given target
  96905. * @param target defines the target to look animatables for
  96906. * @returns an array of Animatables
  96907. */
  96908. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  96909. /**
  96910. * Stops and removes all animations that have been applied to the scene
  96911. */
  96912. stopAllAnimations(): void;
  96913. /**
  96914. * Gets the current delta time used by animation engine
  96915. */
  96916. deltaTime: number;
  96917. }
  96918. interface Bone {
  96919. /**
  96920. * Copy an animation range from another bone
  96921. * @param source defines the source bone
  96922. * @param rangeName defines the range name to copy
  96923. * @param frameOffset defines the frame offset
  96924. * @param rescaleAsRequired defines if rescaling must be applied if required
  96925. * @param skelDimensionsRatio defines the scaling ratio
  96926. * @returns true if operation was successful
  96927. */
  96928. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  96929. }
  96930. }
  96931. declare module BABYLON {
  96932. /**
  96933. * Class used to handle skinning animations
  96934. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96935. */
  96936. export class Skeleton implements IAnimatable {
  96937. /** defines the skeleton name */
  96938. name: string;
  96939. /** defines the skeleton Id */
  96940. id: string;
  96941. /**
  96942. * Defines the list of child bones
  96943. */
  96944. bones: Bone[];
  96945. /**
  96946. * Defines an estimate of the dimension of the skeleton at rest
  96947. */
  96948. dimensionsAtRest: Vector3;
  96949. /**
  96950. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  96951. */
  96952. needInitialSkinMatrix: boolean;
  96953. /**
  96954. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  96955. */
  96956. overrideMesh: Nullable<AbstractMesh>;
  96957. /**
  96958. * Gets the list of animations attached to this skeleton
  96959. */
  96960. animations: Array<Animation>;
  96961. private _scene;
  96962. private _isDirty;
  96963. private _transformMatrices;
  96964. private _transformMatrixTexture;
  96965. private _meshesWithPoseMatrix;
  96966. private _animatables;
  96967. private _identity;
  96968. private _synchronizedWithMesh;
  96969. private _ranges;
  96970. private _lastAbsoluteTransformsUpdateId;
  96971. private _canUseTextureForBones;
  96972. private _uniqueId;
  96973. /** @hidden */
  96974. _numBonesWithLinkedTransformNode: number;
  96975. /** @hidden */
  96976. _hasWaitingData: Nullable<boolean>;
  96977. /** @hidden */
  96978. _waitingOverrideMeshId: Nullable<string>;
  96979. /**
  96980. * Specifies if the skeleton should be serialized
  96981. */
  96982. doNotSerialize: boolean;
  96983. private _useTextureToStoreBoneMatrices;
  96984. /**
  96985. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  96986. * Please note that this option is not available if the hardware does not support it
  96987. */
  96988. get useTextureToStoreBoneMatrices(): boolean;
  96989. set useTextureToStoreBoneMatrices(value: boolean);
  96990. private _animationPropertiesOverride;
  96991. /**
  96992. * Gets or sets the animation properties override
  96993. */
  96994. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96995. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96996. /**
  96997. * List of inspectable custom properties (used by the Inspector)
  96998. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96999. */
  97000. inspectableCustomProperties: IInspectable[];
  97001. /**
  97002. * An observable triggered before computing the skeleton's matrices
  97003. */
  97004. onBeforeComputeObservable: Observable<Skeleton>;
  97005. /**
  97006. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  97007. */
  97008. get isUsingTextureForMatrices(): boolean;
  97009. /**
  97010. * Gets the unique ID of this skeleton
  97011. */
  97012. get uniqueId(): number;
  97013. /**
  97014. * Creates a new skeleton
  97015. * @param name defines the skeleton name
  97016. * @param id defines the skeleton Id
  97017. * @param scene defines the hosting scene
  97018. */
  97019. constructor(
  97020. /** defines the skeleton name */
  97021. name: string,
  97022. /** defines the skeleton Id */
  97023. id: string, scene: Scene);
  97024. /**
  97025. * Gets the current object class name.
  97026. * @return the class name
  97027. */
  97028. getClassName(): string;
  97029. /**
  97030. * Returns an array containing the root bones
  97031. * @returns an array containing the root bones
  97032. */
  97033. getChildren(): Array<Bone>;
  97034. /**
  97035. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  97036. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  97037. * @returns a Float32Array containing matrices data
  97038. */
  97039. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  97040. /**
  97041. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  97042. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  97043. * @returns a raw texture containing the data
  97044. */
  97045. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  97046. /**
  97047. * Gets the current hosting scene
  97048. * @returns a scene object
  97049. */
  97050. getScene(): Scene;
  97051. /**
  97052. * Gets a string representing the current skeleton data
  97053. * @param fullDetails defines a boolean indicating if we want a verbose version
  97054. * @returns a string representing the current skeleton data
  97055. */
  97056. toString(fullDetails?: boolean): string;
  97057. /**
  97058. * Get bone's index searching by name
  97059. * @param name defines bone's name to search for
  97060. * @return the indice of the bone. Returns -1 if not found
  97061. */
  97062. getBoneIndexByName(name: string): number;
  97063. /**
  97064. * Creater a new animation range
  97065. * @param name defines the name of the range
  97066. * @param from defines the start key
  97067. * @param to defines the end key
  97068. */
  97069. createAnimationRange(name: string, from: number, to: number): void;
  97070. /**
  97071. * Delete a specific animation range
  97072. * @param name defines the name of the range
  97073. * @param deleteFrames defines if frames must be removed as well
  97074. */
  97075. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  97076. /**
  97077. * Gets a specific animation range
  97078. * @param name defines the name of the range to look for
  97079. * @returns the requested animation range or null if not found
  97080. */
  97081. getAnimationRange(name: string): Nullable<AnimationRange>;
  97082. /**
  97083. * Gets the list of all animation ranges defined on this skeleton
  97084. * @returns an array
  97085. */
  97086. getAnimationRanges(): Nullable<AnimationRange>[];
  97087. /**
  97088. * Copy animation range from a source skeleton.
  97089. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  97090. * @param source defines the source skeleton
  97091. * @param name defines the name of the range to copy
  97092. * @param rescaleAsRequired defines if rescaling must be applied if required
  97093. * @returns true if operation was successful
  97094. */
  97095. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  97096. /**
  97097. * Forces the skeleton to go to rest pose
  97098. */
  97099. returnToRest(): void;
  97100. private _getHighestAnimationFrame;
  97101. /**
  97102. * Begin a specific animation range
  97103. * @param name defines the name of the range to start
  97104. * @param loop defines if looping must be turned on (false by default)
  97105. * @param speedRatio defines the speed ratio to apply (1 by default)
  97106. * @param onAnimationEnd defines a callback which will be called when animation will end
  97107. * @returns a new animatable
  97108. */
  97109. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  97110. /**
  97111. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  97112. * @param skeleton defines the Skeleton containing the animation range to convert
  97113. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  97114. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  97115. * @returns the original skeleton
  97116. */
  97117. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  97118. /** @hidden */
  97119. _markAsDirty(): void;
  97120. /** @hidden */
  97121. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  97122. /** @hidden */
  97123. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  97124. private _computeTransformMatrices;
  97125. /**
  97126. * Build all resources required to render a skeleton
  97127. */
  97128. prepare(): void;
  97129. /**
  97130. * Gets the list of animatables currently running for this skeleton
  97131. * @returns an array of animatables
  97132. */
  97133. getAnimatables(): IAnimatable[];
  97134. /**
  97135. * Clone the current skeleton
  97136. * @param name defines the name of the new skeleton
  97137. * @param id defines the id of the new skeleton
  97138. * @returns the new skeleton
  97139. */
  97140. clone(name: string, id?: string): Skeleton;
  97141. /**
  97142. * Enable animation blending for this skeleton
  97143. * @param blendingSpeed defines the blending speed to apply
  97144. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  97145. */
  97146. enableBlending(blendingSpeed?: number): void;
  97147. /**
  97148. * Releases all resources associated with the current skeleton
  97149. */
  97150. dispose(): void;
  97151. /**
  97152. * Serialize the skeleton in a JSON object
  97153. * @returns a JSON object
  97154. */
  97155. serialize(): any;
  97156. /**
  97157. * Creates a new skeleton from serialized data
  97158. * @param parsedSkeleton defines the serialized data
  97159. * @param scene defines the hosting scene
  97160. * @returns a new skeleton
  97161. */
  97162. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  97163. /**
  97164. * Compute all node absolute transforms
  97165. * @param forceUpdate defines if computation must be done even if cache is up to date
  97166. */
  97167. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  97168. /**
  97169. * Gets the root pose matrix
  97170. * @returns a matrix
  97171. */
  97172. getPoseMatrix(): Nullable<Matrix>;
  97173. /**
  97174. * Sorts bones per internal index
  97175. */
  97176. sortBones(): void;
  97177. private _sortBones;
  97178. /**
  97179. * Set the current local matrix as the restPose for all bones in the skeleton.
  97180. */
  97181. setCurrentPoseAsRest(): void;
  97182. }
  97183. }
  97184. declare module BABYLON {
  97185. /**
  97186. * Creates an instance based on a source mesh.
  97187. */
  97188. export class InstancedMesh extends AbstractMesh {
  97189. private _sourceMesh;
  97190. private _currentLOD;
  97191. /** @hidden */
  97192. _indexInSourceMeshInstanceArray: number;
  97193. constructor(name: string, source: Mesh);
  97194. /**
  97195. * Returns the string "InstancedMesh".
  97196. */
  97197. getClassName(): string;
  97198. /** Gets the list of lights affecting that mesh */
  97199. get lightSources(): Light[];
  97200. _resyncLightSources(): void;
  97201. _resyncLightSource(light: Light): void;
  97202. _removeLightSource(light: Light, dispose: boolean): void;
  97203. /**
  97204. * If the source mesh receives shadows
  97205. */
  97206. get receiveShadows(): boolean;
  97207. /**
  97208. * The material of the source mesh
  97209. */
  97210. get material(): Nullable<Material>;
  97211. /**
  97212. * Visibility of the source mesh
  97213. */
  97214. get visibility(): number;
  97215. /**
  97216. * Skeleton of the source mesh
  97217. */
  97218. get skeleton(): Nullable<Skeleton>;
  97219. /**
  97220. * Rendering ground id of the source mesh
  97221. */
  97222. get renderingGroupId(): number;
  97223. set renderingGroupId(value: number);
  97224. /**
  97225. * Returns the total number of vertices (integer).
  97226. */
  97227. getTotalVertices(): number;
  97228. /**
  97229. * Returns a positive integer : the total number of indices in this mesh geometry.
  97230. * @returns the numner of indices or zero if the mesh has no geometry.
  97231. */
  97232. getTotalIndices(): number;
  97233. /**
  97234. * The source mesh of the instance
  97235. */
  97236. get sourceMesh(): Mesh;
  97237. /**
  97238. * Creates a new InstancedMesh object from the mesh model.
  97239. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97240. * @param name defines the name of the new instance
  97241. * @returns a new InstancedMesh
  97242. */
  97243. createInstance(name: string): InstancedMesh;
  97244. /**
  97245. * Is this node ready to be used/rendered
  97246. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97247. * @return {boolean} is it ready
  97248. */
  97249. isReady(completeCheck?: boolean): boolean;
  97250. /**
  97251. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97252. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  97253. * @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.
  97254. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  97255. */
  97256. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  97257. /**
  97258. * Sets the vertex data of the mesh geometry for the requested `kind`.
  97259. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  97260. * The `data` are either a numeric array either a Float32Array.
  97261. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  97262. * 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).
  97263. * Note that a new underlying VertexBuffer object is created each call.
  97264. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  97265. *
  97266. * Possible `kind` values :
  97267. * - VertexBuffer.PositionKind
  97268. * - VertexBuffer.UVKind
  97269. * - VertexBuffer.UV2Kind
  97270. * - VertexBuffer.UV3Kind
  97271. * - VertexBuffer.UV4Kind
  97272. * - VertexBuffer.UV5Kind
  97273. * - VertexBuffer.UV6Kind
  97274. * - VertexBuffer.ColorKind
  97275. * - VertexBuffer.MatricesIndicesKind
  97276. * - VertexBuffer.MatricesIndicesExtraKind
  97277. * - VertexBuffer.MatricesWeightsKind
  97278. * - VertexBuffer.MatricesWeightsExtraKind
  97279. *
  97280. * Returns the Mesh.
  97281. */
  97282. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97283. /**
  97284. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  97285. * If the mesh has no geometry, it is simply returned as it is.
  97286. * The `data` are either a numeric array either a Float32Array.
  97287. * No new underlying VertexBuffer object is created.
  97288. * 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.
  97289. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  97290. *
  97291. * Possible `kind` values :
  97292. * - VertexBuffer.PositionKind
  97293. * - VertexBuffer.UVKind
  97294. * - VertexBuffer.UV2Kind
  97295. * - VertexBuffer.UV3Kind
  97296. * - VertexBuffer.UV4Kind
  97297. * - VertexBuffer.UV5Kind
  97298. * - VertexBuffer.UV6Kind
  97299. * - VertexBuffer.ColorKind
  97300. * - VertexBuffer.MatricesIndicesKind
  97301. * - VertexBuffer.MatricesIndicesExtraKind
  97302. * - VertexBuffer.MatricesWeightsKind
  97303. * - VertexBuffer.MatricesWeightsExtraKind
  97304. *
  97305. * Returns the Mesh.
  97306. */
  97307. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  97308. /**
  97309. * Sets the mesh indices.
  97310. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  97311. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  97312. * This method creates a new index buffer each call.
  97313. * Returns the Mesh.
  97314. */
  97315. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  97316. /**
  97317. * Boolean : True if the mesh owns the requested kind of data.
  97318. */
  97319. isVerticesDataPresent(kind: string): boolean;
  97320. /**
  97321. * Returns an array of indices (IndicesArray).
  97322. */
  97323. getIndices(): Nullable<IndicesArray>;
  97324. get _positions(): Nullable<Vector3[]>;
  97325. /**
  97326. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97327. * This means the mesh underlying bounding box and sphere are recomputed.
  97328. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97329. * @returns the current mesh
  97330. */
  97331. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  97332. /** @hidden */
  97333. _preActivate(): InstancedMesh;
  97334. /** @hidden */
  97335. _activate(renderId: number, intermediateRendering: boolean): boolean;
  97336. /** @hidden */
  97337. _postActivate(): void;
  97338. getWorldMatrix(): Matrix;
  97339. get isAnInstance(): boolean;
  97340. /**
  97341. * Returns the current associated LOD AbstractMesh.
  97342. */
  97343. getLOD(camera: Camera): AbstractMesh;
  97344. /** @hidden */
  97345. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97346. /** @hidden */
  97347. _syncSubMeshes(): InstancedMesh;
  97348. /** @hidden */
  97349. _generatePointsArray(): boolean;
  97350. /** @hidden */
  97351. _updateBoundingInfo(): AbstractMesh;
  97352. /**
  97353. * Creates a new InstancedMesh from the current mesh.
  97354. * - name (string) : the cloned mesh name
  97355. * - newParent (optional Node) : the optional Node to parent the clone to.
  97356. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  97357. *
  97358. * Returns the clone.
  97359. */
  97360. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  97361. /**
  97362. * Disposes the InstancedMesh.
  97363. * Returns nothing.
  97364. */
  97365. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97366. }
  97367. interface Mesh {
  97368. /**
  97369. * Register a custom buffer that will be instanced
  97370. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97371. * @param kind defines the buffer kind
  97372. * @param stride defines the stride in floats
  97373. */
  97374. registerInstancedBuffer(kind: string, stride: number): void;
  97375. /**
  97376. * true to use the edge renderer for all instances of this mesh
  97377. */
  97378. edgesShareWithInstances: boolean;
  97379. /** @hidden */
  97380. _userInstancedBuffersStorage: {
  97381. data: {
  97382. [key: string]: Float32Array;
  97383. };
  97384. sizes: {
  97385. [key: string]: number;
  97386. };
  97387. vertexBuffers: {
  97388. [key: string]: Nullable<VertexBuffer>;
  97389. };
  97390. strides: {
  97391. [key: string]: number;
  97392. };
  97393. };
  97394. }
  97395. interface AbstractMesh {
  97396. /**
  97397. * Object used to store instanced buffers defined by user
  97398. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97399. */
  97400. instancedBuffers: {
  97401. [key: string]: any;
  97402. };
  97403. }
  97404. }
  97405. declare module BABYLON {
  97406. /**
  97407. * Defines the options associated with the creation of a shader material.
  97408. */
  97409. export interface IShaderMaterialOptions {
  97410. /**
  97411. * Does the material work in alpha blend mode
  97412. */
  97413. needAlphaBlending: boolean;
  97414. /**
  97415. * Does the material work in alpha test mode
  97416. */
  97417. needAlphaTesting: boolean;
  97418. /**
  97419. * The list of attribute names used in the shader
  97420. */
  97421. attributes: string[];
  97422. /**
  97423. * The list of unifrom names used in the shader
  97424. */
  97425. uniforms: string[];
  97426. /**
  97427. * The list of UBO names used in the shader
  97428. */
  97429. uniformBuffers: string[];
  97430. /**
  97431. * The list of sampler names used in the shader
  97432. */
  97433. samplers: string[];
  97434. /**
  97435. * The list of defines used in the shader
  97436. */
  97437. defines: string[];
  97438. }
  97439. /**
  97440. * 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.
  97441. *
  97442. * This returned material effects how the mesh will look based on the code in the shaders.
  97443. *
  97444. * @see https://doc.babylonjs.com/how_to/shader_material
  97445. */
  97446. export class ShaderMaterial extends Material {
  97447. private _shaderPath;
  97448. private _options;
  97449. private _textures;
  97450. private _textureArrays;
  97451. private _floats;
  97452. private _ints;
  97453. private _floatsArrays;
  97454. private _colors3;
  97455. private _colors3Arrays;
  97456. private _colors4;
  97457. private _colors4Arrays;
  97458. private _vectors2;
  97459. private _vectors3;
  97460. private _vectors4;
  97461. private _matrices;
  97462. private _matrixArrays;
  97463. private _matrices3x3;
  97464. private _matrices2x2;
  97465. private _vectors2Arrays;
  97466. private _vectors3Arrays;
  97467. private _vectors4Arrays;
  97468. private _cachedWorldViewMatrix;
  97469. private _cachedWorldViewProjectionMatrix;
  97470. private _renderId;
  97471. private _multiview;
  97472. private _cachedDefines;
  97473. /** Define the Url to load snippets */
  97474. static SnippetUrl: string;
  97475. /** Snippet ID if the material was created from the snippet server */
  97476. snippetId: string;
  97477. /**
  97478. * Instantiate a new shader material.
  97479. * 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.
  97480. * This returned material effects how the mesh will look based on the code in the shaders.
  97481. * @see https://doc.babylonjs.com/how_to/shader_material
  97482. * @param name Define the name of the material in the scene
  97483. * @param scene Define the scene the material belongs to
  97484. * @param shaderPath Defines the route to the shader code in one of three ways:
  97485. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  97486. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  97487. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  97488. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  97489. * @param options Define the options used to create the shader
  97490. */
  97491. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  97492. /**
  97493. * Gets the shader path used to define the shader code
  97494. * It can be modified to trigger a new compilation
  97495. */
  97496. get shaderPath(): any;
  97497. /**
  97498. * Sets the shader path used to define the shader code
  97499. * It can be modified to trigger a new compilation
  97500. */
  97501. set shaderPath(shaderPath: any);
  97502. /**
  97503. * Gets the options used to compile the shader.
  97504. * They can be modified to trigger a new compilation
  97505. */
  97506. get options(): IShaderMaterialOptions;
  97507. /**
  97508. * Gets the current class name of the material e.g. "ShaderMaterial"
  97509. * Mainly use in serialization.
  97510. * @returns the class name
  97511. */
  97512. getClassName(): string;
  97513. /**
  97514. * Specifies if the material will require alpha blending
  97515. * @returns a boolean specifying if alpha blending is needed
  97516. */
  97517. needAlphaBlending(): boolean;
  97518. /**
  97519. * Specifies if this material should be rendered in alpha test mode
  97520. * @returns a boolean specifying if an alpha test is needed.
  97521. */
  97522. needAlphaTesting(): boolean;
  97523. private _checkUniform;
  97524. /**
  97525. * Set a texture in the shader.
  97526. * @param name Define the name of the uniform samplers as defined in the shader
  97527. * @param texture Define the texture to bind to this sampler
  97528. * @return the material itself allowing "fluent" like uniform updates
  97529. */
  97530. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  97531. /**
  97532. * Set a texture array in the shader.
  97533. * @param name Define the name of the uniform sampler array as defined in the shader
  97534. * @param textures Define the list of textures to bind to this sampler
  97535. * @return the material itself allowing "fluent" like uniform updates
  97536. */
  97537. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  97538. /**
  97539. * Set a float in the shader.
  97540. * @param name Define the name of the uniform as defined in the shader
  97541. * @param value Define the value to give to the uniform
  97542. * @return the material itself allowing "fluent" like uniform updates
  97543. */
  97544. setFloat(name: string, value: number): ShaderMaterial;
  97545. /**
  97546. * Set a int in the shader.
  97547. * @param name Define the name of the uniform as defined in the shader
  97548. * @param value Define the value to give to the uniform
  97549. * @return the material itself allowing "fluent" like uniform updates
  97550. */
  97551. setInt(name: string, value: number): ShaderMaterial;
  97552. /**
  97553. * Set an array of floats in the shader.
  97554. * @param name Define the name of the uniform as defined in the shader
  97555. * @param value Define the value to give to the uniform
  97556. * @return the material itself allowing "fluent" like uniform updates
  97557. */
  97558. setFloats(name: string, value: number[]): ShaderMaterial;
  97559. /**
  97560. * Set a vec3 in the shader from a Color3.
  97561. * @param name Define the name of the uniform as defined in the shader
  97562. * @param value Define the value to give to the uniform
  97563. * @return the material itself allowing "fluent" like uniform updates
  97564. */
  97565. setColor3(name: string, value: Color3): ShaderMaterial;
  97566. /**
  97567. * Set a vec3 array in the shader from a Color3 array.
  97568. * @param name Define the name of the uniform as defined in the shader
  97569. * @param value Define the value to give to the uniform
  97570. * @return the material itself allowing "fluent" like uniform updates
  97571. */
  97572. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  97573. /**
  97574. * Set a vec4 in the shader from a Color4.
  97575. * @param name Define the name of the uniform as defined in the shader
  97576. * @param value Define the value to give to the uniform
  97577. * @return the material itself allowing "fluent" like uniform updates
  97578. */
  97579. setColor4(name: string, value: Color4): ShaderMaterial;
  97580. /**
  97581. * Set a vec4 array in the shader from a Color4 array.
  97582. * @param name Define the name of the uniform as defined in the shader
  97583. * @param value Define the value to give to the uniform
  97584. * @return the material itself allowing "fluent" like uniform updates
  97585. */
  97586. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  97587. /**
  97588. * Set a vec2 in the shader from a Vector2.
  97589. * @param name Define the name of the uniform as defined in the shader
  97590. * @param value Define the value to give to the uniform
  97591. * @return the material itself allowing "fluent" like uniform updates
  97592. */
  97593. setVector2(name: string, value: Vector2): ShaderMaterial;
  97594. /**
  97595. * Set a vec3 in the shader from a Vector3.
  97596. * @param name Define the name of the uniform as defined in the shader
  97597. * @param value Define the value to give to the uniform
  97598. * @return the material itself allowing "fluent" like uniform updates
  97599. */
  97600. setVector3(name: string, value: Vector3): ShaderMaterial;
  97601. /**
  97602. * Set a vec4 in the shader from a Vector4.
  97603. * @param name Define the name of the uniform as defined in the shader
  97604. * @param value Define the value to give to the uniform
  97605. * @return the material itself allowing "fluent" like uniform updates
  97606. */
  97607. setVector4(name: string, value: Vector4): ShaderMaterial;
  97608. /**
  97609. * Set a mat4 in the shader from a Matrix.
  97610. * @param name Define the name of the uniform as defined in the shader
  97611. * @param value Define the value to give to the uniform
  97612. * @return the material itself allowing "fluent" like uniform updates
  97613. */
  97614. setMatrix(name: string, value: Matrix): ShaderMaterial;
  97615. /**
  97616. * Set a float32Array in the shader from a matrix array.
  97617. * @param name Define the name of the uniform as defined in the shader
  97618. * @param value Define the value to give to the uniform
  97619. * @return the material itself allowing "fluent" like uniform updates
  97620. */
  97621. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  97622. /**
  97623. * Set a mat3 in the shader from a Float32Array.
  97624. * @param name Define the name of the uniform as defined in the shader
  97625. * @param value Define the value to give to the uniform
  97626. * @return the material itself allowing "fluent" like uniform updates
  97627. */
  97628. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97629. /**
  97630. * Set a mat2 in the shader from a Float32Array.
  97631. * @param name Define the name of the uniform as defined in the shader
  97632. * @param value Define the value to give to the uniform
  97633. * @return the material itself allowing "fluent" like uniform updates
  97634. */
  97635. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97636. /**
  97637. * Set a vec2 array in the shader from a number array.
  97638. * @param name Define the name of the uniform as defined in the shader
  97639. * @param value Define the value to give to the uniform
  97640. * @return the material itself allowing "fluent" like uniform updates
  97641. */
  97642. setArray2(name: string, value: number[]): ShaderMaterial;
  97643. /**
  97644. * Set a vec3 array in the shader from a number array.
  97645. * @param name Define the name of the uniform as defined in the shader
  97646. * @param value Define the value to give to the uniform
  97647. * @return the material itself allowing "fluent" like uniform updates
  97648. */
  97649. setArray3(name: string, value: number[]): ShaderMaterial;
  97650. /**
  97651. * Set a vec4 array in the shader from a number array.
  97652. * @param name Define the name of the uniform as defined in the shader
  97653. * @param value Define the value to give to the uniform
  97654. * @return the material itself allowing "fluent" like uniform updates
  97655. */
  97656. setArray4(name: string, value: number[]): ShaderMaterial;
  97657. private _checkCache;
  97658. /**
  97659. * Specifies that the submesh is ready to be used
  97660. * @param mesh defines the mesh to check
  97661. * @param subMesh defines which submesh to check
  97662. * @param useInstances specifies that instances should be used
  97663. * @returns a boolean indicating that the submesh is ready or not
  97664. */
  97665. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97666. /**
  97667. * Checks if the material is ready to render the requested mesh
  97668. * @param mesh Define the mesh to render
  97669. * @param useInstances Define whether or not the material is used with instances
  97670. * @returns true if ready, otherwise false
  97671. */
  97672. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97673. /**
  97674. * Binds the world matrix to the material
  97675. * @param world defines the world transformation matrix
  97676. * @param effectOverride - If provided, use this effect instead of internal effect
  97677. */
  97678. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  97679. /**
  97680. * Binds the submesh to this material by preparing the effect and shader to draw
  97681. * @param world defines the world transformation matrix
  97682. * @param mesh defines the mesh containing the submesh
  97683. * @param subMesh defines the submesh to bind the material to
  97684. */
  97685. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97686. /**
  97687. * Binds the material to the mesh
  97688. * @param world defines the world transformation matrix
  97689. * @param mesh defines the mesh to bind the material to
  97690. * @param effectOverride - If provided, use this effect instead of internal effect
  97691. */
  97692. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  97693. protected _afterBind(mesh?: Mesh): void;
  97694. /**
  97695. * Gets the active textures from the material
  97696. * @returns an array of textures
  97697. */
  97698. getActiveTextures(): BaseTexture[];
  97699. /**
  97700. * Specifies if the material uses a texture
  97701. * @param texture defines the texture to check against the material
  97702. * @returns a boolean specifying if the material uses the texture
  97703. */
  97704. hasTexture(texture: BaseTexture): boolean;
  97705. /**
  97706. * Makes a duplicate of the material, and gives it a new name
  97707. * @param name defines the new name for the duplicated material
  97708. * @returns the cloned material
  97709. */
  97710. clone(name: string): ShaderMaterial;
  97711. /**
  97712. * Disposes the material
  97713. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97714. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97715. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97716. */
  97717. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97718. /**
  97719. * Serializes this material in a JSON representation
  97720. * @returns the serialized material object
  97721. */
  97722. serialize(): any;
  97723. /**
  97724. * Creates a shader material from parsed shader material data
  97725. * @param source defines the JSON represnetation of the material
  97726. * @param scene defines the hosting scene
  97727. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97728. * @returns a new material
  97729. */
  97730. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  97731. /**
  97732. * Creates a new ShaderMaterial from a snippet saved in a remote file
  97733. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  97734. * @param url defines the url to load from
  97735. * @param scene defines the hosting scene
  97736. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97737. * @returns a promise that will resolve to the new ShaderMaterial
  97738. */
  97739. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97740. /**
  97741. * Creates a ShaderMaterial from a snippet saved by the Inspector
  97742. * @param snippetId defines the snippet to load
  97743. * @param scene defines the hosting scene
  97744. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97745. * @returns a promise that will resolve to the new ShaderMaterial
  97746. */
  97747. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97748. }
  97749. }
  97750. declare module BABYLON {
  97751. /** @hidden */
  97752. export var colorPixelShader: {
  97753. name: string;
  97754. shader: string;
  97755. };
  97756. }
  97757. declare module BABYLON {
  97758. /** @hidden */
  97759. export var colorVertexShader: {
  97760. name: string;
  97761. shader: string;
  97762. };
  97763. }
  97764. declare module BABYLON {
  97765. /**
  97766. * Line mesh
  97767. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  97768. */
  97769. export class LinesMesh extends Mesh {
  97770. /**
  97771. * If vertex color should be applied to the mesh
  97772. */
  97773. readonly useVertexColor?: boolean | undefined;
  97774. /**
  97775. * If vertex alpha should be applied to the mesh
  97776. */
  97777. readonly useVertexAlpha?: boolean | undefined;
  97778. /**
  97779. * Color of the line (Default: White)
  97780. */
  97781. color: Color3;
  97782. /**
  97783. * Alpha of the line (Default: 1)
  97784. */
  97785. alpha: number;
  97786. /**
  97787. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97788. * This margin is expressed in world space coordinates, so its value may vary.
  97789. * Default value is 0.1
  97790. */
  97791. intersectionThreshold: number;
  97792. private _colorShader;
  97793. private color4;
  97794. /**
  97795. * Creates a new LinesMesh
  97796. * @param name defines the name
  97797. * @param scene defines the hosting scene
  97798. * @param parent defines the parent mesh if any
  97799. * @param source defines the optional source LinesMesh used to clone data from
  97800. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97801. * When false, achieved by calling a clone(), also passing False.
  97802. * This will make creation of children, recursive.
  97803. * @param useVertexColor defines if this LinesMesh supports vertex color
  97804. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  97805. */
  97806. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  97807. /**
  97808. * If vertex color should be applied to the mesh
  97809. */
  97810. useVertexColor?: boolean | undefined,
  97811. /**
  97812. * If vertex alpha should be applied to the mesh
  97813. */
  97814. useVertexAlpha?: boolean | undefined);
  97815. private _addClipPlaneDefine;
  97816. private _removeClipPlaneDefine;
  97817. isReady(): boolean;
  97818. /**
  97819. * Returns the string "LineMesh"
  97820. */
  97821. getClassName(): string;
  97822. /**
  97823. * @hidden
  97824. */
  97825. get material(): Material;
  97826. /**
  97827. * @hidden
  97828. */
  97829. set material(value: Material);
  97830. /**
  97831. * @hidden
  97832. */
  97833. get checkCollisions(): boolean;
  97834. /** @hidden */
  97835. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97836. /** @hidden */
  97837. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97838. /**
  97839. * Disposes of the line mesh
  97840. * @param doNotRecurse If children should be disposed
  97841. */
  97842. dispose(doNotRecurse?: boolean): void;
  97843. /**
  97844. * Returns a new LineMesh object cloned from the current one.
  97845. */
  97846. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  97847. /**
  97848. * Creates a new InstancedLinesMesh object from the mesh model.
  97849. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97850. * @param name defines the name of the new instance
  97851. * @returns a new InstancedLinesMesh
  97852. */
  97853. createInstance(name: string): InstancedLinesMesh;
  97854. }
  97855. /**
  97856. * Creates an instance based on a source LinesMesh
  97857. */
  97858. export class InstancedLinesMesh extends InstancedMesh {
  97859. /**
  97860. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97861. * This margin is expressed in world space coordinates, so its value may vary.
  97862. * Initilized with the intersectionThreshold value of the source LinesMesh
  97863. */
  97864. intersectionThreshold: number;
  97865. constructor(name: string, source: LinesMesh);
  97866. /**
  97867. * Returns the string "InstancedLinesMesh".
  97868. */
  97869. getClassName(): string;
  97870. }
  97871. }
  97872. declare module BABYLON {
  97873. /** @hidden */
  97874. export var linePixelShader: {
  97875. name: string;
  97876. shader: string;
  97877. };
  97878. }
  97879. declare module BABYLON {
  97880. /** @hidden */
  97881. export var lineVertexShader: {
  97882. name: string;
  97883. shader: string;
  97884. };
  97885. }
  97886. declare module BABYLON {
  97887. interface Scene {
  97888. /** @hidden */
  97889. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  97890. }
  97891. interface AbstractMesh {
  97892. /**
  97893. * Gets the edgesRenderer associated with the mesh
  97894. */
  97895. edgesRenderer: Nullable<EdgesRenderer>;
  97896. }
  97897. interface LinesMesh {
  97898. /**
  97899. * Enables the edge rendering mode on the mesh.
  97900. * This mode makes the mesh edges visible
  97901. * @param epsilon defines the maximal distance between two angles to detect a face
  97902. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97903. * @returns the currentAbstractMesh
  97904. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97905. */
  97906. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97907. }
  97908. interface InstancedLinesMesh {
  97909. /**
  97910. * Enables the edge rendering mode on the mesh.
  97911. * This mode makes the mesh edges visible
  97912. * @param epsilon defines the maximal distance between two angles to detect a face
  97913. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97914. * @returns the current InstancedLinesMesh
  97915. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97916. */
  97917. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  97918. }
  97919. /**
  97920. * Defines the minimum contract an Edges renderer should follow.
  97921. */
  97922. export interface IEdgesRenderer extends IDisposable {
  97923. /**
  97924. * Gets or sets a boolean indicating if the edgesRenderer is active
  97925. */
  97926. isEnabled: boolean;
  97927. /**
  97928. * Renders the edges of the attached mesh,
  97929. */
  97930. render(): void;
  97931. /**
  97932. * Checks wether or not the edges renderer is ready to render.
  97933. * @return true if ready, otherwise false.
  97934. */
  97935. isReady(): boolean;
  97936. /**
  97937. * List of instances to render in case the source mesh has instances
  97938. */
  97939. customInstances: SmartArray<Matrix>;
  97940. }
  97941. /**
  97942. * Defines the additional options of the edges renderer
  97943. */
  97944. export interface IEdgesRendererOptions {
  97945. /**
  97946. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  97947. * If not defined, the default value is true
  97948. */
  97949. useAlternateEdgeFinder?: boolean;
  97950. /**
  97951. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  97952. * If not defined, the default value is true.
  97953. * 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)
  97954. * This option is used only if useAlternateEdgeFinder = true
  97955. */
  97956. useFastVertexMerger?: boolean;
  97957. /**
  97958. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  97959. * The default value is 1e-6
  97960. * This option is used only if useAlternateEdgeFinder = true
  97961. */
  97962. epsilonVertexMerge?: number;
  97963. /**
  97964. * 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
  97965. * 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.
  97966. * This option is used only if useAlternateEdgeFinder = true
  97967. */
  97968. applyTessellation?: boolean;
  97969. /**
  97970. * 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
  97971. * The default value is 1e-6
  97972. * This option is used only if useAlternateEdgeFinder = true
  97973. */
  97974. epsilonVertexAligned?: number;
  97975. }
  97976. /**
  97977. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  97978. */
  97979. export class EdgesRenderer implements IEdgesRenderer {
  97980. /**
  97981. * Define the size of the edges with an orthographic camera
  97982. */
  97983. edgesWidthScalerForOrthographic: number;
  97984. /**
  97985. * Define the size of the edges with a perspective camera
  97986. */
  97987. edgesWidthScalerForPerspective: number;
  97988. protected _source: AbstractMesh;
  97989. protected _linesPositions: number[];
  97990. protected _linesNormals: number[];
  97991. protected _linesIndices: number[];
  97992. protected _epsilon: number;
  97993. protected _indicesCount: number;
  97994. protected _lineShader: ShaderMaterial;
  97995. protected _ib: DataBuffer;
  97996. protected _buffers: {
  97997. [key: string]: Nullable<VertexBuffer>;
  97998. };
  97999. protected _buffersForInstances: {
  98000. [key: string]: Nullable<VertexBuffer>;
  98001. };
  98002. protected _checkVerticesInsteadOfIndices: boolean;
  98003. protected _options: Nullable<IEdgesRendererOptions>;
  98004. private _meshRebuildObserver;
  98005. private _meshDisposeObserver;
  98006. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  98007. isEnabled: boolean;
  98008. /**
  98009. * List of instances to render in case the source mesh has instances
  98010. */
  98011. customInstances: SmartArray<Matrix>;
  98012. private static GetShader;
  98013. /**
  98014. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  98015. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  98016. * @param source Mesh used to create edges
  98017. * @param epsilon sum of angles in adjacency to check for edge
  98018. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  98019. * @param generateEdgesLines - should generate Lines or only prepare resources.
  98020. * @param options The options to apply when generating the edges
  98021. */
  98022. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  98023. protected _prepareRessources(): void;
  98024. /** @hidden */
  98025. _rebuild(): void;
  98026. /**
  98027. * Releases the required resources for the edges renderer
  98028. */
  98029. dispose(): void;
  98030. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  98031. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  98032. /**
  98033. * Checks if the pair of p0 and p1 is en edge
  98034. * @param faceIndex
  98035. * @param edge
  98036. * @param faceNormals
  98037. * @param p0
  98038. * @param p1
  98039. * @private
  98040. */
  98041. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  98042. /**
  98043. * push line into the position, normal and index buffer
  98044. * @protected
  98045. */
  98046. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  98047. /**
  98048. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  98049. */
  98050. private _tessellateTriangle;
  98051. private _generateEdgesLinesAlternate;
  98052. /**
  98053. * Generates lines edges from adjacencjes
  98054. * @private
  98055. */
  98056. _generateEdgesLines(): void;
  98057. /**
  98058. * Checks wether or not the edges renderer is ready to render.
  98059. * @return true if ready, otherwise false.
  98060. */
  98061. isReady(): boolean;
  98062. /**
  98063. * Renders the edges of the attached mesh,
  98064. */
  98065. render(): void;
  98066. }
  98067. /**
  98068. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  98069. */
  98070. export class LineEdgesRenderer extends EdgesRenderer {
  98071. /**
  98072. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  98073. * @param source LineMesh used to generate edges
  98074. * @param epsilon not important (specified angle for edge detection)
  98075. * @param checkVerticesInsteadOfIndices not important for LineMesh
  98076. */
  98077. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  98078. /**
  98079. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  98080. */
  98081. _generateEdgesLines(): void;
  98082. }
  98083. }
  98084. declare module BABYLON {
  98085. /**
  98086. * This represents the object necessary to create a rendering group.
  98087. * This is exclusively used and created by the rendering manager.
  98088. * To modify the behavior, you use the available helpers in your scene or meshes.
  98089. * @hidden
  98090. */
  98091. export class RenderingGroup {
  98092. index: number;
  98093. private static _zeroVector;
  98094. private _scene;
  98095. private _opaqueSubMeshes;
  98096. private _transparentSubMeshes;
  98097. private _alphaTestSubMeshes;
  98098. private _depthOnlySubMeshes;
  98099. private _particleSystems;
  98100. private _spriteManagers;
  98101. private _opaqueSortCompareFn;
  98102. private _alphaTestSortCompareFn;
  98103. private _transparentSortCompareFn;
  98104. private _renderOpaque;
  98105. private _renderAlphaTest;
  98106. private _renderTransparent;
  98107. /** @hidden */
  98108. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  98109. onBeforeTransparentRendering: () => void;
  98110. /**
  98111. * Set the opaque sort comparison function.
  98112. * If null the sub meshes will be render in the order they were created
  98113. */
  98114. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98115. /**
  98116. * Set the alpha test sort comparison function.
  98117. * If null the sub meshes will be render in the order they were created
  98118. */
  98119. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98120. /**
  98121. * Set the transparent sort comparison function.
  98122. * If null the sub meshes will be render in the order they were created
  98123. */
  98124. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98125. /**
  98126. * Creates a new rendering group.
  98127. * @param index The rendering group index
  98128. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  98129. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  98130. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  98131. */
  98132. 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>);
  98133. /**
  98134. * Render all the sub meshes contained in the group.
  98135. * @param customRenderFunction Used to override the default render behaviour of the group.
  98136. * @returns true if rendered some submeshes.
  98137. */
  98138. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  98139. /**
  98140. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  98141. * @param subMeshes The submeshes to render
  98142. */
  98143. private renderOpaqueSorted;
  98144. /**
  98145. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  98146. * @param subMeshes The submeshes to render
  98147. */
  98148. private renderAlphaTestSorted;
  98149. /**
  98150. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  98151. * @param subMeshes The submeshes to render
  98152. */
  98153. private renderTransparentSorted;
  98154. /**
  98155. * Renders the submeshes in a specified order.
  98156. * @param subMeshes The submeshes to sort before render
  98157. * @param sortCompareFn The comparison function use to sort
  98158. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  98159. * @param transparent Specifies to activate blending if true
  98160. */
  98161. private static renderSorted;
  98162. /**
  98163. * Renders the submeshes in the order they were dispatched (no sort applied).
  98164. * @param subMeshes The submeshes to render
  98165. */
  98166. private static renderUnsorted;
  98167. /**
  98168. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98169. * are rendered back to front if in the same alpha index.
  98170. *
  98171. * @param a The first submesh
  98172. * @param b The second submesh
  98173. * @returns The result of the comparison
  98174. */
  98175. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  98176. /**
  98177. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98178. * are rendered back to front.
  98179. *
  98180. * @param a The first submesh
  98181. * @param b The second submesh
  98182. * @returns The result of the comparison
  98183. */
  98184. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  98185. /**
  98186. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98187. * are rendered front to back (prevent overdraw).
  98188. *
  98189. * @param a The first submesh
  98190. * @param b The second submesh
  98191. * @returns The result of the comparison
  98192. */
  98193. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  98194. /**
  98195. * Resets the different lists of submeshes to prepare a new frame.
  98196. */
  98197. prepare(): void;
  98198. dispose(): void;
  98199. /**
  98200. * Inserts the submesh in its correct queue depending on its material.
  98201. * @param subMesh The submesh to dispatch
  98202. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98203. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98204. */
  98205. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98206. dispatchSprites(spriteManager: ISpriteManager): void;
  98207. dispatchParticles(particleSystem: IParticleSystem): void;
  98208. private _renderParticles;
  98209. private _renderSprites;
  98210. }
  98211. }
  98212. declare module BABYLON {
  98213. /**
  98214. * Interface describing the different options available in the rendering manager
  98215. * regarding Auto Clear between groups.
  98216. */
  98217. export interface IRenderingManagerAutoClearSetup {
  98218. /**
  98219. * Defines whether or not autoclear is enable.
  98220. */
  98221. autoClear: boolean;
  98222. /**
  98223. * Defines whether or not to autoclear the depth buffer.
  98224. */
  98225. depth: boolean;
  98226. /**
  98227. * Defines whether or not to autoclear the stencil buffer.
  98228. */
  98229. stencil: boolean;
  98230. }
  98231. /**
  98232. * This class is used by the onRenderingGroupObservable
  98233. */
  98234. export class RenderingGroupInfo {
  98235. /**
  98236. * The Scene that being rendered
  98237. */
  98238. scene: Scene;
  98239. /**
  98240. * The camera currently used for the rendering pass
  98241. */
  98242. camera: Nullable<Camera>;
  98243. /**
  98244. * The ID of the renderingGroup being processed
  98245. */
  98246. renderingGroupId: number;
  98247. }
  98248. /**
  98249. * This is the manager responsible of all the rendering for meshes sprites and particles.
  98250. * It is enable to manage the different groups as well as the different necessary sort functions.
  98251. * This should not be used directly aside of the few static configurations
  98252. */
  98253. export class RenderingManager {
  98254. /**
  98255. * The max id used for rendering groups (not included)
  98256. */
  98257. static MAX_RENDERINGGROUPS: number;
  98258. /**
  98259. * The min id used for rendering groups (included)
  98260. */
  98261. static MIN_RENDERINGGROUPS: number;
  98262. /**
  98263. * Used to globally prevent autoclearing scenes.
  98264. */
  98265. static AUTOCLEAR: boolean;
  98266. /**
  98267. * @hidden
  98268. */
  98269. _useSceneAutoClearSetup: boolean;
  98270. private _scene;
  98271. private _renderingGroups;
  98272. private _depthStencilBufferAlreadyCleaned;
  98273. private _autoClearDepthStencil;
  98274. private _customOpaqueSortCompareFn;
  98275. private _customAlphaTestSortCompareFn;
  98276. private _customTransparentSortCompareFn;
  98277. private _renderingGroupInfo;
  98278. /**
  98279. * Instantiates a new rendering group for a particular scene
  98280. * @param scene Defines the scene the groups belongs to
  98281. */
  98282. constructor(scene: Scene);
  98283. private _clearDepthStencilBuffer;
  98284. /**
  98285. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  98286. * @hidden
  98287. */
  98288. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  98289. /**
  98290. * Resets the different information of the group to prepare a new frame
  98291. * @hidden
  98292. */
  98293. reset(): void;
  98294. /**
  98295. * Dispose and release the group and its associated resources.
  98296. * @hidden
  98297. */
  98298. dispose(): void;
  98299. /**
  98300. * Clear the info related to rendering groups preventing retention points during dispose.
  98301. */
  98302. freeRenderingGroups(): void;
  98303. private _prepareRenderingGroup;
  98304. /**
  98305. * Add a sprite manager to the rendering manager in order to render it this frame.
  98306. * @param spriteManager Define the sprite manager to render
  98307. */
  98308. dispatchSprites(spriteManager: ISpriteManager): void;
  98309. /**
  98310. * Add a particle system to the rendering manager in order to render it this frame.
  98311. * @param particleSystem Define the particle system to render
  98312. */
  98313. dispatchParticles(particleSystem: IParticleSystem): void;
  98314. /**
  98315. * Add a submesh to the manager in order to render it this frame
  98316. * @param subMesh The submesh to dispatch
  98317. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98318. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98319. */
  98320. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98321. /**
  98322. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98323. * This allowed control for front to back rendering or reversly depending of the special needs.
  98324. *
  98325. * @param renderingGroupId The rendering group id corresponding to its index
  98326. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98327. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98328. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98329. */
  98330. 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;
  98331. /**
  98332. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98333. *
  98334. * @param renderingGroupId The rendering group id corresponding to its index
  98335. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98336. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98337. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98338. */
  98339. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98340. /**
  98341. * Gets the current auto clear configuration for one rendering group of the rendering
  98342. * manager.
  98343. * @param index the rendering group index to get the information for
  98344. * @returns The auto clear setup for the requested rendering group
  98345. */
  98346. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98347. }
  98348. }
  98349. declare module BABYLON {
  98350. /**
  98351. * Defines the options associated with the creation of a custom shader for a shadow generator.
  98352. */
  98353. export interface ICustomShaderOptions {
  98354. /**
  98355. * Gets or sets the custom shader name to use
  98356. */
  98357. shaderName: string;
  98358. /**
  98359. * The list of attribute names used in the shader
  98360. */
  98361. attributes?: string[];
  98362. /**
  98363. * The list of unifrom names used in the shader
  98364. */
  98365. uniforms?: string[];
  98366. /**
  98367. * The list of sampler names used in the shader
  98368. */
  98369. samplers?: string[];
  98370. /**
  98371. * The list of defines used in the shader
  98372. */
  98373. defines?: string[];
  98374. }
  98375. /**
  98376. * Interface to implement to create a shadow generator compatible with BJS.
  98377. */
  98378. export interface IShadowGenerator {
  98379. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98380. id: string;
  98381. /**
  98382. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98383. * @returns The render target texture if present otherwise, null
  98384. */
  98385. getShadowMap(): Nullable<RenderTargetTexture>;
  98386. /**
  98387. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98388. * @param subMesh The submesh we want to render in the shadow map
  98389. * @param useInstances Defines wether will draw in the map using instances
  98390. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98391. * @returns true if ready otherwise, false
  98392. */
  98393. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98394. /**
  98395. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98396. * @param defines Defines of the material we want to update
  98397. * @param lightIndex Index of the light in the enabled light list of the material
  98398. */
  98399. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  98400. /**
  98401. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98402. * defined in the generator but impacting the effect).
  98403. * It implies the unifroms available on the materials are the standard BJS ones.
  98404. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98405. * @param effect The effect we are binfing the information for
  98406. */
  98407. bindShadowLight(lightIndex: string, effect: Effect): void;
  98408. /**
  98409. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98410. * (eq to shadow prjection matrix * light transform matrix)
  98411. * @returns The transform matrix used to create the shadow map
  98412. */
  98413. getTransformMatrix(): Matrix;
  98414. /**
  98415. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98416. * Cube and 2D textures for instance.
  98417. */
  98418. recreateShadowMap(): void;
  98419. /**
  98420. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98421. * @param onCompiled Callback triggered at the and of the effects compilation
  98422. * @param options Sets of optional options forcing the compilation with different modes
  98423. */
  98424. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98425. useInstances: boolean;
  98426. }>): void;
  98427. /**
  98428. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98429. * @param options Sets of optional options forcing the compilation with different modes
  98430. * @returns A promise that resolves when the compilation completes
  98431. */
  98432. forceCompilationAsync(options?: Partial<{
  98433. useInstances: boolean;
  98434. }>): Promise<void>;
  98435. /**
  98436. * Serializes the shadow generator setup to a json object.
  98437. * @returns The serialized JSON object
  98438. */
  98439. serialize(): any;
  98440. /**
  98441. * Disposes the Shadow map and related Textures and effects.
  98442. */
  98443. dispose(): void;
  98444. }
  98445. /**
  98446. * Default implementation IShadowGenerator.
  98447. * This is the main object responsible of generating shadows in the framework.
  98448. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  98449. */
  98450. export class ShadowGenerator implements IShadowGenerator {
  98451. /**
  98452. * Name of the shadow generator class
  98453. */
  98454. static CLASSNAME: string;
  98455. /**
  98456. * Shadow generator mode None: no filtering applied.
  98457. */
  98458. static readonly FILTER_NONE: number;
  98459. /**
  98460. * Shadow generator mode ESM: Exponential Shadow Mapping.
  98461. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98462. */
  98463. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  98464. /**
  98465. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  98466. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  98467. */
  98468. static readonly FILTER_POISSONSAMPLING: number;
  98469. /**
  98470. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  98471. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98472. */
  98473. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  98474. /**
  98475. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  98476. * edge artifacts on steep falloff.
  98477. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98478. */
  98479. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  98480. /**
  98481. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  98482. * edge artifacts on steep falloff.
  98483. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98484. */
  98485. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  98486. /**
  98487. * Shadow generator mode PCF: Percentage Closer Filtering
  98488. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98489. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  98490. */
  98491. static readonly FILTER_PCF: number;
  98492. /**
  98493. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  98494. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98495. * Contact Hardening
  98496. */
  98497. static readonly FILTER_PCSS: number;
  98498. /**
  98499. * Reserved for PCF and PCSS
  98500. * Highest Quality.
  98501. *
  98502. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  98503. *
  98504. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  98505. */
  98506. static readonly QUALITY_HIGH: number;
  98507. /**
  98508. * Reserved for PCF and PCSS
  98509. * Good tradeoff for quality/perf cross devices
  98510. *
  98511. * Execute PCF on a 3*3 kernel.
  98512. *
  98513. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  98514. */
  98515. static readonly QUALITY_MEDIUM: number;
  98516. /**
  98517. * Reserved for PCF and PCSS
  98518. * The lowest quality but the fastest.
  98519. *
  98520. * Execute PCF on a 1*1 kernel.
  98521. *
  98522. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  98523. */
  98524. static readonly QUALITY_LOW: number;
  98525. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98526. id: string;
  98527. /** Gets or sets the custom shader name to use */
  98528. customShaderOptions: ICustomShaderOptions;
  98529. /**
  98530. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  98531. */
  98532. onBeforeShadowMapRenderObservable: Observable<Effect>;
  98533. /**
  98534. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  98535. */
  98536. onAfterShadowMapRenderObservable: Observable<Effect>;
  98537. /**
  98538. * Observable triggered before a mesh is rendered in the shadow map.
  98539. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  98540. */
  98541. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  98542. /**
  98543. * Observable triggered after a mesh is rendered in the shadow map.
  98544. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  98545. */
  98546. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  98547. protected _bias: number;
  98548. /**
  98549. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  98550. */
  98551. get bias(): number;
  98552. /**
  98553. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  98554. */
  98555. set bias(bias: number);
  98556. protected _normalBias: number;
  98557. /**
  98558. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98559. */
  98560. get normalBias(): number;
  98561. /**
  98562. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98563. */
  98564. set normalBias(normalBias: number);
  98565. protected _blurBoxOffset: number;
  98566. /**
  98567. * Gets the blur box offset: offset applied during the blur pass.
  98568. * Only useful if useKernelBlur = false
  98569. */
  98570. get blurBoxOffset(): number;
  98571. /**
  98572. * Sets the blur box offset: offset applied during the blur pass.
  98573. * Only useful if useKernelBlur = false
  98574. */
  98575. set blurBoxOffset(value: number);
  98576. protected _blurScale: number;
  98577. /**
  98578. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  98579. * 2 means half of the size.
  98580. */
  98581. get blurScale(): number;
  98582. /**
  98583. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  98584. * 2 means half of the size.
  98585. */
  98586. set blurScale(value: number);
  98587. protected _blurKernel: number;
  98588. /**
  98589. * Gets the blur kernel: kernel size of the blur pass.
  98590. * Only useful if useKernelBlur = true
  98591. */
  98592. get blurKernel(): number;
  98593. /**
  98594. * Sets the blur kernel: kernel size of the blur pass.
  98595. * Only useful if useKernelBlur = true
  98596. */
  98597. set blurKernel(value: number);
  98598. protected _useKernelBlur: boolean;
  98599. /**
  98600. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  98601. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98602. */
  98603. get useKernelBlur(): boolean;
  98604. /**
  98605. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  98606. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98607. */
  98608. set useKernelBlur(value: boolean);
  98609. protected _depthScale: number;
  98610. /**
  98611. * Gets the depth scale used in ESM mode.
  98612. */
  98613. get depthScale(): number;
  98614. /**
  98615. * Sets the depth scale used in ESM mode.
  98616. * This can override the scale stored on the light.
  98617. */
  98618. set depthScale(value: number);
  98619. protected _validateFilter(filter: number): number;
  98620. protected _filter: number;
  98621. /**
  98622. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  98623. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98624. */
  98625. get filter(): number;
  98626. /**
  98627. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  98628. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98629. */
  98630. set filter(value: number);
  98631. /**
  98632. * Gets if the current filter is set to Poisson Sampling.
  98633. */
  98634. get usePoissonSampling(): boolean;
  98635. /**
  98636. * Sets the current filter to Poisson Sampling.
  98637. */
  98638. set usePoissonSampling(value: boolean);
  98639. /**
  98640. * Gets if the current filter is set to ESM.
  98641. */
  98642. get useExponentialShadowMap(): boolean;
  98643. /**
  98644. * Sets the current filter is to ESM.
  98645. */
  98646. set useExponentialShadowMap(value: boolean);
  98647. /**
  98648. * Gets if the current filter is set to filtered ESM.
  98649. */
  98650. get useBlurExponentialShadowMap(): boolean;
  98651. /**
  98652. * Gets if the current filter is set to filtered ESM.
  98653. */
  98654. set useBlurExponentialShadowMap(value: boolean);
  98655. /**
  98656. * Gets if the current filter is set to "close ESM" (using the inverse of the
  98657. * exponential to prevent steep falloff artifacts).
  98658. */
  98659. get useCloseExponentialShadowMap(): boolean;
  98660. /**
  98661. * Sets the current filter to "close ESM" (using the inverse of the
  98662. * exponential to prevent steep falloff artifacts).
  98663. */
  98664. set useCloseExponentialShadowMap(value: boolean);
  98665. /**
  98666. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  98667. * exponential to prevent steep falloff artifacts).
  98668. */
  98669. get useBlurCloseExponentialShadowMap(): boolean;
  98670. /**
  98671. * Sets the current filter to filtered "close ESM" (using the inverse of the
  98672. * exponential to prevent steep falloff artifacts).
  98673. */
  98674. set useBlurCloseExponentialShadowMap(value: boolean);
  98675. /**
  98676. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  98677. */
  98678. get usePercentageCloserFiltering(): boolean;
  98679. /**
  98680. * Sets the current filter to "PCF" (percentage closer filtering).
  98681. */
  98682. set usePercentageCloserFiltering(value: boolean);
  98683. protected _filteringQuality: number;
  98684. /**
  98685. * Gets the PCF or PCSS Quality.
  98686. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98687. */
  98688. get filteringQuality(): number;
  98689. /**
  98690. * Sets the PCF or PCSS Quality.
  98691. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98692. */
  98693. set filteringQuality(filteringQuality: number);
  98694. /**
  98695. * Gets if the current filter is set to "PCSS" (contact hardening).
  98696. */
  98697. get useContactHardeningShadow(): boolean;
  98698. /**
  98699. * Sets the current filter to "PCSS" (contact hardening).
  98700. */
  98701. set useContactHardeningShadow(value: boolean);
  98702. protected _contactHardeningLightSizeUVRatio: number;
  98703. /**
  98704. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98705. * Using a ratio helps keeping shape stability independently of the map size.
  98706. *
  98707. * It does not account for the light projection as it was having too much
  98708. * instability during the light setup or during light position changes.
  98709. *
  98710. * Only valid if useContactHardeningShadow is true.
  98711. */
  98712. get contactHardeningLightSizeUVRatio(): number;
  98713. /**
  98714. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98715. * Using a ratio helps keeping shape stability independently of the map size.
  98716. *
  98717. * It does not account for the light projection as it was having too much
  98718. * instability during the light setup or during light position changes.
  98719. *
  98720. * Only valid if useContactHardeningShadow is true.
  98721. */
  98722. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  98723. protected _darkness: number;
  98724. /** Gets or sets the actual darkness of a shadow */
  98725. get darkness(): number;
  98726. set darkness(value: number);
  98727. /**
  98728. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  98729. * 0 means strongest and 1 would means no shadow.
  98730. * @returns the darkness.
  98731. */
  98732. getDarkness(): number;
  98733. /**
  98734. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  98735. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  98736. * @returns the shadow generator allowing fluent coding.
  98737. */
  98738. setDarkness(darkness: number): ShadowGenerator;
  98739. protected _transparencyShadow: boolean;
  98740. /** Gets or sets the ability to have transparent shadow */
  98741. get transparencyShadow(): boolean;
  98742. set transparencyShadow(value: boolean);
  98743. /**
  98744. * Sets the ability to have transparent shadow (boolean).
  98745. * @param transparent True if transparent else False
  98746. * @returns the shadow generator allowing fluent coding
  98747. */
  98748. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  98749. /**
  98750. * Enables or disables shadows with varying strength based on the transparency
  98751. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  98752. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  98753. * mesh.visibility * alphaTexture.a
  98754. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  98755. */
  98756. enableSoftTransparentShadow: boolean;
  98757. protected _shadowMap: Nullable<RenderTargetTexture>;
  98758. protected _shadowMap2: Nullable<RenderTargetTexture>;
  98759. /**
  98760. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98761. * @returns The render target texture if present otherwise, null
  98762. */
  98763. getShadowMap(): Nullable<RenderTargetTexture>;
  98764. /**
  98765. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  98766. * @returns The render target texture if the shadow map is present otherwise, null
  98767. */
  98768. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  98769. /**
  98770. * Gets the class name of that object
  98771. * @returns "ShadowGenerator"
  98772. */
  98773. getClassName(): string;
  98774. /**
  98775. * Helper function to add a mesh and its descendants to the list of shadow casters.
  98776. * @param mesh Mesh to add
  98777. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  98778. * @returns the Shadow Generator itself
  98779. */
  98780. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98781. /**
  98782. * Helper function to remove a mesh and its descendants from the list of shadow casters
  98783. * @param mesh Mesh to remove
  98784. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  98785. * @returns the Shadow Generator itself
  98786. */
  98787. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98788. /**
  98789. * Controls the extent to which the shadows fade out at the edge of the frustum
  98790. */
  98791. frustumEdgeFalloff: number;
  98792. protected _light: IShadowLight;
  98793. /**
  98794. * Returns the associated light object.
  98795. * @returns the light generating the shadow
  98796. */
  98797. getLight(): IShadowLight;
  98798. /**
  98799. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  98800. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  98801. * It might on the other hand introduce peter panning.
  98802. */
  98803. forceBackFacesOnly: boolean;
  98804. protected _scene: Scene;
  98805. protected _lightDirection: Vector3;
  98806. protected _effect: Effect;
  98807. protected _viewMatrix: Matrix;
  98808. protected _projectionMatrix: Matrix;
  98809. protected _transformMatrix: Matrix;
  98810. protected _cachedPosition: Vector3;
  98811. protected _cachedDirection: Vector3;
  98812. protected _cachedDefines: string;
  98813. protected _currentRenderID: number;
  98814. protected _boxBlurPostprocess: Nullable<PostProcess>;
  98815. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  98816. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  98817. protected _blurPostProcesses: PostProcess[];
  98818. protected _mapSize: number;
  98819. protected _currentFaceIndex: number;
  98820. protected _currentFaceIndexCache: number;
  98821. protected _textureType: number;
  98822. protected _defaultTextureMatrix: Matrix;
  98823. protected _storedUniqueId: Nullable<number>;
  98824. /** @hidden */
  98825. static _SceneComponentInitialization: (scene: Scene) => void;
  98826. /**
  98827. * Gets or sets the size of the texture what stores the shadows
  98828. */
  98829. get mapSize(): number;
  98830. set mapSize(size: number);
  98831. /**
  98832. * Creates a ShadowGenerator object.
  98833. * A ShadowGenerator is the required tool to use the shadows.
  98834. * Each light casting shadows needs to use its own ShadowGenerator.
  98835. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  98836. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  98837. * @param light The light object generating the shadows.
  98838. * @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.
  98839. */
  98840. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  98841. protected _initializeGenerator(): void;
  98842. protected _createTargetRenderTexture(): void;
  98843. protected _initializeShadowMap(): void;
  98844. protected _initializeBlurRTTAndPostProcesses(): void;
  98845. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  98846. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  98847. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  98848. protected _applyFilterValues(): void;
  98849. /**
  98850. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98851. * @param onCompiled Callback triggered at the and of the effects compilation
  98852. * @param options Sets of optional options forcing the compilation with different modes
  98853. */
  98854. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98855. useInstances: boolean;
  98856. }>): void;
  98857. /**
  98858. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98859. * @param options Sets of optional options forcing the compilation with different modes
  98860. * @returns A promise that resolves when the compilation completes
  98861. */
  98862. forceCompilationAsync(options?: Partial<{
  98863. useInstances: boolean;
  98864. }>): Promise<void>;
  98865. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  98866. private _prepareShadowDefines;
  98867. /**
  98868. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98869. * @param subMesh The submesh we want to render in the shadow map
  98870. * @param useInstances Defines wether will draw in the map using instances
  98871. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98872. * @returns true if ready otherwise, false
  98873. */
  98874. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98875. /**
  98876. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98877. * @param defines Defines of the material we want to update
  98878. * @param lightIndex Index of the light in the enabled light list of the material
  98879. */
  98880. prepareDefines(defines: any, lightIndex: number): void;
  98881. /**
  98882. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98883. * defined in the generator but impacting the effect).
  98884. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98885. * @param effect The effect we are binfing the information for
  98886. */
  98887. bindShadowLight(lightIndex: string, effect: Effect): void;
  98888. /**
  98889. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98890. * (eq to shadow prjection matrix * light transform matrix)
  98891. * @returns The transform matrix used to create the shadow map
  98892. */
  98893. getTransformMatrix(): Matrix;
  98894. /**
  98895. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98896. * Cube and 2D textures for instance.
  98897. */
  98898. recreateShadowMap(): void;
  98899. protected _disposeBlurPostProcesses(): void;
  98900. protected _disposeRTTandPostProcesses(): void;
  98901. /**
  98902. * Disposes the ShadowGenerator.
  98903. * Returns nothing.
  98904. */
  98905. dispose(): void;
  98906. /**
  98907. * Serializes the shadow generator setup to a json object.
  98908. * @returns The serialized JSON object
  98909. */
  98910. serialize(): any;
  98911. /**
  98912. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  98913. * @param parsedShadowGenerator The JSON object to parse
  98914. * @param scene The scene to create the shadow map for
  98915. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  98916. * @returns The parsed shadow generator
  98917. */
  98918. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  98919. }
  98920. }
  98921. declare module BABYLON {
  98922. /**
  98923. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  98924. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  98925. * 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.
  98926. */
  98927. export abstract class Light extends Node {
  98928. /**
  98929. * Falloff Default: light is falling off following the material specification:
  98930. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  98931. */
  98932. static readonly FALLOFF_DEFAULT: number;
  98933. /**
  98934. * Falloff Physical: light is falling off following the inverse squared distance law.
  98935. */
  98936. static readonly FALLOFF_PHYSICAL: number;
  98937. /**
  98938. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  98939. * to enhance interoperability with other engines.
  98940. */
  98941. static readonly FALLOFF_GLTF: number;
  98942. /**
  98943. * Falloff Standard: light is falling off like in the standard material
  98944. * to enhance interoperability with other materials.
  98945. */
  98946. static readonly FALLOFF_STANDARD: number;
  98947. /**
  98948. * If every light affecting the material is in this lightmapMode,
  98949. * material.lightmapTexture adds or multiplies
  98950. * (depends on material.useLightmapAsShadowmap)
  98951. * after every other light calculations.
  98952. */
  98953. static readonly LIGHTMAP_DEFAULT: number;
  98954. /**
  98955. * material.lightmapTexture as only diffuse lighting from this light
  98956. * adds only specular lighting from this light
  98957. * adds dynamic shadows
  98958. */
  98959. static readonly LIGHTMAP_SPECULAR: number;
  98960. /**
  98961. * material.lightmapTexture as only lighting
  98962. * no light calculation from this light
  98963. * only adds dynamic shadows from this light
  98964. */
  98965. static readonly LIGHTMAP_SHADOWSONLY: number;
  98966. /**
  98967. * Each light type uses the default quantity according to its type:
  98968. * point/spot lights use luminous intensity
  98969. * directional lights use illuminance
  98970. */
  98971. static readonly INTENSITYMODE_AUTOMATIC: number;
  98972. /**
  98973. * lumen (lm)
  98974. */
  98975. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  98976. /**
  98977. * candela (lm/sr)
  98978. */
  98979. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  98980. /**
  98981. * lux (lm/m^2)
  98982. */
  98983. static readonly INTENSITYMODE_ILLUMINANCE: number;
  98984. /**
  98985. * nit (cd/m^2)
  98986. */
  98987. static readonly INTENSITYMODE_LUMINANCE: number;
  98988. /**
  98989. * Light type const id of the point light.
  98990. */
  98991. static readonly LIGHTTYPEID_POINTLIGHT: number;
  98992. /**
  98993. * Light type const id of the directional light.
  98994. */
  98995. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  98996. /**
  98997. * Light type const id of the spot light.
  98998. */
  98999. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  99000. /**
  99001. * Light type const id of the hemispheric light.
  99002. */
  99003. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  99004. /**
  99005. * Diffuse gives the basic color to an object.
  99006. */
  99007. diffuse: Color3;
  99008. /**
  99009. * Specular produces a highlight color on an object.
  99010. * Note: This is note affecting PBR materials.
  99011. */
  99012. specular: Color3;
  99013. /**
  99014. * Defines the falloff type for this light. This lets overrriding how punctual light are
  99015. * falling off base on range or angle.
  99016. * This can be set to any values in Light.FALLOFF_x.
  99017. *
  99018. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  99019. * other types of materials.
  99020. */
  99021. falloffType: number;
  99022. /**
  99023. * Strength of the light.
  99024. * Note: By default it is define in the framework own unit.
  99025. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  99026. */
  99027. intensity: number;
  99028. private _range;
  99029. protected _inverseSquaredRange: number;
  99030. /**
  99031. * Defines how far from the source the light is impacting in scene units.
  99032. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  99033. */
  99034. get range(): number;
  99035. /**
  99036. * Defines how far from the source the light is impacting in scene units.
  99037. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  99038. */
  99039. set range(value: number);
  99040. /**
  99041. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  99042. * of light.
  99043. */
  99044. private _photometricScale;
  99045. private _intensityMode;
  99046. /**
  99047. * Gets the photometric scale used to interpret the intensity.
  99048. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  99049. */
  99050. get intensityMode(): number;
  99051. /**
  99052. * Sets the photometric scale used to interpret the intensity.
  99053. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  99054. */
  99055. set intensityMode(value: number);
  99056. private _radius;
  99057. /**
  99058. * Gets the light radius used by PBR Materials to simulate soft area lights.
  99059. */
  99060. get radius(): number;
  99061. /**
  99062. * sets the light radius used by PBR Materials to simulate soft area lights.
  99063. */
  99064. set radius(value: number);
  99065. private _renderPriority;
  99066. /**
  99067. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  99068. * exceeding the number allowed of the materials.
  99069. */
  99070. renderPriority: number;
  99071. private _shadowEnabled;
  99072. /**
  99073. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  99074. * the current shadow generator.
  99075. */
  99076. get shadowEnabled(): boolean;
  99077. /**
  99078. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  99079. * the current shadow generator.
  99080. */
  99081. set shadowEnabled(value: boolean);
  99082. private _includedOnlyMeshes;
  99083. /**
  99084. * Gets the only meshes impacted by this light.
  99085. */
  99086. get includedOnlyMeshes(): AbstractMesh[];
  99087. /**
  99088. * Sets the only meshes impacted by this light.
  99089. */
  99090. set includedOnlyMeshes(value: AbstractMesh[]);
  99091. private _excludedMeshes;
  99092. /**
  99093. * Gets the meshes not impacted by this light.
  99094. */
  99095. get excludedMeshes(): AbstractMesh[];
  99096. /**
  99097. * Sets the meshes not impacted by this light.
  99098. */
  99099. set excludedMeshes(value: AbstractMesh[]);
  99100. private _excludeWithLayerMask;
  99101. /**
  99102. * Gets the layer id use to find what meshes are not impacted by the light.
  99103. * Inactive if 0
  99104. */
  99105. get excludeWithLayerMask(): number;
  99106. /**
  99107. * Sets the layer id use to find what meshes are not impacted by the light.
  99108. * Inactive if 0
  99109. */
  99110. set excludeWithLayerMask(value: number);
  99111. private _includeOnlyWithLayerMask;
  99112. /**
  99113. * Gets the layer id use to find what meshes are impacted by the light.
  99114. * Inactive if 0
  99115. */
  99116. get includeOnlyWithLayerMask(): number;
  99117. /**
  99118. * Sets the layer id use to find what meshes are impacted by the light.
  99119. * Inactive if 0
  99120. */
  99121. set includeOnlyWithLayerMask(value: number);
  99122. private _lightmapMode;
  99123. /**
  99124. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  99125. */
  99126. get lightmapMode(): number;
  99127. /**
  99128. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  99129. */
  99130. set lightmapMode(value: number);
  99131. /**
  99132. * Shadow generator associted to the light.
  99133. * @hidden Internal use only.
  99134. */
  99135. _shadowGenerator: Nullable<IShadowGenerator>;
  99136. /**
  99137. * @hidden Internal use only.
  99138. */
  99139. _excludedMeshesIds: string[];
  99140. /**
  99141. * @hidden Internal use only.
  99142. */
  99143. _includedOnlyMeshesIds: string[];
  99144. /**
  99145. * The current light unifom buffer.
  99146. * @hidden Internal use only.
  99147. */
  99148. _uniformBuffer: UniformBuffer;
  99149. /** @hidden */
  99150. _renderId: number;
  99151. /**
  99152. * Creates a Light object in the scene.
  99153. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99154. * @param name The firendly name of the light
  99155. * @param scene The scene the light belongs too
  99156. */
  99157. constructor(name: string, scene: Scene);
  99158. protected abstract _buildUniformLayout(): void;
  99159. /**
  99160. * Sets the passed Effect "effect" with the Light information.
  99161. * @param effect The effect to update
  99162. * @param lightIndex The index of the light in the effect to update
  99163. * @returns The light
  99164. */
  99165. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  99166. /**
  99167. * Sets the passed Effect "effect" with the Light textures.
  99168. * @param effect The effect to update
  99169. * @param lightIndex The index of the light in the effect to update
  99170. * @returns The light
  99171. */
  99172. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  99173. /**
  99174. * Binds the lights information from the scene to the effect for the given mesh.
  99175. * @param lightIndex Light index
  99176. * @param scene The scene where the light belongs to
  99177. * @param effect The effect we are binding the data to
  99178. * @param useSpecular Defines if specular is supported
  99179. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99180. */
  99181. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  99182. /**
  99183. * Sets the passed Effect "effect" with the Light information.
  99184. * @param effect The effect to update
  99185. * @param lightDataUniformName The uniform used to store light data (position or direction)
  99186. * @returns The light
  99187. */
  99188. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  99189. /**
  99190. * Returns the string "Light".
  99191. * @returns the class name
  99192. */
  99193. getClassName(): string;
  99194. /** @hidden */
  99195. readonly _isLight: boolean;
  99196. /**
  99197. * Converts the light information to a readable string for debug purpose.
  99198. * @param fullDetails Supports for multiple levels of logging within scene loading
  99199. * @returns the human readable light info
  99200. */
  99201. toString(fullDetails?: boolean): string;
  99202. /** @hidden */
  99203. protected _syncParentEnabledState(): void;
  99204. /**
  99205. * Set the enabled state of this node.
  99206. * @param value - the new enabled state
  99207. */
  99208. setEnabled(value: boolean): void;
  99209. /**
  99210. * Returns the Light associated shadow generator if any.
  99211. * @return the associated shadow generator.
  99212. */
  99213. getShadowGenerator(): Nullable<IShadowGenerator>;
  99214. /**
  99215. * Returns a Vector3, the absolute light position in the World.
  99216. * @returns the world space position of the light
  99217. */
  99218. getAbsolutePosition(): Vector3;
  99219. /**
  99220. * Specifies if the light will affect the passed mesh.
  99221. * @param mesh The mesh to test against the light
  99222. * @return true the mesh is affected otherwise, false.
  99223. */
  99224. canAffectMesh(mesh: AbstractMesh): boolean;
  99225. /**
  99226. * Sort function to order lights for rendering.
  99227. * @param a First Light object to compare to second.
  99228. * @param b Second Light object to compare first.
  99229. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  99230. */
  99231. static CompareLightsPriority(a: Light, b: Light): number;
  99232. /**
  99233. * Releases resources associated with this node.
  99234. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99235. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99236. */
  99237. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99238. /**
  99239. * Returns the light type ID (integer).
  99240. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  99241. */
  99242. getTypeID(): number;
  99243. /**
  99244. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  99245. * @returns the scaled intensity in intensity mode unit
  99246. */
  99247. getScaledIntensity(): number;
  99248. /**
  99249. * Returns a new Light object, named "name", from the current one.
  99250. * @param name The name of the cloned light
  99251. * @param newParent The parent of this light, if it has one
  99252. * @returns the new created light
  99253. */
  99254. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  99255. /**
  99256. * Serializes the current light into a Serialization object.
  99257. * @returns the serialized object.
  99258. */
  99259. serialize(): any;
  99260. /**
  99261. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  99262. * This new light is named "name" and added to the passed scene.
  99263. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  99264. * @param name The friendly name of the light
  99265. * @param scene The scene the new light will belong to
  99266. * @returns the constructor function
  99267. */
  99268. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  99269. /**
  99270. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  99271. * @param parsedLight The JSON representation of the light
  99272. * @param scene The scene to create the parsed light in
  99273. * @returns the created light after parsing
  99274. */
  99275. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  99276. private _hookArrayForExcluded;
  99277. private _hookArrayForIncludedOnly;
  99278. private _resyncMeshes;
  99279. /**
  99280. * Forces the meshes to update their light related information in their rendering used effects
  99281. * @hidden Internal Use Only
  99282. */
  99283. _markMeshesAsLightDirty(): void;
  99284. /**
  99285. * Recomputes the cached photometric scale if needed.
  99286. */
  99287. private _computePhotometricScale;
  99288. /**
  99289. * Returns the Photometric Scale according to the light type and intensity mode.
  99290. */
  99291. private _getPhotometricScale;
  99292. /**
  99293. * Reorder the light in the scene according to their defined priority.
  99294. * @hidden Internal Use Only
  99295. */
  99296. _reorderLightsInScene(): void;
  99297. /**
  99298. * Prepares the list of defines specific to the light type.
  99299. * @param defines the list of defines
  99300. * @param lightIndex defines the index of the light for the effect
  99301. */
  99302. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99303. }
  99304. }
  99305. declare module BABYLON {
  99306. /**
  99307. * Configuration needed for prepass-capable materials
  99308. */
  99309. export class PrePassConfiguration {
  99310. /**
  99311. * Previous world matrices of meshes carrying this material
  99312. * Used for computing velocity
  99313. */
  99314. previousWorldMatrices: {
  99315. [index: number]: Matrix;
  99316. };
  99317. /**
  99318. * Previous view project matrix
  99319. * Used for computing velocity
  99320. */
  99321. previousViewProjection: Matrix;
  99322. /**
  99323. * Previous bones of meshes carrying this material
  99324. * Used for computing velocity
  99325. */
  99326. previousBones: {
  99327. [index: number]: Float32Array;
  99328. };
  99329. /**
  99330. * Add the required uniforms to the current list.
  99331. * @param uniforms defines the current uniform list.
  99332. */
  99333. static AddUniforms(uniforms: string[]): void;
  99334. /**
  99335. * Add the required samplers to the current list.
  99336. * @param samplers defines the current sampler list.
  99337. */
  99338. static AddSamplers(samplers: string[]): void;
  99339. /**
  99340. * Binds the material data.
  99341. * @param effect defines the effect to update
  99342. * @param scene defines the scene the material belongs to.
  99343. * @param mesh The mesh
  99344. * @param world World matrix of this mesh
  99345. * @param isFrozen Is the material frozen
  99346. */
  99347. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  99348. }
  99349. }
  99350. declare module BABYLON {
  99351. /**
  99352. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  99353. * This is the base of the follow, arc rotate cameras and Free camera
  99354. * @see https://doc.babylonjs.com/features/cameras
  99355. */
  99356. export class TargetCamera extends Camera {
  99357. private static _RigCamTransformMatrix;
  99358. private static _TargetTransformMatrix;
  99359. private static _TargetFocalPoint;
  99360. private _tmpUpVector;
  99361. private _tmpTargetVector;
  99362. /**
  99363. * Define the current direction the camera is moving to
  99364. */
  99365. cameraDirection: Vector3;
  99366. /**
  99367. * Define the current rotation the camera is rotating to
  99368. */
  99369. cameraRotation: Vector2;
  99370. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  99371. ignoreParentScaling: boolean;
  99372. /**
  99373. * When set, the up vector of the camera will be updated by the rotation of the camera
  99374. */
  99375. updateUpVectorFromRotation: boolean;
  99376. private _tmpQuaternion;
  99377. /**
  99378. * Define the current rotation of the camera
  99379. */
  99380. rotation: Vector3;
  99381. /**
  99382. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  99383. */
  99384. rotationQuaternion: Quaternion;
  99385. /**
  99386. * Define the current speed of the camera
  99387. */
  99388. speed: number;
  99389. /**
  99390. * Add constraint to the camera to prevent it to move freely in all directions and
  99391. * around all axis.
  99392. */
  99393. noRotationConstraint: boolean;
  99394. /**
  99395. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  99396. * panning
  99397. */
  99398. invertRotation: boolean;
  99399. /**
  99400. * Speed multiplier for inverse camera panning
  99401. */
  99402. inverseRotationSpeed: number;
  99403. /**
  99404. * Define the current target of the camera as an object or a position.
  99405. */
  99406. lockedTarget: any;
  99407. /** @hidden */
  99408. _currentTarget: Vector3;
  99409. /** @hidden */
  99410. _initialFocalDistance: number;
  99411. /** @hidden */
  99412. _viewMatrix: Matrix;
  99413. /** @hidden */
  99414. _camMatrix: Matrix;
  99415. /** @hidden */
  99416. _cameraTransformMatrix: Matrix;
  99417. /** @hidden */
  99418. _cameraRotationMatrix: Matrix;
  99419. /** @hidden */
  99420. _referencePoint: Vector3;
  99421. /** @hidden */
  99422. _transformedReferencePoint: Vector3;
  99423. /** @hidden */
  99424. _reset: () => void;
  99425. private _defaultUp;
  99426. /**
  99427. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  99428. * This is the base of the follow, arc rotate cameras and Free camera
  99429. * @see https://doc.babylonjs.com/features/cameras
  99430. * @param name Defines the name of the camera in the scene
  99431. * @param position Defines the start position of the camera in the scene
  99432. * @param scene Defines the scene the camera belongs to
  99433. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99434. */
  99435. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99436. /**
  99437. * Gets the position in front of the camera at a given distance.
  99438. * @param distance The distance from the camera we want the position to be
  99439. * @returns the position
  99440. */
  99441. getFrontPosition(distance: number): Vector3;
  99442. /** @hidden */
  99443. _getLockedTargetPosition(): Nullable<Vector3>;
  99444. private _storedPosition;
  99445. private _storedRotation;
  99446. private _storedRotationQuaternion;
  99447. /**
  99448. * Store current camera state of the camera (fov, position, rotation, etc..)
  99449. * @returns the camera
  99450. */
  99451. storeState(): Camera;
  99452. /**
  99453. * Restored camera state. You must call storeState() first
  99454. * @returns whether it was successful or not
  99455. * @hidden
  99456. */
  99457. _restoreStateValues(): boolean;
  99458. /** @hidden */
  99459. _initCache(): void;
  99460. /** @hidden */
  99461. _updateCache(ignoreParentClass?: boolean): void;
  99462. /** @hidden */
  99463. _isSynchronizedViewMatrix(): boolean;
  99464. /** @hidden */
  99465. _computeLocalCameraSpeed(): number;
  99466. /**
  99467. * Defines the target the camera should look at.
  99468. * @param target Defines the new target as a Vector or a mesh
  99469. */
  99470. setTarget(target: Vector3): void;
  99471. /**
  99472. * Defines the target point of the camera.
  99473. * The camera looks towards it form the radius distance.
  99474. */
  99475. get target(): Vector3;
  99476. set target(value: Vector3);
  99477. /**
  99478. * Return the current target position of the camera. This value is expressed in local space.
  99479. * @returns the target position
  99480. */
  99481. getTarget(): Vector3;
  99482. /** @hidden */
  99483. _decideIfNeedsToMove(): boolean;
  99484. /** @hidden */
  99485. _updatePosition(): void;
  99486. /** @hidden */
  99487. _checkInputs(): void;
  99488. protected _updateCameraRotationMatrix(): void;
  99489. /**
  99490. * 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)
  99491. * @returns the current camera
  99492. */
  99493. private _rotateUpVectorWithCameraRotationMatrix;
  99494. private _cachedRotationZ;
  99495. private _cachedQuaternionRotationZ;
  99496. /** @hidden */
  99497. _getViewMatrix(): Matrix;
  99498. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  99499. /**
  99500. * @hidden
  99501. */
  99502. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99503. /**
  99504. * @hidden
  99505. */
  99506. _updateRigCameras(): void;
  99507. private _getRigCamPositionAndTarget;
  99508. /**
  99509. * Gets the current object class name.
  99510. * @return the class name
  99511. */
  99512. getClassName(): string;
  99513. }
  99514. }
  99515. declare module BABYLON {
  99516. /**
  99517. * Gather the list of keyboard event types as constants.
  99518. */
  99519. export class KeyboardEventTypes {
  99520. /**
  99521. * The keydown event is fired when a key becomes active (pressed).
  99522. */
  99523. static readonly KEYDOWN: number;
  99524. /**
  99525. * The keyup event is fired when a key has been released.
  99526. */
  99527. static readonly KEYUP: number;
  99528. }
  99529. /**
  99530. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99531. */
  99532. export class KeyboardInfo {
  99533. /**
  99534. * Defines the type of event (KeyboardEventTypes)
  99535. */
  99536. type: number;
  99537. /**
  99538. * Defines the related dom event
  99539. */
  99540. event: KeyboardEvent;
  99541. /**
  99542. * Instantiates a new keyboard info.
  99543. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99544. * @param type Defines the type of event (KeyboardEventTypes)
  99545. * @param event Defines the related dom event
  99546. */
  99547. constructor(
  99548. /**
  99549. * Defines the type of event (KeyboardEventTypes)
  99550. */
  99551. type: number,
  99552. /**
  99553. * Defines the related dom event
  99554. */
  99555. event: KeyboardEvent);
  99556. }
  99557. /**
  99558. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99559. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  99560. */
  99561. export class KeyboardInfoPre extends KeyboardInfo {
  99562. /**
  99563. * Defines the type of event (KeyboardEventTypes)
  99564. */
  99565. type: number;
  99566. /**
  99567. * Defines the related dom event
  99568. */
  99569. event: KeyboardEvent;
  99570. /**
  99571. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  99572. */
  99573. skipOnPointerObservable: boolean;
  99574. /**
  99575. * Instantiates a new keyboard pre info.
  99576. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99577. * @param type Defines the type of event (KeyboardEventTypes)
  99578. * @param event Defines the related dom event
  99579. */
  99580. constructor(
  99581. /**
  99582. * Defines the type of event (KeyboardEventTypes)
  99583. */
  99584. type: number,
  99585. /**
  99586. * Defines the related dom event
  99587. */
  99588. event: KeyboardEvent);
  99589. }
  99590. }
  99591. declare module BABYLON {
  99592. /**
  99593. * Manage the keyboard inputs to control the movement of a free camera.
  99594. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99595. */
  99596. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  99597. /**
  99598. * Defines the camera the input is attached to.
  99599. */
  99600. camera: FreeCamera;
  99601. /**
  99602. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99603. */
  99604. keysUp: number[];
  99605. /**
  99606. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99607. */
  99608. keysUpward: number[];
  99609. /**
  99610. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99611. */
  99612. keysDown: number[];
  99613. /**
  99614. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99615. */
  99616. keysDownward: number[];
  99617. /**
  99618. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99619. */
  99620. keysLeft: number[];
  99621. /**
  99622. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99623. */
  99624. keysRight: number[];
  99625. private _keys;
  99626. private _onCanvasBlurObserver;
  99627. private _onKeyboardObserver;
  99628. private _engine;
  99629. private _scene;
  99630. /**
  99631. * Attach the input controls to a specific dom element to get the input from.
  99632. * @param element Defines the element the controls should be listened from
  99633. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99634. */
  99635. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99636. /**
  99637. * Detach the current controls from the specified dom element.
  99638. * @param element Defines the element to stop listening the inputs from
  99639. */
  99640. detachControl(element: Nullable<HTMLElement>): void;
  99641. /**
  99642. * Update the current camera state depending on the inputs that have been used this frame.
  99643. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99644. */
  99645. checkInputs(): void;
  99646. /**
  99647. * Gets the class name of the current intput.
  99648. * @returns the class name
  99649. */
  99650. getClassName(): string;
  99651. /** @hidden */
  99652. _onLostFocus(): void;
  99653. /**
  99654. * Get the friendly name associated with the input class.
  99655. * @returns the input friendly name
  99656. */
  99657. getSimpleName(): string;
  99658. }
  99659. }
  99660. declare module BABYLON {
  99661. /**
  99662. * Gather the list of pointer event types as constants.
  99663. */
  99664. export class PointerEventTypes {
  99665. /**
  99666. * 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.
  99667. */
  99668. static readonly POINTERDOWN: number;
  99669. /**
  99670. * The pointerup event is fired when a pointer is no longer active.
  99671. */
  99672. static readonly POINTERUP: number;
  99673. /**
  99674. * The pointermove event is fired when a pointer changes coordinates.
  99675. */
  99676. static readonly POINTERMOVE: number;
  99677. /**
  99678. * The pointerwheel event is fired when a mouse wheel has been rotated.
  99679. */
  99680. static readonly POINTERWHEEL: number;
  99681. /**
  99682. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  99683. */
  99684. static readonly POINTERPICK: number;
  99685. /**
  99686. * The pointertap event is fired when a the object has been touched and released without drag.
  99687. */
  99688. static readonly POINTERTAP: number;
  99689. /**
  99690. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  99691. */
  99692. static readonly POINTERDOUBLETAP: number;
  99693. }
  99694. /**
  99695. * Base class of pointer info types.
  99696. */
  99697. export class PointerInfoBase {
  99698. /**
  99699. * Defines the type of event (PointerEventTypes)
  99700. */
  99701. type: number;
  99702. /**
  99703. * Defines the related dom event
  99704. */
  99705. event: PointerEvent | MouseWheelEvent;
  99706. /**
  99707. * Instantiates the base class of pointers info.
  99708. * @param type Defines the type of event (PointerEventTypes)
  99709. * @param event Defines the related dom event
  99710. */
  99711. constructor(
  99712. /**
  99713. * Defines the type of event (PointerEventTypes)
  99714. */
  99715. type: number,
  99716. /**
  99717. * Defines the related dom event
  99718. */
  99719. event: PointerEvent | MouseWheelEvent);
  99720. }
  99721. /**
  99722. * This class is used to store pointer related info for the onPrePointerObservable event.
  99723. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  99724. */
  99725. export class PointerInfoPre extends PointerInfoBase {
  99726. /**
  99727. * Ray from a pointer if availible (eg. 6dof controller)
  99728. */
  99729. ray: Nullable<Ray>;
  99730. /**
  99731. * Defines the local position of the pointer on the canvas.
  99732. */
  99733. localPosition: Vector2;
  99734. /**
  99735. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  99736. */
  99737. skipOnPointerObservable: boolean;
  99738. /**
  99739. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  99740. * @param type Defines the type of event (PointerEventTypes)
  99741. * @param event Defines the related dom event
  99742. * @param localX Defines the local x coordinates of the pointer when the event occured
  99743. * @param localY Defines the local y coordinates of the pointer when the event occured
  99744. */
  99745. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  99746. }
  99747. /**
  99748. * This type contains all the data related to a pointer event in Babylon.js.
  99749. * 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.
  99750. */
  99751. export class PointerInfo extends PointerInfoBase {
  99752. /**
  99753. * Defines the picking info associated to the info (if any)\
  99754. */
  99755. pickInfo: Nullable<PickingInfo>;
  99756. /**
  99757. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  99758. * @param type Defines the type of event (PointerEventTypes)
  99759. * @param event Defines the related dom event
  99760. * @param pickInfo Defines the picking info associated to the info (if any)\
  99761. */
  99762. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  99763. /**
  99764. * Defines the picking info associated to the info (if any)\
  99765. */
  99766. pickInfo: Nullable<PickingInfo>);
  99767. }
  99768. /**
  99769. * Data relating to a touch event on the screen.
  99770. */
  99771. export interface PointerTouch {
  99772. /**
  99773. * X coordinate of touch.
  99774. */
  99775. x: number;
  99776. /**
  99777. * Y coordinate of touch.
  99778. */
  99779. y: number;
  99780. /**
  99781. * Id of touch. Unique for each finger.
  99782. */
  99783. pointerId: number;
  99784. /**
  99785. * Event type passed from DOM.
  99786. */
  99787. type: any;
  99788. }
  99789. }
  99790. declare module BABYLON {
  99791. /**
  99792. * Manage the mouse inputs to control the movement of a free camera.
  99793. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99794. */
  99795. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  99796. /**
  99797. * Define if touch is enabled in the mouse input
  99798. */
  99799. touchEnabled: boolean;
  99800. /**
  99801. * Defines the camera the input is attached to.
  99802. */
  99803. camera: FreeCamera;
  99804. /**
  99805. * Defines the buttons associated with the input to handle camera move.
  99806. */
  99807. buttons: number[];
  99808. /**
  99809. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  99810. */
  99811. angularSensibility: number;
  99812. private _pointerInput;
  99813. private _onMouseMove;
  99814. private _observer;
  99815. private previousPosition;
  99816. /**
  99817. * Observable for when a pointer move event occurs containing the move offset
  99818. */
  99819. onPointerMovedObservable: Observable<{
  99820. offsetX: number;
  99821. offsetY: number;
  99822. }>;
  99823. /**
  99824. * @hidden
  99825. * If the camera should be rotated automatically based on pointer movement
  99826. */
  99827. _allowCameraRotation: boolean;
  99828. /**
  99829. * Manage the mouse inputs to control the movement of a free camera.
  99830. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99831. * @param touchEnabled Defines if touch is enabled or not
  99832. */
  99833. constructor(
  99834. /**
  99835. * Define if touch is enabled in the mouse input
  99836. */
  99837. touchEnabled?: boolean);
  99838. /**
  99839. * Attach the input controls to a specific dom element to get the input from.
  99840. * @param element Defines the element the controls should be listened from
  99841. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99842. */
  99843. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99844. /**
  99845. * Called on JS contextmenu event.
  99846. * Override this method to provide functionality.
  99847. */
  99848. protected onContextMenu(evt: PointerEvent): void;
  99849. /**
  99850. * Detach the current controls from the specified dom element.
  99851. * @param element Defines the element to stop listening the inputs from
  99852. */
  99853. detachControl(element: Nullable<HTMLElement>): void;
  99854. /**
  99855. * Gets the class name of the current intput.
  99856. * @returns the class name
  99857. */
  99858. getClassName(): string;
  99859. /**
  99860. * Get the friendly name associated with the input class.
  99861. * @returns the input friendly name
  99862. */
  99863. getSimpleName(): string;
  99864. }
  99865. }
  99866. declare module BABYLON {
  99867. /**
  99868. * Manage the touch inputs to control the movement of a free camera.
  99869. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99870. */
  99871. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  99872. /**
  99873. * Define if mouse events can be treated as touch events
  99874. */
  99875. allowMouse: boolean;
  99876. /**
  99877. * Defines the camera the input is attached to.
  99878. */
  99879. camera: FreeCamera;
  99880. /**
  99881. * Defines the touch sensibility for rotation.
  99882. * The higher the faster.
  99883. */
  99884. touchAngularSensibility: number;
  99885. /**
  99886. * Defines the touch sensibility for move.
  99887. * The higher the faster.
  99888. */
  99889. touchMoveSensibility: number;
  99890. private _offsetX;
  99891. private _offsetY;
  99892. private _pointerPressed;
  99893. private _pointerInput;
  99894. private _observer;
  99895. private _onLostFocus;
  99896. /**
  99897. * Manage the touch inputs to control the movement of a free camera.
  99898. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99899. * @param allowMouse Defines if mouse events can be treated as touch events
  99900. */
  99901. constructor(
  99902. /**
  99903. * Define if mouse events can be treated as touch events
  99904. */
  99905. allowMouse?: boolean);
  99906. /**
  99907. * Attach the input controls to a specific dom element to get the input from.
  99908. * @param element Defines the element the controls should be listened from
  99909. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99910. */
  99911. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99912. /**
  99913. * Detach the current controls from the specified dom element.
  99914. * @param element Defines the element to stop listening the inputs from
  99915. */
  99916. detachControl(element: Nullable<HTMLElement>): void;
  99917. /**
  99918. * Update the current camera state depending on the inputs that have been used this frame.
  99919. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99920. */
  99921. checkInputs(): void;
  99922. /**
  99923. * Gets the class name of the current intput.
  99924. * @returns the class name
  99925. */
  99926. getClassName(): string;
  99927. /**
  99928. * Get the friendly name associated with the input class.
  99929. * @returns the input friendly name
  99930. */
  99931. getSimpleName(): string;
  99932. }
  99933. }
  99934. declare module BABYLON {
  99935. /**
  99936. * Default Inputs manager for the FreeCamera.
  99937. * It groups all the default supported inputs for ease of use.
  99938. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99939. */
  99940. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  99941. /**
  99942. * @hidden
  99943. */
  99944. _mouseInput: Nullable<FreeCameraMouseInput>;
  99945. /**
  99946. * Instantiates a new FreeCameraInputsManager.
  99947. * @param camera Defines the camera the inputs belong to
  99948. */
  99949. constructor(camera: FreeCamera);
  99950. /**
  99951. * Add keyboard input support to the input manager.
  99952. * @returns the current input manager
  99953. */
  99954. addKeyboard(): FreeCameraInputsManager;
  99955. /**
  99956. * Add mouse input support to the input manager.
  99957. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  99958. * @returns the current input manager
  99959. */
  99960. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  99961. /**
  99962. * Removes the mouse input support from the manager
  99963. * @returns the current input manager
  99964. */
  99965. removeMouse(): FreeCameraInputsManager;
  99966. /**
  99967. * Add touch input support to the input manager.
  99968. * @returns the current input manager
  99969. */
  99970. addTouch(): FreeCameraInputsManager;
  99971. /**
  99972. * Remove all attached input methods from a camera
  99973. */
  99974. clear(): void;
  99975. }
  99976. }
  99977. declare module BABYLON {
  99978. /**
  99979. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99980. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  99981. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99982. */
  99983. export class FreeCamera extends TargetCamera {
  99984. /**
  99985. * Define the collision ellipsoid of the camera.
  99986. * This is helpful to simulate a camera body like the player body around the camera
  99987. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99988. */
  99989. ellipsoid: Vector3;
  99990. /**
  99991. * Define an offset for the position of the ellipsoid around the camera.
  99992. * This can be helpful to determine the center of the body near the gravity center of the body
  99993. * instead of its head.
  99994. */
  99995. ellipsoidOffset: Vector3;
  99996. /**
  99997. * Enable or disable collisions of the camera with the rest of the scene objects.
  99998. */
  99999. checkCollisions: boolean;
  100000. /**
  100001. * Enable or disable gravity on the camera.
  100002. */
  100003. applyGravity: boolean;
  100004. /**
  100005. * Define the input manager associated to the camera.
  100006. */
  100007. inputs: FreeCameraInputsManager;
  100008. /**
  100009. * Gets the input sensibility for a mouse input. (default is 2000.0)
  100010. * Higher values reduce sensitivity.
  100011. */
  100012. get angularSensibility(): number;
  100013. /**
  100014. * Sets the input sensibility for a mouse input. (default is 2000.0)
  100015. * Higher values reduce sensitivity.
  100016. */
  100017. set angularSensibility(value: number);
  100018. /**
  100019. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  100020. */
  100021. get keysUp(): number[];
  100022. set keysUp(value: number[]);
  100023. /**
  100024. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  100025. */
  100026. get keysUpward(): number[];
  100027. set keysUpward(value: number[]);
  100028. /**
  100029. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  100030. */
  100031. get keysDown(): number[];
  100032. set keysDown(value: number[]);
  100033. /**
  100034. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  100035. */
  100036. get keysDownward(): number[];
  100037. set keysDownward(value: number[]);
  100038. /**
  100039. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  100040. */
  100041. get keysLeft(): number[];
  100042. set keysLeft(value: number[]);
  100043. /**
  100044. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  100045. */
  100046. get keysRight(): number[];
  100047. set keysRight(value: number[]);
  100048. /**
  100049. * Event raised when the camera collide with a mesh in the scene.
  100050. */
  100051. onCollide: (collidedMesh: AbstractMesh) => void;
  100052. private _collider;
  100053. private _needMoveForGravity;
  100054. private _oldPosition;
  100055. private _diffPosition;
  100056. private _newPosition;
  100057. /** @hidden */
  100058. _localDirection: Vector3;
  100059. /** @hidden */
  100060. _transformedDirection: Vector3;
  100061. /**
  100062. * Instantiates a Free Camera.
  100063. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  100064. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  100065. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  100066. * @param name Define the name of the camera in the scene
  100067. * @param position Define the start position of the camera in the scene
  100068. * @param scene Define the scene the camera belongs to
  100069. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  100070. */
  100071. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100072. /**
  100073. * Attached controls to the current camera.
  100074. * @param element Defines the element the controls should be listened from
  100075. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100076. */
  100077. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100078. /**
  100079. * Detach the current controls from the camera.
  100080. * The camera will stop reacting to inputs.
  100081. * @param element Defines the element to stop listening the inputs from
  100082. */
  100083. detachControl(element: HTMLElement): void;
  100084. private _collisionMask;
  100085. /**
  100086. * Define a collision mask to limit the list of object the camera can collide with
  100087. */
  100088. get collisionMask(): number;
  100089. set collisionMask(mask: number);
  100090. /** @hidden */
  100091. _collideWithWorld(displacement: Vector3): void;
  100092. private _onCollisionPositionChange;
  100093. /** @hidden */
  100094. _checkInputs(): void;
  100095. /** @hidden */
  100096. _decideIfNeedsToMove(): boolean;
  100097. /** @hidden */
  100098. _updatePosition(): void;
  100099. /**
  100100. * Destroy the camera and release the current resources hold by it.
  100101. */
  100102. dispose(): void;
  100103. /**
  100104. * Gets the current object class name.
  100105. * @return the class name
  100106. */
  100107. getClassName(): string;
  100108. }
  100109. }
  100110. declare module BABYLON {
  100111. /**
  100112. * Represents a gamepad control stick position
  100113. */
  100114. export class StickValues {
  100115. /**
  100116. * The x component of the control stick
  100117. */
  100118. x: number;
  100119. /**
  100120. * The y component of the control stick
  100121. */
  100122. y: number;
  100123. /**
  100124. * Initializes the gamepad x and y control stick values
  100125. * @param x The x component of the gamepad control stick value
  100126. * @param y The y component of the gamepad control stick value
  100127. */
  100128. constructor(
  100129. /**
  100130. * The x component of the control stick
  100131. */
  100132. x: number,
  100133. /**
  100134. * The y component of the control stick
  100135. */
  100136. y: number);
  100137. }
  100138. /**
  100139. * An interface which manages callbacks for gamepad button changes
  100140. */
  100141. export interface GamepadButtonChanges {
  100142. /**
  100143. * Called when a gamepad has been changed
  100144. */
  100145. changed: boolean;
  100146. /**
  100147. * Called when a gamepad press event has been triggered
  100148. */
  100149. pressChanged: boolean;
  100150. /**
  100151. * Called when a touch event has been triggered
  100152. */
  100153. touchChanged: boolean;
  100154. /**
  100155. * Called when a value has changed
  100156. */
  100157. valueChanged: boolean;
  100158. }
  100159. /**
  100160. * Represents a gamepad
  100161. */
  100162. export class Gamepad {
  100163. /**
  100164. * The id of the gamepad
  100165. */
  100166. id: string;
  100167. /**
  100168. * The index of the gamepad
  100169. */
  100170. index: number;
  100171. /**
  100172. * The browser gamepad
  100173. */
  100174. browserGamepad: any;
  100175. /**
  100176. * Specifies what type of gamepad this represents
  100177. */
  100178. type: number;
  100179. private _leftStick;
  100180. private _rightStick;
  100181. /** @hidden */
  100182. _isConnected: boolean;
  100183. private _leftStickAxisX;
  100184. private _leftStickAxisY;
  100185. private _rightStickAxisX;
  100186. private _rightStickAxisY;
  100187. /**
  100188. * Triggered when the left control stick has been changed
  100189. */
  100190. private _onleftstickchanged;
  100191. /**
  100192. * Triggered when the right control stick has been changed
  100193. */
  100194. private _onrightstickchanged;
  100195. /**
  100196. * Represents a gamepad controller
  100197. */
  100198. static GAMEPAD: number;
  100199. /**
  100200. * Represents a generic controller
  100201. */
  100202. static GENERIC: number;
  100203. /**
  100204. * Represents an XBox controller
  100205. */
  100206. static XBOX: number;
  100207. /**
  100208. * Represents a pose-enabled controller
  100209. */
  100210. static POSE_ENABLED: number;
  100211. /**
  100212. * Represents an Dual Shock controller
  100213. */
  100214. static DUALSHOCK: number;
  100215. /**
  100216. * Specifies whether the left control stick should be Y-inverted
  100217. */
  100218. protected _invertLeftStickY: boolean;
  100219. /**
  100220. * Specifies if the gamepad has been connected
  100221. */
  100222. get isConnected(): boolean;
  100223. /**
  100224. * Initializes the gamepad
  100225. * @param id The id of the gamepad
  100226. * @param index The index of the gamepad
  100227. * @param browserGamepad The browser gamepad
  100228. * @param leftStickX The x component of the left joystick
  100229. * @param leftStickY The y component of the left joystick
  100230. * @param rightStickX The x component of the right joystick
  100231. * @param rightStickY The y component of the right joystick
  100232. */
  100233. constructor(
  100234. /**
  100235. * The id of the gamepad
  100236. */
  100237. id: string,
  100238. /**
  100239. * The index of the gamepad
  100240. */
  100241. index: number,
  100242. /**
  100243. * The browser gamepad
  100244. */
  100245. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  100246. /**
  100247. * Callback triggered when the left joystick has changed
  100248. * @param callback
  100249. */
  100250. onleftstickchanged(callback: (values: StickValues) => void): void;
  100251. /**
  100252. * Callback triggered when the right joystick has changed
  100253. * @param callback
  100254. */
  100255. onrightstickchanged(callback: (values: StickValues) => void): void;
  100256. /**
  100257. * Gets the left joystick
  100258. */
  100259. get leftStick(): StickValues;
  100260. /**
  100261. * Sets the left joystick values
  100262. */
  100263. set leftStick(newValues: StickValues);
  100264. /**
  100265. * Gets the right joystick
  100266. */
  100267. get rightStick(): StickValues;
  100268. /**
  100269. * Sets the right joystick value
  100270. */
  100271. set rightStick(newValues: StickValues);
  100272. /**
  100273. * Updates the gamepad joystick positions
  100274. */
  100275. update(): void;
  100276. /**
  100277. * Disposes the gamepad
  100278. */
  100279. dispose(): void;
  100280. }
  100281. /**
  100282. * Represents a generic gamepad
  100283. */
  100284. export class GenericPad extends Gamepad {
  100285. private _buttons;
  100286. private _onbuttondown;
  100287. private _onbuttonup;
  100288. /**
  100289. * Observable triggered when a button has been pressed
  100290. */
  100291. onButtonDownObservable: Observable<number>;
  100292. /**
  100293. * Observable triggered when a button has been released
  100294. */
  100295. onButtonUpObservable: Observable<number>;
  100296. /**
  100297. * Callback triggered when a button has been pressed
  100298. * @param callback Called when a button has been pressed
  100299. */
  100300. onbuttondown(callback: (buttonPressed: number) => void): void;
  100301. /**
  100302. * Callback triggered when a button has been released
  100303. * @param callback Called when a button has been released
  100304. */
  100305. onbuttonup(callback: (buttonReleased: number) => void): void;
  100306. /**
  100307. * Initializes the generic gamepad
  100308. * @param id The id of the generic gamepad
  100309. * @param index The index of the generic gamepad
  100310. * @param browserGamepad The browser gamepad
  100311. */
  100312. constructor(id: string, index: number, browserGamepad: any);
  100313. private _setButtonValue;
  100314. /**
  100315. * Updates the generic gamepad
  100316. */
  100317. update(): void;
  100318. /**
  100319. * Disposes the generic gamepad
  100320. */
  100321. dispose(): void;
  100322. }
  100323. }
  100324. declare module BABYLON {
  100325. /**
  100326. * Defines the types of pose enabled controllers that are supported
  100327. */
  100328. export enum PoseEnabledControllerType {
  100329. /**
  100330. * HTC Vive
  100331. */
  100332. VIVE = 0,
  100333. /**
  100334. * Oculus Rift
  100335. */
  100336. OCULUS = 1,
  100337. /**
  100338. * Windows mixed reality
  100339. */
  100340. WINDOWS = 2,
  100341. /**
  100342. * Samsung gear VR
  100343. */
  100344. GEAR_VR = 3,
  100345. /**
  100346. * Google Daydream
  100347. */
  100348. DAYDREAM = 4,
  100349. /**
  100350. * Generic
  100351. */
  100352. GENERIC = 5
  100353. }
  100354. /**
  100355. * Defines the MutableGamepadButton interface for the state of a gamepad button
  100356. */
  100357. export interface MutableGamepadButton {
  100358. /**
  100359. * Value of the button/trigger
  100360. */
  100361. value: number;
  100362. /**
  100363. * If the button/trigger is currently touched
  100364. */
  100365. touched: boolean;
  100366. /**
  100367. * If the button/trigger is currently pressed
  100368. */
  100369. pressed: boolean;
  100370. }
  100371. /**
  100372. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  100373. * @hidden
  100374. */
  100375. export interface ExtendedGamepadButton extends GamepadButton {
  100376. /**
  100377. * If the button/trigger is currently pressed
  100378. */
  100379. readonly pressed: boolean;
  100380. /**
  100381. * If the button/trigger is currently touched
  100382. */
  100383. readonly touched: boolean;
  100384. /**
  100385. * Value of the button/trigger
  100386. */
  100387. readonly value: number;
  100388. }
  100389. /** @hidden */
  100390. export interface _GamePadFactory {
  100391. /**
  100392. * Returns whether or not the current gamepad can be created for this type of controller.
  100393. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100394. * @returns true if it can be created, otherwise false
  100395. */
  100396. canCreate(gamepadInfo: any): boolean;
  100397. /**
  100398. * Creates a new instance of the Gamepad.
  100399. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100400. * @returns the new gamepad instance
  100401. */
  100402. create(gamepadInfo: any): Gamepad;
  100403. }
  100404. /**
  100405. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100406. */
  100407. export class PoseEnabledControllerHelper {
  100408. /** @hidden */
  100409. static _ControllerFactories: _GamePadFactory[];
  100410. /** @hidden */
  100411. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  100412. /**
  100413. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100414. * @param vrGamepad the gamepad to initialized
  100415. * @returns a vr controller of the type the gamepad identified as
  100416. */
  100417. static InitiateController(vrGamepad: any): Gamepad;
  100418. }
  100419. /**
  100420. * Defines the PoseEnabledController object that contains state of a vr capable controller
  100421. */
  100422. export class PoseEnabledController extends Gamepad implements PoseControlled {
  100423. /**
  100424. * If the controller is used in a webXR session
  100425. */
  100426. isXR: boolean;
  100427. private _deviceRoomPosition;
  100428. private _deviceRoomRotationQuaternion;
  100429. /**
  100430. * The device position in babylon space
  100431. */
  100432. devicePosition: Vector3;
  100433. /**
  100434. * The device rotation in babylon space
  100435. */
  100436. deviceRotationQuaternion: Quaternion;
  100437. /**
  100438. * The scale factor of the device in babylon space
  100439. */
  100440. deviceScaleFactor: number;
  100441. /**
  100442. * (Likely devicePosition should be used instead) The device position in its room space
  100443. */
  100444. position: Vector3;
  100445. /**
  100446. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  100447. */
  100448. rotationQuaternion: Quaternion;
  100449. /**
  100450. * The type of controller (Eg. Windows mixed reality)
  100451. */
  100452. controllerType: PoseEnabledControllerType;
  100453. protected _calculatedPosition: Vector3;
  100454. private _calculatedRotation;
  100455. /**
  100456. * The raw pose from the device
  100457. */
  100458. rawPose: DevicePose;
  100459. private _trackPosition;
  100460. private _maxRotationDistFromHeadset;
  100461. private _draggedRoomRotation;
  100462. /**
  100463. * @hidden
  100464. */
  100465. _disableTrackPosition(fixedPosition: Vector3): void;
  100466. /**
  100467. * Internal, the mesh attached to the controller
  100468. * @hidden
  100469. */
  100470. _mesh: Nullable<AbstractMesh>;
  100471. private _poseControlledCamera;
  100472. private _leftHandSystemQuaternion;
  100473. /**
  100474. * Internal, matrix used to convert room space to babylon space
  100475. * @hidden
  100476. */
  100477. _deviceToWorld: Matrix;
  100478. /**
  100479. * Node to be used when casting a ray from the controller
  100480. * @hidden
  100481. */
  100482. _pointingPoseNode: Nullable<TransformNode>;
  100483. /**
  100484. * Name of the child mesh that can be used to cast a ray from the controller
  100485. */
  100486. static readonly POINTING_POSE: string;
  100487. /**
  100488. * Creates a new PoseEnabledController from a gamepad
  100489. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  100490. */
  100491. constructor(browserGamepad: any);
  100492. private _workingMatrix;
  100493. /**
  100494. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  100495. */
  100496. update(): void;
  100497. /**
  100498. * Updates only the pose device and mesh without doing any button event checking
  100499. */
  100500. protected _updatePoseAndMesh(): void;
  100501. /**
  100502. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  100503. * @param poseData raw pose fromthe device
  100504. */
  100505. updateFromDevice(poseData: DevicePose): void;
  100506. /**
  100507. * @hidden
  100508. */
  100509. _meshAttachedObservable: Observable<AbstractMesh>;
  100510. /**
  100511. * Attaches a mesh to the controller
  100512. * @param mesh the mesh to be attached
  100513. */
  100514. attachToMesh(mesh: AbstractMesh): void;
  100515. /**
  100516. * Attaches the controllers mesh to a camera
  100517. * @param camera the camera the mesh should be attached to
  100518. */
  100519. attachToPoseControlledCamera(camera: TargetCamera): void;
  100520. /**
  100521. * Disposes of the controller
  100522. */
  100523. dispose(): void;
  100524. /**
  100525. * The mesh that is attached to the controller
  100526. */
  100527. get mesh(): Nullable<AbstractMesh>;
  100528. /**
  100529. * Gets the ray of the controller in the direction the controller is pointing
  100530. * @param length the length the resulting ray should be
  100531. * @returns a ray in the direction the controller is pointing
  100532. */
  100533. getForwardRay(length?: number): Ray;
  100534. }
  100535. }
  100536. declare module BABYLON {
  100537. /**
  100538. * Defines the WebVRController object that represents controllers tracked in 3D space
  100539. */
  100540. export abstract class WebVRController extends PoseEnabledController {
  100541. /**
  100542. * Internal, the default controller model for the controller
  100543. */
  100544. protected _defaultModel: Nullable<AbstractMesh>;
  100545. /**
  100546. * Fired when the trigger state has changed
  100547. */
  100548. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  100549. /**
  100550. * Fired when the main button state has changed
  100551. */
  100552. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100553. /**
  100554. * Fired when the secondary button state has changed
  100555. */
  100556. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100557. /**
  100558. * Fired when the pad state has changed
  100559. */
  100560. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  100561. /**
  100562. * Fired when controllers stick values have changed
  100563. */
  100564. onPadValuesChangedObservable: Observable<StickValues>;
  100565. /**
  100566. * Array of button availible on the controller
  100567. */
  100568. protected _buttons: Array<MutableGamepadButton>;
  100569. private _onButtonStateChange;
  100570. /**
  100571. * Fired when a controller button's state has changed
  100572. * @param callback the callback containing the button that was modified
  100573. */
  100574. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  100575. /**
  100576. * X and Y axis corresponding to the controllers joystick
  100577. */
  100578. pad: StickValues;
  100579. /**
  100580. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  100581. */
  100582. hand: string;
  100583. /**
  100584. * The default controller model for the controller
  100585. */
  100586. get defaultModel(): Nullable<AbstractMesh>;
  100587. /**
  100588. * Creates a new WebVRController from a gamepad
  100589. * @param vrGamepad the gamepad that the WebVRController should be created from
  100590. */
  100591. constructor(vrGamepad: any);
  100592. /**
  100593. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  100594. */
  100595. update(): void;
  100596. /**
  100597. * Function to be called when a button is modified
  100598. */
  100599. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100600. /**
  100601. * Loads a mesh and attaches it to the controller
  100602. * @param scene the scene the mesh should be added to
  100603. * @param meshLoaded callback for when the mesh has been loaded
  100604. */
  100605. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100606. private _setButtonValue;
  100607. private _changes;
  100608. private _checkChanges;
  100609. /**
  100610. * Disposes of th webVRCOntroller
  100611. */
  100612. dispose(): void;
  100613. }
  100614. }
  100615. declare module BABYLON {
  100616. /**
  100617. * The HemisphericLight simulates the ambient environment light,
  100618. * so the passed direction is the light reflection direction, not the incoming direction.
  100619. */
  100620. export class HemisphericLight extends Light {
  100621. /**
  100622. * The groundColor is the light in the opposite direction to the one specified during creation.
  100623. * 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.
  100624. */
  100625. groundColor: Color3;
  100626. /**
  100627. * The light reflection direction, not the incoming direction.
  100628. */
  100629. direction: Vector3;
  100630. /**
  100631. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  100632. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  100633. * The HemisphericLight can't cast shadows.
  100634. * Documentation : https://doc.babylonjs.com/babylon101/lights
  100635. * @param name The friendly name of the light
  100636. * @param direction The direction of the light reflection
  100637. * @param scene The scene the light belongs to
  100638. */
  100639. constructor(name: string, direction: Vector3, scene: Scene);
  100640. protected _buildUniformLayout(): void;
  100641. /**
  100642. * Returns the string "HemisphericLight".
  100643. * @return The class name
  100644. */
  100645. getClassName(): string;
  100646. /**
  100647. * Sets the HemisphericLight direction towards the passed target (Vector3).
  100648. * Returns the updated direction.
  100649. * @param target The target the direction should point to
  100650. * @return The computed direction
  100651. */
  100652. setDirectionToTarget(target: Vector3): Vector3;
  100653. /**
  100654. * Returns the shadow generator associated to the light.
  100655. * @returns Always null for hemispheric lights because it does not support shadows.
  100656. */
  100657. getShadowGenerator(): Nullable<IShadowGenerator>;
  100658. /**
  100659. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  100660. * @param effect The effect to update
  100661. * @param lightIndex The index of the light in the effect to update
  100662. * @returns The hemispheric light
  100663. */
  100664. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  100665. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  100666. /**
  100667. * Computes the world matrix of the node
  100668. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  100669. * @param useWasUpdatedFlag defines a reserved property
  100670. * @returns the world matrix
  100671. */
  100672. computeWorldMatrix(): Matrix;
  100673. /**
  100674. * Returns the integer 3.
  100675. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  100676. */
  100677. getTypeID(): number;
  100678. /**
  100679. * Prepares the list of defines specific to the light type.
  100680. * @param defines the list of defines
  100681. * @param lightIndex defines the index of the light for the effect
  100682. */
  100683. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  100684. }
  100685. }
  100686. declare module BABYLON {
  100687. /** @hidden */
  100688. export var vrMultiviewToSingleviewPixelShader: {
  100689. name: string;
  100690. shader: string;
  100691. };
  100692. }
  100693. declare module BABYLON {
  100694. /**
  100695. * Renders to multiple views with a single draw call
  100696. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  100697. */
  100698. export class MultiviewRenderTarget extends RenderTargetTexture {
  100699. /**
  100700. * Creates a multiview render target
  100701. * @param scene scene used with the render target
  100702. * @param size the size of the render target (used for each view)
  100703. */
  100704. constructor(scene: Scene, size?: number | {
  100705. width: number;
  100706. height: number;
  100707. } | {
  100708. ratio: number;
  100709. });
  100710. /**
  100711. * @hidden
  100712. * @param faceIndex the face index, if its a cube texture
  100713. */
  100714. _bindFrameBuffer(faceIndex?: number): void;
  100715. /**
  100716. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100717. * @returns the view count
  100718. */
  100719. getViewCount(): number;
  100720. }
  100721. }
  100722. declare module BABYLON {
  100723. interface Engine {
  100724. /**
  100725. * Creates a new multiview render target
  100726. * @param width defines the width of the texture
  100727. * @param height defines the height of the texture
  100728. * @returns the created multiview texture
  100729. */
  100730. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  100731. /**
  100732. * Binds a multiview framebuffer to be drawn to
  100733. * @param multiviewTexture texture to bind
  100734. */
  100735. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  100736. }
  100737. interface Camera {
  100738. /**
  100739. * @hidden
  100740. * 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)
  100741. */
  100742. _useMultiviewToSingleView: boolean;
  100743. /**
  100744. * @hidden
  100745. * 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)
  100746. */
  100747. _multiviewTexture: Nullable<RenderTargetTexture>;
  100748. /**
  100749. * @hidden
  100750. * ensures the multiview texture of the camera exists and has the specified width/height
  100751. * @param width height to set on the multiview texture
  100752. * @param height width to set on the multiview texture
  100753. */
  100754. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  100755. }
  100756. interface Scene {
  100757. /** @hidden */
  100758. _transformMatrixR: Matrix;
  100759. /** @hidden */
  100760. _multiviewSceneUbo: Nullable<UniformBuffer>;
  100761. /** @hidden */
  100762. _createMultiviewUbo(): void;
  100763. /** @hidden */
  100764. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  100765. /** @hidden */
  100766. _renderMultiviewToSingleView(camera: Camera): void;
  100767. }
  100768. }
  100769. declare module BABYLON {
  100770. /**
  100771. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  100772. * This will not be used for webXR as it supports displaying texture arrays directly
  100773. */
  100774. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  100775. /**
  100776. * Gets a string identifying the name of the class
  100777. * @returns "VRMultiviewToSingleviewPostProcess" string
  100778. */
  100779. getClassName(): string;
  100780. /**
  100781. * Initializes a VRMultiviewToSingleview
  100782. * @param name name of the post process
  100783. * @param camera camera to be applied to
  100784. * @param scaleFactor scaling factor to the size of the output texture
  100785. */
  100786. constructor(name: string, camera: Camera, scaleFactor: number);
  100787. }
  100788. }
  100789. declare module BABYLON {
  100790. /**
  100791. * Interface used to define additional presentation attributes
  100792. */
  100793. export interface IVRPresentationAttributes {
  100794. /**
  100795. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  100796. */
  100797. highRefreshRate: boolean;
  100798. /**
  100799. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  100800. */
  100801. foveationLevel: number;
  100802. }
  100803. interface Engine {
  100804. /** @hidden */
  100805. _vrDisplay: any;
  100806. /** @hidden */
  100807. _vrSupported: boolean;
  100808. /** @hidden */
  100809. _oldSize: Size;
  100810. /** @hidden */
  100811. _oldHardwareScaleFactor: number;
  100812. /** @hidden */
  100813. _vrExclusivePointerMode: boolean;
  100814. /** @hidden */
  100815. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  100816. /** @hidden */
  100817. _onVRDisplayPointerRestricted: () => void;
  100818. /** @hidden */
  100819. _onVRDisplayPointerUnrestricted: () => void;
  100820. /** @hidden */
  100821. _onVrDisplayConnect: Nullable<(display: any) => void>;
  100822. /** @hidden */
  100823. _onVrDisplayDisconnect: Nullable<() => void>;
  100824. /** @hidden */
  100825. _onVrDisplayPresentChange: Nullable<() => void>;
  100826. /**
  100827. * Observable signaled when VR display mode changes
  100828. */
  100829. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  100830. /**
  100831. * Observable signaled when VR request present is complete
  100832. */
  100833. onVRRequestPresentComplete: Observable<boolean>;
  100834. /**
  100835. * Observable signaled when VR request present starts
  100836. */
  100837. onVRRequestPresentStart: Observable<Engine>;
  100838. /**
  100839. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  100840. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  100841. */
  100842. isInVRExclusivePointerMode: boolean;
  100843. /**
  100844. * Gets a boolean indicating if a webVR device was detected
  100845. * @returns true if a webVR device was detected
  100846. */
  100847. isVRDevicePresent(): boolean;
  100848. /**
  100849. * Gets the current webVR device
  100850. * @returns the current webVR device (or null)
  100851. */
  100852. getVRDevice(): any;
  100853. /**
  100854. * Initializes a webVR display and starts listening to display change events
  100855. * The onVRDisplayChangedObservable will be notified upon these changes
  100856. * @returns A promise containing a VRDisplay and if vr is supported
  100857. */
  100858. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  100859. /** @hidden */
  100860. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  100861. /**
  100862. * Gets or sets the presentation attributes used to configure VR rendering
  100863. */
  100864. vrPresentationAttributes?: IVRPresentationAttributes;
  100865. /**
  100866. * Call this function to switch to webVR mode
  100867. * Will do nothing if webVR is not supported or if there is no webVR device
  100868. * @param options the webvr options provided to the camera. mainly used for multiview
  100869. * @see https://doc.babylonjs.com/how_to/webvr_camera
  100870. */
  100871. enableVR(options: WebVROptions): void;
  100872. /** @hidden */
  100873. _onVRFullScreenTriggered(): void;
  100874. }
  100875. }
  100876. declare module BABYLON {
  100877. /**
  100878. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  100879. * IMPORTANT!! The data is right-hand data.
  100880. * @export
  100881. * @interface DevicePose
  100882. */
  100883. export interface DevicePose {
  100884. /**
  100885. * The position of the device, values in array are [x,y,z].
  100886. */
  100887. readonly position: Nullable<Float32Array>;
  100888. /**
  100889. * The linearVelocity of the device, values in array are [x,y,z].
  100890. */
  100891. readonly linearVelocity: Nullable<Float32Array>;
  100892. /**
  100893. * The linearAcceleration of the device, values in array are [x,y,z].
  100894. */
  100895. readonly linearAcceleration: Nullable<Float32Array>;
  100896. /**
  100897. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  100898. */
  100899. readonly orientation: Nullable<Float32Array>;
  100900. /**
  100901. * The angularVelocity of the device, values in array are [x,y,z].
  100902. */
  100903. readonly angularVelocity: Nullable<Float32Array>;
  100904. /**
  100905. * The angularAcceleration of the device, values in array are [x,y,z].
  100906. */
  100907. readonly angularAcceleration: Nullable<Float32Array>;
  100908. }
  100909. /**
  100910. * Interface representing a pose controlled object in Babylon.
  100911. * A pose controlled object has both regular pose values as well as pose values
  100912. * from an external device such as a VR head mounted display
  100913. */
  100914. export interface PoseControlled {
  100915. /**
  100916. * The position of the object in babylon space.
  100917. */
  100918. position: Vector3;
  100919. /**
  100920. * The rotation quaternion of the object in babylon space.
  100921. */
  100922. rotationQuaternion: Quaternion;
  100923. /**
  100924. * The position of the device in babylon space.
  100925. */
  100926. devicePosition?: Vector3;
  100927. /**
  100928. * The rotation quaternion of the device in babylon space.
  100929. */
  100930. deviceRotationQuaternion: Quaternion;
  100931. /**
  100932. * The raw pose coming from the device.
  100933. */
  100934. rawPose: Nullable<DevicePose>;
  100935. /**
  100936. * The scale of the device to be used when translating from device space to babylon space.
  100937. */
  100938. deviceScaleFactor: number;
  100939. /**
  100940. * Updates the poseControlled values based on the input device pose.
  100941. * @param poseData the pose data to update the object with
  100942. */
  100943. updateFromDevice(poseData: DevicePose): void;
  100944. }
  100945. /**
  100946. * Set of options to customize the webVRCamera
  100947. */
  100948. export interface WebVROptions {
  100949. /**
  100950. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  100951. */
  100952. trackPosition?: boolean;
  100953. /**
  100954. * Sets the scale of the vrDevice in babylon space. (default: 1)
  100955. */
  100956. positionScale?: number;
  100957. /**
  100958. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  100959. */
  100960. displayName?: string;
  100961. /**
  100962. * Should the native controller meshes be initialized. (default: true)
  100963. */
  100964. controllerMeshes?: boolean;
  100965. /**
  100966. * Creating a default HemiLight only on controllers. (default: true)
  100967. */
  100968. defaultLightingOnControllers?: boolean;
  100969. /**
  100970. * If you don't want to use the default VR button of the helper. (default: false)
  100971. */
  100972. useCustomVRButton?: boolean;
  100973. /**
  100974. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  100975. */
  100976. customVRButton?: HTMLButtonElement;
  100977. /**
  100978. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  100979. */
  100980. rayLength?: number;
  100981. /**
  100982. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  100983. */
  100984. defaultHeight?: number;
  100985. /**
  100986. * If multiview should be used if availible (default: false)
  100987. */
  100988. useMultiview?: boolean;
  100989. }
  100990. /**
  100991. * This represents a WebVR camera.
  100992. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  100993. * @example https://doc.babylonjs.com/how_to/webvr_camera
  100994. */
  100995. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  100996. private webVROptions;
  100997. /**
  100998. * @hidden
  100999. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  101000. */
  101001. _vrDevice: any;
  101002. /**
  101003. * The rawPose of the vrDevice.
  101004. */
  101005. rawPose: Nullable<DevicePose>;
  101006. private _onVREnabled;
  101007. private _specsVersion;
  101008. private _attached;
  101009. private _frameData;
  101010. protected _descendants: Array<Node>;
  101011. private _deviceRoomPosition;
  101012. /** @hidden */
  101013. _deviceRoomRotationQuaternion: Quaternion;
  101014. private _standingMatrix;
  101015. /**
  101016. * Represents device position in babylon space.
  101017. */
  101018. devicePosition: Vector3;
  101019. /**
  101020. * Represents device rotation in babylon space.
  101021. */
  101022. deviceRotationQuaternion: Quaternion;
  101023. /**
  101024. * The scale of the device to be used when translating from device space to babylon space.
  101025. */
  101026. deviceScaleFactor: number;
  101027. private _deviceToWorld;
  101028. private _worldToDevice;
  101029. /**
  101030. * References to the webVR controllers for the vrDevice.
  101031. */
  101032. controllers: Array<WebVRController>;
  101033. /**
  101034. * Emits an event when a controller is attached.
  101035. */
  101036. onControllersAttachedObservable: Observable<WebVRController[]>;
  101037. /**
  101038. * Emits an event when a controller's mesh has been loaded;
  101039. */
  101040. onControllerMeshLoadedObservable: Observable<WebVRController>;
  101041. /**
  101042. * Emits an event when the HMD's pose has been updated.
  101043. */
  101044. onPoseUpdatedFromDeviceObservable: Observable<any>;
  101045. private _poseSet;
  101046. /**
  101047. * If the rig cameras be used as parent instead of this camera.
  101048. */
  101049. rigParenting: boolean;
  101050. private _lightOnControllers;
  101051. private _defaultHeight?;
  101052. /**
  101053. * Instantiates a WebVRFreeCamera.
  101054. * @param name The name of the WebVRFreeCamera
  101055. * @param position The starting anchor position for the camera
  101056. * @param scene The scene the camera belongs to
  101057. * @param webVROptions a set of customizable options for the webVRCamera
  101058. */
  101059. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  101060. /**
  101061. * Gets the device distance from the ground in meters.
  101062. * @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.
  101063. */
  101064. deviceDistanceToRoomGround(): number;
  101065. /**
  101066. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  101067. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  101068. */
  101069. useStandingMatrix(callback?: (bool: boolean) => void): void;
  101070. /**
  101071. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  101072. * @returns A promise with a boolean set to if the standing matrix is supported.
  101073. */
  101074. useStandingMatrixAsync(): Promise<boolean>;
  101075. /**
  101076. * Disposes the camera
  101077. */
  101078. dispose(): void;
  101079. /**
  101080. * Gets a vrController by name.
  101081. * @param name The name of the controller to retreive
  101082. * @returns the controller matching the name specified or null if not found
  101083. */
  101084. getControllerByName(name: string): Nullable<WebVRController>;
  101085. private _leftController;
  101086. /**
  101087. * The controller corresponding to the users left hand.
  101088. */
  101089. get leftController(): Nullable<WebVRController>;
  101090. private _rightController;
  101091. /**
  101092. * The controller corresponding to the users right hand.
  101093. */
  101094. get rightController(): Nullable<WebVRController>;
  101095. /**
  101096. * Casts a ray forward from the vrCamera's gaze.
  101097. * @param length Length of the ray (default: 100)
  101098. * @returns the ray corresponding to the gaze
  101099. */
  101100. getForwardRay(length?: number): Ray;
  101101. /**
  101102. * @hidden
  101103. * Updates the camera based on device's frame data
  101104. */
  101105. _checkInputs(): void;
  101106. /**
  101107. * Updates the poseControlled values based on the input device pose.
  101108. * @param poseData Pose coming from the device
  101109. */
  101110. updateFromDevice(poseData: DevicePose): void;
  101111. private _htmlElementAttached;
  101112. private _detachIfAttached;
  101113. /**
  101114. * WebVR's attach control will start broadcasting frames to the device.
  101115. * Note that in certain browsers (chrome for example) this function must be called
  101116. * within a user-interaction callback. Example:
  101117. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  101118. *
  101119. * @param element html element to attach the vrDevice to
  101120. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  101121. */
  101122. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101123. /**
  101124. * Detaches the camera from the html element and disables VR
  101125. *
  101126. * @param element html element to detach from
  101127. */
  101128. detachControl(element: HTMLElement): void;
  101129. /**
  101130. * @returns the name of this class
  101131. */
  101132. getClassName(): string;
  101133. /**
  101134. * Calls resetPose on the vrDisplay
  101135. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  101136. */
  101137. resetToCurrentRotation(): void;
  101138. /**
  101139. * @hidden
  101140. * Updates the rig cameras (left and right eye)
  101141. */
  101142. _updateRigCameras(): void;
  101143. private _workingVector;
  101144. private _oneVector;
  101145. private _workingMatrix;
  101146. private updateCacheCalled;
  101147. private _correctPositionIfNotTrackPosition;
  101148. /**
  101149. * @hidden
  101150. * Updates the cached values of the camera
  101151. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  101152. */
  101153. _updateCache(ignoreParentClass?: boolean): void;
  101154. /**
  101155. * @hidden
  101156. * Get current device position in babylon world
  101157. */
  101158. _computeDevicePosition(): void;
  101159. /**
  101160. * Updates the current device position and rotation in the babylon world
  101161. */
  101162. update(): void;
  101163. /**
  101164. * @hidden
  101165. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  101166. * @returns an identity matrix
  101167. */
  101168. _getViewMatrix(): Matrix;
  101169. private _tmpMatrix;
  101170. /**
  101171. * This function is called by the two RIG cameras.
  101172. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  101173. * @hidden
  101174. */
  101175. _getWebVRViewMatrix(): Matrix;
  101176. /** @hidden */
  101177. _getWebVRProjectionMatrix(): Matrix;
  101178. private _onGamepadConnectedObserver;
  101179. private _onGamepadDisconnectedObserver;
  101180. private _updateCacheWhenTrackingDisabledObserver;
  101181. /**
  101182. * Initializes the controllers and their meshes
  101183. */
  101184. initControllers(): void;
  101185. }
  101186. }
  101187. declare module BABYLON {
  101188. /**
  101189. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  101190. *
  101191. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  101192. *
  101193. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  101194. */
  101195. export class MaterialHelper {
  101196. /**
  101197. * Bind the current view position to an effect.
  101198. * @param effect The effect to be bound
  101199. * @param scene The scene the eyes position is used from
  101200. * @param variableName name of the shader variable that will hold the eye position
  101201. */
  101202. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  101203. /**
  101204. * Helps preparing the defines values about the UVs in used in the effect.
  101205. * UVs are shared as much as we can accross channels in the shaders.
  101206. * @param texture The texture we are preparing the UVs for
  101207. * @param defines The defines to update
  101208. * @param key The channel key "diffuse", "specular"... used in the shader
  101209. */
  101210. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  101211. /**
  101212. * Binds a texture matrix value to its corrsponding uniform
  101213. * @param texture The texture to bind the matrix for
  101214. * @param uniformBuffer The uniform buffer receivin the data
  101215. * @param key The channel key "diffuse", "specular"... used in the shader
  101216. */
  101217. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  101218. /**
  101219. * Gets the current status of the fog (should it be enabled?)
  101220. * @param mesh defines the mesh to evaluate for fog support
  101221. * @param scene defines the hosting scene
  101222. * @returns true if fog must be enabled
  101223. */
  101224. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  101225. /**
  101226. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  101227. * @param mesh defines the current mesh
  101228. * @param scene defines the current scene
  101229. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  101230. * @param pointsCloud defines if point cloud rendering has to be turned on
  101231. * @param fogEnabled defines if fog has to be turned on
  101232. * @param alphaTest defines if alpha testing has to be turned on
  101233. * @param defines defines the current list of defines
  101234. */
  101235. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  101236. /**
  101237. * Helper used to prepare the list of defines associated with frame values for shader compilation
  101238. * @param scene defines the current scene
  101239. * @param engine defines the current engine
  101240. * @param defines specifies the list of active defines
  101241. * @param useInstances defines if instances have to be turned on
  101242. * @param useClipPlane defines if clip plane have to be turned on
  101243. * @param useInstances defines if instances have to be turned on
  101244. * @param useThinInstances defines if thin instances have to be turned on
  101245. */
  101246. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  101247. /**
  101248. * Prepares the defines for bones
  101249. * @param mesh The mesh containing the geometry data we will draw
  101250. * @param defines The defines to update
  101251. */
  101252. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  101253. /**
  101254. * Prepares the defines for morph targets
  101255. * @param mesh The mesh containing the geometry data we will draw
  101256. * @param defines The defines to update
  101257. */
  101258. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  101259. /**
  101260. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  101261. * @param mesh The mesh containing the geometry data we will draw
  101262. * @param defines The defines to update
  101263. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  101264. * @param useBones Precise whether bones should be used or not (override mesh info)
  101265. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  101266. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  101267. * @returns false if defines are considered not dirty and have not been checked
  101268. */
  101269. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  101270. /**
  101271. * Prepares the defines related to multiview
  101272. * @param scene The scene we are intending to draw
  101273. * @param defines The defines to update
  101274. */
  101275. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  101276. /**
  101277. * Prepares the defines related to the prepass
  101278. * @param scene The scene we are intending to draw
  101279. * @param defines The defines to update
  101280. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  101281. */
  101282. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  101283. /**
  101284. * Prepares the defines related to the light information passed in parameter
  101285. * @param scene The scene we are intending to draw
  101286. * @param mesh The mesh the effect is compiling for
  101287. * @param light The light the effect is compiling for
  101288. * @param lightIndex The index of the light
  101289. * @param defines The defines to update
  101290. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101291. * @param state Defines the current state regarding what is needed (normals, etc...)
  101292. */
  101293. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  101294. needNormals: boolean;
  101295. needRebuild: boolean;
  101296. shadowEnabled: boolean;
  101297. specularEnabled: boolean;
  101298. lightmapMode: boolean;
  101299. }): void;
  101300. /**
  101301. * Prepares the defines related to the light information passed in parameter
  101302. * @param scene The scene we are intending to draw
  101303. * @param mesh The mesh the effect is compiling for
  101304. * @param defines The defines to update
  101305. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101306. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  101307. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  101308. * @returns true if normals will be required for the rest of the effect
  101309. */
  101310. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  101311. /**
  101312. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  101313. * @param lightIndex defines the light index
  101314. * @param uniformsList The uniform list
  101315. * @param samplersList The sampler list
  101316. * @param projectedLightTexture defines if projected texture must be used
  101317. * @param uniformBuffersList defines an optional list of uniform buffers
  101318. */
  101319. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  101320. /**
  101321. * Prepares the uniforms and samplers list to be used in the effect
  101322. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  101323. * @param samplersList The sampler list
  101324. * @param defines The defines helping in the list generation
  101325. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  101326. */
  101327. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  101328. /**
  101329. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  101330. * @param defines The defines to update while falling back
  101331. * @param fallbacks The authorized effect fallbacks
  101332. * @param maxSimultaneousLights The maximum number of lights allowed
  101333. * @param rank the current rank of the Effect
  101334. * @returns The newly affected rank
  101335. */
  101336. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  101337. private static _TmpMorphInfluencers;
  101338. /**
  101339. * Prepares the list of attributes required for morph targets according to the effect defines.
  101340. * @param attribs The current list of supported attribs
  101341. * @param mesh The mesh to prepare the morph targets attributes for
  101342. * @param influencers The number of influencers
  101343. */
  101344. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  101345. /**
  101346. * Prepares the list of attributes required for morph targets according to the effect defines.
  101347. * @param attribs The current list of supported attribs
  101348. * @param mesh The mesh to prepare the morph targets attributes for
  101349. * @param defines The current Defines of the effect
  101350. */
  101351. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  101352. /**
  101353. * Prepares the list of attributes required for bones according to the effect defines.
  101354. * @param attribs The current list of supported attribs
  101355. * @param mesh The mesh to prepare the bones attributes for
  101356. * @param defines The current Defines of the effect
  101357. * @param fallbacks The current efffect fallback strategy
  101358. */
  101359. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  101360. /**
  101361. * Check and prepare the list of attributes required for instances according to the effect defines.
  101362. * @param attribs The current list of supported attribs
  101363. * @param defines The current MaterialDefines of the effect
  101364. */
  101365. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  101366. /**
  101367. * Add the list of attributes required for instances to the attribs array.
  101368. * @param attribs The current list of supported attribs
  101369. */
  101370. static PushAttributesForInstances(attribs: string[]): void;
  101371. /**
  101372. * Binds the light information to the effect.
  101373. * @param light The light containing the generator
  101374. * @param effect The effect we are binding the data to
  101375. * @param lightIndex The light index in the effect used to render
  101376. */
  101377. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  101378. /**
  101379. * Binds the lights information from the scene to the effect for the given mesh.
  101380. * @param light Light to bind
  101381. * @param lightIndex Light index
  101382. * @param scene The scene where the light belongs to
  101383. * @param effect The effect we are binding the data to
  101384. * @param useSpecular Defines if specular is supported
  101385. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101386. */
  101387. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  101388. /**
  101389. * Binds the lights information from the scene to the effect for the given mesh.
  101390. * @param scene The scene the lights belongs to
  101391. * @param mesh The mesh we are binding the information to render
  101392. * @param effect The effect we are binding the data to
  101393. * @param defines The generated defines for the effect
  101394. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  101395. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101396. */
  101397. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  101398. private static _tempFogColor;
  101399. /**
  101400. * Binds the fog information from the scene to the effect for the given mesh.
  101401. * @param scene The scene the lights belongs to
  101402. * @param mesh The mesh we are binding the information to render
  101403. * @param effect The effect we are binding the data to
  101404. * @param linearSpace Defines if the fog effect is applied in linear space
  101405. */
  101406. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  101407. /**
  101408. * Binds the bones information from the mesh to the effect.
  101409. * @param mesh The mesh we are binding the information to render
  101410. * @param effect The effect we are binding the data to
  101411. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  101412. */
  101413. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  101414. private static _CopyBonesTransformationMatrices;
  101415. /**
  101416. * Binds the morph targets information from the mesh to the effect.
  101417. * @param abstractMesh The mesh we are binding the information to render
  101418. * @param effect The effect we are binding the data to
  101419. */
  101420. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  101421. /**
  101422. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  101423. * @param defines The generated defines used in the effect
  101424. * @param effect The effect we are binding the data to
  101425. * @param scene The scene we are willing to render with logarithmic scale for
  101426. */
  101427. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  101428. /**
  101429. * Binds the clip plane information from the scene to the effect.
  101430. * @param scene The scene the clip plane information are extracted from
  101431. * @param effect The effect we are binding the data to
  101432. */
  101433. static BindClipPlane(effect: Effect, scene: Scene): void;
  101434. }
  101435. }
  101436. declare module BABYLON {
  101437. /**
  101438. * Block used to expose an input value
  101439. */
  101440. export class InputBlock extends NodeMaterialBlock {
  101441. private _mode;
  101442. private _associatedVariableName;
  101443. private _storedValue;
  101444. private _valueCallback;
  101445. private _type;
  101446. private _animationType;
  101447. /** Gets or set a value used to limit the range of float values */
  101448. min: number;
  101449. /** Gets or set a value used to limit the range of float values */
  101450. max: number;
  101451. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  101452. isBoolean: boolean;
  101453. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  101454. matrixMode: number;
  101455. /** @hidden */
  101456. _systemValue: Nullable<NodeMaterialSystemValues>;
  101457. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  101458. isConstant: boolean;
  101459. /** Gets or sets the group to use to display this block in the Inspector */
  101460. groupInInspector: string;
  101461. /** Gets an observable raised when the value is changed */
  101462. onValueChangedObservable: Observable<InputBlock>;
  101463. /**
  101464. * Gets or sets the connection point type (default is float)
  101465. */
  101466. get type(): NodeMaterialBlockConnectionPointTypes;
  101467. /**
  101468. * Creates a new InputBlock
  101469. * @param name defines the block name
  101470. * @param target defines the target of that block (Vertex by default)
  101471. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  101472. */
  101473. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  101474. /**
  101475. * Validates if a name is a reserve word.
  101476. * @param newName the new name to be given to the node.
  101477. * @returns false if the name is a reserve word, else true.
  101478. */
  101479. validateBlockName(newName: string): boolean;
  101480. /**
  101481. * Gets the output component
  101482. */
  101483. get output(): NodeMaterialConnectionPoint;
  101484. /**
  101485. * Set the source of this connection point to a vertex attribute
  101486. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  101487. * @returns the current connection point
  101488. */
  101489. setAsAttribute(attributeName?: string): InputBlock;
  101490. /**
  101491. * Set the source of this connection point to a system value
  101492. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  101493. * @returns the current connection point
  101494. */
  101495. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  101496. /**
  101497. * Gets or sets the value of that point.
  101498. * Please note that this value will be ignored if valueCallback is defined
  101499. */
  101500. get value(): any;
  101501. set value(value: any);
  101502. /**
  101503. * Gets or sets a callback used to get the value of that point.
  101504. * Please note that setting this value will force the connection point to ignore the value property
  101505. */
  101506. get valueCallback(): () => any;
  101507. set valueCallback(value: () => any);
  101508. /**
  101509. * Gets or sets the associated variable name in the shader
  101510. */
  101511. get associatedVariableName(): string;
  101512. set associatedVariableName(value: string);
  101513. /** Gets or sets the type of animation applied to the input */
  101514. get animationType(): AnimatedInputBlockTypes;
  101515. set animationType(value: AnimatedInputBlockTypes);
  101516. /**
  101517. * Gets a boolean indicating that this connection point not defined yet
  101518. */
  101519. get isUndefined(): boolean;
  101520. /**
  101521. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  101522. * In this case the connection point name must be the name of the uniform to use.
  101523. * Can only be set on inputs
  101524. */
  101525. get isUniform(): boolean;
  101526. set isUniform(value: boolean);
  101527. /**
  101528. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  101529. * In this case the connection point name must be the name of the attribute to use
  101530. * Can only be set on inputs
  101531. */
  101532. get isAttribute(): boolean;
  101533. set isAttribute(value: boolean);
  101534. /**
  101535. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  101536. * Can only be set on exit points
  101537. */
  101538. get isVarying(): boolean;
  101539. set isVarying(value: boolean);
  101540. /**
  101541. * Gets a boolean indicating that the current connection point is a system value
  101542. */
  101543. get isSystemValue(): boolean;
  101544. /**
  101545. * Gets or sets the current well known value or null if not defined as a system value
  101546. */
  101547. get systemValue(): Nullable<NodeMaterialSystemValues>;
  101548. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  101549. /**
  101550. * Gets the current class name
  101551. * @returns the class name
  101552. */
  101553. getClassName(): string;
  101554. /**
  101555. * Animate the input if animationType !== None
  101556. * @param scene defines the rendering scene
  101557. */
  101558. animate(scene: Scene): void;
  101559. private _emitDefine;
  101560. initialize(state: NodeMaterialBuildState): void;
  101561. /**
  101562. * Set the input block to its default value (based on its type)
  101563. */
  101564. setDefaultValue(): void;
  101565. private _emitConstant;
  101566. /** @hidden */
  101567. get _noContextSwitch(): boolean;
  101568. private _emit;
  101569. /** @hidden */
  101570. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  101571. /** @hidden */
  101572. _transmit(effect: Effect, scene: Scene): void;
  101573. protected _buildBlock(state: NodeMaterialBuildState): void;
  101574. protected _dumpPropertiesCode(): string;
  101575. dispose(): void;
  101576. serialize(): any;
  101577. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101578. }
  101579. }
  101580. declare module BABYLON {
  101581. /**
  101582. * Enum used to define the compatibility state between two connection points
  101583. */
  101584. export enum NodeMaterialConnectionPointCompatibilityStates {
  101585. /** Points are compatibles */
  101586. Compatible = 0,
  101587. /** Points are incompatible because of their types */
  101588. TypeIncompatible = 1,
  101589. /** Points are incompatible because of their targets (vertex vs fragment) */
  101590. TargetIncompatible = 2
  101591. }
  101592. /**
  101593. * Defines the direction of a connection point
  101594. */
  101595. export enum NodeMaterialConnectionPointDirection {
  101596. /** Input */
  101597. Input = 0,
  101598. /** Output */
  101599. Output = 1
  101600. }
  101601. /**
  101602. * Defines a connection point for a block
  101603. */
  101604. export class NodeMaterialConnectionPoint {
  101605. /** @hidden */
  101606. _ownerBlock: NodeMaterialBlock;
  101607. /** @hidden */
  101608. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  101609. private _endpoints;
  101610. private _associatedVariableName;
  101611. private _direction;
  101612. /** @hidden */
  101613. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101614. /** @hidden */
  101615. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101616. private _type;
  101617. /** @hidden */
  101618. _enforceAssociatedVariableName: boolean;
  101619. /** Gets the direction of the point */
  101620. get direction(): NodeMaterialConnectionPointDirection;
  101621. /** Indicates that this connection point needs dual validation before being connected to another point */
  101622. needDualDirectionValidation: boolean;
  101623. /**
  101624. * Gets or sets the additional types supported by this connection point
  101625. */
  101626. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101627. /**
  101628. * Gets or sets the additional types excluded by this connection point
  101629. */
  101630. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101631. /**
  101632. * Observable triggered when this point is connected
  101633. */
  101634. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  101635. /**
  101636. * Gets or sets the associated variable name in the shader
  101637. */
  101638. get associatedVariableName(): string;
  101639. set associatedVariableName(value: string);
  101640. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  101641. get innerType(): NodeMaterialBlockConnectionPointTypes;
  101642. /**
  101643. * Gets or sets the connection point type (default is float)
  101644. */
  101645. get type(): NodeMaterialBlockConnectionPointTypes;
  101646. set type(value: NodeMaterialBlockConnectionPointTypes);
  101647. /**
  101648. * Gets or sets the connection point name
  101649. */
  101650. name: string;
  101651. /**
  101652. * Gets or sets the connection point name
  101653. */
  101654. displayName: string;
  101655. /**
  101656. * Gets or sets a boolean indicating that this connection point can be omitted
  101657. */
  101658. isOptional: boolean;
  101659. /**
  101660. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  101661. */
  101662. isExposedOnFrame: boolean;
  101663. /**
  101664. * Gets or sets number indicating the position that the port is exposed to on a frame
  101665. */
  101666. exposedPortPosition: number;
  101667. /**
  101668. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  101669. */
  101670. define: string;
  101671. /** @hidden */
  101672. _prioritizeVertex: boolean;
  101673. private _target;
  101674. /** Gets or sets the target of that connection point */
  101675. get target(): NodeMaterialBlockTargets;
  101676. set target(value: NodeMaterialBlockTargets);
  101677. /**
  101678. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  101679. */
  101680. get isConnected(): boolean;
  101681. /**
  101682. * Gets a boolean indicating that the current point is connected to an input block
  101683. */
  101684. get isConnectedToInputBlock(): boolean;
  101685. /**
  101686. * Gets a the connected input block (if any)
  101687. */
  101688. get connectInputBlock(): Nullable<InputBlock>;
  101689. /** Get the other side of the connection (if any) */
  101690. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  101691. /** Get the block that owns this connection point */
  101692. get ownerBlock(): NodeMaterialBlock;
  101693. /** Get the block connected on the other side of this connection (if any) */
  101694. get sourceBlock(): Nullable<NodeMaterialBlock>;
  101695. /** Get the block connected on the endpoints of this connection (if any) */
  101696. get connectedBlocks(): Array<NodeMaterialBlock>;
  101697. /** Gets the list of connected endpoints */
  101698. get endpoints(): NodeMaterialConnectionPoint[];
  101699. /** Gets a boolean indicating if that output point is connected to at least one input */
  101700. get hasEndpoints(): boolean;
  101701. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  101702. get isConnectedInVertexShader(): boolean;
  101703. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  101704. get isConnectedInFragmentShader(): boolean;
  101705. /**
  101706. * Creates a block suitable to be used as an input for this input point.
  101707. * If null is returned, a block based on the point type will be created.
  101708. * @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
  101709. */
  101710. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101711. /**
  101712. * Creates a new connection point
  101713. * @param name defines the connection point name
  101714. * @param ownerBlock defines the block hosting this connection point
  101715. * @param direction defines the direction of the connection point
  101716. */
  101717. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  101718. /**
  101719. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  101720. * @returns the class name
  101721. */
  101722. getClassName(): string;
  101723. /**
  101724. * Gets a boolean indicating if the current point can be connected to another point
  101725. * @param connectionPoint defines the other connection point
  101726. * @returns a boolean
  101727. */
  101728. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  101729. /**
  101730. * Gets a number indicating if the current point can be connected to another point
  101731. * @param connectionPoint defines the other connection point
  101732. * @returns a number defining the compatibility state
  101733. */
  101734. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101735. /**
  101736. * Connect this point to another connection point
  101737. * @param connectionPoint defines the other connection point
  101738. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  101739. * @returns the current connection point
  101740. */
  101741. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  101742. /**
  101743. * Disconnect this point from one of his endpoint
  101744. * @param endpoint defines the other connection point
  101745. * @returns the current connection point
  101746. */
  101747. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  101748. /**
  101749. * Serializes this point in a JSON representation
  101750. * @param isInput defines if the connection point is an input (default is true)
  101751. * @returns the serialized point object
  101752. */
  101753. serialize(isInput?: boolean): any;
  101754. /**
  101755. * Release resources
  101756. */
  101757. dispose(): void;
  101758. }
  101759. }
  101760. declare module BABYLON {
  101761. /**
  101762. * Enum used to define the material modes
  101763. */
  101764. export enum NodeMaterialModes {
  101765. /** Regular material */
  101766. Material = 0,
  101767. /** For post process */
  101768. PostProcess = 1,
  101769. /** For particle system */
  101770. Particle = 2,
  101771. /** For procedural texture */
  101772. ProceduralTexture = 3
  101773. }
  101774. }
  101775. declare module BABYLON {
  101776. /**
  101777. * Block used to read a texture from a sampler
  101778. */
  101779. export class TextureBlock extends NodeMaterialBlock {
  101780. private _defineName;
  101781. private _linearDefineName;
  101782. private _gammaDefineName;
  101783. private _tempTextureRead;
  101784. private _samplerName;
  101785. private _transformedUVName;
  101786. private _textureTransformName;
  101787. private _textureInfoName;
  101788. private _mainUVName;
  101789. private _mainUVDefineName;
  101790. private _fragmentOnly;
  101791. /**
  101792. * Gets or sets the texture associated with the node
  101793. */
  101794. texture: Nullable<Texture>;
  101795. /**
  101796. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101797. */
  101798. convertToGammaSpace: boolean;
  101799. /**
  101800. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101801. */
  101802. convertToLinearSpace: boolean;
  101803. /**
  101804. * Create a new TextureBlock
  101805. * @param name defines the block name
  101806. */
  101807. constructor(name: string, fragmentOnly?: boolean);
  101808. /**
  101809. * Gets the current class name
  101810. * @returns the class name
  101811. */
  101812. getClassName(): string;
  101813. /**
  101814. * Gets the uv input component
  101815. */
  101816. get uv(): NodeMaterialConnectionPoint;
  101817. /**
  101818. * Gets the rgba output component
  101819. */
  101820. get rgba(): NodeMaterialConnectionPoint;
  101821. /**
  101822. * Gets the rgb output component
  101823. */
  101824. get rgb(): NodeMaterialConnectionPoint;
  101825. /**
  101826. * Gets the r output component
  101827. */
  101828. get r(): NodeMaterialConnectionPoint;
  101829. /**
  101830. * Gets the g output component
  101831. */
  101832. get g(): NodeMaterialConnectionPoint;
  101833. /**
  101834. * Gets the b output component
  101835. */
  101836. get b(): NodeMaterialConnectionPoint;
  101837. /**
  101838. * Gets the a output component
  101839. */
  101840. get a(): NodeMaterialConnectionPoint;
  101841. get target(): NodeMaterialBlockTargets;
  101842. autoConfigure(material: NodeMaterial): void;
  101843. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101844. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101845. isReady(): boolean;
  101846. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101847. private get _isMixed();
  101848. private _injectVertexCode;
  101849. private _writeTextureRead;
  101850. private _writeOutput;
  101851. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101852. protected _dumpPropertiesCode(): string;
  101853. serialize(): any;
  101854. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101855. }
  101856. }
  101857. declare module BABYLON {
  101858. /** @hidden */
  101859. export var reflectionFunction: {
  101860. name: string;
  101861. shader: string;
  101862. };
  101863. }
  101864. declare module BABYLON {
  101865. /**
  101866. * Base block used to read a reflection texture from a sampler
  101867. */
  101868. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  101869. /** @hidden */
  101870. _define3DName: string;
  101871. /** @hidden */
  101872. _defineCubicName: string;
  101873. /** @hidden */
  101874. _defineExplicitName: string;
  101875. /** @hidden */
  101876. _defineProjectionName: string;
  101877. /** @hidden */
  101878. _defineLocalCubicName: string;
  101879. /** @hidden */
  101880. _defineSphericalName: string;
  101881. /** @hidden */
  101882. _definePlanarName: string;
  101883. /** @hidden */
  101884. _defineEquirectangularName: string;
  101885. /** @hidden */
  101886. _defineMirroredEquirectangularFixedName: string;
  101887. /** @hidden */
  101888. _defineEquirectangularFixedName: string;
  101889. /** @hidden */
  101890. _defineSkyboxName: string;
  101891. /** @hidden */
  101892. _defineOppositeZ: string;
  101893. /** @hidden */
  101894. _cubeSamplerName: string;
  101895. /** @hidden */
  101896. _2DSamplerName: string;
  101897. protected _positionUVWName: string;
  101898. protected _directionWName: string;
  101899. protected _reflectionVectorName: string;
  101900. /** @hidden */
  101901. _reflectionCoordsName: string;
  101902. /** @hidden */
  101903. _reflectionMatrixName: string;
  101904. protected _reflectionColorName: string;
  101905. /**
  101906. * Gets or sets the texture associated with the node
  101907. */
  101908. texture: Nullable<BaseTexture>;
  101909. /**
  101910. * Create a new ReflectionTextureBaseBlock
  101911. * @param name defines the block name
  101912. */
  101913. constructor(name: string);
  101914. /**
  101915. * Gets the current class name
  101916. * @returns the class name
  101917. */
  101918. getClassName(): string;
  101919. /**
  101920. * Gets the world position input component
  101921. */
  101922. abstract get position(): NodeMaterialConnectionPoint;
  101923. /**
  101924. * Gets the world position input component
  101925. */
  101926. abstract get worldPosition(): NodeMaterialConnectionPoint;
  101927. /**
  101928. * Gets the world normal input component
  101929. */
  101930. abstract get worldNormal(): NodeMaterialConnectionPoint;
  101931. /**
  101932. * Gets the world input component
  101933. */
  101934. abstract get world(): NodeMaterialConnectionPoint;
  101935. /**
  101936. * Gets the camera (or eye) position component
  101937. */
  101938. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  101939. /**
  101940. * Gets the view input component
  101941. */
  101942. abstract get view(): NodeMaterialConnectionPoint;
  101943. protected _getTexture(): Nullable<BaseTexture>;
  101944. autoConfigure(material: NodeMaterial): void;
  101945. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101946. isReady(): boolean;
  101947. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101948. /**
  101949. * Gets the code to inject in the vertex shader
  101950. * @param state current state of the node material building
  101951. * @returns the shader code
  101952. */
  101953. handleVertexSide(state: NodeMaterialBuildState): string;
  101954. /**
  101955. * Handles the inits for the fragment code path
  101956. * @param state node material build state
  101957. */
  101958. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  101959. /**
  101960. * Generates the reflection coords code for the fragment code path
  101961. * @param worldNormalVarName name of the world normal variable
  101962. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  101963. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  101964. * @returns the shader code
  101965. */
  101966. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  101967. /**
  101968. * Generates the reflection color code for the fragment code path
  101969. * @param lodVarName name of the lod variable
  101970. * @param swizzleLookupTexture swizzle to use for the final color variable
  101971. * @returns the shader code
  101972. */
  101973. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  101974. /**
  101975. * Generates the code corresponding to the connected output points
  101976. * @param state node material build state
  101977. * @param varName name of the variable to output
  101978. * @returns the shader code
  101979. */
  101980. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  101981. protected _buildBlock(state: NodeMaterialBuildState): this;
  101982. protected _dumpPropertiesCode(): string;
  101983. serialize(): any;
  101984. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101985. }
  101986. }
  101987. declare module BABYLON {
  101988. /**
  101989. * Defines a connection point to be used for points with a custom object type
  101990. */
  101991. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  101992. private _blockType;
  101993. private _blockName;
  101994. private _nameForCheking?;
  101995. /**
  101996. * Creates a new connection point
  101997. * @param name defines the connection point name
  101998. * @param ownerBlock defines the block hosting this connection point
  101999. * @param direction defines the direction of the connection point
  102000. */
  102001. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  102002. /**
  102003. * Gets a number indicating if the current point can be connected to another point
  102004. * @param connectionPoint defines the other connection point
  102005. * @returns a number defining the compatibility state
  102006. */
  102007. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  102008. /**
  102009. * Creates a block suitable to be used as an input for this input point.
  102010. * If null is returned, a block based on the point type will be created.
  102011. * @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
  102012. */
  102013. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  102014. }
  102015. }
  102016. declare module BABYLON {
  102017. /**
  102018. * Enum defining the type of properties that can be edited in the property pages in the NME
  102019. */
  102020. export enum PropertyTypeForEdition {
  102021. /** property is a boolean */
  102022. Boolean = 0,
  102023. /** property is a float */
  102024. Float = 1,
  102025. /** property is a Vector2 */
  102026. Vector2 = 2,
  102027. /** property is a list of values */
  102028. List = 3
  102029. }
  102030. /**
  102031. * Interface that defines an option in a variable of type list
  102032. */
  102033. export interface IEditablePropertyListOption {
  102034. /** label of the option */
  102035. "label": string;
  102036. /** value of the option */
  102037. "value": number;
  102038. }
  102039. /**
  102040. * Interface that defines the options available for an editable property
  102041. */
  102042. export interface IEditablePropertyOption {
  102043. /** min value */
  102044. "min"?: number;
  102045. /** max value */
  102046. "max"?: number;
  102047. /** notifiers: indicates which actions to take when the property is changed */
  102048. "notifiers"?: {
  102049. /** the material should be rebuilt */
  102050. "rebuild"?: boolean;
  102051. /** the preview should be updated */
  102052. "update"?: boolean;
  102053. };
  102054. /** list of the options for a variable of type list */
  102055. "options"?: IEditablePropertyListOption[];
  102056. }
  102057. /**
  102058. * Interface that describes an editable property
  102059. */
  102060. export interface IPropertyDescriptionForEdition {
  102061. /** name of the property */
  102062. "propertyName": string;
  102063. /** display name of the property */
  102064. "displayName": string;
  102065. /** type of the property */
  102066. "type": PropertyTypeForEdition;
  102067. /** group of the property - all properties with the same group value will be displayed in a specific section */
  102068. "groupName": string;
  102069. /** options for the property */
  102070. "options": IEditablePropertyOption;
  102071. }
  102072. /**
  102073. * Decorator that flags a property in a node material block as being editable
  102074. */
  102075. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  102076. }
  102077. declare module BABYLON {
  102078. /**
  102079. * Block used to implement the refraction part of the sub surface module of the PBR material
  102080. */
  102081. export class RefractionBlock extends NodeMaterialBlock {
  102082. /** @hidden */
  102083. _define3DName: string;
  102084. /** @hidden */
  102085. _refractionMatrixName: string;
  102086. /** @hidden */
  102087. _defineLODRefractionAlpha: string;
  102088. /** @hidden */
  102089. _defineLinearSpecularRefraction: string;
  102090. /** @hidden */
  102091. _defineOppositeZ: string;
  102092. /** @hidden */
  102093. _cubeSamplerName: string;
  102094. /** @hidden */
  102095. _2DSamplerName: string;
  102096. /** @hidden */
  102097. _vRefractionMicrosurfaceInfosName: string;
  102098. /** @hidden */
  102099. _vRefractionInfosName: string;
  102100. private _scene;
  102101. /**
  102102. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102103. * Materials half opaque for instance using refraction could benefit from this control.
  102104. */
  102105. linkRefractionWithTransparency: boolean;
  102106. /**
  102107. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102108. */
  102109. invertRefractionY: boolean;
  102110. /**
  102111. * Gets or sets the texture associated with the node
  102112. */
  102113. texture: Nullable<BaseTexture>;
  102114. /**
  102115. * Create a new RefractionBlock
  102116. * @param name defines the block name
  102117. */
  102118. constructor(name: string);
  102119. /**
  102120. * Gets the current class name
  102121. * @returns the class name
  102122. */
  102123. getClassName(): string;
  102124. /**
  102125. * Gets the intensity input component
  102126. */
  102127. get intensity(): NodeMaterialConnectionPoint;
  102128. /**
  102129. * Gets the index of refraction input component
  102130. */
  102131. get indexOfRefraction(): NodeMaterialConnectionPoint;
  102132. /**
  102133. * Gets the tint at distance input component
  102134. */
  102135. get tintAtDistance(): NodeMaterialConnectionPoint;
  102136. /**
  102137. * Gets the view input component
  102138. */
  102139. get view(): NodeMaterialConnectionPoint;
  102140. /**
  102141. * Gets the refraction object output component
  102142. */
  102143. get refraction(): NodeMaterialConnectionPoint;
  102144. /**
  102145. * Returns true if the block has a texture
  102146. */
  102147. get hasTexture(): boolean;
  102148. protected _getTexture(): Nullable<BaseTexture>;
  102149. autoConfigure(material: NodeMaterial): void;
  102150. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102151. isReady(): boolean;
  102152. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102153. /**
  102154. * Gets the main code of the block (fragment side)
  102155. * @param state current state of the node material building
  102156. * @returns the shader code
  102157. */
  102158. getCode(state: NodeMaterialBuildState): string;
  102159. protected _buildBlock(state: NodeMaterialBuildState): this;
  102160. protected _dumpPropertiesCode(): string;
  102161. serialize(): any;
  102162. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102163. }
  102164. }
  102165. declare module BABYLON {
  102166. /**
  102167. * Base block used as input for post process
  102168. */
  102169. export class CurrentScreenBlock extends NodeMaterialBlock {
  102170. private _samplerName;
  102171. private _linearDefineName;
  102172. private _gammaDefineName;
  102173. private _mainUVName;
  102174. private _tempTextureRead;
  102175. /**
  102176. * Gets or sets the texture associated with the node
  102177. */
  102178. texture: Nullable<BaseTexture>;
  102179. /**
  102180. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102181. */
  102182. convertToGammaSpace: boolean;
  102183. /**
  102184. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102185. */
  102186. convertToLinearSpace: boolean;
  102187. /**
  102188. * Create a new CurrentScreenBlock
  102189. * @param name defines the block name
  102190. */
  102191. constructor(name: string);
  102192. /**
  102193. * Gets the current class name
  102194. * @returns the class name
  102195. */
  102196. getClassName(): string;
  102197. /**
  102198. * Gets the uv input component
  102199. */
  102200. get uv(): NodeMaterialConnectionPoint;
  102201. /**
  102202. * Gets the rgba output component
  102203. */
  102204. get rgba(): NodeMaterialConnectionPoint;
  102205. /**
  102206. * Gets the rgb output component
  102207. */
  102208. get rgb(): NodeMaterialConnectionPoint;
  102209. /**
  102210. * Gets the r output component
  102211. */
  102212. get r(): NodeMaterialConnectionPoint;
  102213. /**
  102214. * Gets the g output component
  102215. */
  102216. get g(): NodeMaterialConnectionPoint;
  102217. /**
  102218. * Gets the b output component
  102219. */
  102220. get b(): NodeMaterialConnectionPoint;
  102221. /**
  102222. * Gets the a output component
  102223. */
  102224. get a(): NodeMaterialConnectionPoint;
  102225. /**
  102226. * Initialize the block and prepare the context for build
  102227. * @param state defines the state that will be used for the build
  102228. */
  102229. initialize(state: NodeMaterialBuildState): void;
  102230. get target(): NodeMaterialBlockTargets;
  102231. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102232. isReady(): boolean;
  102233. private _injectVertexCode;
  102234. private _writeTextureRead;
  102235. private _writeOutput;
  102236. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102237. serialize(): any;
  102238. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102239. }
  102240. }
  102241. declare module BABYLON {
  102242. /**
  102243. * Base block used for the particle texture
  102244. */
  102245. export class ParticleTextureBlock extends NodeMaterialBlock {
  102246. private _samplerName;
  102247. private _linearDefineName;
  102248. private _gammaDefineName;
  102249. private _tempTextureRead;
  102250. /**
  102251. * Gets or sets the texture associated with the node
  102252. */
  102253. texture: Nullable<BaseTexture>;
  102254. /**
  102255. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102256. */
  102257. convertToGammaSpace: boolean;
  102258. /**
  102259. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102260. */
  102261. convertToLinearSpace: boolean;
  102262. /**
  102263. * Create a new ParticleTextureBlock
  102264. * @param name defines the block name
  102265. */
  102266. constructor(name: string);
  102267. /**
  102268. * Gets the current class name
  102269. * @returns the class name
  102270. */
  102271. getClassName(): string;
  102272. /**
  102273. * Gets the uv input component
  102274. */
  102275. get uv(): NodeMaterialConnectionPoint;
  102276. /**
  102277. * Gets the rgba output component
  102278. */
  102279. get rgba(): NodeMaterialConnectionPoint;
  102280. /**
  102281. * Gets the rgb output component
  102282. */
  102283. get rgb(): NodeMaterialConnectionPoint;
  102284. /**
  102285. * Gets the r output component
  102286. */
  102287. get r(): NodeMaterialConnectionPoint;
  102288. /**
  102289. * Gets the g output component
  102290. */
  102291. get g(): NodeMaterialConnectionPoint;
  102292. /**
  102293. * Gets the b output component
  102294. */
  102295. get b(): NodeMaterialConnectionPoint;
  102296. /**
  102297. * Gets the a output component
  102298. */
  102299. get a(): NodeMaterialConnectionPoint;
  102300. /**
  102301. * Initialize the block and prepare the context for build
  102302. * @param state defines the state that will be used for the build
  102303. */
  102304. initialize(state: NodeMaterialBuildState): void;
  102305. autoConfigure(material: NodeMaterial): void;
  102306. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102307. isReady(): boolean;
  102308. private _writeOutput;
  102309. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102310. serialize(): any;
  102311. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102312. }
  102313. }
  102314. declare module BABYLON {
  102315. /**
  102316. * Class used to store shared data between 2 NodeMaterialBuildState
  102317. */
  102318. export class NodeMaterialBuildStateSharedData {
  102319. /**
  102320. * Gets the list of emitted varyings
  102321. */
  102322. temps: string[];
  102323. /**
  102324. * Gets the list of emitted varyings
  102325. */
  102326. varyings: string[];
  102327. /**
  102328. * Gets the varying declaration string
  102329. */
  102330. varyingDeclaration: string;
  102331. /**
  102332. * Input blocks
  102333. */
  102334. inputBlocks: InputBlock[];
  102335. /**
  102336. * Input blocks
  102337. */
  102338. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102339. /**
  102340. * Bindable blocks (Blocks that need to set data to the effect)
  102341. */
  102342. bindableBlocks: NodeMaterialBlock[];
  102343. /**
  102344. * List of blocks that can provide a compilation fallback
  102345. */
  102346. blocksWithFallbacks: NodeMaterialBlock[];
  102347. /**
  102348. * List of blocks that can provide a define update
  102349. */
  102350. blocksWithDefines: NodeMaterialBlock[];
  102351. /**
  102352. * List of blocks that can provide a repeatable content
  102353. */
  102354. repeatableContentBlocks: NodeMaterialBlock[];
  102355. /**
  102356. * List of blocks that can provide a dynamic list of uniforms
  102357. */
  102358. dynamicUniformBlocks: NodeMaterialBlock[];
  102359. /**
  102360. * List of blocks that can block the isReady function for the material
  102361. */
  102362. blockingBlocks: NodeMaterialBlock[];
  102363. /**
  102364. * Gets the list of animated inputs
  102365. */
  102366. animatedInputs: InputBlock[];
  102367. /**
  102368. * Build Id used to avoid multiple recompilations
  102369. */
  102370. buildId: number;
  102371. /** List of emitted variables */
  102372. variableNames: {
  102373. [key: string]: number;
  102374. };
  102375. /** List of emitted defines */
  102376. defineNames: {
  102377. [key: string]: number;
  102378. };
  102379. /** Should emit comments? */
  102380. emitComments: boolean;
  102381. /** Emit build activity */
  102382. verbose: boolean;
  102383. /** Gets or sets the hosting scene */
  102384. scene: Scene;
  102385. /**
  102386. * Gets the compilation hints emitted at compilation time
  102387. */
  102388. hints: {
  102389. needWorldViewMatrix: boolean;
  102390. needWorldViewProjectionMatrix: boolean;
  102391. needAlphaBlending: boolean;
  102392. needAlphaTesting: boolean;
  102393. };
  102394. /**
  102395. * List of compilation checks
  102396. */
  102397. checks: {
  102398. emitVertex: boolean;
  102399. emitFragment: boolean;
  102400. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  102401. };
  102402. /**
  102403. * Is vertex program allowed to be empty?
  102404. */
  102405. allowEmptyVertexProgram: boolean;
  102406. /** Creates a new shared data */
  102407. constructor();
  102408. /**
  102409. * Emits console errors and exceptions if there is a failing check
  102410. */
  102411. emitErrors(): void;
  102412. }
  102413. }
  102414. declare module BABYLON {
  102415. /**
  102416. * Class used to store node based material build state
  102417. */
  102418. export class NodeMaterialBuildState {
  102419. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  102420. supportUniformBuffers: boolean;
  102421. /**
  102422. * Gets the list of emitted attributes
  102423. */
  102424. attributes: string[];
  102425. /**
  102426. * Gets the list of emitted uniforms
  102427. */
  102428. uniforms: string[];
  102429. /**
  102430. * Gets the list of emitted constants
  102431. */
  102432. constants: string[];
  102433. /**
  102434. * Gets the list of emitted samplers
  102435. */
  102436. samplers: string[];
  102437. /**
  102438. * Gets the list of emitted functions
  102439. */
  102440. functions: {
  102441. [key: string]: string;
  102442. };
  102443. /**
  102444. * Gets the list of emitted extensions
  102445. */
  102446. extensions: {
  102447. [key: string]: string;
  102448. };
  102449. /**
  102450. * Gets the target of the compilation state
  102451. */
  102452. target: NodeMaterialBlockTargets;
  102453. /**
  102454. * Gets the list of emitted counters
  102455. */
  102456. counters: {
  102457. [key: string]: number;
  102458. };
  102459. /**
  102460. * Shared data between multiple NodeMaterialBuildState instances
  102461. */
  102462. sharedData: NodeMaterialBuildStateSharedData;
  102463. /** @hidden */
  102464. _vertexState: NodeMaterialBuildState;
  102465. /** @hidden */
  102466. _attributeDeclaration: string;
  102467. /** @hidden */
  102468. _uniformDeclaration: string;
  102469. /** @hidden */
  102470. _constantDeclaration: string;
  102471. /** @hidden */
  102472. _samplerDeclaration: string;
  102473. /** @hidden */
  102474. _varyingTransfer: string;
  102475. /** @hidden */
  102476. _injectAtEnd: string;
  102477. private _repeatableContentAnchorIndex;
  102478. /** @hidden */
  102479. _builtCompilationString: string;
  102480. /**
  102481. * Gets the emitted compilation strings
  102482. */
  102483. compilationString: string;
  102484. /**
  102485. * Finalize the compilation strings
  102486. * @param state defines the current compilation state
  102487. */
  102488. finalize(state: NodeMaterialBuildState): void;
  102489. /** @hidden */
  102490. get _repeatableContentAnchor(): string;
  102491. /** @hidden */
  102492. _getFreeVariableName(prefix: string): string;
  102493. /** @hidden */
  102494. _getFreeDefineName(prefix: string): string;
  102495. /** @hidden */
  102496. _excludeVariableName(name: string): void;
  102497. /** @hidden */
  102498. _emit2DSampler(name: string): void;
  102499. /** @hidden */
  102500. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  102501. /** @hidden */
  102502. _emitExtension(name: string, extension: string, define?: string): void;
  102503. /** @hidden */
  102504. _emitFunction(name: string, code: string, comments: string): void;
  102505. /** @hidden */
  102506. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  102507. replaceStrings?: {
  102508. search: RegExp;
  102509. replace: string;
  102510. }[];
  102511. repeatKey?: string;
  102512. }): string;
  102513. /** @hidden */
  102514. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  102515. repeatKey?: string;
  102516. removeAttributes?: boolean;
  102517. removeUniforms?: boolean;
  102518. removeVaryings?: boolean;
  102519. removeIfDef?: boolean;
  102520. replaceStrings?: {
  102521. search: RegExp;
  102522. replace: string;
  102523. }[];
  102524. }, storeKey?: string): void;
  102525. /** @hidden */
  102526. _registerTempVariable(name: string): boolean;
  102527. /** @hidden */
  102528. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  102529. /** @hidden */
  102530. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  102531. /** @hidden */
  102532. _emitFloat(value: number): string;
  102533. }
  102534. }
  102535. declare module BABYLON {
  102536. /**
  102537. * Helper class used to generate session unique ID
  102538. */
  102539. export class UniqueIdGenerator {
  102540. private static _UniqueIdCounter;
  102541. /**
  102542. * Gets an unique (relatively to the current scene) Id
  102543. */
  102544. static get UniqueId(): number;
  102545. }
  102546. }
  102547. declare module BABYLON {
  102548. /**
  102549. * Defines a block that can be used inside a node based material
  102550. */
  102551. export class NodeMaterialBlock {
  102552. private _buildId;
  102553. private _buildTarget;
  102554. private _target;
  102555. private _isFinalMerger;
  102556. private _isInput;
  102557. private _name;
  102558. protected _isUnique: boolean;
  102559. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  102560. inputsAreExclusive: boolean;
  102561. /** @hidden */
  102562. _codeVariableName: string;
  102563. /** @hidden */
  102564. _inputs: NodeMaterialConnectionPoint[];
  102565. /** @hidden */
  102566. _outputs: NodeMaterialConnectionPoint[];
  102567. /** @hidden */
  102568. _preparationId: number;
  102569. /**
  102570. * Gets the name of the block
  102571. */
  102572. get name(): string;
  102573. /**
  102574. * Sets the name of the block. Will check if the name is valid.
  102575. */
  102576. set name(newName: string);
  102577. /**
  102578. * Gets or sets the unique id of the node
  102579. */
  102580. uniqueId: number;
  102581. /**
  102582. * Gets or sets the comments associated with this block
  102583. */
  102584. comments: string;
  102585. /**
  102586. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  102587. */
  102588. get isUnique(): boolean;
  102589. /**
  102590. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  102591. */
  102592. get isFinalMerger(): boolean;
  102593. /**
  102594. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  102595. */
  102596. get isInput(): boolean;
  102597. /**
  102598. * Gets or sets the build Id
  102599. */
  102600. get buildId(): number;
  102601. set buildId(value: number);
  102602. /**
  102603. * Gets or sets the target of the block
  102604. */
  102605. get target(): NodeMaterialBlockTargets;
  102606. set target(value: NodeMaterialBlockTargets);
  102607. /**
  102608. * Gets the list of input points
  102609. */
  102610. get inputs(): NodeMaterialConnectionPoint[];
  102611. /** Gets the list of output points */
  102612. get outputs(): NodeMaterialConnectionPoint[];
  102613. /**
  102614. * Find an input by its name
  102615. * @param name defines the name of the input to look for
  102616. * @returns the input or null if not found
  102617. */
  102618. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102619. /**
  102620. * Find an output by its name
  102621. * @param name defines the name of the outputto look for
  102622. * @returns the output or null if not found
  102623. */
  102624. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102625. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  102626. visibleInInspector: boolean;
  102627. /**
  102628. * Creates a new NodeMaterialBlock
  102629. * @param name defines the block name
  102630. * @param target defines the target of that block (Vertex by default)
  102631. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  102632. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  102633. */
  102634. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  102635. /**
  102636. * Initialize the block and prepare the context for build
  102637. * @param state defines the state that will be used for the build
  102638. */
  102639. initialize(state: NodeMaterialBuildState): void;
  102640. /**
  102641. * Bind data to effect. Will only be called for blocks with isBindable === true
  102642. * @param effect defines the effect to bind data to
  102643. * @param nodeMaterial defines the hosting NodeMaterial
  102644. * @param mesh defines the mesh that will be rendered
  102645. * @param subMesh defines the submesh that will be rendered
  102646. */
  102647. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102648. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  102649. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  102650. protected _writeFloat(value: number): string;
  102651. /**
  102652. * Gets the current class name e.g. "NodeMaterialBlock"
  102653. * @returns the class name
  102654. */
  102655. getClassName(): string;
  102656. /**
  102657. * Register a new input. Must be called inside a block constructor
  102658. * @param name defines the connection point name
  102659. * @param type defines the connection point type
  102660. * @param isOptional defines a boolean indicating that this input can be omitted
  102661. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102662. * @param point an already created connection point. If not provided, create a new one
  102663. * @returns the current block
  102664. */
  102665. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102666. /**
  102667. * Register a new output. Must be called inside a block constructor
  102668. * @param name defines the connection point name
  102669. * @param type defines the connection point type
  102670. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102671. * @param point an already created connection point. If not provided, create a new one
  102672. * @returns the current block
  102673. */
  102674. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102675. /**
  102676. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  102677. * @param forOutput defines an optional connection point to check compatibility with
  102678. * @returns the first available input or null
  102679. */
  102680. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  102681. /**
  102682. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  102683. * @param forBlock defines an optional block to check compatibility with
  102684. * @returns the first available input or null
  102685. */
  102686. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  102687. /**
  102688. * Gets the sibling of the given output
  102689. * @param current defines the current output
  102690. * @returns the next output in the list or null
  102691. */
  102692. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  102693. /**
  102694. * Connect current block with another block
  102695. * @param other defines the block to connect with
  102696. * @param options define the various options to help pick the right connections
  102697. * @returns the current block
  102698. */
  102699. connectTo(other: NodeMaterialBlock, options?: {
  102700. input?: string;
  102701. output?: string;
  102702. outputSwizzle?: string;
  102703. }): this | undefined;
  102704. protected _buildBlock(state: NodeMaterialBuildState): void;
  102705. /**
  102706. * Add uniforms, samplers and uniform buffers at compilation time
  102707. * @param state defines the state to update
  102708. * @param nodeMaterial defines the node material requesting the update
  102709. * @param defines defines the material defines to update
  102710. * @param uniformBuffers defines the list of uniform buffer names
  102711. */
  102712. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  102713. /**
  102714. * Add potential fallbacks if shader compilation fails
  102715. * @param mesh defines the mesh to be rendered
  102716. * @param fallbacks defines the current prioritized list of fallbacks
  102717. */
  102718. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  102719. /**
  102720. * Initialize defines for shader compilation
  102721. * @param mesh defines the mesh to be rendered
  102722. * @param nodeMaterial defines the node material requesting the update
  102723. * @param defines defines the material defines to update
  102724. * @param useInstances specifies that instances should be used
  102725. */
  102726. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102727. /**
  102728. * Update defines for shader compilation
  102729. * @param mesh defines the mesh to be rendered
  102730. * @param nodeMaterial defines the node material requesting the update
  102731. * @param defines defines the material defines to update
  102732. * @param useInstances specifies that instances should be used
  102733. * @param subMesh defines which submesh to render
  102734. */
  102735. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102736. /**
  102737. * Lets the block try to connect some inputs automatically
  102738. * @param material defines the hosting NodeMaterial
  102739. */
  102740. autoConfigure(material: NodeMaterial): void;
  102741. /**
  102742. * Function called when a block is declared as repeatable content generator
  102743. * @param vertexShaderState defines the current compilation state for the vertex shader
  102744. * @param fragmentShaderState defines the current compilation state for the fragment shader
  102745. * @param mesh defines the mesh to be rendered
  102746. * @param defines defines the material defines to update
  102747. */
  102748. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  102749. /**
  102750. * Checks if the block is ready
  102751. * @param mesh defines the mesh to be rendered
  102752. * @param nodeMaterial defines the node material requesting the update
  102753. * @param defines defines the material defines to update
  102754. * @param useInstances specifies that instances should be used
  102755. * @returns true if the block is ready
  102756. */
  102757. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  102758. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  102759. private _processBuild;
  102760. /**
  102761. * Validates the new name for the block node.
  102762. * @param newName the new name to be given to the node.
  102763. * @returns false if the name is a reserve word, else true.
  102764. */
  102765. validateBlockName(newName: string): boolean;
  102766. /**
  102767. * Compile the current node and generate the shader code
  102768. * @param state defines the current compilation state (uniforms, samplers, current string)
  102769. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  102770. * @returns true if already built
  102771. */
  102772. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  102773. protected _inputRename(name: string): string;
  102774. protected _outputRename(name: string): string;
  102775. protected _dumpPropertiesCode(): string;
  102776. /** @hidden */
  102777. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  102778. /** @hidden */
  102779. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  102780. /**
  102781. * Clone the current block to a new identical block
  102782. * @param scene defines the hosting scene
  102783. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102784. * @returns a copy of the current block
  102785. */
  102786. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  102787. /**
  102788. * Serializes this block in a JSON representation
  102789. * @returns the serialized block object
  102790. */
  102791. serialize(): any;
  102792. /** @hidden */
  102793. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102794. private _deserializePortDisplayNamesAndExposedOnFrame;
  102795. /**
  102796. * Release resources
  102797. */
  102798. dispose(): void;
  102799. }
  102800. }
  102801. declare module BABYLON {
  102802. /**
  102803. * Base class of materials working in push mode in babylon JS
  102804. * @hidden
  102805. */
  102806. export class PushMaterial extends Material {
  102807. protected _activeEffect: Effect;
  102808. protected _normalMatrix: Matrix;
  102809. constructor(name: string, scene: Scene);
  102810. getEffect(): Effect;
  102811. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102812. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102813. /**
  102814. * Binds the given world matrix to the active effect
  102815. *
  102816. * @param world the matrix to bind
  102817. */
  102818. bindOnlyWorldMatrix(world: Matrix): void;
  102819. /**
  102820. * Binds the given normal matrix to the active effect
  102821. *
  102822. * @param normalMatrix the matrix to bind
  102823. */
  102824. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102825. bind(world: Matrix, mesh?: Mesh): void;
  102826. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102827. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102828. }
  102829. }
  102830. declare module BABYLON {
  102831. /**
  102832. * Root class for all node material optimizers
  102833. */
  102834. export class NodeMaterialOptimizer {
  102835. /**
  102836. * Function used to optimize a NodeMaterial graph
  102837. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  102838. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  102839. */
  102840. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  102841. }
  102842. }
  102843. declare module BABYLON {
  102844. /**
  102845. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  102846. */
  102847. export class TransformBlock extends NodeMaterialBlock {
  102848. /**
  102849. * Defines the value to use to complement W value to transform it to a Vector4
  102850. */
  102851. complementW: number;
  102852. /**
  102853. * Defines the value to use to complement z value to transform it to a Vector4
  102854. */
  102855. complementZ: number;
  102856. /**
  102857. * Creates a new TransformBlock
  102858. * @param name defines the block name
  102859. */
  102860. constructor(name: string);
  102861. /**
  102862. * Gets the current class name
  102863. * @returns the class name
  102864. */
  102865. getClassName(): string;
  102866. /**
  102867. * Gets the vector input
  102868. */
  102869. get vector(): NodeMaterialConnectionPoint;
  102870. /**
  102871. * Gets the output component
  102872. */
  102873. get output(): NodeMaterialConnectionPoint;
  102874. /**
  102875. * Gets the xyz output component
  102876. */
  102877. get xyz(): NodeMaterialConnectionPoint;
  102878. /**
  102879. * Gets the matrix transform input
  102880. */
  102881. get transform(): NodeMaterialConnectionPoint;
  102882. protected _buildBlock(state: NodeMaterialBuildState): this;
  102883. /**
  102884. * Update defines for shader compilation
  102885. * @param mesh defines the mesh to be rendered
  102886. * @param nodeMaterial defines the node material requesting the update
  102887. * @param defines defines the material defines to update
  102888. * @param useInstances specifies that instances should be used
  102889. * @param subMesh defines which submesh to render
  102890. */
  102891. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102892. serialize(): any;
  102893. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102894. protected _dumpPropertiesCode(): string;
  102895. }
  102896. }
  102897. declare module BABYLON {
  102898. /**
  102899. * Block used to output the vertex position
  102900. */
  102901. export class VertexOutputBlock extends NodeMaterialBlock {
  102902. /**
  102903. * Creates a new VertexOutputBlock
  102904. * @param name defines the block name
  102905. */
  102906. constructor(name: string);
  102907. /**
  102908. * Gets the current class name
  102909. * @returns the class name
  102910. */
  102911. getClassName(): string;
  102912. /**
  102913. * Gets the vector input component
  102914. */
  102915. get vector(): NodeMaterialConnectionPoint;
  102916. protected _buildBlock(state: NodeMaterialBuildState): this;
  102917. }
  102918. }
  102919. declare module BABYLON {
  102920. /**
  102921. * Block used to output the final color
  102922. */
  102923. export class FragmentOutputBlock extends NodeMaterialBlock {
  102924. /**
  102925. * Create a new FragmentOutputBlock
  102926. * @param name defines the block name
  102927. */
  102928. constructor(name: string);
  102929. /**
  102930. * Gets the current class name
  102931. * @returns the class name
  102932. */
  102933. getClassName(): string;
  102934. /**
  102935. * Gets the rgba input component
  102936. */
  102937. get rgba(): NodeMaterialConnectionPoint;
  102938. /**
  102939. * Gets the rgb input component
  102940. */
  102941. get rgb(): NodeMaterialConnectionPoint;
  102942. /**
  102943. * Gets the a input component
  102944. */
  102945. get a(): NodeMaterialConnectionPoint;
  102946. protected _buildBlock(state: NodeMaterialBuildState): this;
  102947. }
  102948. }
  102949. declare module BABYLON {
  102950. /**
  102951. * Block used for the particle ramp gradient section
  102952. */
  102953. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  102954. /**
  102955. * Create a new ParticleRampGradientBlock
  102956. * @param name defines the block name
  102957. */
  102958. constructor(name: string);
  102959. /**
  102960. * Gets the current class name
  102961. * @returns the class name
  102962. */
  102963. getClassName(): string;
  102964. /**
  102965. * Gets the color input component
  102966. */
  102967. get color(): NodeMaterialConnectionPoint;
  102968. /**
  102969. * Gets the rampColor output component
  102970. */
  102971. get rampColor(): NodeMaterialConnectionPoint;
  102972. /**
  102973. * Initialize the block and prepare the context for build
  102974. * @param state defines the state that will be used for the build
  102975. */
  102976. initialize(state: NodeMaterialBuildState): void;
  102977. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102978. }
  102979. }
  102980. declare module BABYLON {
  102981. /**
  102982. * Block used for the particle blend multiply section
  102983. */
  102984. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  102985. /**
  102986. * Create a new ParticleBlendMultiplyBlock
  102987. * @param name defines the block name
  102988. */
  102989. constructor(name: string);
  102990. /**
  102991. * Gets the current class name
  102992. * @returns the class name
  102993. */
  102994. getClassName(): string;
  102995. /**
  102996. * Gets the color input component
  102997. */
  102998. get color(): NodeMaterialConnectionPoint;
  102999. /**
  103000. * Gets the alphaTexture input component
  103001. */
  103002. get alphaTexture(): NodeMaterialConnectionPoint;
  103003. /**
  103004. * Gets the alphaColor input component
  103005. */
  103006. get alphaColor(): NodeMaterialConnectionPoint;
  103007. /**
  103008. * Gets the blendColor output component
  103009. */
  103010. get blendColor(): NodeMaterialConnectionPoint;
  103011. /**
  103012. * Initialize the block and prepare the context for build
  103013. * @param state defines the state that will be used for the build
  103014. */
  103015. initialize(state: NodeMaterialBuildState): void;
  103016. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  103017. }
  103018. }
  103019. declare module BABYLON {
  103020. /**
  103021. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  103022. */
  103023. export class VectorMergerBlock extends NodeMaterialBlock {
  103024. /**
  103025. * Create a new VectorMergerBlock
  103026. * @param name defines the block name
  103027. */
  103028. constructor(name: string);
  103029. /**
  103030. * Gets the current class name
  103031. * @returns the class name
  103032. */
  103033. getClassName(): string;
  103034. /**
  103035. * Gets the xyz component (input)
  103036. */
  103037. get xyzIn(): NodeMaterialConnectionPoint;
  103038. /**
  103039. * Gets the xy component (input)
  103040. */
  103041. get xyIn(): NodeMaterialConnectionPoint;
  103042. /**
  103043. * Gets the x component (input)
  103044. */
  103045. get x(): NodeMaterialConnectionPoint;
  103046. /**
  103047. * Gets the y component (input)
  103048. */
  103049. get y(): NodeMaterialConnectionPoint;
  103050. /**
  103051. * Gets the z component (input)
  103052. */
  103053. get z(): NodeMaterialConnectionPoint;
  103054. /**
  103055. * Gets the w component (input)
  103056. */
  103057. get w(): NodeMaterialConnectionPoint;
  103058. /**
  103059. * Gets the xyzw component (output)
  103060. */
  103061. get xyzw(): NodeMaterialConnectionPoint;
  103062. /**
  103063. * Gets the xyz component (output)
  103064. */
  103065. get xyzOut(): NodeMaterialConnectionPoint;
  103066. /**
  103067. * Gets the xy component (output)
  103068. */
  103069. get xyOut(): NodeMaterialConnectionPoint;
  103070. /**
  103071. * Gets the xy component (output)
  103072. * @deprecated Please use xyOut instead.
  103073. */
  103074. get xy(): NodeMaterialConnectionPoint;
  103075. /**
  103076. * Gets the xyz component (output)
  103077. * @deprecated Please use xyzOut instead.
  103078. */
  103079. get xyz(): NodeMaterialConnectionPoint;
  103080. protected _buildBlock(state: NodeMaterialBuildState): this;
  103081. }
  103082. }
  103083. declare module BABYLON {
  103084. /**
  103085. * Block used to remap a float from a range to a new one
  103086. */
  103087. export class RemapBlock extends NodeMaterialBlock {
  103088. /**
  103089. * Gets or sets the source range
  103090. */
  103091. sourceRange: Vector2;
  103092. /**
  103093. * Gets or sets the target range
  103094. */
  103095. targetRange: Vector2;
  103096. /**
  103097. * Creates a new RemapBlock
  103098. * @param name defines the block name
  103099. */
  103100. constructor(name: string);
  103101. /**
  103102. * Gets the current class name
  103103. * @returns the class name
  103104. */
  103105. getClassName(): string;
  103106. /**
  103107. * Gets the input component
  103108. */
  103109. get input(): NodeMaterialConnectionPoint;
  103110. /**
  103111. * Gets the source min input component
  103112. */
  103113. get sourceMin(): NodeMaterialConnectionPoint;
  103114. /**
  103115. * Gets the source max input component
  103116. */
  103117. get sourceMax(): NodeMaterialConnectionPoint;
  103118. /**
  103119. * Gets the target min input component
  103120. */
  103121. get targetMin(): NodeMaterialConnectionPoint;
  103122. /**
  103123. * Gets the target max input component
  103124. */
  103125. get targetMax(): NodeMaterialConnectionPoint;
  103126. /**
  103127. * Gets the output component
  103128. */
  103129. get output(): NodeMaterialConnectionPoint;
  103130. protected _buildBlock(state: NodeMaterialBuildState): this;
  103131. protected _dumpPropertiesCode(): string;
  103132. serialize(): any;
  103133. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103134. }
  103135. }
  103136. declare module BABYLON {
  103137. /**
  103138. * Block used to multiply 2 values
  103139. */
  103140. export class MultiplyBlock extends NodeMaterialBlock {
  103141. /**
  103142. * Creates a new MultiplyBlock
  103143. * @param name defines the block name
  103144. */
  103145. constructor(name: string);
  103146. /**
  103147. * Gets the current class name
  103148. * @returns the class name
  103149. */
  103150. getClassName(): string;
  103151. /**
  103152. * Gets the left operand input component
  103153. */
  103154. get left(): NodeMaterialConnectionPoint;
  103155. /**
  103156. * Gets the right operand input component
  103157. */
  103158. get right(): NodeMaterialConnectionPoint;
  103159. /**
  103160. * Gets the output component
  103161. */
  103162. get output(): NodeMaterialConnectionPoint;
  103163. protected _buildBlock(state: NodeMaterialBuildState): this;
  103164. }
  103165. }
  103166. declare module BABYLON {
  103167. /**
  103168. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  103169. */
  103170. export class ColorSplitterBlock extends NodeMaterialBlock {
  103171. /**
  103172. * Create a new ColorSplitterBlock
  103173. * @param name defines the block name
  103174. */
  103175. constructor(name: string);
  103176. /**
  103177. * Gets the current class name
  103178. * @returns the class name
  103179. */
  103180. getClassName(): string;
  103181. /**
  103182. * Gets the rgba component (input)
  103183. */
  103184. get rgba(): NodeMaterialConnectionPoint;
  103185. /**
  103186. * Gets the rgb component (input)
  103187. */
  103188. get rgbIn(): NodeMaterialConnectionPoint;
  103189. /**
  103190. * Gets the rgb component (output)
  103191. */
  103192. get rgbOut(): NodeMaterialConnectionPoint;
  103193. /**
  103194. * Gets the r component (output)
  103195. */
  103196. get r(): NodeMaterialConnectionPoint;
  103197. /**
  103198. * Gets the g component (output)
  103199. */
  103200. get g(): NodeMaterialConnectionPoint;
  103201. /**
  103202. * Gets the b component (output)
  103203. */
  103204. get b(): NodeMaterialConnectionPoint;
  103205. /**
  103206. * Gets the a component (output)
  103207. */
  103208. get a(): NodeMaterialConnectionPoint;
  103209. protected _inputRename(name: string): string;
  103210. protected _outputRename(name: string): string;
  103211. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  103212. }
  103213. }
  103214. declare module BABYLON {
  103215. /**
  103216. * Operations supported by the Trigonometry block
  103217. */
  103218. export enum TrigonometryBlockOperations {
  103219. /** Cos */
  103220. Cos = 0,
  103221. /** Sin */
  103222. Sin = 1,
  103223. /** Abs */
  103224. Abs = 2,
  103225. /** Exp */
  103226. Exp = 3,
  103227. /** Exp2 */
  103228. Exp2 = 4,
  103229. /** Round */
  103230. Round = 5,
  103231. /** Floor */
  103232. Floor = 6,
  103233. /** Ceiling */
  103234. Ceiling = 7,
  103235. /** Square root */
  103236. Sqrt = 8,
  103237. /** Log */
  103238. Log = 9,
  103239. /** Tangent */
  103240. Tan = 10,
  103241. /** Arc tangent */
  103242. ArcTan = 11,
  103243. /** Arc cosinus */
  103244. ArcCos = 12,
  103245. /** Arc sinus */
  103246. ArcSin = 13,
  103247. /** Fraction */
  103248. Fract = 14,
  103249. /** Sign */
  103250. Sign = 15,
  103251. /** To radians (from degrees) */
  103252. Radians = 16,
  103253. /** To degrees (from radians) */
  103254. Degrees = 17
  103255. }
  103256. /**
  103257. * Block used to apply trigonometry operation to floats
  103258. */
  103259. export class TrigonometryBlock extends NodeMaterialBlock {
  103260. /**
  103261. * Gets or sets the operation applied by the block
  103262. */
  103263. operation: TrigonometryBlockOperations;
  103264. /**
  103265. * Creates a new TrigonometryBlock
  103266. * @param name defines the block name
  103267. */
  103268. constructor(name: string);
  103269. /**
  103270. * Gets the current class name
  103271. * @returns the class name
  103272. */
  103273. getClassName(): string;
  103274. /**
  103275. * Gets the input component
  103276. */
  103277. get input(): NodeMaterialConnectionPoint;
  103278. /**
  103279. * Gets the output component
  103280. */
  103281. get output(): NodeMaterialConnectionPoint;
  103282. protected _buildBlock(state: NodeMaterialBuildState): this;
  103283. serialize(): any;
  103284. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103285. protected _dumpPropertiesCode(): string;
  103286. }
  103287. }
  103288. declare module BABYLON {
  103289. /**
  103290. * Interface used to configure the node material editor
  103291. */
  103292. export interface INodeMaterialEditorOptions {
  103293. /** Define the URl to load node editor script */
  103294. editorURL?: string;
  103295. }
  103296. /** @hidden */
  103297. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103298. NORMAL: boolean;
  103299. TANGENT: boolean;
  103300. UV1: boolean;
  103301. /** BONES */
  103302. NUM_BONE_INFLUENCERS: number;
  103303. BonesPerMesh: number;
  103304. BONETEXTURE: boolean;
  103305. /** MORPH TARGETS */
  103306. MORPHTARGETS: boolean;
  103307. MORPHTARGETS_NORMAL: boolean;
  103308. MORPHTARGETS_TANGENT: boolean;
  103309. MORPHTARGETS_UV: boolean;
  103310. NUM_MORPH_INFLUENCERS: number;
  103311. /** IMAGE PROCESSING */
  103312. IMAGEPROCESSING: boolean;
  103313. VIGNETTE: boolean;
  103314. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103315. VIGNETTEBLENDMODEOPAQUE: boolean;
  103316. TONEMAPPING: boolean;
  103317. TONEMAPPING_ACES: boolean;
  103318. CONTRAST: boolean;
  103319. EXPOSURE: boolean;
  103320. COLORCURVES: boolean;
  103321. COLORGRADING: boolean;
  103322. COLORGRADING3D: boolean;
  103323. SAMPLER3DGREENDEPTH: boolean;
  103324. SAMPLER3DBGRMAP: boolean;
  103325. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103326. /** MISC. */
  103327. BUMPDIRECTUV: number;
  103328. constructor();
  103329. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  103330. }
  103331. /**
  103332. * Class used to configure NodeMaterial
  103333. */
  103334. export interface INodeMaterialOptions {
  103335. /**
  103336. * Defines if blocks should emit comments
  103337. */
  103338. emitComments: boolean;
  103339. }
  103340. /**
  103341. * Class used to create a node based material built by assembling shader blocks
  103342. */
  103343. export class NodeMaterial extends PushMaterial {
  103344. private static _BuildIdGenerator;
  103345. private _options;
  103346. private _vertexCompilationState;
  103347. private _fragmentCompilationState;
  103348. private _sharedData;
  103349. private _buildId;
  103350. private _buildWasSuccessful;
  103351. private _cachedWorldViewMatrix;
  103352. private _cachedWorldViewProjectionMatrix;
  103353. private _optimizers;
  103354. private _animationFrame;
  103355. /** Define the Url to load node editor script */
  103356. static EditorURL: string;
  103357. /** Define the Url to load snippets */
  103358. static SnippetUrl: string;
  103359. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  103360. static IgnoreTexturesAtLoadTime: boolean;
  103361. private BJSNODEMATERIALEDITOR;
  103362. /** Get the inspector from bundle or global */
  103363. private _getGlobalNodeMaterialEditor;
  103364. /**
  103365. * Snippet ID if the material was created from the snippet server
  103366. */
  103367. snippetId: string;
  103368. /**
  103369. * Gets or sets data used by visual editor
  103370. * @see https://nme.babylonjs.com
  103371. */
  103372. editorData: any;
  103373. /**
  103374. * 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)
  103375. */
  103376. ignoreAlpha: boolean;
  103377. /**
  103378. * Defines the maximum number of lights that can be used in the material
  103379. */
  103380. maxSimultaneousLights: number;
  103381. /**
  103382. * Observable raised when the material is built
  103383. */
  103384. onBuildObservable: Observable<NodeMaterial>;
  103385. /**
  103386. * Gets or sets the root nodes of the material vertex shader
  103387. */
  103388. _vertexOutputNodes: NodeMaterialBlock[];
  103389. /**
  103390. * Gets or sets the root nodes of the material fragment (pixel) shader
  103391. */
  103392. _fragmentOutputNodes: NodeMaterialBlock[];
  103393. /** Gets or sets options to control the node material overall behavior */
  103394. get options(): INodeMaterialOptions;
  103395. set options(options: INodeMaterialOptions);
  103396. /**
  103397. * Default configuration related to image processing available in the standard Material.
  103398. */
  103399. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103400. /**
  103401. * Gets the image processing configuration used either in this material.
  103402. */
  103403. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103404. /**
  103405. * Sets the Default image processing configuration used either in the this material.
  103406. *
  103407. * If sets to null, the scene one is in use.
  103408. */
  103409. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103410. /**
  103411. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  103412. */
  103413. attachedBlocks: NodeMaterialBlock[];
  103414. /**
  103415. * Specifies the mode of the node material
  103416. * @hidden
  103417. */
  103418. _mode: NodeMaterialModes;
  103419. /**
  103420. * Gets the mode property
  103421. */
  103422. get mode(): NodeMaterialModes;
  103423. /**
  103424. * Create a new node based material
  103425. * @param name defines the material name
  103426. * @param scene defines the hosting scene
  103427. * @param options defines creation option
  103428. */
  103429. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  103430. /**
  103431. * Gets the current class name of the material e.g. "NodeMaterial"
  103432. * @returns the class name
  103433. */
  103434. getClassName(): string;
  103435. /**
  103436. * Keep track of the image processing observer to allow dispose and replace.
  103437. */
  103438. private _imageProcessingObserver;
  103439. /**
  103440. * Attaches a new image processing configuration to the Standard Material.
  103441. * @param configuration
  103442. */
  103443. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103444. /**
  103445. * Get a block by its name
  103446. * @param name defines the name of the block to retrieve
  103447. * @returns the required block or null if not found
  103448. */
  103449. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  103450. /**
  103451. * Get a block by its name
  103452. * @param predicate defines the predicate used to find the good candidate
  103453. * @returns the required block or null if not found
  103454. */
  103455. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  103456. /**
  103457. * Get an input block by its name
  103458. * @param predicate defines the predicate used to find the good candidate
  103459. * @returns the required input block or null if not found
  103460. */
  103461. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  103462. /**
  103463. * Gets the list of input blocks attached to this material
  103464. * @returns an array of InputBlocks
  103465. */
  103466. getInputBlocks(): InputBlock[];
  103467. /**
  103468. * Adds a new optimizer to the list of optimizers
  103469. * @param optimizer defines the optimizers to add
  103470. * @returns the current material
  103471. */
  103472. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103473. /**
  103474. * Remove an optimizer from the list of optimizers
  103475. * @param optimizer defines the optimizers to remove
  103476. * @returns the current material
  103477. */
  103478. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103479. /**
  103480. * Add a new block to the list of output nodes
  103481. * @param node defines the node to add
  103482. * @returns the current material
  103483. */
  103484. addOutputNode(node: NodeMaterialBlock): this;
  103485. /**
  103486. * Remove a block from the list of root nodes
  103487. * @param node defines the node to remove
  103488. * @returns the current material
  103489. */
  103490. removeOutputNode(node: NodeMaterialBlock): this;
  103491. private _addVertexOutputNode;
  103492. private _removeVertexOutputNode;
  103493. private _addFragmentOutputNode;
  103494. private _removeFragmentOutputNode;
  103495. /**
  103496. * Specifies if the material will require alpha blending
  103497. * @returns a boolean specifying if alpha blending is needed
  103498. */
  103499. needAlphaBlending(): boolean;
  103500. /**
  103501. * Specifies if this material should be rendered in alpha test mode
  103502. * @returns a boolean specifying if an alpha test is needed.
  103503. */
  103504. needAlphaTesting(): boolean;
  103505. private _initializeBlock;
  103506. private _resetDualBlocks;
  103507. /**
  103508. * Remove a block from the current node material
  103509. * @param block defines the block to remove
  103510. */
  103511. removeBlock(block: NodeMaterialBlock): void;
  103512. /**
  103513. * Build the material and generates the inner effect
  103514. * @param verbose defines if the build should log activity
  103515. */
  103516. build(verbose?: boolean): void;
  103517. /**
  103518. * Runs an otpimization phase to try to improve the shader code
  103519. */
  103520. optimize(): void;
  103521. private _prepareDefinesForAttributes;
  103522. /**
  103523. * Create a post process from the material
  103524. * @param camera The camera to apply the render pass to.
  103525. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103526. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103527. * @param engine The engine which the post process will be applied. (default: current engine)
  103528. * @param reusable If the post process can be reused on the same frame. (default: false)
  103529. * @param textureType Type of textures used when performing the post process. (default: 0)
  103530. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103531. * @returns the post process created
  103532. */
  103533. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  103534. /**
  103535. * Create the post process effect from the material
  103536. * @param postProcess The post process to create the effect for
  103537. */
  103538. createEffectForPostProcess(postProcess: PostProcess): void;
  103539. private _createEffectForPostProcess;
  103540. /**
  103541. * Create a new procedural texture based on this node material
  103542. * @param size defines the size of the texture
  103543. * @param scene defines the hosting scene
  103544. * @returns the new procedural texture attached to this node material
  103545. */
  103546. createProceduralTexture(size: number | {
  103547. width: number;
  103548. height: number;
  103549. layers?: number;
  103550. }, scene: Scene): Nullable<ProceduralTexture>;
  103551. private _createEffectForParticles;
  103552. private _checkInternals;
  103553. /**
  103554. * Create the effect to be used as the custom effect for a particle system
  103555. * @param particleSystem Particle system to create the effect for
  103556. * @param onCompiled defines a function to call when the effect creation is successful
  103557. * @param onError defines a function to call when the effect creation has failed
  103558. */
  103559. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103560. private _processDefines;
  103561. /**
  103562. * Get if the submesh is ready to be used and all its information available.
  103563. * Child classes can use it to update shaders
  103564. * @param mesh defines the mesh to check
  103565. * @param subMesh defines which submesh to check
  103566. * @param useInstances specifies that instances should be used
  103567. * @returns a boolean indicating that the submesh is ready or not
  103568. */
  103569. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103570. /**
  103571. * Get a string representing the shaders built by the current node graph
  103572. */
  103573. get compiledShaders(): string;
  103574. /**
  103575. * Binds the world matrix to the material
  103576. * @param world defines the world transformation matrix
  103577. */
  103578. bindOnlyWorldMatrix(world: Matrix): void;
  103579. /**
  103580. * Binds the submesh to this material by preparing the effect and shader to draw
  103581. * @param world defines the world transformation matrix
  103582. * @param mesh defines the mesh containing the submesh
  103583. * @param subMesh defines the submesh to bind the material to
  103584. */
  103585. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103586. /**
  103587. * Gets the active textures from the material
  103588. * @returns an array of textures
  103589. */
  103590. getActiveTextures(): BaseTexture[];
  103591. /**
  103592. * Gets the list of texture blocks
  103593. * @returns an array of texture blocks
  103594. */
  103595. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  103596. /**
  103597. * Specifies if the material uses a texture
  103598. * @param texture defines the texture to check against the material
  103599. * @returns a boolean specifying if the material uses the texture
  103600. */
  103601. hasTexture(texture: BaseTexture): boolean;
  103602. /**
  103603. * Disposes the material
  103604. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103605. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103606. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  103607. */
  103608. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  103609. /** Creates the node editor window. */
  103610. private _createNodeEditor;
  103611. /**
  103612. * Launch the node material editor
  103613. * @param config Define the configuration of the editor
  103614. * @return a promise fulfilled when the node editor is visible
  103615. */
  103616. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  103617. /**
  103618. * Clear the current material
  103619. */
  103620. clear(): void;
  103621. /**
  103622. * Clear the current material and set it to a default state
  103623. */
  103624. setToDefault(): void;
  103625. /**
  103626. * Clear the current material and set it to a default state for post process
  103627. */
  103628. setToDefaultPostProcess(): void;
  103629. /**
  103630. * Clear the current material and set it to a default state for procedural texture
  103631. */
  103632. setToDefaultProceduralTexture(): void;
  103633. /**
  103634. * Clear the current material and set it to a default state for particle
  103635. */
  103636. setToDefaultParticle(): void;
  103637. /**
  103638. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  103639. * @param url defines the url to load from
  103640. * @returns a promise that will fullfil when the material is fully loaded
  103641. */
  103642. loadAsync(url: string): Promise<void>;
  103643. private _gatherBlocks;
  103644. /**
  103645. * Generate a string containing the code declaration required to create an equivalent of this material
  103646. * @returns a string
  103647. */
  103648. generateCode(): string;
  103649. /**
  103650. * Serializes this material in a JSON representation
  103651. * @returns the serialized material object
  103652. */
  103653. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  103654. private _restoreConnections;
  103655. /**
  103656. * Clear the current graph and load a new one from a serialization object
  103657. * @param source defines the JSON representation of the material
  103658. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103659. * @param merge defines whether or not the source must be merged or replace the current content
  103660. */
  103661. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  103662. /**
  103663. * Makes a duplicate of the current material.
  103664. * @param name - name to use for the new material.
  103665. */
  103666. clone(name: string): NodeMaterial;
  103667. /**
  103668. * Creates a node material from parsed material data
  103669. * @param source defines the JSON representation of the material
  103670. * @param scene defines the hosting scene
  103671. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103672. * @returns a new node material
  103673. */
  103674. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  103675. /**
  103676. * Creates a node material from a snippet saved in a remote file
  103677. * @param name defines the name of the material to create
  103678. * @param url defines the url to load from
  103679. * @param scene defines the hosting scene
  103680. * @returns a promise that will resolve to the new node material
  103681. */
  103682. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  103683. /**
  103684. * Creates a node material from a snippet saved by the node material editor
  103685. * @param snippetId defines the snippet to load
  103686. * @param scene defines the hosting scene
  103687. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103688. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  103689. * @returns a promise that will resolve to the new node material
  103690. */
  103691. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  103692. /**
  103693. * Creates a new node material set to default basic configuration
  103694. * @param name defines the name of the material
  103695. * @param scene defines the hosting scene
  103696. * @returns a new NodeMaterial
  103697. */
  103698. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  103699. }
  103700. }
  103701. declare module BABYLON {
  103702. interface ThinEngine {
  103703. /**
  103704. * Unbind a list of render target textures from the webGL context
  103705. * This is used only when drawBuffer extension or webGL2 are active
  103706. * @param textures defines the render target textures to unbind
  103707. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103708. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103709. */
  103710. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103711. /**
  103712. * Create a multi render target texture
  103713. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103714. * @param size defines the size of the texture
  103715. * @param options defines the creation options
  103716. * @returns the cube texture as an InternalTexture
  103717. */
  103718. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103719. /**
  103720. * Update the sample count for a given multiple render target texture
  103721. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103722. * @param textures defines the textures to update
  103723. * @param samples defines the sample count to set
  103724. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103725. */
  103726. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103727. /**
  103728. * Select a subsets of attachments to draw to.
  103729. * @param attachments gl attachments
  103730. */
  103731. bindAttachments(attachments: number[]): void;
  103732. /**
  103733. * Creates a layout object to draw/clear on specific textures in a MRT
  103734. * @param textureStatus textureStatus[i] indicates if the i-th is active
  103735. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  103736. */
  103737. buildTextureLayout(textureStatus: boolean[]): number[];
  103738. /**
  103739. * Restores the webgl state to only draw on the main color attachment
  103740. */
  103741. restoreSingleAttachment(): void;
  103742. }
  103743. }
  103744. declare module BABYLON {
  103745. /**
  103746. * Creation options of the multi render target texture.
  103747. */
  103748. export interface IMultiRenderTargetOptions {
  103749. /**
  103750. * Define if the texture needs to create mip maps after render.
  103751. */
  103752. generateMipMaps?: boolean;
  103753. /**
  103754. * Define the types of all the draw buffers we want to create
  103755. */
  103756. types?: number[];
  103757. /**
  103758. * Define the sampling modes of all the draw buffers we want to create
  103759. */
  103760. samplingModes?: number[];
  103761. /**
  103762. * Define if a depth buffer is required
  103763. */
  103764. generateDepthBuffer?: boolean;
  103765. /**
  103766. * Define if a stencil buffer is required
  103767. */
  103768. generateStencilBuffer?: boolean;
  103769. /**
  103770. * Define if a depth texture is required instead of a depth buffer
  103771. */
  103772. generateDepthTexture?: boolean;
  103773. /**
  103774. * Define the number of desired draw buffers
  103775. */
  103776. textureCount?: number;
  103777. /**
  103778. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103779. */
  103780. doNotChangeAspectRatio?: boolean;
  103781. /**
  103782. * Define the default type of the buffers we are creating
  103783. */
  103784. defaultType?: number;
  103785. }
  103786. /**
  103787. * A multi render target, like a render target provides the ability to render to a texture.
  103788. * Unlike the render target, it can render to several draw buffers in one draw.
  103789. * This is specially interesting in deferred rendering or for any effects requiring more than
  103790. * just one color from a single pass.
  103791. */
  103792. export class MultiRenderTarget extends RenderTargetTexture {
  103793. private _internalTextures;
  103794. private _textures;
  103795. private _multiRenderTargetOptions;
  103796. private _count;
  103797. /**
  103798. * Get if draw buffers are currently supported by the used hardware and browser.
  103799. */
  103800. get isSupported(): boolean;
  103801. /**
  103802. * Get the list of textures generated by the multi render target.
  103803. */
  103804. get textures(): Texture[];
  103805. /**
  103806. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103807. */
  103808. get count(): number;
  103809. /**
  103810. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103811. */
  103812. get depthTexture(): Texture;
  103813. /**
  103814. * Set the wrapping mode on U of all the textures we are rendering to.
  103815. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103816. */
  103817. set wrapU(wrap: number);
  103818. /**
  103819. * Set the wrapping mode on V of all the textures we are rendering to.
  103820. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103821. */
  103822. set wrapV(wrap: number);
  103823. /**
  103824. * Instantiate a new multi render target texture.
  103825. * A multi render target, like a render target provides the ability to render to a texture.
  103826. * Unlike the render target, it can render to several draw buffers in one draw.
  103827. * This is specially interesting in deferred rendering or for any effects requiring more than
  103828. * just one color from a single pass.
  103829. * @param name Define the name of the texture
  103830. * @param size Define the size of the buffers to render to
  103831. * @param count Define the number of target we are rendering into
  103832. * @param scene Define the scene the texture belongs to
  103833. * @param options Define the options used to create the multi render target
  103834. */
  103835. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103836. private _initTypes;
  103837. /** @hidden */
  103838. _rebuild(forceFullRebuild?: boolean): void;
  103839. private _createInternalTextures;
  103840. private _createTextures;
  103841. /**
  103842. * Replaces a texture within the MRT.
  103843. * @param texture The new texture to insert in the MRT
  103844. * @param index The index of the texture to replace
  103845. */
  103846. replaceTexture(texture: Texture, index: number): void;
  103847. /**
  103848. * Define the number of samples used if MSAA is enabled.
  103849. */
  103850. get samples(): number;
  103851. set samples(value: number);
  103852. /**
  103853. * Resize all the textures in the multi render target.
  103854. * Be careful as it will recreate all the data in the new texture.
  103855. * @param size Define the new size
  103856. */
  103857. resize(size: any): void;
  103858. /**
  103859. * Changes the number of render targets in this MRT
  103860. * Be careful as it will recreate all the data in the new texture.
  103861. * @param count new texture count
  103862. * @param options Specifies texture types and sampling modes for new textures
  103863. */
  103864. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  103865. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103866. /**
  103867. * Dispose the render targets and their associated resources
  103868. */
  103869. dispose(): void;
  103870. /**
  103871. * Release all the underlying texture used as draw buffers.
  103872. */
  103873. releaseInternalTextures(): void;
  103874. }
  103875. }
  103876. declare module BABYLON {
  103877. /** @hidden */
  103878. export var imageProcessingPixelShader: {
  103879. name: string;
  103880. shader: string;
  103881. };
  103882. }
  103883. declare module BABYLON {
  103884. /**
  103885. * ImageProcessingPostProcess
  103886. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103887. */
  103888. export class ImageProcessingPostProcess extends PostProcess {
  103889. /**
  103890. * Default configuration related to image processing available in the PBR Material.
  103891. */
  103892. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103893. /**
  103894. * Gets the image processing configuration used either in this material.
  103895. */
  103896. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103897. /**
  103898. * Sets the Default image processing configuration used either in the this material.
  103899. *
  103900. * If sets to null, the scene one is in use.
  103901. */
  103902. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103903. /**
  103904. * Keep track of the image processing observer to allow dispose and replace.
  103905. */
  103906. private _imageProcessingObserver;
  103907. /**
  103908. * Attaches a new image processing configuration to the PBR Material.
  103909. * @param configuration
  103910. */
  103911. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103912. /**
  103913. * If the post process is supported.
  103914. */
  103915. get isSupported(): boolean;
  103916. /**
  103917. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103918. */
  103919. get colorCurves(): Nullable<ColorCurves>;
  103920. /**
  103921. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103922. */
  103923. set colorCurves(value: Nullable<ColorCurves>);
  103924. /**
  103925. * Gets wether the color curves effect is enabled.
  103926. */
  103927. get colorCurvesEnabled(): boolean;
  103928. /**
  103929. * Sets wether the color curves effect is enabled.
  103930. */
  103931. set colorCurvesEnabled(value: boolean);
  103932. /**
  103933. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103934. */
  103935. get colorGradingTexture(): Nullable<BaseTexture>;
  103936. /**
  103937. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103938. */
  103939. set colorGradingTexture(value: Nullable<BaseTexture>);
  103940. /**
  103941. * Gets wether the color grading effect is enabled.
  103942. */
  103943. get colorGradingEnabled(): boolean;
  103944. /**
  103945. * Gets wether the color grading effect is enabled.
  103946. */
  103947. set colorGradingEnabled(value: boolean);
  103948. /**
  103949. * Gets exposure used in the effect.
  103950. */
  103951. get exposure(): number;
  103952. /**
  103953. * Sets exposure used in the effect.
  103954. */
  103955. set exposure(value: number);
  103956. /**
  103957. * Gets wether tonemapping is enabled or not.
  103958. */
  103959. get toneMappingEnabled(): boolean;
  103960. /**
  103961. * Sets wether tonemapping is enabled or not
  103962. */
  103963. set toneMappingEnabled(value: boolean);
  103964. /**
  103965. * Gets the type of tone mapping effect.
  103966. */
  103967. get toneMappingType(): number;
  103968. /**
  103969. * Sets the type of tone mapping effect.
  103970. */
  103971. set toneMappingType(value: number);
  103972. /**
  103973. * Gets contrast used in the effect.
  103974. */
  103975. get contrast(): number;
  103976. /**
  103977. * Sets contrast used in the effect.
  103978. */
  103979. set contrast(value: number);
  103980. /**
  103981. * Gets Vignette stretch size.
  103982. */
  103983. get vignetteStretch(): number;
  103984. /**
  103985. * Sets Vignette stretch size.
  103986. */
  103987. set vignetteStretch(value: number);
  103988. /**
  103989. * Gets Vignette centre X Offset.
  103990. */
  103991. get vignetteCentreX(): number;
  103992. /**
  103993. * Sets Vignette centre X Offset.
  103994. */
  103995. set vignetteCentreX(value: number);
  103996. /**
  103997. * Gets Vignette centre Y Offset.
  103998. */
  103999. get vignetteCentreY(): number;
  104000. /**
  104001. * Sets Vignette centre Y Offset.
  104002. */
  104003. set vignetteCentreY(value: number);
  104004. /**
  104005. * Gets Vignette weight or intensity of the vignette effect.
  104006. */
  104007. get vignetteWeight(): number;
  104008. /**
  104009. * Sets Vignette weight or intensity of the vignette effect.
  104010. */
  104011. set vignetteWeight(value: number);
  104012. /**
  104013. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104014. * if vignetteEnabled is set to true.
  104015. */
  104016. get vignetteColor(): Color4;
  104017. /**
  104018. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104019. * if vignetteEnabled is set to true.
  104020. */
  104021. set vignetteColor(value: Color4);
  104022. /**
  104023. * Gets Camera field of view used by the Vignette effect.
  104024. */
  104025. get vignetteCameraFov(): number;
  104026. /**
  104027. * Sets Camera field of view used by the Vignette effect.
  104028. */
  104029. set vignetteCameraFov(value: number);
  104030. /**
  104031. * Gets the vignette blend mode allowing different kind of effect.
  104032. */
  104033. get vignetteBlendMode(): number;
  104034. /**
  104035. * Sets the vignette blend mode allowing different kind of effect.
  104036. */
  104037. set vignetteBlendMode(value: number);
  104038. /**
  104039. * Gets wether the vignette effect is enabled.
  104040. */
  104041. get vignetteEnabled(): boolean;
  104042. /**
  104043. * Sets wether the vignette effect is enabled.
  104044. */
  104045. set vignetteEnabled(value: boolean);
  104046. private _fromLinearSpace;
  104047. /**
  104048. * Gets wether the input of the processing is in Gamma or Linear Space.
  104049. */
  104050. get fromLinearSpace(): boolean;
  104051. /**
  104052. * Sets wether the input of the processing is in Gamma or Linear Space.
  104053. */
  104054. set fromLinearSpace(value: boolean);
  104055. /**
  104056. * Defines cache preventing GC.
  104057. */
  104058. private _defines;
  104059. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104060. /**
  104061. * "ImageProcessingPostProcess"
  104062. * @returns "ImageProcessingPostProcess"
  104063. */
  104064. getClassName(): string;
  104065. /**
  104066. * @hidden
  104067. */
  104068. _updateParameters(): void;
  104069. dispose(camera?: Camera): void;
  104070. }
  104071. }
  104072. declare module BABYLON {
  104073. /**
  104074. * Interface for defining prepass effects in the prepass post-process pipeline
  104075. */
  104076. export interface PrePassEffectConfiguration {
  104077. /**
  104078. * Name of the effect
  104079. */
  104080. name: string;
  104081. /**
  104082. * Post process to attach for this effect
  104083. */
  104084. postProcess?: PostProcess;
  104085. /**
  104086. * Textures required in the MRT
  104087. */
  104088. texturesRequired: number[];
  104089. /**
  104090. * Is the effect enabled
  104091. */
  104092. enabled: boolean;
  104093. /**
  104094. * Disposes the effect configuration
  104095. */
  104096. dispose?: () => void;
  104097. /**
  104098. * Creates the associated post process
  104099. */
  104100. createPostProcess?: () => PostProcess;
  104101. }
  104102. }
  104103. declare module BABYLON {
  104104. /**
  104105. * Options to be used when creating a FresnelParameters.
  104106. */
  104107. export type IFresnelParametersCreationOptions = {
  104108. /**
  104109. * Define the color used on edges (grazing angle)
  104110. */
  104111. leftColor?: Color3;
  104112. /**
  104113. * Define the color used on center
  104114. */
  104115. rightColor?: Color3;
  104116. /**
  104117. * Define bias applied to computed fresnel term
  104118. */
  104119. bias?: number;
  104120. /**
  104121. * Defined the power exponent applied to fresnel term
  104122. */
  104123. power?: number;
  104124. /**
  104125. * Define if the fresnel effect is enable or not.
  104126. */
  104127. isEnabled?: boolean;
  104128. };
  104129. /**
  104130. * Serialized format for FresnelParameters.
  104131. */
  104132. export type IFresnelParametersSerialized = {
  104133. /**
  104134. * Define the color used on edges (grazing angle) [as an array]
  104135. */
  104136. leftColor: number[];
  104137. /**
  104138. * Define the color used on center [as an array]
  104139. */
  104140. rightColor: number[];
  104141. /**
  104142. * Define bias applied to computed fresnel term
  104143. */
  104144. bias: number;
  104145. /**
  104146. * Defined the power exponent applied to fresnel term
  104147. */
  104148. power?: number;
  104149. /**
  104150. * Define if the fresnel effect is enable or not.
  104151. */
  104152. isEnabled: boolean;
  104153. };
  104154. /**
  104155. * This represents all the required information to add a fresnel effect on a material:
  104156. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104157. */
  104158. export class FresnelParameters {
  104159. private _isEnabled;
  104160. /**
  104161. * Define if the fresnel effect is enable or not.
  104162. */
  104163. get isEnabled(): boolean;
  104164. set isEnabled(value: boolean);
  104165. /**
  104166. * Define the color used on edges (grazing angle)
  104167. */
  104168. leftColor: Color3;
  104169. /**
  104170. * Define the color used on center
  104171. */
  104172. rightColor: Color3;
  104173. /**
  104174. * Define bias applied to computed fresnel term
  104175. */
  104176. bias: number;
  104177. /**
  104178. * Defined the power exponent applied to fresnel term
  104179. */
  104180. power: number;
  104181. /**
  104182. * Creates a new FresnelParameters object.
  104183. *
  104184. * @param options provide your own settings to optionally to override defaults
  104185. */
  104186. constructor(options?: IFresnelParametersCreationOptions);
  104187. /**
  104188. * Clones the current fresnel and its valuues
  104189. * @returns a clone fresnel configuration
  104190. */
  104191. clone(): FresnelParameters;
  104192. /**
  104193. * Determines equality between FresnelParameters objects
  104194. * @param otherFresnelParameters defines the second operand
  104195. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  104196. */
  104197. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  104198. /**
  104199. * Serializes the current fresnel parameters to a JSON representation.
  104200. * @return the JSON serialization
  104201. */
  104202. serialize(): IFresnelParametersSerialized;
  104203. /**
  104204. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  104205. * @param parsedFresnelParameters Define the JSON representation
  104206. * @returns the parsed parameters
  104207. */
  104208. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  104209. }
  104210. }
  104211. declare module BABYLON {
  104212. /**
  104213. * This groups all the flags used to control the materials channel.
  104214. */
  104215. export class MaterialFlags {
  104216. private static _DiffuseTextureEnabled;
  104217. /**
  104218. * Are diffuse textures enabled in the application.
  104219. */
  104220. static get DiffuseTextureEnabled(): boolean;
  104221. static set DiffuseTextureEnabled(value: boolean);
  104222. private static _DetailTextureEnabled;
  104223. /**
  104224. * Are detail textures enabled in the application.
  104225. */
  104226. static get DetailTextureEnabled(): boolean;
  104227. static set DetailTextureEnabled(value: boolean);
  104228. private static _AmbientTextureEnabled;
  104229. /**
  104230. * Are ambient textures enabled in the application.
  104231. */
  104232. static get AmbientTextureEnabled(): boolean;
  104233. static set AmbientTextureEnabled(value: boolean);
  104234. private static _OpacityTextureEnabled;
  104235. /**
  104236. * Are opacity textures enabled in the application.
  104237. */
  104238. static get OpacityTextureEnabled(): boolean;
  104239. static set OpacityTextureEnabled(value: boolean);
  104240. private static _ReflectionTextureEnabled;
  104241. /**
  104242. * Are reflection textures enabled in the application.
  104243. */
  104244. static get ReflectionTextureEnabled(): boolean;
  104245. static set ReflectionTextureEnabled(value: boolean);
  104246. private static _EmissiveTextureEnabled;
  104247. /**
  104248. * Are emissive textures enabled in the application.
  104249. */
  104250. static get EmissiveTextureEnabled(): boolean;
  104251. static set EmissiveTextureEnabled(value: boolean);
  104252. private static _SpecularTextureEnabled;
  104253. /**
  104254. * Are specular textures enabled in the application.
  104255. */
  104256. static get SpecularTextureEnabled(): boolean;
  104257. static set SpecularTextureEnabled(value: boolean);
  104258. private static _BumpTextureEnabled;
  104259. /**
  104260. * Are bump textures enabled in the application.
  104261. */
  104262. static get BumpTextureEnabled(): boolean;
  104263. static set BumpTextureEnabled(value: boolean);
  104264. private static _LightmapTextureEnabled;
  104265. /**
  104266. * Are lightmap textures enabled in the application.
  104267. */
  104268. static get LightmapTextureEnabled(): boolean;
  104269. static set LightmapTextureEnabled(value: boolean);
  104270. private static _RefractionTextureEnabled;
  104271. /**
  104272. * Are refraction textures enabled in the application.
  104273. */
  104274. static get RefractionTextureEnabled(): boolean;
  104275. static set RefractionTextureEnabled(value: boolean);
  104276. private static _ColorGradingTextureEnabled;
  104277. /**
  104278. * Are color grading textures enabled in the application.
  104279. */
  104280. static get ColorGradingTextureEnabled(): boolean;
  104281. static set ColorGradingTextureEnabled(value: boolean);
  104282. private static _FresnelEnabled;
  104283. /**
  104284. * Are fresnels enabled in the application.
  104285. */
  104286. static get FresnelEnabled(): boolean;
  104287. static set FresnelEnabled(value: boolean);
  104288. private static _ClearCoatTextureEnabled;
  104289. /**
  104290. * Are clear coat textures enabled in the application.
  104291. */
  104292. static get ClearCoatTextureEnabled(): boolean;
  104293. static set ClearCoatTextureEnabled(value: boolean);
  104294. private static _ClearCoatBumpTextureEnabled;
  104295. /**
  104296. * Are clear coat bump textures enabled in the application.
  104297. */
  104298. static get ClearCoatBumpTextureEnabled(): boolean;
  104299. static set ClearCoatBumpTextureEnabled(value: boolean);
  104300. private static _ClearCoatTintTextureEnabled;
  104301. /**
  104302. * Are clear coat tint textures enabled in the application.
  104303. */
  104304. static get ClearCoatTintTextureEnabled(): boolean;
  104305. static set ClearCoatTintTextureEnabled(value: boolean);
  104306. private static _SheenTextureEnabled;
  104307. /**
  104308. * Are sheen textures enabled in the application.
  104309. */
  104310. static get SheenTextureEnabled(): boolean;
  104311. static set SheenTextureEnabled(value: boolean);
  104312. private static _AnisotropicTextureEnabled;
  104313. /**
  104314. * Are anisotropic textures enabled in the application.
  104315. */
  104316. static get AnisotropicTextureEnabled(): boolean;
  104317. static set AnisotropicTextureEnabled(value: boolean);
  104318. private static _ThicknessTextureEnabled;
  104319. /**
  104320. * Are thickness textures enabled in the application.
  104321. */
  104322. static get ThicknessTextureEnabled(): boolean;
  104323. static set ThicknessTextureEnabled(value: boolean);
  104324. }
  104325. }
  104326. declare module BABYLON {
  104327. /** @hidden */
  104328. export var defaultFragmentDeclaration: {
  104329. name: string;
  104330. shader: string;
  104331. };
  104332. }
  104333. declare module BABYLON {
  104334. /** @hidden */
  104335. export var defaultUboDeclaration: {
  104336. name: string;
  104337. shader: string;
  104338. };
  104339. }
  104340. declare module BABYLON {
  104341. /** @hidden */
  104342. export var prePassDeclaration: {
  104343. name: string;
  104344. shader: string;
  104345. };
  104346. }
  104347. declare module BABYLON {
  104348. /** @hidden */
  104349. export var lightFragmentDeclaration: {
  104350. name: string;
  104351. shader: string;
  104352. };
  104353. }
  104354. declare module BABYLON {
  104355. /** @hidden */
  104356. export var lightUboDeclaration: {
  104357. name: string;
  104358. shader: string;
  104359. };
  104360. }
  104361. declare module BABYLON {
  104362. /** @hidden */
  104363. export var lightsFragmentFunctions: {
  104364. name: string;
  104365. shader: string;
  104366. };
  104367. }
  104368. declare module BABYLON {
  104369. /** @hidden */
  104370. export var shadowsFragmentFunctions: {
  104371. name: string;
  104372. shader: string;
  104373. };
  104374. }
  104375. declare module BABYLON {
  104376. /** @hidden */
  104377. export var fresnelFunction: {
  104378. name: string;
  104379. shader: string;
  104380. };
  104381. }
  104382. declare module BABYLON {
  104383. /** @hidden */
  104384. export var bumpFragmentMainFunctions: {
  104385. name: string;
  104386. shader: string;
  104387. };
  104388. }
  104389. declare module BABYLON {
  104390. /** @hidden */
  104391. export var bumpFragmentFunctions: {
  104392. name: string;
  104393. shader: string;
  104394. };
  104395. }
  104396. declare module BABYLON {
  104397. /** @hidden */
  104398. export var logDepthDeclaration: {
  104399. name: string;
  104400. shader: string;
  104401. };
  104402. }
  104403. declare module BABYLON {
  104404. /** @hidden */
  104405. export var bumpFragment: {
  104406. name: string;
  104407. shader: string;
  104408. };
  104409. }
  104410. declare module BABYLON {
  104411. /** @hidden */
  104412. export var depthPrePass: {
  104413. name: string;
  104414. shader: string;
  104415. };
  104416. }
  104417. declare module BABYLON {
  104418. /** @hidden */
  104419. export var lightFragment: {
  104420. name: string;
  104421. shader: string;
  104422. };
  104423. }
  104424. declare module BABYLON {
  104425. /** @hidden */
  104426. export var logDepthFragment: {
  104427. name: string;
  104428. shader: string;
  104429. };
  104430. }
  104431. declare module BABYLON {
  104432. /** @hidden */
  104433. export var defaultPixelShader: {
  104434. name: string;
  104435. shader: string;
  104436. };
  104437. }
  104438. declare module BABYLON {
  104439. /** @hidden */
  104440. export var defaultVertexDeclaration: {
  104441. name: string;
  104442. shader: string;
  104443. };
  104444. }
  104445. declare module BABYLON {
  104446. /** @hidden */
  104447. export var prePassVertexDeclaration: {
  104448. name: string;
  104449. shader: string;
  104450. };
  104451. }
  104452. declare module BABYLON {
  104453. /** @hidden */
  104454. export var bumpVertexDeclaration: {
  104455. name: string;
  104456. shader: string;
  104457. };
  104458. }
  104459. declare module BABYLON {
  104460. /** @hidden */
  104461. export var prePassVertex: {
  104462. name: string;
  104463. shader: string;
  104464. };
  104465. }
  104466. declare module BABYLON {
  104467. /** @hidden */
  104468. export var bumpVertex: {
  104469. name: string;
  104470. shader: string;
  104471. };
  104472. }
  104473. declare module BABYLON {
  104474. /** @hidden */
  104475. export var fogVertex: {
  104476. name: string;
  104477. shader: string;
  104478. };
  104479. }
  104480. declare module BABYLON {
  104481. /** @hidden */
  104482. export var shadowsVertex: {
  104483. name: string;
  104484. shader: string;
  104485. };
  104486. }
  104487. declare module BABYLON {
  104488. /** @hidden */
  104489. export var pointCloudVertex: {
  104490. name: string;
  104491. shader: string;
  104492. };
  104493. }
  104494. declare module BABYLON {
  104495. /** @hidden */
  104496. export var logDepthVertex: {
  104497. name: string;
  104498. shader: string;
  104499. };
  104500. }
  104501. declare module BABYLON {
  104502. /** @hidden */
  104503. export var defaultVertexShader: {
  104504. name: string;
  104505. shader: string;
  104506. };
  104507. }
  104508. declare module BABYLON {
  104509. /**
  104510. * @hidden
  104511. */
  104512. export interface IMaterialDetailMapDefines {
  104513. DETAIL: boolean;
  104514. DETAILDIRECTUV: number;
  104515. DETAIL_NORMALBLENDMETHOD: number;
  104516. /** @hidden */
  104517. _areTexturesDirty: boolean;
  104518. }
  104519. /**
  104520. * Define the code related to the detail map parameters of a material
  104521. *
  104522. * Inspired from:
  104523. * 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
  104524. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  104525. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  104526. */
  104527. export class DetailMapConfiguration {
  104528. private _texture;
  104529. /**
  104530. * The detail texture of the material.
  104531. */
  104532. texture: Nullable<BaseTexture>;
  104533. /**
  104534. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  104535. * Bigger values mean stronger blending
  104536. */
  104537. diffuseBlendLevel: number;
  104538. /**
  104539. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  104540. * Bigger values mean stronger blending. Only used with PBR materials
  104541. */
  104542. roughnessBlendLevel: number;
  104543. /**
  104544. * Defines how strong the bump effect from the detail map is
  104545. * Bigger values mean stronger effect
  104546. */
  104547. bumpLevel: number;
  104548. private _normalBlendMethod;
  104549. /**
  104550. * The method used to blend the bump and detail normals together
  104551. */
  104552. normalBlendMethod: number;
  104553. private _isEnabled;
  104554. /**
  104555. * Enable or disable the detail map on this material
  104556. */
  104557. isEnabled: boolean;
  104558. /** @hidden */
  104559. private _internalMarkAllSubMeshesAsTexturesDirty;
  104560. /** @hidden */
  104561. _markAllSubMeshesAsTexturesDirty(): void;
  104562. /**
  104563. * Instantiate a new detail map
  104564. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104565. */
  104566. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104567. /**
  104568. * Gets whether the submesh is ready to be used or not.
  104569. * @param defines the list of "defines" to update.
  104570. * @param scene defines the scene the material belongs to.
  104571. * @returns - boolean indicating that the submesh is ready or not.
  104572. */
  104573. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  104574. /**
  104575. * Update the defines for detail map usage
  104576. * @param defines the list of "defines" to update.
  104577. * @param scene defines the scene the material belongs to.
  104578. */
  104579. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  104580. /**
  104581. * Binds the material data.
  104582. * @param uniformBuffer defines the Uniform buffer to fill in.
  104583. * @param scene defines the scene the material belongs to.
  104584. * @param isFrozen defines whether the material is frozen or not.
  104585. */
  104586. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104587. /**
  104588. * Checks to see if a texture is used in the material.
  104589. * @param texture - Base texture to use.
  104590. * @returns - Boolean specifying if a texture is used in the material.
  104591. */
  104592. hasTexture(texture: BaseTexture): boolean;
  104593. /**
  104594. * Returns an array of the actively used textures.
  104595. * @param activeTextures Array of BaseTextures
  104596. */
  104597. getActiveTextures(activeTextures: BaseTexture[]): void;
  104598. /**
  104599. * Returns the animatable textures.
  104600. * @param animatables Array of animatable textures.
  104601. */
  104602. getAnimatables(animatables: IAnimatable[]): void;
  104603. /**
  104604. * Disposes the resources of the material.
  104605. * @param forceDisposeTextures - Forces the disposal of all textures.
  104606. */
  104607. dispose(forceDisposeTextures?: boolean): void;
  104608. /**
  104609. * Get the current class name useful for serialization or dynamic coding.
  104610. * @returns "DetailMap"
  104611. */
  104612. getClassName(): string;
  104613. /**
  104614. * Add the required uniforms to the current list.
  104615. * @param uniforms defines the current uniform list.
  104616. */
  104617. static AddUniforms(uniforms: string[]): void;
  104618. /**
  104619. * Add the required samplers to the current list.
  104620. * @param samplers defines the current sampler list.
  104621. */
  104622. static AddSamplers(samplers: string[]): void;
  104623. /**
  104624. * Add the required uniforms to the current buffer.
  104625. * @param uniformBuffer defines the current uniform buffer.
  104626. */
  104627. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104628. /**
  104629. * Makes a duplicate of the current instance into another one.
  104630. * @param detailMap define the instance where to copy the info
  104631. */
  104632. copyTo(detailMap: DetailMapConfiguration): void;
  104633. /**
  104634. * Serializes this detail map instance
  104635. * @returns - An object with the serialized instance.
  104636. */
  104637. serialize(): any;
  104638. /**
  104639. * Parses a detail map setting from a serialized object.
  104640. * @param source - Serialized object.
  104641. * @param scene Defines the scene we are parsing for
  104642. * @param rootUrl Defines the rootUrl to load from
  104643. */
  104644. parse(source: any, scene: Scene, rootUrl: string): void;
  104645. }
  104646. }
  104647. declare module BABYLON {
  104648. /** @hidden */
  104649. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  104650. MAINUV1: boolean;
  104651. MAINUV2: boolean;
  104652. DIFFUSE: boolean;
  104653. DIFFUSEDIRECTUV: number;
  104654. DETAIL: boolean;
  104655. DETAILDIRECTUV: number;
  104656. DETAIL_NORMALBLENDMETHOD: number;
  104657. AMBIENT: boolean;
  104658. AMBIENTDIRECTUV: number;
  104659. OPACITY: boolean;
  104660. OPACITYDIRECTUV: number;
  104661. OPACITYRGB: boolean;
  104662. REFLECTION: boolean;
  104663. EMISSIVE: boolean;
  104664. EMISSIVEDIRECTUV: number;
  104665. SPECULAR: boolean;
  104666. SPECULARDIRECTUV: number;
  104667. BUMP: boolean;
  104668. BUMPDIRECTUV: number;
  104669. PARALLAX: boolean;
  104670. PARALLAXOCCLUSION: boolean;
  104671. SPECULAROVERALPHA: boolean;
  104672. CLIPPLANE: boolean;
  104673. CLIPPLANE2: boolean;
  104674. CLIPPLANE3: boolean;
  104675. CLIPPLANE4: boolean;
  104676. CLIPPLANE5: boolean;
  104677. CLIPPLANE6: boolean;
  104678. ALPHATEST: boolean;
  104679. DEPTHPREPASS: boolean;
  104680. ALPHAFROMDIFFUSE: boolean;
  104681. POINTSIZE: boolean;
  104682. FOG: boolean;
  104683. SPECULARTERM: boolean;
  104684. DIFFUSEFRESNEL: boolean;
  104685. OPACITYFRESNEL: boolean;
  104686. REFLECTIONFRESNEL: boolean;
  104687. REFRACTIONFRESNEL: boolean;
  104688. EMISSIVEFRESNEL: boolean;
  104689. FRESNEL: boolean;
  104690. NORMAL: boolean;
  104691. UV1: boolean;
  104692. UV2: boolean;
  104693. VERTEXCOLOR: boolean;
  104694. VERTEXALPHA: boolean;
  104695. NUM_BONE_INFLUENCERS: number;
  104696. BonesPerMesh: number;
  104697. BONETEXTURE: boolean;
  104698. BONES_VELOCITY_ENABLED: boolean;
  104699. INSTANCES: boolean;
  104700. THIN_INSTANCES: boolean;
  104701. GLOSSINESS: boolean;
  104702. ROUGHNESS: boolean;
  104703. EMISSIVEASILLUMINATION: boolean;
  104704. LINKEMISSIVEWITHDIFFUSE: boolean;
  104705. REFLECTIONFRESNELFROMSPECULAR: boolean;
  104706. LIGHTMAP: boolean;
  104707. LIGHTMAPDIRECTUV: number;
  104708. OBJECTSPACE_NORMALMAP: boolean;
  104709. USELIGHTMAPASSHADOWMAP: boolean;
  104710. REFLECTIONMAP_3D: boolean;
  104711. REFLECTIONMAP_SPHERICAL: boolean;
  104712. REFLECTIONMAP_PLANAR: boolean;
  104713. REFLECTIONMAP_CUBIC: boolean;
  104714. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104715. REFLECTIONMAP_PROJECTION: boolean;
  104716. REFLECTIONMAP_SKYBOX: boolean;
  104717. REFLECTIONMAP_EXPLICIT: boolean;
  104718. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104719. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104720. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104721. INVERTCUBICMAP: boolean;
  104722. LOGARITHMICDEPTH: boolean;
  104723. REFRACTION: boolean;
  104724. REFRACTIONMAP_3D: boolean;
  104725. REFLECTIONOVERALPHA: boolean;
  104726. TWOSIDEDLIGHTING: boolean;
  104727. SHADOWFLOAT: boolean;
  104728. MORPHTARGETS: boolean;
  104729. MORPHTARGETS_NORMAL: boolean;
  104730. MORPHTARGETS_TANGENT: boolean;
  104731. MORPHTARGETS_UV: boolean;
  104732. NUM_MORPH_INFLUENCERS: number;
  104733. NONUNIFORMSCALING: boolean;
  104734. PREMULTIPLYALPHA: boolean;
  104735. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  104736. ALPHABLEND: boolean;
  104737. PREPASS: boolean;
  104738. PREPASS_IRRADIANCE: boolean;
  104739. PREPASS_IRRADIANCE_INDEX: number;
  104740. PREPASS_ALBEDO: boolean;
  104741. PREPASS_ALBEDO_INDEX: number;
  104742. PREPASS_DEPTHNORMAL: boolean;
  104743. PREPASS_DEPTHNORMAL_INDEX: number;
  104744. PREPASS_POSITION: boolean;
  104745. PREPASS_POSITION_INDEX: number;
  104746. PREPASS_VELOCITY: boolean;
  104747. PREPASS_VELOCITY_INDEX: number;
  104748. PREPASS_REFLECTIVITY: boolean;
  104749. PREPASS_REFLECTIVITY_INDEX: number;
  104750. SCENE_MRT_COUNT: number;
  104751. RGBDLIGHTMAP: boolean;
  104752. RGBDREFLECTION: boolean;
  104753. RGBDREFRACTION: boolean;
  104754. IMAGEPROCESSING: boolean;
  104755. VIGNETTE: boolean;
  104756. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104757. VIGNETTEBLENDMODEOPAQUE: boolean;
  104758. TONEMAPPING: boolean;
  104759. TONEMAPPING_ACES: boolean;
  104760. CONTRAST: boolean;
  104761. COLORCURVES: boolean;
  104762. COLORGRADING: boolean;
  104763. COLORGRADING3D: boolean;
  104764. SAMPLER3DGREENDEPTH: boolean;
  104765. SAMPLER3DBGRMAP: boolean;
  104766. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104767. MULTIVIEW: boolean;
  104768. /**
  104769. * If the reflection texture on this material is in linear color space
  104770. * @hidden
  104771. */
  104772. IS_REFLECTION_LINEAR: boolean;
  104773. /**
  104774. * If the refraction texture on this material is in linear color space
  104775. * @hidden
  104776. */
  104777. IS_REFRACTION_LINEAR: boolean;
  104778. EXPOSURE: boolean;
  104779. constructor();
  104780. setReflectionMode(modeToEnable: string): void;
  104781. }
  104782. /**
  104783. * This is the default material used in Babylon. It is the best trade off between quality
  104784. * and performances.
  104785. * @see https://doc.babylonjs.com/babylon101/materials
  104786. */
  104787. export class StandardMaterial extends PushMaterial {
  104788. private _diffuseTexture;
  104789. /**
  104790. * The basic texture of the material as viewed under a light.
  104791. */
  104792. diffuseTexture: Nullable<BaseTexture>;
  104793. private _ambientTexture;
  104794. /**
  104795. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  104796. */
  104797. ambientTexture: Nullable<BaseTexture>;
  104798. private _opacityTexture;
  104799. /**
  104800. * Define the transparency of the material from a texture.
  104801. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  104802. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  104803. */
  104804. opacityTexture: Nullable<BaseTexture>;
  104805. private _reflectionTexture;
  104806. /**
  104807. * Define the texture used to display the reflection.
  104808. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104809. */
  104810. reflectionTexture: Nullable<BaseTexture>;
  104811. private _emissiveTexture;
  104812. /**
  104813. * Define texture of the material as if self lit.
  104814. * This will be mixed in the final result even in the absence of light.
  104815. */
  104816. emissiveTexture: Nullable<BaseTexture>;
  104817. private _specularTexture;
  104818. /**
  104819. * Define how the color and intensity of the highlight given by the light in the material.
  104820. */
  104821. specularTexture: Nullable<BaseTexture>;
  104822. private _bumpTexture;
  104823. /**
  104824. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  104825. * 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.
  104826. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  104827. */
  104828. bumpTexture: Nullable<BaseTexture>;
  104829. private _lightmapTexture;
  104830. /**
  104831. * Complex lighting can be computationally expensive to compute at runtime.
  104832. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  104833. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  104834. */
  104835. lightmapTexture: Nullable<BaseTexture>;
  104836. private _refractionTexture;
  104837. /**
  104838. * Define the texture used to display the refraction.
  104839. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104840. */
  104841. refractionTexture: Nullable<BaseTexture>;
  104842. /**
  104843. * The color of the material lit by the environmental background lighting.
  104844. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  104845. */
  104846. ambientColor: Color3;
  104847. /**
  104848. * The basic color of the material as viewed under a light.
  104849. */
  104850. diffuseColor: Color3;
  104851. /**
  104852. * Define how the color and intensity of the highlight given by the light in the material.
  104853. */
  104854. specularColor: Color3;
  104855. /**
  104856. * Define the color of the material as if self lit.
  104857. * This will be mixed in the final result even in the absence of light.
  104858. */
  104859. emissiveColor: Color3;
  104860. /**
  104861. * Defines how sharp are the highlights in the material.
  104862. * The bigger the value the sharper giving a more glossy feeling to the result.
  104863. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  104864. */
  104865. specularPower: number;
  104866. private _useAlphaFromDiffuseTexture;
  104867. /**
  104868. * Does the transparency come from the diffuse texture alpha channel.
  104869. */
  104870. useAlphaFromDiffuseTexture: boolean;
  104871. private _useEmissiveAsIllumination;
  104872. /**
  104873. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  104874. */
  104875. useEmissiveAsIllumination: boolean;
  104876. private _linkEmissiveWithDiffuse;
  104877. /**
  104878. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  104879. * the emissive level when the final color is close to one.
  104880. */
  104881. linkEmissiveWithDiffuse: boolean;
  104882. private _useSpecularOverAlpha;
  104883. /**
  104884. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104885. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104886. */
  104887. useSpecularOverAlpha: boolean;
  104888. private _useReflectionOverAlpha;
  104889. /**
  104890. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104891. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104892. */
  104893. useReflectionOverAlpha: boolean;
  104894. private _disableLighting;
  104895. /**
  104896. * Does lights from the scene impacts this material.
  104897. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  104898. */
  104899. disableLighting: boolean;
  104900. private _useObjectSpaceNormalMap;
  104901. /**
  104902. * Allows using an object space normal map (instead of tangent space).
  104903. */
  104904. useObjectSpaceNormalMap: boolean;
  104905. private _useParallax;
  104906. /**
  104907. * Is parallax enabled or not.
  104908. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104909. */
  104910. useParallax: boolean;
  104911. private _useParallaxOcclusion;
  104912. /**
  104913. * Is parallax occlusion enabled or not.
  104914. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  104915. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104916. */
  104917. useParallaxOcclusion: boolean;
  104918. /**
  104919. * 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.
  104920. */
  104921. parallaxScaleBias: number;
  104922. private _roughness;
  104923. /**
  104924. * Helps to define how blurry the reflections should appears in the material.
  104925. */
  104926. roughness: number;
  104927. /**
  104928. * In case of refraction, define the value of the index of refraction.
  104929. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104930. */
  104931. indexOfRefraction: number;
  104932. /**
  104933. * Invert the refraction texture alongside the y axis.
  104934. * It can be useful with procedural textures or probe for instance.
  104935. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104936. */
  104937. invertRefractionY: boolean;
  104938. /**
  104939. * Defines the alpha limits in alpha test mode.
  104940. */
  104941. alphaCutOff: number;
  104942. private _useLightmapAsShadowmap;
  104943. /**
  104944. * In case of light mapping, define whether the map contains light or shadow informations.
  104945. */
  104946. useLightmapAsShadowmap: boolean;
  104947. private _diffuseFresnelParameters;
  104948. /**
  104949. * Define the diffuse fresnel parameters of the material.
  104950. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104951. */
  104952. diffuseFresnelParameters: FresnelParameters;
  104953. private _opacityFresnelParameters;
  104954. /**
  104955. * Define the opacity fresnel parameters of the material.
  104956. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104957. */
  104958. opacityFresnelParameters: FresnelParameters;
  104959. private _reflectionFresnelParameters;
  104960. /**
  104961. * Define the reflection fresnel parameters of the material.
  104962. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104963. */
  104964. reflectionFresnelParameters: FresnelParameters;
  104965. private _refractionFresnelParameters;
  104966. /**
  104967. * Define the refraction fresnel parameters of the material.
  104968. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104969. */
  104970. refractionFresnelParameters: FresnelParameters;
  104971. private _emissiveFresnelParameters;
  104972. /**
  104973. * Define the emissive fresnel parameters of the material.
  104974. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104975. */
  104976. emissiveFresnelParameters: FresnelParameters;
  104977. private _useReflectionFresnelFromSpecular;
  104978. /**
  104979. * If true automatically deducts the fresnels values from the material specularity.
  104980. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104981. */
  104982. useReflectionFresnelFromSpecular: boolean;
  104983. private _useGlossinessFromSpecularMapAlpha;
  104984. /**
  104985. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  104986. */
  104987. useGlossinessFromSpecularMapAlpha: boolean;
  104988. private _maxSimultaneousLights;
  104989. /**
  104990. * Defines the maximum number of lights that can be used in the material
  104991. */
  104992. maxSimultaneousLights: number;
  104993. private _invertNormalMapX;
  104994. /**
  104995. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104996. */
  104997. invertNormalMapX: boolean;
  104998. private _invertNormalMapY;
  104999. /**
  105000. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105001. */
  105002. invertNormalMapY: boolean;
  105003. private _twoSidedLighting;
  105004. /**
  105005. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105006. */
  105007. twoSidedLighting: boolean;
  105008. /**
  105009. * Default configuration related to image processing available in the standard Material.
  105010. */
  105011. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105012. /**
  105013. * Gets the image processing configuration used either in this material.
  105014. */
  105015. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  105016. /**
  105017. * Sets the Default image processing configuration used either in the this material.
  105018. *
  105019. * If sets to null, the scene one is in use.
  105020. */
  105021. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  105022. /**
  105023. * Keep track of the image processing observer to allow dispose and replace.
  105024. */
  105025. private _imageProcessingObserver;
  105026. /**
  105027. * Attaches a new image processing configuration to the Standard Material.
  105028. * @param configuration
  105029. */
  105030. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105031. /**
  105032. * Defines additionnal PrePass parameters for the material.
  105033. */
  105034. readonly prePassConfiguration: PrePassConfiguration;
  105035. /**
  105036. * Gets wether the color curves effect is enabled.
  105037. */
  105038. get cameraColorCurvesEnabled(): boolean;
  105039. /**
  105040. * Sets wether the color curves effect is enabled.
  105041. */
  105042. set cameraColorCurvesEnabled(value: boolean);
  105043. /**
  105044. * Gets wether the color grading effect is enabled.
  105045. */
  105046. get cameraColorGradingEnabled(): boolean;
  105047. /**
  105048. * Gets wether the color grading effect is enabled.
  105049. */
  105050. set cameraColorGradingEnabled(value: boolean);
  105051. /**
  105052. * Gets wether tonemapping is enabled or not.
  105053. */
  105054. get cameraToneMappingEnabled(): boolean;
  105055. /**
  105056. * Sets wether tonemapping is enabled or not
  105057. */
  105058. set cameraToneMappingEnabled(value: boolean);
  105059. /**
  105060. * The camera exposure used on this material.
  105061. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105062. * This corresponds to a photographic exposure.
  105063. */
  105064. get cameraExposure(): number;
  105065. /**
  105066. * The camera exposure used on this material.
  105067. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105068. * This corresponds to a photographic exposure.
  105069. */
  105070. set cameraExposure(value: number);
  105071. /**
  105072. * Gets The camera contrast used on this material.
  105073. */
  105074. get cameraContrast(): number;
  105075. /**
  105076. * Sets The camera contrast used on this material.
  105077. */
  105078. set cameraContrast(value: number);
  105079. /**
  105080. * Gets the Color Grading 2D Lookup Texture.
  105081. */
  105082. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  105083. /**
  105084. * Sets the Color Grading 2D Lookup Texture.
  105085. */
  105086. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  105087. /**
  105088. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105089. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105090. * 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;
  105091. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105092. */
  105093. get cameraColorCurves(): Nullable<ColorCurves>;
  105094. /**
  105095. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105096. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105097. * 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;
  105098. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105099. */
  105100. set cameraColorCurves(value: Nullable<ColorCurves>);
  105101. /**
  105102. * Can this material render to several textures at once
  105103. */
  105104. get canRenderToMRT(): boolean;
  105105. /**
  105106. * Defines the detail map parameters for the material.
  105107. */
  105108. readonly detailMap: DetailMapConfiguration;
  105109. protected _renderTargets: SmartArray<RenderTargetTexture>;
  105110. protected _worldViewProjectionMatrix: Matrix;
  105111. protected _globalAmbientColor: Color3;
  105112. protected _useLogarithmicDepth: boolean;
  105113. protected _rebuildInParallel: boolean;
  105114. /**
  105115. * Instantiates a new standard material.
  105116. * This is the default material used in Babylon. It is the best trade off between quality
  105117. * and performances.
  105118. * @see https://doc.babylonjs.com/babylon101/materials
  105119. * @param name Define the name of the material in the scene
  105120. * @param scene Define the scene the material belong to
  105121. */
  105122. constructor(name: string, scene: Scene);
  105123. /**
  105124. * Gets a boolean indicating that current material needs to register RTT
  105125. */
  105126. get hasRenderTargetTextures(): boolean;
  105127. /**
  105128. * Gets the current class name of the material e.g. "StandardMaterial"
  105129. * Mainly use in serialization.
  105130. * @returns the class name
  105131. */
  105132. getClassName(): string;
  105133. /**
  105134. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  105135. * You can try switching to logarithmic depth.
  105136. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  105137. */
  105138. get useLogarithmicDepth(): boolean;
  105139. set useLogarithmicDepth(value: boolean);
  105140. /**
  105141. * Specifies if the material will require alpha blending
  105142. * @returns a boolean specifying if alpha blending is needed
  105143. */
  105144. needAlphaBlending(): boolean;
  105145. /**
  105146. * Specifies if this material should be rendered in alpha test mode
  105147. * @returns a boolean specifying if an alpha test is needed.
  105148. */
  105149. needAlphaTesting(): boolean;
  105150. /**
  105151. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  105152. */
  105153. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  105154. /**
  105155. * Specifies whether or not there is a usable alpha channel for transparency.
  105156. */
  105157. protected _hasAlphaChannel(): boolean;
  105158. /**
  105159. * Get the texture used for alpha test purpose.
  105160. * @returns the diffuse texture in case of the standard material.
  105161. */
  105162. getAlphaTestTexture(): Nullable<BaseTexture>;
  105163. /**
  105164. * Get if the submesh is ready to be used and all its information available.
  105165. * Child classes can use it to update shaders
  105166. * @param mesh defines the mesh to check
  105167. * @param subMesh defines which submesh to check
  105168. * @param useInstances specifies that instances should be used
  105169. * @returns a boolean indicating that the submesh is ready or not
  105170. */
  105171. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105172. /**
  105173. * Builds the material UBO layouts.
  105174. * Used internally during the effect preparation.
  105175. */
  105176. buildUniformLayout(): void;
  105177. /**
  105178. * Unbinds the material from the mesh
  105179. */
  105180. unbind(): void;
  105181. /**
  105182. * Binds the submesh to this material by preparing the effect and shader to draw
  105183. * @param world defines the world transformation matrix
  105184. * @param mesh defines the mesh containing the submesh
  105185. * @param subMesh defines the submesh to bind the material to
  105186. */
  105187. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105188. /**
  105189. * Get the list of animatables in the material.
  105190. * @returns the list of animatables object used in the material
  105191. */
  105192. getAnimatables(): IAnimatable[];
  105193. /**
  105194. * Gets the active textures from the material
  105195. * @returns an array of textures
  105196. */
  105197. getActiveTextures(): BaseTexture[];
  105198. /**
  105199. * Specifies if the material uses a texture
  105200. * @param texture defines the texture to check against the material
  105201. * @returns a boolean specifying if the material uses the texture
  105202. */
  105203. hasTexture(texture: BaseTexture): boolean;
  105204. /**
  105205. * Disposes the material
  105206. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105207. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105208. */
  105209. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105210. /**
  105211. * Makes a duplicate of the material, and gives it a new name
  105212. * @param name defines the new name for the duplicated material
  105213. * @returns the cloned material
  105214. */
  105215. clone(name: string): StandardMaterial;
  105216. /**
  105217. * Serializes this material in a JSON representation
  105218. * @returns the serialized material object
  105219. */
  105220. serialize(): any;
  105221. /**
  105222. * Creates a standard material from parsed material data
  105223. * @param source defines the JSON representation of the material
  105224. * @param scene defines the hosting scene
  105225. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105226. * @returns a new standard material
  105227. */
  105228. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  105229. /**
  105230. * Are diffuse textures enabled in the application.
  105231. */
  105232. static get DiffuseTextureEnabled(): boolean;
  105233. static set DiffuseTextureEnabled(value: boolean);
  105234. /**
  105235. * Are detail textures enabled in the application.
  105236. */
  105237. static get DetailTextureEnabled(): boolean;
  105238. static set DetailTextureEnabled(value: boolean);
  105239. /**
  105240. * Are ambient textures enabled in the application.
  105241. */
  105242. static get AmbientTextureEnabled(): boolean;
  105243. static set AmbientTextureEnabled(value: boolean);
  105244. /**
  105245. * Are opacity textures enabled in the application.
  105246. */
  105247. static get OpacityTextureEnabled(): boolean;
  105248. static set OpacityTextureEnabled(value: boolean);
  105249. /**
  105250. * Are reflection textures enabled in the application.
  105251. */
  105252. static get ReflectionTextureEnabled(): boolean;
  105253. static set ReflectionTextureEnabled(value: boolean);
  105254. /**
  105255. * Are emissive textures enabled in the application.
  105256. */
  105257. static get EmissiveTextureEnabled(): boolean;
  105258. static set EmissiveTextureEnabled(value: boolean);
  105259. /**
  105260. * Are specular textures enabled in the application.
  105261. */
  105262. static get SpecularTextureEnabled(): boolean;
  105263. static set SpecularTextureEnabled(value: boolean);
  105264. /**
  105265. * Are bump textures enabled in the application.
  105266. */
  105267. static get BumpTextureEnabled(): boolean;
  105268. static set BumpTextureEnabled(value: boolean);
  105269. /**
  105270. * Are lightmap textures enabled in the application.
  105271. */
  105272. static get LightmapTextureEnabled(): boolean;
  105273. static set LightmapTextureEnabled(value: boolean);
  105274. /**
  105275. * Are refraction textures enabled in the application.
  105276. */
  105277. static get RefractionTextureEnabled(): boolean;
  105278. static set RefractionTextureEnabled(value: boolean);
  105279. /**
  105280. * Are color grading textures enabled in the application.
  105281. */
  105282. static get ColorGradingTextureEnabled(): boolean;
  105283. static set ColorGradingTextureEnabled(value: boolean);
  105284. /**
  105285. * Are fresnels enabled in the application.
  105286. */
  105287. static get FresnelEnabled(): boolean;
  105288. static set FresnelEnabled(value: boolean);
  105289. }
  105290. }
  105291. declare module BABYLON {
  105292. /** @hidden */
  105293. export var rgbdDecodePixelShader: {
  105294. name: string;
  105295. shader: string;
  105296. };
  105297. }
  105298. declare module BABYLON {
  105299. /**
  105300. * Class used to host RGBD texture specific utilities
  105301. */
  105302. export class RGBDTextureTools {
  105303. /**
  105304. * Expand the RGBD Texture from RGBD to Half Float if possible.
  105305. * @param texture the texture to expand.
  105306. */
  105307. static ExpandRGBDTexture(texture: Texture): void;
  105308. }
  105309. }
  105310. declare module BABYLON {
  105311. /**
  105312. * Class used to host texture specific utilities
  105313. */
  105314. export class BRDFTextureTools {
  105315. /**
  105316. * Prevents texture cache collision
  105317. */
  105318. private static _instanceNumber;
  105319. /**
  105320. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  105321. * @param scene defines the hosting scene
  105322. * @returns the environment BRDF texture
  105323. */
  105324. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  105325. private static _environmentBRDFBase64Texture;
  105326. }
  105327. }
  105328. declare module BABYLON {
  105329. /**
  105330. * @hidden
  105331. */
  105332. export interface IMaterialClearCoatDefines {
  105333. CLEARCOAT: boolean;
  105334. CLEARCOAT_DEFAULTIOR: boolean;
  105335. CLEARCOAT_TEXTURE: boolean;
  105336. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  105337. CLEARCOAT_TEXTUREDIRECTUV: number;
  105338. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  105339. CLEARCOAT_BUMP: boolean;
  105340. CLEARCOAT_BUMPDIRECTUV: number;
  105341. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  105342. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  105343. CLEARCOAT_REMAP_F0: boolean;
  105344. CLEARCOAT_TINT: boolean;
  105345. CLEARCOAT_TINT_TEXTURE: boolean;
  105346. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  105347. /** @hidden */
  105348. _areTexturesDirty: boolean;
  105349. }
  105350. /**
  105351. * Define the code related to the clear coat parameters of the pbr material.
  105352. */
  105353. export class PBRClearCoatConfiguration {
  105354. /**
  105355. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105356. * The default fits with a polyurethane material.
  105357. */
  105358. private static readonly _DefaultIndexOfRefraction;
  105359. private _isEnabled;
  105360. /**
  105361. * Defines if the clear coat is enabled in the material.
  105362. */
  105363. isEnabled: boolean;
  105364. /**
  105365. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  105366. */
  105367. intensity: number;
  105368. /**
  105369. * Defines the clear coat layer roughness.
  105370. */
  105371. roughness: number;
  105372. private _indexOfRefraction;
  105373. /**
  105374. * Defines the index of refraction of the clear coat.
  105375. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105376. * The default fits with a polyurethane material.
  105377. * Changing the default value is more performance intensive.
  105378. */
  105379. indexOfRefraction: number;
  105380. private _texture;
  105381. /**
  105382. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  105383. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  105384. * if textureRoughness is not empty, else no texture roughness is used
  105385. */
  105386. texture: Nullable<BaseTexture>;
  105387. private _useRoughnessFromMainTexture;
  105388. /**
  105389. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  105390. * If false, the green channel from textureRoughness is used for roughness
  105391. */
  105392. useRoughnessFromMainTexture: boolean;
  105393. private _textureRoughness;
  105394. /**
  105395. * Stores the clear coat roughness in a texture (green channel)
  105396. * Not used if useRoughnessFromMainTexture is true
  105397. */
  105398. textureRoughness: Nullable<BaseTexture>;
  105399. private _remapF0OnInterfaceChange;
  105400. /**
  105401. * Defines if the F0 value should be remapped to account for the interface change in the material.
  105402. */
  105403. remapF0OnInterfaceChange: boolean;
  105404. private _bumpTexture;
  105405. /**
  105406. * Define the clear coat specific bump texture.
  105407. */
  105408. bumpTexture: Nullable<BaseTexture>;
  105409. private _isTintEnabled;
  105410. /**
  105411. * Defines if the clear coat tint is enabled in the material.
  105412. */
  105413. isTintEnabled: boolean;
  105414. /**
  105415. * Defines the clear coat tint of the material.
  105416. * This is only use if tint is enabled
  105417. */
  105418. tintColor: Color3;
  105419. /**
  105420. * Defines the distance at which the tint color should be found in the
  105421. * clear coat media.
  105422. * This is only use if tint is enabled
  105423. */
  105424. tintColorAtDistance: number;
  105425. /**
  105426. * Defines the clear coat layer thickness.
  105427. * This is only use if tint is enabled
  105428. */
  105429. tintThickness: number;
  105430. private _tintTexture;
  105431. /**
  105432. * Stores the clear tint values in a texture.
  105433. * rgb is tint
  105434. * a is a thickness factor
  105435. */
  105436. tintTexture: Nullable<BaseTexture>;
  105437. /** @hidden */
  105438. private _internalMarkAllSubMeshesAsTexturesDirty;
  105439. /** @hidden */
  105440. _markAllSubMeshesAsTexturesDirty(): void;
  105441. /**
  105442. * Instantiate a new istance of clear coat configuration.
  105443. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105444. */
  105445. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105446. /**
  105447. * Gets wehter the submesh is ready to be used or not.
  105448. * @param defines the list of "defines" to update.
  105449. * @param scene defines the scene the material belongs to.
  105450. * @param engine defines the engine the material belongs to.
  105451. * @param disableBumpMap defines wether the material disables bump or not.
  105452. * @returns - boolean indicating that the submesh is ready or not.
  105453. */
  105454. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  105455. /**
  105456. * Checks to see if a texture is used in the material.
  105457. * @param defines the list of "defines" to update.
  105458. * @param scene defines the scene to the material belongs to.
  105459. */
  105460. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  105461. /**
  105462. * Binds the material data.
  105463. * @param uniformBuffer defines the Uniform buffer to fill in.
  105464. * @param scene defines the scene the material belongs to.
  105465. * @param engine defines the engine the material belongs to.
  105466. * @param disableBumpMap defines wether the material disables bump or not.
  105467. * @param isFrozen defines wether the material is frozen or not.
  105468. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105469. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105470. * @param subMesh the submesh to bind data for
  105471. */
  105472. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  105473. /**
  105474. * Checks to see if a texture is used in the material.
  105475. * @param texture - Base texture to use.
  105476. * @returns - Boolean specifying if a texture is used in the material.
  105477. */
  105478. hasTexture(texture: BaseTexture): boolean;
  105479. /**
  105480. * Returns an array of the actively used textures.
  105481. * @param activeTextures Array of BaseTextures
  105482. */
  105483. getActiveTextures(activeTextures: BaseTexture[]): void;
  105484. /**
  105485. * Returns the animatable textures.
  105486. * @param animatables Array of animatable textures.
  105487. */
  105488. getAnimatables(animatables: IAnimatable[]): void;
  105489. /**
  105490. * Disposes the resources of the material.
  105491. * @param forceDisposeTextures - Forces the disposal of all textures.
  105492. */
  105493. dispose(forceDisposeTextures?: boolean): void;
  105494. /**
  105495. * Get the current class name of the texture useful for serialization or dynamic coding.
  105496. * @returns "PBRClearCoatConfiguration"
  105497. */
  105498. getClassName(): string;
  105499. /**
  105500. * Add fallbacks to the effect fallbacks list.
  105501. * @param defines defines the Base texture to use.
  105502. * @param fallbacks defines the current fallback list.
  105503. * @param currentRank defines the current fallback rank.
  105504. * @returns the new fallback rank.
  105505. */
  105506. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105507. /**
  105508. * Add the required uniforms to the current list.
  105509. * @param uniforms defines the current uniform list.
  105510. */
  105511. static AddUniforms(uniforms: string[]): void;
  105512. /**
  105513. * Add the required samplers to the current list.
  105514. * @param samplers defines the current sampler list.
  105515. */
  105516. static AddSamplers(samplers: string[]): void;
  105517. /**
  105518. * Add the required uniforms to the current buffer.
  105519. * @param uniformBuffer defines the current uniform buffer.
  105520. */
  105521. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105522. /**
  105523. * Makes a duplicate of the current configuration into another one.
  105524. * @param clearCoatConfiguration define the config where to copy the info
  105525. */
  105526. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  105527. /**
  105528. * Serializes this clear coat configuration.
  105529. * @returns - An object with the serialized config.
  105530. */
  105531. serialize(): any;
  105532. /**
  105533. * Parses a anisotropy Configuration from a serialized object.
  105534. * @param source - Serialized object.
  105535. * @param scene Defines the scene we are parsing for
  105536. * @param rootUrl Defines the rootUrl to load from
  105537. */
  105538. parse(source: any, scene: Scene, rootUrl: string): void;
  105539. }
  105540. }
  105541. declare module BABYLON {
  105542. /**
  105543. * @hidden
  105544. */
  105545. export interface IMaterialAnisotropicDefines {
  105546. ANISOTROPIC: boolean;
  105547. ANISOTROPIC_TEXTURE: boolean;
  105548. ANISOTROPIC_TEXTUREDIRECTUV: number;
  105549. MAINUV1: boolean;
  105550. _areTexturesDirty: boolean;
  105551. _needUVs: boolean;
  105552. }
  105553. /**
  105554. * Define the code related to the anisotropic parameters of the pbr material.
  105555. */
  105556. export class PBRAnisotropicConfiguration {
  105557. private _isEnabled;
  105558. /**
  105559. * Defines if the anisotropy is enabled in the material.
  105560. */
  105561. isEnabled: boolean;
  105562. /**
  105563. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  105564. */
  105565. intensity: number;
  105566. /**
  105567. * Defines if the effect is along the tangents, bitangents or in between.
  105568. * By default, the effect is "strectching" the highlights along the tangents.
  105569. */
  105570. direction: Vector2;
  105571. private _texture;
  105572. /**
  105573. * Stores the anisotropy values in a texture.
  105574. * rg is direction (like normal from -1 to 1)
  105575. * b is a intensity
  105576. */
  105577. texture: Nullable<BaseTexture>;
  105578. /** @hidden */
  105579. private _internalMarkAllSubMeshesAsTexturesDirty;
  105580. /** @hidden */
  105581. _markAllSubMeshesAsTexturesDirty(): void;
  105582. /**
  105583. * Instantiate a new istance of anisotropy configuration.
  105584. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105585. */
  105586. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105587. /**
  105588. * Specifies that the submesh is ready to be used.
  105589. * @param defines the list of "defines" to update.
  105590. * @param scene defines the scene the material belongs to.
  105591. * @returns - boolean indicating that the submesh is ready or not.
  105592. */
  105593. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  105594. /**
  105595. * Checks to see if a texture is used in the material.
  105596. * @param defines the list of "defines" to update.
  105597. * @param mesh the mesh we are preparing the defines for.
  105598. * @param scene defines the scene the material belongs to.
  105599. */
  105600. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  105601. /**
  105602. * Binds the material data.
  105603. * @param uniformBuffer defines the Uniform buffer to fill in.
  105604. * @param scene defines the scene the material belongs to.
  105605. * @param isFrozen defines wether the material is frozen or not.
  105606. */
  105607. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  105608. /**
  105609. * Checks to see if a texture is used in the material.
  105610. * @param texture - Base texture to use.
  105611. * @returns - Boolean specifying if a texture is used in the material.
  105612. */
  105613. hasTexture(texture: BaseTexture): boolean;
  105614. /**
  105615. * Returns an array of the actively used textures.
  105616. * @param activeTextures Array of BaseTextures
  105617. */
  105618. getActiveTextures(activeTextures: BaseTexture[]): void;
  105619. /**
  105620. * Returns the animatable textures.
  105621. * @param animatables Array of animatable textures.
  105622. */
  105623. getAnimatables(animatables: IAnimatable[]): void;
  105624. /**
  105625. * Disposes the resources of the material.
  105626. * @param forceDisposeTextures - Forces the disposal of all textures.
  105627. */
  105628. dispose(forceDisposeTextures?: boolean): void;
  105629. /**
  105630. * Get the current class name of the texture useful for serialization or dynamic coding.
  105631. * @returns "PBRAnisotropicConfiguration"
  105632. */
  105633. getClassName(): string;
  105634. /**
  105635. * Add fallbacks to the effect fallbacks list.
  105636. * @param defines defines the Base texture to use.
  105637. * @param fallbacks defines the current fallback list.
  105638. * @param currentRank defines the current fallback rank.
  105639. * @returns the new fallback rank.
  105640. */
  105641. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105642. /**
  105643. * Add the required uniforms to the current list.
  105644. * @param uniforms defines the current uniform list.
  105645. */
  105646. static AddUniforms(uniforms: string[]): void;
  105647. /**
  105648. * Add the required uniforms to the current buffer.
  105649. * @param uniformBuffer defines the current uniform buffer.
  105650. */
  105651. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105652. /**
  105653. * Add the required samplers to the current list.
  105654. * @param samplers defines the current sampler list.
  105655. */
  105656. static AddSamplers(samplers: string[]): void;
  105657. /**
  105658. * Makes a duplicate of the current configuration into another one.
  105659. * @param anisotropicConfiguration define the config where to copy the info
  105660. */
  105661. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  105662. /**
  105663. * Serializes this anisotropy configuration.
  105664. * @returns - An object with the serialized config.
  105665. */
  105666. serialize(): any;
  105667. /**
  105668. * Parses a anisotropy Configuration from a serialized object.
  105669. * @param source - Serialized object.
  105670. * @param scene Defines the scene we are parsing for
  105671. * @param rootUrl Defines the rootUrl to load from
  105672. */
  105673. parse(source: any, scene: Scene, rootUrl: string): void;
  105674. }
  105675. }
  105676. declare module BABYLON {
  105677. /**
  105678. * @hidden
  105679. */
  105680. export interface IMaterialBRDFDefines {
  105681. BRDF_V_HEIGHT_CORRELATED: boolean;
  105682. MS_BRDF_ENERGY_CONSERVATION: boolean;
  105683. SPHERICAL_HARMONICS: boolean;
  105684. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  105685. /** @hidden */
  105686. _areMiscDirty: boolean;
  105687. }
  105688. /**
  105689. * Define the code related to the BRDF parameters of the pbr material.
  105690. */
  105691. export class PBRBRDFConfiguration {
  105692. /**
  105693. * Default value used for the energy conservation.
  105694. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105695. */
  105696. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  105697. /**
  105698. * Default value used for the Smith Visibility Height Correlated mode.
  105699. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105700. */
  105701. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  105702. /**
  105703. * Default value used for the IBL diffuse part.
  105704. * This can help switching back to the polynomials mode globally which is a tiny bit
  105705. * less GPU intensive at the drawback of a lower quality.
  105706. */
  105707. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  105708. /**
  105709. * Default value used for activating energy conservation for the specular workflow.
  105710. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105711. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105712. */
  105713. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  105714. private _useEnergyConservation;
  105715. /**
  105716. * Defines if the material uses energy conservation.
  105717. */
  105718. useEnergyConservation: boolean;
  105719. private _useSmithVisibilityHeightCorrelated;
  105720. /**
  105721. * LEGACY Mode set to false
  105722. * Defines if the material uses height smith correlated visibility term.
  105723. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  105724. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105725. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  105726. * Not relying on height correlated will also disable energy conservation.
  105727. */
  105728. useSmithVisibilityHeightCorrelated: boolean;
  105729. private _useSphericalHarmonics;
  105730. /**
  105731. * LEGACY Mode set to false
  105732. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  105733. * diffuse part of the IBL.
  105734. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  105735. * to the ground truth.
  105736. */
  105737. useSphericalHarmonics: boolean;
  105738. private _useSpecularGlossinessInputEnergyConservation;
  105739. /**
  105740. * Defines if the material uses energy conservation, when the specular workflow is active.
  105741. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105742. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105743. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  105744. */
  105745. useSpecularGlossinessInputEnergyConservation: boolean;
  105746. /** @hidden */
  105747. private _internalMarkAllSubMeshesAsMiscDirty;
  105748. /** @hidden */
  105749. _markAllSubMeshesAsMiscDirty(): void;
  105750. /**
  105751. * Instantiate a new istance of clear coat configuration.
  105752. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  105753. */
  105754. constructor(markAllSubMeshesAsMiscDirty: () => void);
  105755. /**
  105756. * Checks to see if a texture is used in the material.
  105757. * @param defines the list of "defines" to update.
  105758. */
  105759. prepareDefines(defines: IMaterialBRDFDefines): void;
  105760. /**
  105761. * Get the current class name of the texture useful for serialization or dynamic coding.
  105762. * @returns "PBRClearCoatConfiguration"
  105763. */
  105764. getClassName(): string;
  105765. /**
  105766. * Makes a duplicate of the current configuration into another one.
  105767. * @param brdfConfiguration define the config where to copy the info
  105768. */
  105769. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  105770. /**
  105771. * Serializes this BRDF configuration.
  105772. * @returns - An object with the serialized config.
  105773. */
  105774. serialize(): any;
  105775. /**
  105776. * Parses a anisotropy Configuration from a serialized object.
  105777. * @param source - Serialized object.
  105778. * @param scene Defines the scene we are parsing for
  105779. * @param rootUrl Defines the rootUrl to load from
  105780. */
  105781. parse(source: any, scene: Scene, rootUrl: string): void;
  105782. }
  105783. }
  105784. declare module BABYLON {
  105785. /**
  105786. * @hidden
  105787. */
  105788. export interface IMaterialSheenDefines {
  105789. SHEEN: boolean;
  105790. SHEEN_TEXTURE: boolean;
  105791. SHEEN_TEXTURE_ROUGHNESS: boolean;
  105792. SHEEN_TEXTUREDIRECTUV: number;
  105793. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  105794. SHEEN_LINKWITHALBEDO: boolean;
  105795. SHEEN_ROUGHNESS: boolean;
  105796. SHEEN_ALBEDOSCALING: boolean;
  105797. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  105798. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  105799. /** @hidden */
  105800. _areTexturesDirty: boolean;
  105801. }
  105802. /**
  105803. * Define the code related to the Sheen parameters of the pbr material.
  105804. */
  105805. export class PBRSheenConfiguration {
  105806. private _isEnabled;
  105807. /**
  105808. * Defines if the material uses sheen.
  105809. */
  105810. isEnabled: boolean;
  105811. private _linkSheenWithAlbedo;
  105812. /**
  105813. * Defines if the sheen is linked to the sheen color.
  105814. */
  105815. linkSheenWithAlbedo: boolean;
  105816. /**
  105817. * Defines the sheen intensity.
  105818. */
  105819. intensity: number;
  105820. /**
  105821. * Defines the sheen color.
  105822. */
  105823. color: Color3;
  105824. private _texture;
  105825. /**
  105826. * Stores the sheen tint values in a texture.
  105827. * rgb is tint
  105828. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  105829. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  105830. */
  105831. texture: Nullable<BaseTexture>;
  105832. private _useRoughnessFromMainTexture;
  105833. /**
  105834. * Indicates that the alpha channel of the texture property will be used for roughness.
  105835. * Has no effect if the roughness (and texture!) property is not defined
  105836. */
  105837. useRoughnessFromMainTexture: boolean;
  105838. private _roughness;
  105839. /**
  105840. * Defines the sheen roughness.
  105841. * It is not taken into account if linkSheenWithAlbedo is true.
  105842. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  105843. */
  105844. roughness: Nullable<number>;
  105845. private _textureRoughness;
  105846. /**
  105847. * Stores the sheen roughness in a texture.
  105848. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  105849. */
  105850. textureRoughness: Nullable<BaseTexture>;
  105851. private _albedoScaling;
  105852. /**
  105853. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  105854. * It allows the strength of the sheen effect to not depend on the base color of the material,
  105855. * making it easier to setup and tweak the effect
  105856. */
  105857. albedoScaling: boolean;
  105858. /** @hidden */
  105859. private _internalMarkAllSubMeshesAsTexturesDirty;
  105860. /** @hidden */
  105861. _markAllSubMeshesAsTexturesDirty(): void;
  105862. /**
  105863. * Instantiate a new istance of clear coat configuration.
  105864. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105865. */
  105866. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105867. /**
  105868. * Specifies that the submesh is ready to be used.
  105869. * @param defines the list of "defines" to update.
  105870. * @param scene defines the scene the material belongs to.
  105871. * @returns - boolean indicating that the submesh is ready or not.
  105872. */
  105873. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  105874. /**
  105875. * Checks to see if a texture is used in the material.
  105876. * @param defines the list of "defines" to update.
  105877. * @param scene defines the scene the material belongs to.
  105878. */
  105879. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  105880. /**
  105881. * Binds the material data.
  105882. * @param uniformBuffer defines the Uniform buffer to fill in.
  105883. * @param scene defines the scene the material belongs to.
  105884. * @param isFrozen defines wether the material is frozen or not.
  105885. * @param subMesh the submesh to bind data for
  105886. */
  105887. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  105888. /**
  105889. * Checks to see if a texture is used in the material.
  105890. * @param texture - Base texture to use.
  105891. * @returns - Boolean specifying if a texture is used in the material.
  105892. */
  105893. hasTexture(texture: BaseTexture): boolean;
  105894. /**
  105895. * Returns an array of the actively used textures.
  105896. * @param activeTextures Array of BaseTextures
  105897. */
  105898. getActiveTextures(activeTextures: BaseTexture[]): void;
  105899. /**
  105900. * Returns the animatable textures.
  105901. * @param animatables Array of animatable textures.
  105902. */
  105903. getAnimatables(animatables: IAnimatable[]): void;
  105904. /**
  105905. * Disposes the resources of the material.
  105906. * @param forceDisposeTextures - Forces the disposal of all textures.
  105907. */
  105908. dispose(forceDisposeTextures?: boolean): void;
  105909. /**
  105910. * Get the current class name of the texture useful for serialization or dynamic coding.
  105911. * @returns "PBRSheenConfiguration"
  105912. */
  105913. getClassName(): string;
  105914. /**
  105915. * Add fallbacks to the effect fallbacks list.
  105916. * @param defines defines the Base texture to use.
  105917. * @param fallbacks defines the current fallback list.
  105918. * @param currentRank defines the current fallback rank.
  105919. * @returns the new fallback rank.
  105920. */
  105921. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105922. /**
  105923. * Add the required uniforms to the current list.
  105924. * @param uniforms defines the current uniform list.
  105925. */
  105926. static AddUniforms(uniforms: string[]): void;
  105927. /**
  105928. * Add the required uniforms to the current buffer.
  105929. * @param uniformBuffer defines the current uniform buffer.
  105930. */
  105931. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105932. /**
  105933. * Add the required samplers to the current list.
  105934. * @param samplers defines the current sampler list.
  105935. */
  105936. static AddSamplers(samplers: string[]): void;
  105937. /**
  105938. * Makes a duplicate of the current configuration into another one.
  105939. * @param sheenConfiguration define the config where to copy the info
  105940. */
  105941. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  105942. /**
  105943. * Serializes this BRDF configuration.
  105944. * @returns - An object with the serialized config.
  105945. */
  105946. serialize(): any;
  105947. /**
  105948. * Parses a anisotropy Configuration from a serialized object.
  105949. * @param source - Serialized object.
  105950. * @param scene Defines the scene we are parsing for
  105951. * @param rootUrl Defines the rootUrl to load from
  105952. */
  105953. parse(source: any, scene: Scene, rootUrl: string): void;
  105954. }
  105955. }
  105956. declare module BABYLON {
  105957. /**
  105958. * @hidden
  105959. */
  105960. export interface IMaterialSubSurfaceDefines {
  105961. SUBSURFACE: boolean;
  105962. SS_REFRACTION: boolean;
  105963. SS_TRANSLUCENCY: boolean;
  105964. SS_SCATTERING: boolean;
  105965. SS_THICKNESSANDMASK_TEXTURE: boolean;
  105966. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  105967. SS_REFRACTIONMAP_3D: boolean;
  105968. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  105969. SS_LODINREFRACTIONALPHA: boolean;
  105970. SS_GAMMAREFRACTION: boolean;
  105971. SS_RGBDREFRACTION: boolean;
  105972. SS_LINEARSPECULARREFRACTION: boolean;
  105973. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  105974. SS_ALBEDOFORREFRACTIONTINT: boolean;
  105975. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  105976. /** @hidden */
  105977. _areTexturesDirty: boolean;
  105978. }
  105979. /**
  105980. * Define the code related to the sub surface parameters of the pbr material.
  105981. */
  105982. export class PBRSubSurfaceConfiguration {
  105983. private _isRefractionEnabled;
  105984. /**
  105985. * Defines if the refraction is enabled in the material.
  105986. */
  105987. isRefractionEnabled: boolean;
  105988. private _isTranslucencyEnabled;
  105989. /**
  105990. * Defines if the translucency is enabled in the material.
  105991. */
  105992. isTranslucencyEnabled: boolean;
  105993. private _isScatteringEnabled;
  105994. /**
  105995. * Defines if the sub surface scattering is enabled in the material.
  105996. */
  105997. isScatteringEnabled: boolean;
  105998. private _scatteringDiffusionProfileIndex;
  105999. /**
  106000. * Diffusion profile for subsurface scattering.
  106001. * Useful for better scattering in the skins or foliages.
  106002. */
  106003. get scatteringDiffusionProfile(): Nullable<Color3>;
  106004. set scatteringDiffusionProfile(c: Nullable<Color3>);
  106005. /**
  106006. * Defines the refraction intensity of the material.
  106007. * The refraction when enabled replaces the Diffuse part of the material.
  106008. * The intensity helps transitionning between diffuse and refraction.
  106009. */
  106010. refractionIntensity: number;
  106011. /**
  106012. * Defines the translucency intensity of the material.
  106013. * When translucency has been enabled, this defines how much of the "translucency"
  106014. * is addded to the diffuse part of the material.
  106015. */
  106016. translucencyIntensity: number;
  106017. /**
  106018. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  106019. */
  106020. useAlbedoToTintRefraction: boolean;
  106021. private _thicknessTexture;
  106022. /**
  106023. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  106024. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  106025. * 0 would mean minimumThickness
  106026. * 1 would mean maximumThickness
  106027. * The other channels might be use as a mask to vary the different effects intensity.
  106028. */
  106029. thicknessTexture: Nullable<BaseTexture>;
  106030. private _refractionTexture;
  106031. /**
  106032. * Defines the texture to use for refraction.
  106033. */
  106034. refractionTexture: Nullable<BaseTexture>;
  106035. private _indexOfRefraction;
  106036. /**
  106037. * Index of refraction of the material base layer.
  106038. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  106039. *
  106040. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  106041. *
  106042. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  106043. */
  106044. indexOfRefraction: number;
  106045. private _volumeIndexOfRefraction;
  106046. /**
  106047. * Index of refraction of the material's volume.
  106048. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  106049. *
  106050. * This ONLY impacts refraction. If not provided or given a non-valid value,
  106051. * the volume will use the same IOR as the surface.
  106052. */
  106053. get volumeIndexOfRefraction(): number;
  106054. set volumeIndexOfRefraction(value: number);
  106055. private _invertRefractionY;
  106056. /**
  106057. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  106058. */
  106059. invertRefractionY: boolean;
  106060. private _linkRefractionWithTransparency;
  106061. /**
  106062. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  106063. * Materials half opaque for instance using refraction could benefit from this control.
  106064. */
  106065. linkRefractionWithTransparency: boolean;
  106066. /**
  106067. * Defines the minimum thickness stored in the thickness map.
  106068. * If no thickness map is defined, this value will be used to simulate thickness.
  106069. */
  106070. minimumThickness: number;
  106071. /**
  106072. * Defines the maximum thickness stored in the thickness map.
  106073. */
  106074. maximumThickness: number;
  106075. /**
  106076. * Defines the volume tint of the material.
  106077. * This is used for both translucency and scattering.
  106078. */
  106079. tintColor: Color3;
  106080. /**
  106081. * Defines the distance at which the tint color should be found in the media.
  106082. * This is used for refraction only.
  106083. */
  106084. tintColorAtDistance: number;
  106085. /**
  106086. * Defines how far each channel transmit through the media.
  106087. * It is defined as a color to simplify it selection.
  106088. */
  106089. diffusionDistance: Color3;
  106090. private _useMaskFromThicknessTexture;
  106091. /**
  106092. * Stores the intensity of the different subsurface effects in the thickness texture.
  106093. * * the green channel is the translucency intensity.
  106094. * * the blue channel is the scattering intensity.
  106095. * * the alpha channel is the refraction intensity.
  106096. */
  106097. useMaskFromThicknessTexture: boolean;
  106098. private _scene;
  106099. /** @hidden */
  106100. private _internalMarkAllSubMeshesAsTexturesDirty;
  106101. private _internalMarkScenePrePassDirty;
  106102. /** @hidden */
  106103. _markAllSubMeshesAsTexturesDirty(): void;
  106104. /** @hidden */
  106105. _markScenePrePassDirty(): void;
  106106. /**
  106107. * Instantiate a new istance of sub surface configuration.
  106108. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106109. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  106110. * @param scene The scene
  106111. */
  106112. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  106113. /**
  106114. * Gets wehter the submesh is ready to be used or not.
  106115. * @param defines the list of "defines" to update.
  106116. * @param scene defines the scene the material belongs to.
  106117. * @returns - boolean indicating that the submesh is ready or not.
  106118. */
  106119. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  106120. /**
  106121. * Checks to see if a texture is used in the material.
  106122. * @param defines the list of "defines" to update.
  106123. * @param scene defines the scene to the material belongs to.
  106124. */
  106125. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  106126. /**
  106127. * Binds the material data.
  106128. * @param uniformBuffer defines the Uniform buffer to fill in.
  106129. * @param scene defines the scene the material belongs to.
  106130. * @param engine defines the engine the material belongs to.
  106131. * @param isFrozen defines whether the material is frozen or not.
  106132. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  106133. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  106134. */
  106135. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  106136. /**
  106137. * Unbinds the material from the mesh.
  106138. * @param activeEffect defines the effect that should be unbound from.
  106139. * @returns true if unbound, otherwise false
  106140. */
  106141. unbind(activeEffect: Effect): boolean;
  106142. /**
  106143. * Returns the texture used for refraction or null if none is used.
  106144. * @param scene defines the scene the material belongs to.
  106145. * @returns - Refraction texture if present. If no refraction texture and refraction
  106146. * is linked with transparency, returns environment texture. Otherwise, returns null.
  106147. */
  106148. private _getRefractionTexture;
  106149. /**
  106150. * Returns true if alpha blending should be disabled.
  106151. */
  106152. get disableAlphaBlending(): boolean;
  106153. /**
  106154. * Fills the list of render target textures.
  106155. * @param renderTargets the list of render targets to update
  106156. */
  106157. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  106158. /**
  106159. * Checks to see if a texture is used in the material.
  106160. * @param texture - Base texture to use.
  106161. * @returns - Boolean specifying if a texture is used in the material.
  106162. */
  106163. hasTexture(texture: BaseTexture): boolean;
  106164. /**
  106165. * Gets a boolean indicating that current material needs to register RTT
  106166. * @returns true if this uses a render target otherwise false.
  106167. */
  106168. hasRenderTargetTextures(): boolean;
  106169. /**
  106170. * Returns an array of the actively used textures.
  106171. * @param activeTextures Array of BaseTextures
  106172. */
  106173. getActiveTextures(activeTextures: BaseTexture[]): void;
  106174. /**
  106175. * Returns the animatable textures.
  106176. * @param animatables Array of animatable textures.
  106177. */
  106178. getAnimatables(animatables: IAnimatable[]): void;
  106179. /**
  106180. * Disposes the resources of the material.
  106181. * @param forceDisposeTextures - Forces the disposal of all textures.
  106182. */
  106183. dispose(forceDisposeTextures?: boolean): void;
  106184. /**
  106185. * Get the current class name of the texture useful for serialization or dynamic coding.
  106186. * @returns "PBRSubSurfaceConfiguration"
  106187. */
  106188. getClassName(): string;
  106189. /**
  106190. * Add fallbacks to the effect fallbacks list.
  106191. * @param defines defines the Base texture to use.
  106192. * @param fallbacks defines the current fallback list.
  106193. * @param currentRank defines the current fallback rank.
  106194. * @returns the new fallback rank.
  106195. */
  106196. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106197. /**
  106198. * Add the required uniforms to the current list.
  106199. * @param uniforms defines the current uniform list.
  106200. */
  106201. static AddUniforms(uniforms: string[]): void;
  106202. /**
  106203. * Add the required samplers to the current list.
  106204. * @param samplers defines the current sampler list.
  106205. */
  106206. static AddSamplers(samplers: string[]): void;
  106207. /**
  106208. * Add the required uniforms to the current buffer.
  106209. * @param uniformBuffer defines the current uniform buffer.
  106210. */
  106211. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106212. /**
  106213. * Makes a duplicate of the current configuration into another one.
  106214. * @param configuration define the config where to copy the info
  106215. */
  106216. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  106217. /**
  106218. * Serializes this Sub Surface configuration.
  106219. * @returns - An object with the serialized config.
  106220. */
  106221. serialize(): any;
  106222. /**
  106223. * Parses a anisotropy Configuration from a serialized object.
  106224. * @param source - Serialized object.
  106225. * @param scene Defines the scene we are parsing for
  106226. * @param rootUrl Defines the rootUrl to load from
  106227. */
  106228. parse(source: any, scene: Scene, rootUrl: string): void;
  106229. }
  106230. }
  106231. declare module BABYLON {
  106232. /**
  106233. * Class representing spherical harmonics coefficients to the 3rd degree
  106234. */
  106235. export class SphericalHarmonics {
  106236. /**
  106237. * Defines whether or not the harmonics have been prescaled for rendering.
  106238. */
  106239. preScaled: boolean;
  106240. /**
  106241. * The l0,0 coefficients of the spherical harmonics
  106242. */
  106243. l00: Vector3;
  106244. /**
  106245. * The l1,-1 coefficients of the spherical harmonics
  106246. */
  106247. l1_1: Vector3;
  106248. /**
  106249. * The l1,0 coefficients of the spherical harmonics
  106250. */
  106251. l10: Vector3;
  106252. /**
  106253. * The l1,1 coefficients of the spherical harmonics
  106254. */
  106255. l11: Vector3;
  106256. /**
  106257. * The l2,-2 coefficients of the spherical harmonics
  106258. */
  106259. l2_2: Vector3;
  106260. /**
  106261. * The l2,-1 coefficients of the spherical harmonics
  106262. */
  106263. l2_1: Vector3;
  106264. /**
  106265. * The l2,0 coefficients of the spherical harmonics
  106266. */
  106267. l20: Vector3;
  106268. /**
  106269. * The l2,1 coefficients of the spherical harmonics
  106270. */
  106271. l21: Vector3;
  106272. /**
  106273. * The l2,2 coefficients of the spherical harmonics
  106274. */
  106275. l22: Vector3;
  106276. /**
  106277. * Adds a light to the spherical harmonics
  106278. * @param direction the direction of the light
  106279. * @param color the color of the light
  106280. * @param deltaSolidAngle the delta solid angle of the light
  106281. */
  106282. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  106283. /**
  106284. * Scales the spherical harmonics by the given amount
  106285. * @param scale the amount to scale
  106286. */
  106287. scaleInPlace(scale: number): void;
  106288. /**
  106289. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106290. *
  106291. * ```
  106292. * E_lm = A_l * L_lm
  106293. * ```
  106294. *
  106295. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106296. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106297. * the scaling factors are given in equation 9.
  106298. */
  106299. convertIncidentRadianceToIrradiance(): void;
  106300. /**
  106301. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106302. *
  106303. * ```
  106304. * L = (1/pi) * E * rho
  106305. * ```
  106306. *
  106307. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106308. */
  106309. convertIrradianceToLambertianRadiance(): void;
  106310. /**
  106311. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106312. * required operations at run time.
  106313. *
  106314. * This is simply done by scaling back the SH with Ylm constants parameter.
  106315. * The trigonometric part being applied by the shader at run time.
  106316. */
  106317. preScaleForRendering(): void;
  106318. /**
  106319. * Constructs a spherical harmonics from an array.
  106320. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106321. * @returns the spherical harmonics
  106322. */
  106323. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106324. /**
  106325. * Gets the spherical harmonics from polynomial
  106326. * @param polynomial the spherical polynomial
  106327. * @returns the spherical harmonics
  106328. */
  106329. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106330. }
  106331. /**
  106332. * Class representing spherical polynomial coefficients to the 3rd degree
  106333. */
  106334. export class SphericalPolynomial {
  106335. private _harmonics;
  106336. /**
  106337. * The spherical harmonics used to create the polynomials.
  106338. */
  106339. get preScaledHarmonics(): SphericalHarmonics;
  106340. /**
  106341. * The x coefficients of the spherical polynomial
  106342. */
  106343. x: Vector3;
  106344. /**
  106345. * The y coefficients of the spherical polynomial
  106346. */
  106347. y: Vector3;
  106348. /**
  106349. * The z coefficients of the spherical polynomial
  106350. */
  106351. z: Vector3;
  106352. /**
  106353. * The xx coefficients of the spherical polynomial
  106354. */
  106355. xx: Vector3;
  106356. /**
  106357. * The yy coefficients of the spherical polynomial
  106358. */
  106359. yy: Vector3;
  106360. /**
  106361. * The zz coefficients of the spherical polynomial
  106362. */
  106363. zz: Vector3;
  106364. /**
  106365. * The xy coefficients of the spherical polynomial
  106366. */
  106367. xy: Vector3;
  106368. /**
  106369. * The yz coefficients of the spherical polynomial
  106370. */
  106371. yz: Vector3;
  106372. /**
  106373. * The zx coefficients of the spherical polynomial
  106374. */
  106375. zx: Vector3;
  106376. /**
  106377. * Adds an ambient color to the spherical polynomial
  106378. * @param color the color to add
  106379. */
  106380. addAmbient(color: Color3): void;
  106381. /**
  106382. * Scales the spherical polynomial by the given amount
  106383. * @param scale the amount to scale
  106384. */
  106385. scaleInPlace(scale: number): void;
  106386. /**
  106387. * Gets the spherical polynomial from harmonics
  106388. * @param harmonics the spherical harmonics
  106389. * @returns the spherical polynomial
  106390. */
  106391. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  106392. /**
  106393. * Constructs a spherical polynomial from an array.
  106394. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  106395. * @returns the spherical polynomial
  106396. */
  106397. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  106398. }
  106399. }
  106400. declare module BABYLON {
  106401. /**
  106402. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  106403. */
  106404. export interface CubeMapInfo {
  106405. /**
  106406. * The pixel array for the front face.
  106407. * This is stored in format, left to right, up to down format.
  106408. */
  106409. front: Nullable<ArrayBufferView>;
  106410. /**
  106411. * The pixel array for the back face.
  106412. * This is stored in format, left to right, up to down format.
  106413. */
  106414. back: Nullable<ArrayBufferView>;
  106415. /**
  106416. * The pixel array for the left face.
  106417. * This is stored in format, left to right, up to down format.
  106418. */
  106419. left: Nullable<ArrayBufferView>;
  106420. /**
  106421. * The pixel array for the right face.
  106422. * This is stored in format, left to right, up to down format.
  106423. */
  106424. right: Nullable<ArrayBufferView>;
  106425. /**
  106426. * The pixel array for the up face.
  106427. * This is stored in format, left to right, up to down format.
  106428. */
  106429. up: Nullable<ArrayBufferView>;
  106430. /**
  106431. * The pixel array for the down face.
  106432. * This is stored in format, left to right, up to down format.
  106433. */
  106434. down: Nullable<ArrayBufferView>;
  106435. /**
  106436. * The size of the cubemap stored.
  106437. *
  106438. * Each faces will be size * size pixels.
  106439. */
  106440. size: number;
  106441. /**
  106442. * The format of the texture.
  106443. *
  106444. * RGBA, RGB.
  106445. */
  106446. format: number;
  106447. /**
  106448. * The type of the texture data.
  106449. *
  106450. * UNSIGNED_INT, FLOAT.
  106451. */
  106452. type: number;
  106453. /**
  106454. * Specifies whether the texture is in gamma space.
  106455. */
  106456. gammaSpace: boolean;
  106457. }
  106458. /**
  106459. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  106460. */
  106461. export class PanoramaToCubeMapTools {
  106462. private static FACE_LEFT;
  106463. private static FACE_RIGHT;
  106464. private static FACE_FRONT;
  106465. private static FACE_BACK;
  106466. private static FACE_DOWN;
  106467. private static FACE_UP;
  106468. /**
  106469. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  106470. *
  106471. * @param float32Array The source data.
  106472. * @param inputWidth The width of the input panorama.
  106473. * @param inputHeight The height of the input panorama.
  106474. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  106475. * @return The cubemap data
  106476. */
  106477. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  106478. private static CreateCubemapTexture;
  106479. private static CalcProjectionSpherical;
  106480. }
  106481. }
  106482. declare module BABYLON {
  106483. /**
  106484. * Helper class dealing with the extraction of spherical polynomial dataArray
  106485. * from a cube map.
  106486. */
  106487. export class CubeMapToSphericalPolynomialTools {
  106488. private static FileFaces;
  106489. /**
  106490. * Converts a texture to the according Spherical Polynomial data.
  106491. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106492. *
  106493. * @param texture The texture to extract the information from.
  106494. * @return The Spherical Polynomial data.
  106495. */
  106496. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  106497. /**
  106498. * Converts a cubemap to the according Spherical Polynomial data.
  106499. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106500. *
  106501. * @param cubeInfo The Cube map to extract the information from.
  106502. * @return The Spherical Polynomial data.
  106503. */
  106504. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  106505. }
  106506. }
  106507. declare module BABYLON {
  106508. interface BaseTexture {
  106509. /**
  106510. * Get the polynomial representation of the texture data.
  106511. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  106512. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  106513. */
  106514. sphericalPolynomial: Nullable<SphericalPolynomial>;
  106515. }
  106516. }
  106517. declare module BABYLON {
  106518. /** @hidden */
  106519. export var pbrFragmentDeclaration: {
  106520. name: string;
  106521. shader: string;
  106522. };
  106523. }
  106524. declare module BABYLON {
  106525. /** @hidden */
  106526. export var pbrUboDeclaration: {
  106527. name: string;
  106528. shader: string;
  106529. };
  106530. }
  106531. declare module BABYLON {
  106532. /** @hidden */
  106533. export var pbrFragmentExtraDeclaration: {
  106534. name: string;
  106535. shader: string;
  106536. };
  106537. }
  106538. declare module BABYLON {
  106539. /** @hidden */
  106540. export var pbrFragmentSamplersDeclaration: {
  106541. name: string;
  106542. shader: string;
  106543. };
  106544. }
  106545. declare module BABYLON {
  106546. /** @hidden */
  106547. export var subSurfaceScatteringFunctions: {
  106548. name: string;
  106549. shader: string;
  106550. };
  106551. }
  106552. declare module BABYLON {
  106553. /** @hidden */
  106554. export var importanceSampling: {
  106555. name: string;
  106556. shader: string;
  106557. };
  106558. }
  106559. declare module BABYLON {
  106560. /** @hidden */
  106561. export var pbrHelperFunctions: {
  106562. name: string;
  106563. shader: string;
  106564. };
  106565. }
  106566. declare module BABYLON {
  106567. /** @hidden */
  106568. export var harmonicsFunctions: {
  106569. name: string;
  106570. shader: string;
  106571. };
  106572. }
  106573. declare module BABYLON {
  106574. /** @hidden */
  106575. export var pbrDirectLightingSetupFunctions: {
  106576. name: string;
  106577. shader: string;
  106578. };
  106579. }
  106580. declare module BABYLON {
  106581. /** @hidden */
  106582. export var pbrDirectLightingFalloffFunctions: {
  106583. name: string;
  106584. shader: string;
  106585. };
  106586. }
  106587. declare module BABYLON {
  106588. /** @hidden */
  106589. export var pbrBRDFFunctions: {
  106590. name: string;
  106591. shader: string;
  106592. };
  106593. }
  106594. declare module BABYLON {
  106595. /** @hidden */
  106596. export var hdrFilteringFunctions: {
  106597. name: string;
  106598. shader: string;
  106599. };
  106600. }
  106601. declare module BABYLON {
  106602. /** @hidden */
  106603. export var pbrDirectLightingFunctions: {
  106604. name: string;
  106605. shader: string;
  106606. };
  106607. }
  106608. declare module BABYLON {
  106609. /** @hidden */
  106610. export var pbrIBLFunctions: {
  106611. name: string;
  106612. shader: string;
  106613. };
  106614. }
  106615. declare module BABYLON {
  106616. /** @hidden */
  106617. export var pbrBlockAlbedoOpacity: {
  106618. name: string;
  106619. shader: string;
  106620. };
  106621. }
  106622. declare module BABYLON {
  106623. /** @hidden */
  106624. export var pbrBlockReflectivity: {
  106625. name: string;
  106626. shader: string;
  106627. };
  106628. }
  106629. declare module BABYLON {
  106630. /** @hidden */
  106631. export var pbrBlockAmbientOcclusion: {
  106632. name: string;
  106633. shader: string;
  106634. };
  106635. }
  106636. declare module BABYLON {
  106637. /** @hidden */
  106638. export var pbrBlockAlphaFresnel: {
  106639. name: string;
  106640. shader: string;
  106641. };
  106642. }
  106643. declare module BABYLON {
  106644. /** @hidden */
  106645. export var pbrBlockAnisotropic: {
  106646. name: string;
  106647. shader: string;
  106648. };
  106649. }
  106650. declare module BABYLON {
  106651. /** @hidden */
  106652. export var pbrBlockReflection: {
  106653. name: string;
  106654. shader: string;
  106655. };
  106656. }
  106657. declare module BABYLON {
  106658. /** @hidden */
  106659. export var pbrBlockSheen: {
  106660. name: string;
  106661. shader: string;
  106662. };
  106663. }
  106664. declare module BABYLON {
  106665. /** @hidden */
  106666. export var pbrBlockClearcoat: {
  106667. name: string;
  106668. shader: string;
  106669. };
  106670. }
  106671. declare module BABYLON {
  106672. /** @hidden */
  106673. export var pbrBlockSubSurface: {
  106674. name: string;
  106675. shader: string;
  106676. };
  106677. }
  106678. declare module BABYLON {
  106679. /** @hidden */
  106680. export var pbrBlockNormalGeometric: {
  106681. name: string;
  106682. shader: string;
  106683. };
  106684. }
  106685. declare module BABYLON {
  106686. /** @hidden */
  106687. export var pbrBlockNormalFinal: {
  106688. name: string;
  106689. shader: string;
  106690. };
  106691. }
  106692. declare module BABYLON {
  106693. /** @hidden */
  106694. export var pbrBlockLightmapInit: {
  106695. name: string;
  106696. shader: string;
  106697. };
  106698. }
  106699. declare module BABYLON {
  106700. /** @hidden */
  106701. export var pbrBlockGeometryInfo: {
  106702. name: string;
  106703. shader: string;
  106704. };
  106705. }
  106706. declare module BABYLON {
  106707. /** @hidden */
  106708. export var pbrBlockReflectance0: {
  106709. name: string;
  106710. shader: string;
  106711. };
  106712. }
  106713. declare module BABYLON {
  106714. /** @hidden */
  106715. export var pbrBlockReflectance: {
  106716. name: string;
  106717. shader: string;
  106718. };
  106719. }
  106720. declare module BABYLON {
  106721. /** @hidden */
  106722. export var pbrBlockDirectLighting: {
  106723. name: string;
  106724. shader: string;
  106725. };
  106726. }
  106727. declare module BABYLON {
  106728. /** @hidden */
  106729. export var pbrBlockFinalLitComponents: {
  106730. name: string;
  106731. shader: string;
  106732. };
  106733. }
  106734. declare module BABYLON {
  106735. /** @hidden */
  106736. export var pbrBlockFinalUnlitComponents: {
  106737. name: string;
  106738. shader: string;
  106739. };
  106740. }
  106741. declare module BABYLON {
  106742. /** @hidden */
  106743. export var pbrBlockFinalColorComposition: {
  106744. name: string;
  106745. shader: string;
  106746. };
  106747. }
  106748. declare module BABYLON {
  106749. /** @hidden */
  106750. export var pbrBlockImageProcessing: {
  106751. name: string;
  106752. shader: string;
  106753. };
  106754. }
  106755. declare module BABYLON {
  106756. /** @hidden */
  106757. export var pbrDebug: {
  106758. name: string;
  106759. shader: string;
  106760. };
  106761. }
  106762. declare module BABYLON {
  106763. /** @hidden */
  106764. export var pbrPixelShader: {
  106765. name: string;
  106766. shader: string;
  106767. };
  106768. }
  106769. declare module BABYLON {
  106770. /** @hidden */
  106771. export var pbrVertexDeclaration: {
  106772. name: string;
  106773. shader: string;
  106774. };
  106775. }
  106776. declare module BABYLON {
  106777. /** @hidden */
  106778. export var pbrVertexShader: {
  106779. name: string;
  106780. shader: string;
  106781. };
  106782. }
  106783. declare module BABYLON {
  106784. /**
  106785. * Manages the defines for the PBR Material.
  106786. * @hidden
  106787. */
  106788. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  106789. PBR: boolean;
  106790. NUM_SAMPLES: string;
  106791. REALTIME_FILTERING: boolean;
  106792. MAINUV1: boolean;
  106793. MAINUV2: boolean;
  106794. UV1: boolean;
  106795. UV2: boolean;
  106796. ALBEDO: boolean;
  106797. GAMMAALBEDO: boolean;
  106798. ALBEDODIRECTUV: number;
  106799. VERTEXCOLOR: boolean;
  106800. DETAIL: boolean;
  106801. DETAILDIRECTUV: number;
  106802. DETAIL_NORMALBLENDMETHOD: number;
  106803. AMBIENT: boolean;
  106804. AMBIENTDIRECTUV: number;
  106805. AMBIENTINGRAYSCALE: boolean;
  106806. OPACITY: boolean;
  106807. VERTEXALPHA: boolean;
  106808. OPACITYDIRECTUV: number;
  106809. OPACITYRGB: boolean;
  106810. ALPHATEST: boolean;
  106811. DEPTHPREPASS: boolean;
  106812. ALPHABLEND: boolean;
  106813. ALPHAFROMALBEDO: boolean;
  106814. ALPHATESTVALUE: string;
  106815. SPECULAROVERALPHA: boolean;
  106816. RADIANCEOVERALPHA: boolean;
  106817. ALPHAFRESNEL: boolean;
  106818. LINEARALPHAFRESNEL: boolean;
  106819. PREMULTIPLYALPHA: boolean;
  106820. EMISSIVE: boolean;
  106821. EMISSIVEDIRECTUV: number;
  106822. REFLECTIVITY: boolean;
  106823. REFLECTIVITYDIRECTUV: number;
  106824. SPECULARTERM: boolean;
  106825. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  106826. MICROSURFACEAUTOMATIC: boolean;
  106827. LODBASEDMICROSFURACE: boolean;
  106828. MICROSURFACEMAP: boolean;
  106829. MICROSURFACEMAPDIRECTUV: number;
  106830. METALLICWORKFLOW: boolean;
  106831. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  106832. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  106833. METALLNESSSTOREINMETALMAPBLUE: boolean;
  106834. AOSTOREINMETALMAPRED: boolean;
  106835. METALLIC_REFLECTANCE: boolean;
  106836. METALLIC_REFLECTANCEDIRECTUV: number;
  106837. ENVIRONMENTBRDF: boolean;
  106838. ENVIRONMENTBRDF_RGBD: boolean;
  106839. NORMAL: boolean;
  106840. TANGENT: boolean;
  106841. BUMP: boolean;
  106842. BUMPDIRECTUV: number;
  106843. OBJECTSPACE_NORMALMAP: boolean;
  106844. PARALLAX: boolean;
  106845. PARALLAXOCCLUSION: boolean;
  106846. NORMALXYSCALE: boolean;
  106847. LIGHTMAP: boolean;
  106848. LIGHTMAPDIRECTUV: number;
  106849. USELIGHTMAPASSHADOWMAP: boolean;
  106850. GAMMALIGHTMAP: boolean;
  106851. RGBDLIGHTMAP: boolean;
  106852. REFLECTION: boolean;
  106853. REFLECTIONMAP_3D: boolean;
  106854. REFLECTIONMAP_SPHERICAL: boolean;
  106855. REFLECTIONMAP_PLANAR: boolean;
  106856. REFLECTIONMAP_CUBIC: boolean;
  106857. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106858. REFLECTIONMAP_PROJECTION: boolean;
  106859. REFLECTIONMAP_SKYBOX: boolean;
  106860. REFLECTIONMAP_EXPLICIT: boolean;
  106861. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106862. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106863. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106864. INVERTCUBICMAP: boolean;
  106865. USESPHERICALFROMREFLECTIONMAP: boolean;
  106866. USEIRRADIANCEMAP: boolean;
  106867. SPHERICAL_HARMONICS: boolean;
  106868. USESPHERICALINVERTEX: boolean;
  106869. REFLECTIONMAP_OPPOSITEZ: boolean;
  106870. LODINREFLECTIONALPHA: boolean;
  106871. GAMMAREFLECTION: boolean;
  106872. RGBDREFLECTION: boolean;
  106873. LINEARSPECULARREFLECTION: boolean;
  106874. RADIANCEOCCLUSION: boolean;
  106875. HORIZONOCCLUSION: boolean;
  106876. INSTANCES: boolean;
  106877. THIN_INSTANCES: boolean;
  106878. PREPASS: boolean;
  106879. PREPASS_IRRADIANCE: boolean;
  106880. PREPASS_IRRADIANCE_INDEX: number;
  106881. PREPASS_ALBEDO: boolean;
  106882. PREPASS_ALBEDO_INDEX: number;
  106883. PREPASS_DEPTHNORMAL: boolean;
  106884. PREPASS_DEPTHNORMAL_INDEX: number;
  106885. PREPASS_POSITION: boolean;
  106886. PREPASS_POSITION_INDEX: number;
  106887. PREPASS_VELOCITY: boolean;
  106888. PREPASS_VELOCITY_INDEX: number;
  106889. PREPASS_REFLECTIVITY: boolean;
  106890. PREPASS_REFLECTIVITY_INDEX: number;
  106891. SCENE_MRT_COUNT: number;
  106892. NUM_BONE_INFLUENCERS: number;
  106893. BonesPerMesh: number;
  106894. BONETEXTURE: boolean;
  106895. BONES_VELOCITY_ENABLED: boolean;
  106896. NONUNIFORMSCALING: boolean;
  106897. MORPHTARGETS: boolean;
  106898. MORPHTARGETS_NORMAL: boolean;
  106899. MORPHTARGETS_TANGENT: boolean;
  106900. MORPHTARGETS_UV: boolean;
  106901. NUM_MORPH_INFLUENCERS: number;
  106902. IMAGEPROCESSING: boolean;
  106903. VIGNETTE: boolean;
  106904. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106905. VIGNETTEBLENDMODEOPAQUE: boolean;
  106906. TONEMAPPING: boolean;
  106907. TONEMAPPING_ACES: boolean;
  106908. CONTRAST: boolean;
  106909. COLORCURVES: boolean;
  106910. COLORGRADING: boolean;
  106911. COLORGRADING3D: boolean;
  106912. SAMPLER3DGREENDEPTH: boolean;
  106913. SAMPLER3DBGRMAP: boolean;
  106914. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106915. EXPOSURE: boolean;
  106916. MULTIVIEW: boolean;
  106917. USEPHYSICALLIGHTFALLOFF: boolean;
  106918. USEGLTFLIGHTFALLOFF: boolean;
  106919. TWOSIDEDLIGHTING: boolean;
  106920. SHADOWFLOAT: boolean;
  106921. CLIPPLANE: boolean;
  106922. CLIPPLANE2: boolean;
  106923. CLIPPLANE3: boolean;
  106924. CLIPPLANE4: boolean;
  106925. CLIPPLANE5: boolean;
  106926. CLIPPLANE6: boolean;
  106927. POINTSIZE: boolean;
  106928. FOG: boolean;
  106929. LOGARITHMICDEPTH: boolean;
  106930. FORCENORMALFORWARD: boolean;
  106931. SPECULARAA: boolean;
  106932. CLEARCOAT: boolean;
  106933. CLEARCOAT_DEFAULTIOR: boolean;
  106934. CLEARCOAT_TEXTURE: boolean;
  106935. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  106936. CLEARCOAT_TEXTUREDIRECTUV: number;
  106937. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  106938. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106939. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106940. CLEARCOAT_BUMP: boolean;
  106941. CLEARCOAT_BUMPDIRECTUV: number;
  106942. CLEARCOAT_REMAP_F0: boolean;
  106943. CLEARCOAT_TINT: boolean;
  106944. CLEARCOAT_TINT_TEXTURE: boolean;
  106945. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  106946. ANISOTROPIC: boolean;
  106947. ANISOTROPIC_TEXTURE: boolean;
  106948. ANISOTROPIC_TEXTUREDIRECTUV: number;
  106949. BRDF_V_HEIGHT_CORRELATED: boolean;
  106950. MS_BRDF_ENERGY_CONSERVATION: boolean;
  106951. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  106952. SHEEN: boolean;
  106953. SHEEN_TEXTURE: boolean;
  106954. SHEEN_TEXTURE_ROUGHNESS: boolean;
  106955. SHEEN_TEXTUREDIRECTUV: number;
  106956. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  106957. SHEEN_LINKWITHALBEDO: boolean;
  106958. SHEEN_ROUGHNESS: boolean;
  106959. SHEEN_ALBEDOSCALING: boolean;
  106960. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106961. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106962. SUBSURFACE: boolean;
  106963. SS_REFRACTION: boolean;
  106964. SS_TRANSLUCENCY: boolean;
  106965. SS_SCATTERING: boolean;
  106966. SS_THICKNESSANDMASK_TEXTURE: boolean;
  106967. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  106968. SS_REFRACTIONMAP_3D: boolean;
  106969. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  106970. SS_LODINREFRACTIONALPHA: boolean;
  106971. SS_GAMMAREFRACTION: boolean;
  106972. SS_RGBDREFRACTION: boolean;
  106973. SS_LINEARSPECULARREFRACTION: boolean;
  106974. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  106975. SS_ALBEDOFORREFRACTIONTINT: boolean;
  106976. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  106977. UNLIT: boolean;
  106978. DEBUGMODE: number;
  106979. /**
  106980. * Initializes the PBR Material defines.
  106981. */
  106982. constructor();
  106983. /**
  106984. * Resets the PBR Material defines.
  106985. */
  106986. reset(): void;
  106987. }
  106988. /**
  106989. * The Physically based material base class of BJS.
  106990. *
  106991. * This offers the main features of a standard PBR material.
  106992. * For more information, please refer to the documentation :
  106993. * https://doc.babylonjs.com/how_to/physically_based_rendering
  106994. */
  106995. export abstract class PBRBaseMaterial extends PushMaterial {
  106996. /**
  106997. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  106998. */
  106999. static readonly PBRMATERIAL_OPAQUE: number;
  107000. /**
  107001. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107002. */
  107003. static readonly PBRMATERIAL_ALPHATEST: number;
  107004. /**
  107005. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107006. */
  107007. static readonly PBRMATERIAL_ALPHABLEND: number;
  107008. /**
  107009. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107010. * They are also discarded below the alpha cutoff threshold to improve performances.
  107011. */
  107012. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107013. /**
  107014. * Defines the default value of how much AO map is occluding the analytical lights
  107015. * (point spot...).
  107016. */
  107017. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107018. /**
  107019. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  107020. */
  107021. static readonly LIGHTFALLOFF_PHYSICAL: number;
  107022. /**
  107023. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  107024. * to enhance interoperability with other engines.
  107025. */
  107026. static readonly LIGHTFALLOFF_GLTF: number;
  107027. /**
  107028. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  107029. * to enhance interoperability with other materials.
  107030. */
  107031. static readonly LIGHTFALLOFF_STANDARD: number;
  107032. /**
  107033. * Intensity of the direct lights e.g. the four lights available in your scene.
  107034. * This impacts both the direct diffuse and specular highlights.
  107035. */
  107036. protected _directIntensity: number;
  107037. /**
  107038. * Intensity of the emissive part of the material.
  107039. * This helps controlling the emissive effect without modifying the emissive color.
  107040. */
  107041. protected _emissiveIntensity: number;
  107042. /**
  107043. * Intensity of the environment e.g. how much the environment will light the object
  107044. * either through harmonics for rough material or through the refelction for shiny ones.
  107045. */
  107046. protected _environmentIntensity: number;
  107047. /**
  107048. * This is a special control allowing the reduction of the specular highlights coming from the
  107049. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107050. */
  107051. protected _specularIntensity: number;
  107052. /**
  107053. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  107054. */
  107055. private _lightingInfos;
  107056. /**
  107057. * Debug Control allowing disabling the bump map on this material.
  107058. */
  107059. protected _disableBumpMap: boolean;
  107060. /**
  107061. * AKA Diffuse Texture in standard nomenclature.
  107062. */
  107063. protected _albedoTexture: Nullable<BaseTexture>;
  107064. /**
  107065. * AKA Occlusion Texture in other nomenclature.
  107066. */
  107067. protected _ambientTexture: Nullable<BaseTexture>;
  107068. /**
  107069. * AKA Occlusion Texture Intensity in other nomenclature.
  107070. */
  107071. protected _ambientTextureStrength: number;
  107072. /**
  107073. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107074. * 1 means it completely occludes it
  107075. * 0 mean it has no impact
  107076. */
  107077. protected _ambientTextureImpactOnAnalyticalLights: number;
  107078. /**
  107079. * Stores the alpha values in a texture.
  107080. */
  107081. protected _opacityTexture: Nullable<BaseTexture>;
  107082. /**
  107083. * Stores the reflection values in a texture.
  107084. */
  107085. protected _reflectionTexture: Nullable<BaseTexture>;
  107086. /**
  107087. * Stores the emissive values in a texture.
  107088. */
  107089. protected _emissiveTexture: Nullable<BaseTexture>;
  107090. /**
  107091. * AKA Specular texture in other nomenclature.
  107092. */
  107093. protected _reflectivityTexture: Nullable<BaseTexture>;
  107094. /**
  107095. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107096. */
  107097. protected _metallicTexture: Nullable<BaseTexture>;
  107098. /**
  107099. * Specifies the metallic scalar of the metallic/roughness workflow.
  107100. * Can also be used to scale the metalness values of the metallic texture.
  107101. */
  107102. protected _metallic: Nullable<number>;
  107103. /**
  107104. * Specifies the roughness scalar of the metallic/roughness workflow.
  107105. * Can also be used to scale the roughness values of the metallic texture.
  107106. */
  107107. protected _roughness: Nullable<number>;
  107108. /**
  107109. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  107110. * By default the indexOfrefraction is used to compute F0;
  107111. *
  107112. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  107113. *
  107114. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  107115. * F90 = metallicReflectanceColor;
  107116. */
  107117. protected _metallicF0Factor: number;
  107118. /**
  107119. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  107120. * By default the F90 is always 1;
  107121. *
  107122. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  107123. *
  107124. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  107125. * F90 = metallicReflectanceColor;
  107126. */
  107127. protected _metallicReflectanceColor: Color3;
  107128. /**
  107129. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  107130. * This is multiply against the scalar values defined in the material.
  107131. */
  107132. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  107133. /**
  107134. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107135. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107136. */
  107137. protected _microSurfaceTexture: Nullable<BaseTexture>;
  107138. /**
  107139. * Stores surface normal data used to displace a mesh in a texture.
  107140. */
  107141. protected _bumpTexture: Nullable<BaseTexture>;
  107142. /**
  107143. * Stores the pre-calculated light information of a mesh in a texture.
  107144. */
  107145. protected _lightmapTexture: Nullable<BaseTexture>;
  107146. /**
  107147. * The color of a material in ambient lighting.
  107148. */
  107149. protected _ambientColor: Color3;
  107150. /**
  107151. * AKA Diffuse Color in other nomenclature.
  107152. */
  107153. protected _albedoColor: Color3;
  107154. /**
  107155. * AKA Specular Color in other nomenclature.
  107156. */
  107157. protected _reflectivityColor: Color3;
  107158. /**
  107159. * The color applied when light is reflected from a material.
  107160. */
  107161. protected _reflectionColor: Color3;
  107162. /**
  107163. * The color applied when light is emitted from a material.
  107164. */
  107165. protected _emissiveColor: Color3;
  107166. /**
  107167. * AKA Glossiness in other nomenclature.
  107168. */
  107169. protected _microSurface: number;
  107170. /**
  107171. * Specifies that the material will use the light map as a show map.
  107172. */
  107173. protected _useLightmapAsShadowmap: boolean;
  107174. /**
  107175. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107176. * makes the reflect vector face the model (under horizon).
  107177. */
  107178. protected _useHorizonOcclusion: boolean;
  107179. /**
  107180. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107181. * too much the area relying on ambient texture to define their ambient occlusion.
  107182. */
  107183. protected _useRadianceOcclusion: boolean;
  107184. /**
  107185. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107186. */
  107187. protected _useAlphaFromAlbedoTexture: boolean;
  107188. /**
  107189. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  107190. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107191. */
  107192. protected _useSpecularOverAlpha: boolean;
  107193. /**
  107194. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107195. */
  107196. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107197. /**
  107198. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107199. */
  107200. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  107201. /**
  107202. * Specifies if the metallic texture contains the roughness information in its green channel.
  107203. */
  107204. protected _useRoughnessFromMetallicTextureGreen: boolean;
  107205. /**
  107206. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107207. */
  107208. protected _useMetallnessFromMetallicTextureBlue: boolean;
  107209. /**
  107210. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107211. */
  107212. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  107213. /**
  107214. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107215. */
  107216. protected _useAmbientInGrayScale: boolean;
  107217. /**
  107218. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107219. * The material will try to infer what glossiness each pixel should be.
  107220. */
  107221. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  107222. /**
  107223. * Defines the falloff type used in this material.
  107224. * It by default is Physical.
  107225. */
  107226. protected _lightFalloff: number;
  107227. /**
  107228. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107229. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107230. */
  107231. protected _useRadianceOverAlpha: boolean;
  107232. /**
  107233. * Allows using an object space normal map (instead of tangent space).
  107234. */
  107235. protected _useObjectSpaceNormalMap: boolean;
  107236. /**
  107237. * Allows using the bump map in parallax mode.
  107238. */
  107239. protected _useParallax: boolean;
  107240. /**
  107241. * Allows using the bump map in parallax occlusion mode.
  107242. */
  107243. protected _useParallaxOcclusion: boolean;
  107244. /**
  107245. * Controls the scale bias of the parallax mode.
  107246. */
  107247. protected _parallaxScaleBias: number;
  107248. /**
  107249. * If sets to true, disables all the lights affecting the material.
  107250. */
  107251. protected _disableLighting: boolean;
  107252. /**
  107253. * Number of Simultaneous lights allowed on the material.
  107254. */
  107255. protected _maxSimultaneousLights: number;
  107256. /**
  107257. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107258. */
  107259. protected _invertNormalMapX: boolean;
  107260. /**
  107261. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107262. */
  107263. protected _invertNormalMapY: boolean;
  107264. /**
  107265. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107266. */
  107267. protected _twoSidedLighting: boolean;
  107268. /**
  107269. * Defines the alpha limits in alpha test mode.
  107270. */
  107271. protected _alphaCutOff: number;
  107272. /**
  107273. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107274. */
  107275. protected _forceAlphaTest: boolean;
  107276. /**
  107277. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107278. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107279. */
  107280. protected _useAlphaFresnel: boolean;
  107281. /**
  107282. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107283. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107284. */
  107285. protected _useLinearAlphaFresnel: boolean;
  107286. /**
  107287. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  107288. * from cos thetav and roughness:
  107289. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  107290. */
  107291. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  107292. /**
  107293. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107294. */
  107295. protected _forceIrradianceInFragment: boolean;
  107296. private _realTimeFiltering;
  107297. /**
  107298. * Enables realtime filtering on the texture.
  107299. */
  107300. get realTimeFiltering(): boolean;
  107301. set realTimeFiltering(b: boolean);
  107302. private _realTimeFilteringQuality;
  107303. /**
  107304. * Quality switch for realtime filtering
  107305. */
  107306. get realTimeFilteringQuality(): number;
  107307. set realTimeFilteringQuality(n: number);
  107308. /**
  107309. * Can this material render to several textures at once
  107310. */
  107311. get canRenderToMRT(): boolean;
  107312. /**
  107313. * Force normal to face away from face.
  107314. */
  107315. protected _forceNormalForward: boolean;
  107316. /**
  107317. * Enables specular anti aliasing in the PBR shader.
  107318. * It will both interacts on the Geometry for analytical and IBL lighting.
  107319. * It also prefilter the roughness map based on the bump values.
  107320. */
  107321. protected _enableSpecularAntiAliasing: boolean;
  107322. /**
  107323. * Default configuration related to image processing available in the PBR Material.
  107324. */
  107325. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107326. /**
  107327. * Keep track of the image processing observer to allow dispose and replace.
  107328. */
  107329. private _imageProcessingObserver;
  107330. /**
  107331. * Attaches a new image processing configuration to the PBR Material.
  107332. * @param configuration
  107333. */
  107334. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107335. /**
  107336. * Stores the available render targets.
  107337. */
  107338. private _renderTargets;
  107339. /**
  107340. * Sets the global ambient color for the material used in lighting calculations.
  107341. */
  107342. private _globalAmbientColor;
  107343. /**
  107344. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  107345. */
  107346. private _useLogarithmicDepth;
  107347. /**
  107348. * If set to true, no lighting calculations will be applied.
  107349. */
  107350. private _unlit;
  107351. private _debugMode;
  107352. /**
  107353. * @hidden
  107354. * This is reserved for the inspector.
  107355. * Defines the material debug mode.
  107356. * It helps seeing only some components of the material while troubleshooting.
  107357. */
  107358. debugMode: number;
  107359. /**
  107360. * @hidden
  107361. * This is reserved for the inspector.
  107362. * Specify from where on screen the debug mode should start.
  107363. * The value goes from -1 (full screen) to 1 (not visible)
  107364. * It helps with side by side comparison against the final render
  107365. * This defaults to -1
  107366. */
  107367. private debugLimit;
  107368. /**
  107369. * @hidden
  107370. * This is reserved for the inspector.
  107371. * As the default viewing range might not be enough (if the ambient is really small for instance)
  107372. * You can use the factor to better multiply the final value.
  107373. */
  107374. private debugFactor;
  107375. /**
  107376. * Defines the clear coat layer parameters for the material.
  107377. */
  107378. readonly clearCoat: PBRClearCoatConfiguration;
  107379. /**
  107380. * Defines the anisotropic parameters for the material.
  107381. */
  107382. readonly anisotropy: PBRAnisotropicConfiguration;
  107383. /**
  107384. * Defines the BRDF parameters for the material.
  107385. */
  107386. readonly brdf: PBRBRDFConfiguration;
  107387. /**
  107388. * Defines the Sheen parameters for the material.
  107389. */
  107390. readonly sheen: PBRSheenConfiguration;
  107391. /**
  107392. * Defines the SubSurface parameters for the material.
  107393. */
  107394. readonly subSurface: PBRSubSurfaceConfiguration;
  107395. /**
  107396. * Defines additionnal PrePass parameters for the material.
  107397. */
  107398. readonly prePassConfiguration: PrePassConfiguration;
  107399. /**
  107400. * Defines the detail map parameters for the material.
  107401. */
  107402. readonly detailMap: DetailMapConfiguration;
  107403. protected _rebuildInParallel: boolean;
  107404. /**
  107405. * Instantiates a new PBRMaterial instance.
  107406. *
  107407. * @param name The material name
  107408. * @param scene The scene the material will be use in.
  107409. */
  107410. constructor(name: string, scene: Scene);
  107411. /**
  107412. * Gets a boolean indicating that current material needs to register RTT
  107413. */
  107414. get hasRenderTargetTextures(): boolean;
  107415. /**
  107416. * Gets the name of the material class.
  107417. */
  107418. getClassName(): string;
  107419. /**
  107420. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107421. */
  107422. get useLogarithmicDepth(): boolean;
  107423. /**
  107424. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107425. */
  107426. set useLogarithmicDepth(value: boolean);
  107427. /**
  107428. * Returns true if alpha blending should be disabled.
  107429. */
  107430. protected get _disableAlphaBlending(): boolean;
  107431. /**
  107432. * Specifies whether or not this material should be rendered in alpha blend mode.
  107433. */
  107434. needAlphaBlending(): boolean;
  107435. /**
  107436. * Specifies whether or not this material should be rendered in alpha test mode.
  107437. */
  107438. needAlphaTesting(): boolean;
  107439. /**
  107440. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  107441. */
  107442. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  107443. /**
  107444. * Specifies whether or not there is a usable alpha channel for transparency.
  107445. */
  107446. protected _hasAlphaChannel(): boolean;
  107447. /**
  107448. * Gets the texture used for the alpha test.
  107449. */
  107450. getAlphaTestTexture(): Nullable<BaseTexture>;
  107451. /**
  107452. * Specifies that the submesh is ready to be used.
  107453. * @param mesh - BJS mesh.
  107454. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  107455. * @param useInstances - Specifies that instances should be used.
  107456. * @returns - boolean indicating that the submesh is ready or not.
  107457. */
  107458. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107459. /**
  107460. * Specifies if the material uses metallic roughness workflow.
  107461. * @returns boolean specifiying if the material uses metallic roughness workflow.
  107462. */
  107463. isMetallicWorkflow(): boolean;
  107464. private _prepareEffect;
  107465. private _prepareDefines;
  107466. /**
  107467. * Force shader compilation
  107468. */
  107469. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  107470. /**
  107471. * Initializes the uniform buffer layout for the shader.
  107472. */
  107473. buildUniformLayout(): void;
  107474. /**
  107475. * Unbinds the material from the mesh
  107476. */
  107477. unbind(): void;
  107478. /**
  107479. * Binds the submesh data.
  107480. * @param world - The world matrix.
  107481. * @param mesh - The BJS mesh.
  107482. * @param subMesh - A submesh of the BJS mesh.
  107483. */
  107484. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107485. /**
  107486. * Returns the animatable textures.
  107487. * @returns - Array of animatable textures.
  107488. */
  107489. getAnimatables(): IAnimatable[];
  107490. /**
  107491. * Returns the texture used for reflections.
  107492. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  107493. */
  107494. private _getReflectionTexture;
  107495. /**
  107496. * Returns an array of the actively used textures.
  107497. * @returns - Array of BaseTextures
  107498. */
  107499. getActiveTextures(): BaseTexture[];
  107500. /**
  107501. * Checks to see if a texture is used in the material.
  107502. * @param texture - Base texture to use.
  107503. * @returns - Boolean specifying if a texture is used in the material.
  107504. */
  107505. hasTexture(texture: BaseTexture): boolean;
  107506. /**
  107507. * Sets the required values to the prepass renderer.
  107508. * @param prePassRenderer defines the prepass renderer to setup
  107509. */
  107510. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  107511. /**
  107512. * Disposes the resources of the material.
  107513. * @param forceDisposeEffect - Forces the disposal of effects.
  107514. * @param forceDisposeTextures - Forces the disposal of all textures.
  107515. */
  107516. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107517. }
  107518. }
  107519. declare module BABYLON {
  107520. /**
  107521. * The Physically based material of BJS.
  107522. *
  107523. * This offers the main features of a standard PBR material.
  107524. * For more information, please refer to the documentation :
  107525. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107526. */
  107527. export class PBRMaterial extends PBRBaseMaterial {
  107528. /**
  107529. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107530. */
  107531. static readonly PBRMATERIAL_OPAQUE: number;
  107532. /**
  107533. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107534. */
  107535. static readonly PBRMATERIAL_ALPHATEST: number;
  107536. /**
  107537. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107538. */
  107539. static readonly PBRMATERIAL_ALPHABLEND: number;
  107540. /**
  107541. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107542. * They are also discarded below the alpha cutoff threshold to improve performances.
  107543. */
  107544. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107545. /**
  107546. * Defines the default value of how much AO map is occluding the analytical lights
  107547. * (point spot...).
  107548. */
  107549. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107550. /**
  107551. * Intensity of the direct lights e.g. the four lights available in your scene.
  107552. * This impacts both the direct diffuse and specular highlights.
  107553. */
  107554. directIntensity: number;
  107555. /**
  107556. * Intensity of the emissive part of the material.
  107557. * This helps controlling the emissive effect without modifying the emissive color.
  107558. */
  107559. emissiveIntensity: number;
  107560. /**
  107561. * Intensity of the environment e.g. how much the environment will light the object
  107562. * either through harmonics for rough material or through the refelction for shiny ones.
  107563. */
  107564. environmentIntensity: number;
  107565. /**
  107566. * This is a special control allowing the reduction of the specular highlights coming from the
  107567. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107568. */
  107569. specularIntensity: number;
  107570. /**
  107571. * Debug Control allowing disabling the bump map on this material.
  107572. */
  107573. disableBumpMap: boolean;
  107574. /**
  107575. * AKA Diffuse Texture in standard nomenclature.
  107576. */
  107577. albedoTexture: BaseTexture;
  107578. /**
  107579. * AKA Occlusion Texture in other nomenclature.
  107580. */
  107581. ambientTexture: BaseTexture;
  107582. /**
  107583. * AKA Occlusion Texture Intensity in other nomenclature.
  107584. */
  107585. ambientTextureStrength: number;
  107586. /**
  107587. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107588. * 1 means it completely occludes it
  107589. * 0 mean it has no impact
  107590. */
  107591. ambientTextureImpactOnAnalyticalLights: number;
  107592. /**
  107593. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  107594. */
  107595. opacityTexture: BaseTexture;
  107596. /**
  107597. * Stores the reflection values in a texture.
  107598. */
  107599. reflectionTexture: Nullable<BaseTexture>;
  107600. /**
  107601. * Stores the emissive values in a texture.
  107602. */
  107603. emissiveTexture: BaseTexture;
  107604. /**
  107605. * AKA Specular texture in other nomenclature.
  107606. */
  107607. reflectivityTexture: BaseTexture;
  107608. /**
  107609. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107610. */
  107611. metallicTexture: BaseTexture;
  107612. /**
  107613. * Specifies the metallic scalar of the metallic/roughness workflow.
  107614. * Can also be used to scale the metalness values of the metallic texture.
  107615. */
  107616. metallic: Nullable<number>;
  107617. /**
  107618. * Specifies the roughness scalar of the metallic/roughness workflow.
  107619. * Can also be used to scale the roughness values of the metallic texture.
  107620. */
  107621. roughness: Nullable<number>;
  107622. /**
  107623. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  107624. * By default the indexOfrefraction is used to compute F0;
  107625. *
  107626. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  107627. *
  107628. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  107629. * F90 = metallicReflectanceColor;
  107630. */
  107631. metallicF0Factor: number;
  107632. /**
  107633. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  107634. * By default the F90 is always 1;
  107635. *
  107636. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  107637. *
  107638. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  107639. * F90 = metallicReflectanceColor;
  107640. */
  107641. metallicReflectanceColor: Color3;
  107642. /**
  107643. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  107644. * This is multiply against the scalar values defined in the material.
  107645. */
  107646. metallicReflectanceTexture: Nullable<BaseTexture>;
  107647. /**
  107648. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107649. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107650. */
  107651. microSurfaceTexture: BaseTexture;
  107652. /**
  107653. * Stores surface normal data used to displace a mesh in a texture.
  107654. */
  107655. bumpTexture: BaseTexture;
  107656. /**
  107657. * Stores the pre-calculated light information of a mesh in a texture.
  107658. */
  107659. lightmapTexture: BaseTexture;
  107660. /**
  107661. * Stores the refracted light information in a texture.
  107662. */
  107663. get refractionTexture(): Nullable<BaseTexture>;
  107664. set refractionTexture(value: Nullable<BaseTexture>);
  107665. /**
  107666. * The color of a material in ambient lighting.
  107667. */
  107668. ambientColor: Color3;
  107669. /**
  107670. * AKA Diffuse Color in other nomenclature.
  107671. */
  107672. albedoColor: Color3;
  107673. /**
  107674. * AKA Specular Color in other nomenclature.
  107675. */
  107676. reflectivityColor: Color3;
  107677. /**
  107678. * The color reflected from the material.
  107679. */
  107680. reflectionColor: Color3;
  107681. /**
  107682. * The color emitted from the material.
  107683. */
  107684. emissiveColor: Color3;
  107685. /**
  107686. * AKA Glossiness in other nomenclature.
  107687. */
  107688. microSurface: number;
  107689. /**
  107690. * Index of refraction of the material base layer.
  107691. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  107692. *
  107693. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  107694. *
  107695. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  107696. */
  107697. get indexOfRefraction(): number;
  107698. set indexOfRefraction(value: number);
  107699. /**
  107700. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107701. */
  107702. get invertRefractionY(): boolean;
  107703. set invertRefractionY(value: boolean);
  107704. /**
  107705. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107706. * Materials half opaque for instance using refraction could benefit from this control.
  107707. */
  107708. get linkRefractionWithTransparency(): boolean;
  107709. set linkRefractionWithTransparency(value: boolean);
  107710. /**
  107711. * If true, the light map contains occlusion information instead of lighting info.
  107712. */
  107713. useLightmapAsShadowmap: boolean;
  107714. /**
  107715. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107716. */
  107717. useAlphaFromAlbedoTexture: boolean;
  107718. /**
  107719. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107720. */
  107721. forceAlphaTest: boolean;
  107722. /**
  107723. * Defines the alpha limits in alpha test mode.
  107724. */
  107725. alphaCutOff: number;
  107726. /**
  107727. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107728. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107729. */
  107730. useSpecularOverAlpha: boolean;
  107731. /**
  107732. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107733. */
  107734. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107735. /**
  107736. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107737. */
  107738. useRoughnessFromMetallicTextureAlpha: boolean;
  107739. /**
  107740. * Specifies if the metallic texture contains the roughness information in its green channel.
  107741. */
  107742. useRoughnessFromMetallicTextureGreen: boolean;
  107743. /**
  107744. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107745. */
  107746. useMetallnessFromMetallicTextureBlue: boolean;
  107747. /**
  107748. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107749. */
  107750. useAmbientOcclusionFromMetallicTextureRed: boolean;
  107751. /**
  107752. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107753. */
  107754. useAmbientInGrayScale: boolean;
  107755. /**
  107756. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107757. * The material will try to infer what glossiness each pixel should be.
  107758. */
  107759. useAutoMicroSurfaceFromReflectivityMap: boolean;
  107760. /**
  107761. * BJS is using an harcoded light falloff based on a manually sets up range.
  107762. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107763. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107764. */
  107765. get usePhysicalLightFalloff(): boolean;
  107766. /**
  107767. * BJS is using an harcoded light falloff based on a manually sets up range.
  107768. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107769. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107770. */
  107771. set usePhysicalLightFalloff(value: boolean);
  107772. /**
  107773. * In order to support the falloff compatibility with gltf, a special mode has been added
  107774. * to reproduce the gltf light falloff.
  107775. */
  107776. get useGLTFLightFalloff(): boolean;
  107777. /**
  107778. * In order to support the falloff compatibility with gltf, a special mode has been added
  107779. * to reproduce the gltf light falloff.
  107780. */
  107781. set useGLTFLightFalloff(value: boolean);
  107782. /**
  107783. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107784. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107785. */
  107786. useRadianceOverAlpha: boolean;
  107787. /**
  107788. * Allows using an object space normal map (instead of tangent space).
  107789. */
  107790. useObjectSpaceNormalMap: boolean;
  107791. /**
  107792. * Allows using the bump map in parallax mode.
  107793. */
  107794. useParallax: boolean;
  107795. /**
  107796. * Allows using the bump map in parallax occlusion mode.
  107797. */
  107798. useParallaxOcclusion: boolean;
  107799. /**
  107800. * Controls the scale bias of the parallax mode.
  107801. */
  107802. parallaxScaleBias: number;
  107803. /**
  107804. * If sets to true, disables all the lights affecting the material.
  107805. */
  107806. disableLighting: boolean;
  107807. /**
  107808. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107809. */
  107810. forceIrradianceInFragment: boolean;
  107811. /**
  107812. * Number of Simultaneous lights allowed on the material.
  107813. */
  107814. maxSimultaneousLights: number;
  107815. /**
  107816. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107817. */
  107818. invertNormalMapX: boolean;
  107819. /**
  107820. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107821. */
  107822. invertNormalMapY: boolean;
  107823. /**
  107824. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107825. */
  107826. twoSidedLighting: boolean;
  107827. /**
  107828. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107829. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107830. */
  107831. useAlphaFresnel: boolean;
  107832. /**
  107833. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107834. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107835. */
  107836. useLinearAlphaFresnel: boolean;
  107837. /**
  107838. * Let user defines the brdf lookup texture used for IBL.
  107839. * A default 8bit version is embedded but you could point at :
  107840. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  107841. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  107842. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  107843. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  107844. */
  107845. environmentBRDFTexture: Nullable<BaseTexture>;
  107846. /**
  107847. * Force normal to face away from face.
  107848. */
  107849. forceNormalForward: boolean;
  107850. /**
  107851. * Enables specular anti aliasing in the PBR shader.
  107852. * It will both interacts on the Geometry for analytical and IBL lighting.
  107853. * It also prefilter the roughness map based on the bump values.
  107854. */
  107855. enableSpecularAntiAliasing: boolean;
  107856. /**
  107857. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107858. * makes the reflect vector face the model (under horizon).
  107859. */
  107860. useHorizonOcclusion: boolean;
  107861. /**
  107862. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107863. * too much the area relying on ambient texture to define their ambient occlusion.
  107864. */
  107865. useRadianceOcclusion: boolean;
  107866. /**
  107867. * If set to true, no lighting calculations will be applied.
  107868. */
  107869. unlit: boolean;
  107870. /**
  107871. * Gets the image processing configuration used either in this material.
  107872. */
  107873. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107874. /**
  107875. * Sets the Default image processing configuration used either in the this material.
  107876. *
  107877. * If sets to null, the scene one is in use.
  107878. */
  107879. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  107880. /**
  107881. * Gets wether the color curves effect is enabled.
  107882. */
  107883. get cameraColorCurvesEnabled(): boolean;
  107884. /**
  107885. * Sets wether the color curves effect is enabled.
  107886. */
  107887. set cameraColorCurvesEnabled(value: boolean);
  107888. /**
  107889. * Gets wether the color grading effect is enabled.
  107890. */
  107891. get cameraColorGradingEnabled(): boolean;
  107892. /**
  107893. * Gets wether the color grading effect is enabled.
  107894. */
  107895. set cameraColorGradingEnabled(value: boolean);
  107896. /**
  107897. * Gets wether tonemapping is enabled or not.
  107898. */
  107899. get cameraToneMappingEnabled(): boolean;
  107900. /**
  107901. * Sets wether tonemapping is enabled or not
  107902. */
  107903. set cameraToneMappingEnabled(value: boolean);
  107904. /**
  107905. * The camera exposure used on this material.
  107906. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107907. * This corresponds to a photographic exposure.
  107908. */
  107909. get cameraExposure(): number;
  107910. /**
  107911. * The camera exposure used on this material.
  107912. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107913. * This corresponds to a photographic exposure.
  107914. */
  107915. set cameraExposure(value: number);
  107916. /**
  107917. * Gets The camera contrast used on this material.
  107918. */
  107919. get cameraContrast(): number;
  107920. /**
  107921. * Sets The camera contrast used on this material.
  107922. */
  107923. set cameraContrast(value: number);
  107924. /**
  107925. * Gets the Color Grading 2D Lookup Texture.
  107926. */
  107927. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  107928. /**
  107929. * Sets the Color Grading 2D Lookup Texture.
  107930. */
  107931. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  107932. /**
  107933. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107934. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107935. * 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;
  107936. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107937. */
  107938. get cameraColorCurves(): Nullable<ColorCurves>;
  107939. /**
  107940. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107941. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107942. * 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;
  107943. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107944. */
  107945. set cameraColorCurves(value: Nullable<ColorCurves>);
  107946. /**
  107947. * Instantiates a new PBRMaterial instance.
  107948. *
  107949. * @param name The material name
  107950. * @param scene The scene the material will be use in.
  107951. */
  107952. constructor(name: string, scene: Scene);
  107953. /**
  107954. * Returns the name of this material class.
  107955. */
  107956. getClassName(): string;
  107957. /**
  107958. * Makes a duplicate of the current material.
  107959. * @param name - name to use for the new material.
  107960. */
  107961. clone(name: string): PBRMaterial;
  107962. /**
  107963. * Serializes this PBR Material.
  107964. * @returns - An object with the serialized material.
  107965. */
  107966. serialize(): any;
  107967. /**
  107968. * Parses a PBR Material from a serialized object.
  107969. * @param source - Serialized object.
  107970. * @param scene - BJS scene instance.
  107971. * @param rootUrl - url for the scene object
  107972. * @returns - PBRMaterial
  107973. */
  107974. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  107975. }
  107976. }
  107977. declare module BABYLON {
  107978. /** @hidden */
  107979. export var mrtFragmentDeclaration: {
  107980. name: string;
  107981. shader: string;
  107982. };
  107983. }
  107984. declare module BABYLON {
  107985. /** @hidden */
  107986. export var geometryPixelShader: {
  107987. name: string;
  107988. shader: string;
  107989. };
  107990. }
  107991. declare module BABYLON {
  107992. /** @hidden */
  107993. export var geometryVertexShader: {
  107994. name: string;
  107995. shader: string;
  107996. };
  107997. }
  107998. declare module BABYLON {
  107999. /** @hidden */
  108000. interface ISavedTransformationMatrix {
  108001. world: Matrix;
  108002. viewProjection: Matrix;
  108003. }
  108004. /**
  108005. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  108006. */
  108007. export class GeometryBufferRenderer {
  108008. /**
  108009. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  108010. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  108011. */
  108012. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  108013. /**
  108014. * Constant used to retrieve the position texture index in the G-Buffer textures array
  108015. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  108016. */
  108017. static readonly POSITION_TEXTURE_TYPE: number;
  108018. /**
  108019. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  108020. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  108021. */
  108022. static readonly VELOCITY_TEXTURE_TYPE: number;
  108023. /**
  108024. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  108025. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  108026. */
  108027. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  108028. /**
  108029. * Dictionary used to store the previous transformation matrices of each rendered mesh
  108030. * in order to compute objects velocities when enableVelocity is set to "true"
  108031. * @hidden
  108032. */
  108033. _previousTransformationMatrices: {
  108034. [index: number]: ISavedTransformationMatrix;
  108035. };
  108036. /**
  108037. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  108038. * in order to compute objects velocities when enableVelocity is set to "true"
  108039. * @hidden
  108040. */
  108041. _previousBonesTransformationMatrices: {
  108042. [index: number]: Float32Array;
  108043. };
  108044. /**
  108045. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  108046. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  108047. */
  108048. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  108049. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  108050. renderTransparentMeshes: boolean;
  108051. private _scene;
  108052. private _resizeObserver;
  108053. private _multiRenderTarget;
  108054. private _ratio;
  108055. private _enablePosition;
  108056. private _enableVelocity;
  108057. private _enableReflectivity;
  108058. private _positionIndex;
  108059. private _velocityIndex;
  108060. private _reflectivityIndex;
  108061. private _depthNormalIndex;
  108062. private _linkedWithPrePass;
  108063. private _prePassRenderer;
  108064. private _attachments;
  108065. protected _effect: Effect;
  108066. protected _cachedDefines: string;
  108067. /**
  108068. * @hidden
  108069. * Sets up internal structures to share outputs with PrePassRenderer
  108070. * This method should only be called by the PrePassRenderer itself
  108071. */
  108072. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  108073. /**
  108074. * @hidden
  108075. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  108076. * This method should only be called by the PrePassRenderer itself
  108077. */
  108078. _unlinkPrePassRenderer(): void;
  108079. /**
  108080. * @hidden
  108081. * Resets the geometry buffer layout
  108082. */
  108083. _resetLayout(): void;
  108084. /**
  108085. * @hidden
  108086. * Replaces a texture in the geometry buffer renderer
  108087. * Useful when linking textures of the prepass renderer
  108088. */
  108089. _forceTextureType(geometryBufferType: number, index: number): void;
  108090. /**
  108091. * @hidden
  108092. * Sets texture attachments
  108093. * Useful when linking textures of the prepass renderer
  108094. */
  108095. _setAttachments(attachments: number[]): void;
  108096. /**
  108097. * @hidden
  108098. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  108099. * Useful when linking textures of the prepass renderer
  108100. */
  108101. _linkInternalTexture(internalTexture: InternalTexture): void;
  108102. /**
  108103. * Gets the render list (meshes to be rendered) used in the G buffer.
  108104. */
  108105. get renderList(): Nullable<AbstractMesh[]>;
  108106. /**
  108107. * Set the render list (meshes to be rendered) used in the G buffer.
  108108. */
  108109. set renderList(meshes: Nullable<AbstractMesh[]>);
  108110. /**
  108111. * Gets wether or not G buffer are supported by the running hardware.
  108112. * This requires draw buffer supports
  108113. */
  108114. get isSupported(): boolean;
  108115. /**
  108116. * Returns the index of the given texture type in the G-Buffer textures array
  108117. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108118. * @returns the index of the given texture type in the G-Buffer textures array
  108119. */
  108120. getTextureIndex(textureType: number): number;
  108121. /**
  108122. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108123. */
  108124. get enablePosition(): boolean;
  108125. /**
  108126. * Sets whether or not objects positions are enabled for the G buffer.
  108127. */
  108128. set enablePosition(enable: boolean);
  108129. /**
  108130. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  108131. */
  108132. get enableVelocity(): boolean;
  108133. /**
  108134. * Sets wether or not objects velocities are enabled for the G buffer.
  108135. */
  108136. set enableVelocity(enable: boolean);
  108137. /**
  108138. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  108139. */
  108140. get enableReflectivity(): boolean;
  108141. /**
  108142. * Sets wether or not objects roughness are enabled for the G buffer.
  108143. */
  108144. set enableReflectivity(enable: boolean);
  108145. /**
  108146. * Gets the scene associated with the buffer.
  108147. */
  108148. get scene(): Scene;
  108149. /**
  108150. * Gets the ratio used by the buffer during its creation.
  108151. * How big is the buffer related to the main canvas.
  108152. */
  108153. get ratio(): number;
  108154. /** @hidden */
  108155. static _SceneComponentInitialization: (scene: Scene) => void;
  108156. /**
  108157. * Creates a new G Buffer for the scene
  108158. * @param scene The scene the buffer belongs to
  108159. * @param ratio How big is the buffer related to the main canvas.
  108160. */
  108161. constructor(scene: Scene, ratio?: number);
  108162. /**
  108163. * Checks wether everything is ready to render a submesh to the G buffer.
  108164. * @param subMesh the submesh to check readiness for
  108165. * @param useInstances is the mesh drawn using instance or not
  108166. * @returns true if ready otherwise false
  108167. */
  108168. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108169. /**
  108170. * Gets the current underlying G Buffer.
  108171. * @returns the buffer
  108172. */
  108173. getGBuffer(): MultiRenderTarget;
  108174. /**
  108175. * Gets the number of samples used to render the buffer (anti aliasing).
  108176. */
  108177. get samples(): number;
  108178. /**
  108179. * Sets the number of samples used to render the buffer (anti aliasing).
  108180. */
  108181. set samples(value: number);
  108182. /**
  108183. * Disposes the renderer and frees up associated resources.
  108184. */
  108185. dispose(): void;
  108186. private _assignRenderTargetIndices;
  108187. protected _createRenderTargets(): void;
  108188. private _copyBonesTransformationMatrices;
  108189. }
  108190. }
  108191. declare module BABYLON {
  108192. /**
  108193. * Renders a pre pass of the scene
  108194. * This means every mesh in the scene will be rendered to a render target texture
  108195. * And then this texture will be composited to the rendering canvas with post processes
  108196. * It is necessary for effects like subsurface scattering or deferred shading
  108197. */
  108198. export class PrePassRenderer {
  108199. /** @hidden */
  108200. static _SceneComponentInitialization: (scene: Scene) => void;
  108201. private _textureFormats;
  108202. /**
  108203. * To save performance, we can excluded skinned meshes from the prepass
  108204. */
  108205. excludedSkinnedMesh: AbstractMesh[];
  108206. /**
  108207. * Force material to be excluded from the prepass
  108208. * Can be useful when `useGeometryBufferFallback` is set to `true`
  108209. * and you don't want a material to show in the effect.
  108210. */
  108211. excludedMaterials: Material[];
  108212. private _textureIndices;
  108213. private _scene;
  108214. private _engine;
  108215. private _isDirty;
  108216. /**
  108217. * Number of textures in the multi render target texture where the scene is directly rendered
  108218. */
  108219. mrtCount: number;
  108220. /**
  108221. * The render target where the scene is directly rendered
  108222. */
  108223. prePassRT: MultiRenderTarget;
  108224. private _multiRenderAttachments;
  108225. private _defaultAttachments;
  108226. private _clearAttachments;
  108227. private _postProcesses;
  108228. private readonly _clearColor;
  108229. /**
  108230. * Image processing post process for composition
  108231. */
  108232. imageProcessingPostProcess: ImageProcessingPostProcess;
  108233. /**
  108234. * Configuration for prepass effects
  108235. */
  108236. private _effectConfigurations;
  108237. private _mrtFormats;
  108238. private _mrtLayout;
  108239. private _enabled;
  108240. /**
  108241. * Indicates if the prepass is enabled
  108242. */
  108243. get enabled(): boolean;
  108244. /**
  108245. * How many samples are used for MSAA of the scene render target
  108246. */
  108247. get samples(): number;
  108248. set samples(n: number);
  108249. private _geometryBuffer;
  108250. private _useGeometryBufferFallback;
  108251. /**
  108252. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  108253. */
  108254. get useGeometryBufferFallback(): boolean;
  108255. set useGeometryBufferFallback(value: boolean);
  108256. /**
  108257. * Instanciates a prepass renderer
  108258. * @param scene The scene
  108259. */
  108260. constructor(scene: Scene);
  108261. private _initializeAttachments;
  108262. private _createCompositionEffect;
  108263. /**
  108264. * Indicates if rendering a prepass is supported
  108265. */
  108266. get isSupported(): boolean;
  108267. /**
  108268. * Sets the proper output textures to draw in the engine.
  108269. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  108270. * @param subMesh Submesh on which the effect is applied
  108271. */
  108272. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  108273. /**
  108274. * @hidden
  108275. */
  108276. _beforeCameraDraw(): void;
  108277. /**
  108278. * @hidden
  108279. */
  108280. _afterCameraDraw(): void;
  108281. private _checkRTSize;
  108282. private _bindFrameBuffer;
  108283. /**
  108284. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  108285. */
  108286. clear(): void;
  108287. private _setState;
  108288. private _updateGeometryBufferLayout;
  108289. /**
  108290. * Adds an effect configuration to the prepass.
  108291. * If an effect has already been added, it won't add it twice and will return the configuration
  108292. * already present.
  108293. * @param cfg the effect configuration
  108294. * @return the effect configuration now used by the prepass
  108295. */
  108296. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  108297. /**
  108298. * Returns the index of a texture in the multi render target texture array.
  108299. * @param type Texture type
  108300. * @return The index
  108301. */
  108302. getIndex(type: number): number;
  108303. private _enable;
  108304. private _disable;
  108305. private _resetLayout;
  108306. private _resetPostProcessChain;
  108307. private _bindPostProcessChain;
  108308. /**
  108309. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  108310. */
  108311. markAsDirty(): void;
  108312. /**
  108313. * Enables a texture on the MultiRenderTarget for prepass
  108314. */
  108315. private _enableTextures;
  108316. private _update;
  108317. private _markAllMaterialsAsPrePassDirty;
  108318. /**
  108319. * Disposes the prepass renderer.
  108320. */
  108321. dispose(): void;
  108322. }
  108323. }
  108324. declare module BABYLON {
  108325. /**
  108326. * Size options for a post process
  108327. */
  108328. export type PostProcessOptions = {
  108329. width: number;
  108330. height: number;
  108331. };
  108332. /**
  108333. * PostProcess can be used to apply a shader to a texture after it has been rendered
  108334. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108335. */
  108336. export class PostProcess {
  108337. /**
  108338. * Gets or sets the unique id of the post process
  108339. */
  108340. uniqueId: number;
  108341. /** Name of the PostProcess. */
  108342. name: string;
  108343. /**
  108344. * Width of the texture to apply the post process on
  108345. */
  108346. width: number;
  108347. /**
  108348. * Height of the texture to apply the post process on
  108349. */
  108350. height: number;
  108351. /**
  108352. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  108353. */
  108354. nodeMaterialSource: Nullable<NodeMaterial>;
  108355. /**
  108356. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  108357. * @hidden
  108358. */
  108359. _outputTexture: Nullable<InternalTexture>;
  108360. /**
  108361. * Sampling mode used by the shader
  108362. * See https://doc.babylonjs.com/classes/3.1/texture
  108363. */
  108364. renderTargetSamplingMode: number;
  108365. /**
  108366. * Clear color to use when screen clearing
  108367. */
  108368. clearColor: Color4;
  108369. /**
  108370. * If the buffer needs to be cleared before applying the post process. (default: true)
  108371. * Should be set to false if shader will overwrite all previous pixels.
  108372. */
  108373. autoClear: boolean;
  108374. /**
  108375. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  108376. */
  108377. alphaMode: number;
  108378. /**
  108379. * Sets the setAlphaBlendConstants of the babylon engine
  108380. */
  108381. alphaConstants: Color4;
  108382. /**
  108383. * Animations to be used for the post processing
  108384. */
  108385. animations: Animation[];
  108386. /**
  108387. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  108388. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  108389. */
  108390. enablePixelPerfectMode: boolean;
  108391. /**
  108392. * Force the postprocess to be applied without taking in account viewport
  108393. */
  108394. forceFullscreenViewport: boolean;
  108395. /**
  108396. * List of inspectable custom properties (used by the Inspector)
  108397. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108398. */
  108399. inspectableCustomProperties: IInspectable[];
  108400. /**
  108401. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  108402. *
  108403. * | Value | Type | Description |
  108404. * | ----- | ----------------------------------- | ----------- |
  108405. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  108406. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  108407. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  108408. *
  108409. */
  108410. scaleMode: number;
  108411. /**
  108412. * Force textures to be a power of two (default: false)
  108413. */
  108414. alwaysForcePOT: boolean;
  108415. private _samples;
  108416. /**
  108417. * Number of sample textures (default: 1)
  108418. */
  108419. get samples(): number;
  108420. set samples(n: number);
  108421. /**
  108422. * Modify the scale of the post process to be the same as the viewport (default: false)
  108423. */
  108424. adaptScaleToCurrentViewport: boolean;
  108425. private _camera;
  108426. protected _scene: Scene;
  108427. private _engine;
  108428. private _options;
  108429. private _reusable;
  108430. private _textureType;
  108431. private _textureFormat;
  108432. /**
  108433. * Smart array of input and output textures for the post process.
  108434. * @hidden
  108435. */
  108436. _textures: SmartArray<InternalTexture>;
  108437. /**
  108438. * The index in _textures that corresponds to the output texture.
  108439. * @hidden
  108440. */
  108441. _currentRenderTextureInd: number;
  108442. private _effect;
  108443. private _samplers;
  108444. private _fragmentUrl;
  108445. private _vertexUrl;
  108446. private _parameters;
  108447. private _scaleRatio;
  108448. protected _indexParameters: any;
  108449. private _shareOutputWithPostProcess;
  108450. private _texelSize;
  108451. private _forcedOutputTexture;
  108452. /**
  108453. * Prepass configuration in case this post process needs a texture from prepass
  108454. * @hidden
  108455. */
  108456. _prePassEffectConfiguration: PrePassEffectConfiguration;
  108457. /**
  108458. * Returns the fragment url or shader name used in the post process.
  108459. * @returns the fragment url or name in the shader store.
  108460. */
  108461. getEffectName(): string;
  108462. /**
  108463. * An event triggered when the postprocess is activated.
  108464. */
  108465. onActivateObservable: Observable<Camera>;
  108466. private _onActivateObserver;
  108467. /**
  108468. * A function that is added to the onActivateObservable
  108469. */
  108470. set onActivate(callback: Nullable<(camera: Camera) => void>);
  108471. /**
  108472. * An event triggered when the postprocess changes its size.
  108473. */
  108474. onSizeChangedObservable: Observable<PostProcess>;
  108475. private _onSizeChangedObserver;
  108476. /**
  108477. * A function that is added to the onSizeChangedObservable
  108478. */
  108479. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  108480. /**
  108481. * An event triggered when the postprocess applies its effect.
  108482. */
  108483. onApplyObservable: Observable<Effect>;
  108484. private _onApplyObserver;
  108485. /**
  108486. * A function that is added to the onApplyObservable
  108487. */
  108488. set onApply(callback: (effect: Effect) => void);
  108489. /**
  108490. * An event triggered before rendering the postprocess
  108491. */
  108492. onBeforeRenderObservable: Observable<Effect>;
  108493. private _onBeforeRenderObserver;
  108494. /**
  108495. * A function that is added to the onBeforeRenderObservable
  108496. */
  108497. set onBeforeRender(callback: (effect: Effect) => void);
  108498. /**
  108499. * An event triggered after rendering the postprocess
  108500. */
  108501. onAfterRenderObservable: Observable<Effect>;
  108502. private _onAfterRenderObserver;
  108503. /**
  108504. * A function that is added to the onAfterRenderObservable
  108505. */
  108506. set onAfterRender(callback: (efect: Effect) => void);
  108507. /**
  108508. * 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
  108509. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  108510. */
  108511. get inputTexture(): InternalTexture;
  108512. set inputTexture(value: InternalTexture);
  108513. /**
  108514. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  108515. * the only way to unset it is to use this function to restore its internal state
  108516. */
  108517. restoreDefaultInputTexture(): void;
  108518. /**
  108519. * Gets the camera which post process is applied to.
  108520. * @returns The camera the post process is applied to.
  108521. */
  108522. getCamera(): Camera;
  108523. /**
  108524. * Gets the texel size of the postprocess.
  108525. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  108526. */
  108527. get texelSize(): Vector2;
  108528. /**
  108529. * Creates a new instance PostProcess
  108530. * @param name The name of the PostProcess.
  108531. * @param fragmentUrl The url of the fragment shader to be used.
  108532. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  108533. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  108534. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108535. * @param camera The camera to apply the render pass to.
  108536. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108537. * @param engine The engine which the post process will be applied. (default: current engine)
  108538. * @param reusable If the post process can be reused on the same frame. (default: false)
  108539. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  108540. * @param textureType Type of textures used when performing the post process. (default: 0)
  108541. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  108542. * @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
  108543. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  108544. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  108545. */
  108546. 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);
  108547. /**
  108548. * Gets a string identifying the name of the class
  108549. * @returns "PostProcess" string
  108550. */
  108551. getClassName(): string;
  108552. /**
  108553. * Gets the engine which this post process belongs to.
  108554. * @returns The engine the post process was enabled with.
  108555. */
  108556. getEngine(): Engine;
  108557. /**
  108558. * The effect that is created when initializing the post process.
  108559. * @returns The created effect corresponding the the postprocess.
  108560. */
  108561. getEffect(): Effect;
  108562. /**
  108563. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  108564. * @param postProcess The post process to share the output with.
  108565. * @returns This post process.
  108566. */
  108567. shareOutputWith(postProcess: PostProcess): PostProcess;
  108568. /**
  108569. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  108570. * This should be called if the post process that shares output with this post process is disabled/disposed.
  108571. */
  108572. useOwnOutput(): void;
  108573. /**
  108574. * Updates the effect with the current post process compile time values and recompiles the shader.
  108575. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108576. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108577. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108578. * @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
  108579. * @param onCompiled Called when the shader has been compiled.
  108580. * @param onError Called if there is an error when compiling a shader.
  108581. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  108582. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  108583. */
  108584. 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;
  108585. /**
  108586. * The post process is reusable if it can be used multiple times within one frame.
  108587. * @returns If the post process is reusable
  108588. */
  108589. isReusable(): boolean;
  108590. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  108591. markTextureDirty(): void;
  108592. /**
  108593. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  108594. * 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.
  108595. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  108596. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  108597. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  108598. * @returns The target texture that was bound to be written to.
  108599. */
  108600. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  108601. /**
  108602. * If the post process is supported.
  108603. */
  108604. get isSupported(): boolean;
  108605. /**
  108606. * The aspect ratio of the output texture.
  108607. */
  108608. get aspectRatio(): number;
  108609. /**
  108610. * Get a value indicating if the post-process is ready to be used
  108611. * @returns true if the post-process is ready (shader is compiled)
  108612. */
  108613. isReady(): boolean;
  108614. /**
  108615. * Binds all textures and uniforms to the shader, this will be run on every pass.
  108616. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  108617. */
  108618. apply(): Nullable<Effect>;
  108619. private _disposeTextures;
  108620. /**
  108621. * Sets the required values to the prepass renderer.
  108622. * @param prePassRenderer defines the prepass renderer to setup.
  108623. * @returns true if the pre pass is needed.
  108624. */
  108625. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  108626. /**
  108627. * Disposes the post process.
  108628. * @param camera The camera to dispose the post process on.
  108629. */
  108630. dispose(camera?: Camera): void;
  108631. /**
  108632. * Serializes the particle system to a JSON object
  108633. * @returns the JSON object
  108634. */
  108635. serialize(): any;
  108636. /**
  108637. * Creates a material from parsed material data
  108638. * @param parsedPostProcess defines parsed post process data
  108639. * @param scene defines the hosting scene
  108640. * @param rootUrl defines the root URL to use to load textures
  108641. * @returns a new post process
  108642. */
  108643. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  108644. }
  108645. }
  108646. declare module BABYLON {
  108647. /** @hidden */
  108648. export var kernelBlurVaryingDeclaration: {
  108649. name: string;
  108650. shader: string;
  108651. };
  108652. }
  108653. declare module BABYLON {
  108654. /** @hidden */
  108655. export var kernelBlurFragment: {
  108656. name: string;
  108657. shader: string;
  108658. };
  108659. }
  108660. declare module BABYLON {
  108661. /** @hidden */
  108662. export var kernelBlurFragment2: {
  108663. name: string;
  108664. shader: string;
  108665. };
  108666. }
  108667. declare module BABYLON {
  108668. /** @hidden */
  108669. export var kernelBlurPixelShader: {
  108670. name: string;
  108671. shader: string;
  108672. };
  108673. }
  108674. declare module BABYLON {
  108675. /** @hidden */
  108676. export var kernelBlurVertex: {
  108677. name: string;
  108678. shader: string;
  108679. };
  108680. }
  108681. declare module BABYLON {
  108682. /** @hidden */
  108683. export var kernelBlurVertexShader: {
  108684. name: string;
  108685. shader: string;
  108686. };
  108687. }
  108688. declare module BABYLON {
  108689. /**
  108690. * The Blur Post Process which blurs an image based on a kernel and direction.
  108691. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  108692. */
  108693. export class BlurPostProcess extends PostProcess {
  108694. private blockCompilation;
  108695. protected _kernel: number;
  108696. protected _idealKernel: number;
  108697. protected _packedFloat: boolean;
  108698. private _staticDefines;
  108699. /** The direction in which to blur the image. */
  108700. direction: Vector2;
  108701. /**
  108702. * Sets the length in pixels of the blur sample region
  108703. */
  108704. set kernel(v: number);
  108705. /**
  108706. * Gets the length in pixels of the blur sample region
  108707. */
  108708. get kernel(): number;
  108709. /**
  108710. * Sets wether or not the blur needs to unpack/repack floats
  108711. */
  108712. set packedFloat(v: boolean);
  108713. /**
  108714. * Gets wether or not the blur is unpacking/repacking floats
  108715. */
  108716. get packedFloat(): boolean;
  108717. /**
  108718. * Gets a string identifying the name of the class
  108719. * @returns "BlurPostProcess" string
  108720. */
  108721. getClassName(): string;
  108722. /**
  108723. * Creates a new instance BlurPostProcess
  108724. * @param name The name of the effect.
  108725. * @param direction The direction in which to blur the image.
  108726. * @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.
  108727. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108728. * @param camera The camera to apply the render pass to.
  108729. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108730. * @param engine The engine which the post process will be applied. (default: current engine)
  108731. * @param reusable If the post process can be reused on the same frame. (default: false)
  108732. * @param textureType Type of textures used when performing the post process. (default: 0)
  108733. * @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)
  108734. */
  108735. 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);
  108736. /**
  108737. * Updates the effect with the current post process compile time values and recompiles the shader.
  108738. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108739. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108740. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108741. * @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
  108742. * @param onCompiled Called when the shader has been compiled.
  108743. * @param onError Called if there is an error when compiling a shader.
  108744. */
  108745. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108746. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108747. /**
  108748. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  108749. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  108750. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  108751. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  108752. * The gaps between physical kernels are compensated for in the weighting of the samples
  108753. * @param idealKernel Ideal blur kernel.
  108754. * @return Nearest best kernel.
  108755. */
  108756. protected _nearestBestKernel(idealKernel: number): number;
  108757. /**
  108758. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  108759. * @param x The point on the Gaussian distribution to sample.
  108760. * @return the value of the Gaussian function at x.
  108761. */
  108762. protected _gaussianWeight(x: number): number;
  108763. /**
  108764. * Generates a string that can be used as a floating point number in GLSL.
  108765. * @param x Value to print.
  108766. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  108767. * @return GLSL float string.
  108768. */
  108769. protected _glslFloat(x: number, decimalFigures?: number): string;
  108770. /** @hidden */
  108771. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  108772. }
  108773. }
  108774. declare module BABYLON {
  108775. /**
  108776. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108777. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108778. * You can then easily use it as a reflectionTexture on a flat surface.
  108779. * In case the surface is not a plane, please consider relying on reflection probes.
  108780. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108781. */
  108782. export class MirrorTexture extends RenderTargetTexture {
  108783. private scene;
  108784. /**
  108785. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  108786. * 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.
  108787. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108788. */
  108789. mirrorPlane: Plane;
  108790. /**
  108791. * Define the blur ratio used to blur the reflection if needed.
  108792. */
  108793. set blurRatio(value: number);
  108794. get blurRatio(): number;
  108795. /**
  108796. * Define the adaptive blur kernel used to blur the reflection if needed.
  108797. * This will autocompute the closest best match for the `blurKernel`
  108798. */
  108799. set adaptiveBlurKernel(value: number);
  108800. /**
  108801. * Define the blur kernel used to blur the reflection if needed.
  108802. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108803. */
  108804. set blurKernel(value: number);
  108805. /**
  108806. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  108807. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108808. */
  108809. set blurKernelX(value: number);
  108810. get blurKernelX(): number;
  108811. /**
  108812. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  108813. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108814. */
  108815. set blurKernelY(value: number);
  108816. get blurKernelY(): number;
  108817. private _autoComputeBlurKernel;
  108818. protected _onRatioRescale(): void;
  108819. private _updateGammaSpace;
  108820. private _imageProcessingConfigChangeObserver;
  108821. private _transformMatrix;
  108822. private _mirrorMatrix;
  108823. private _savedViewMatrix;
  108824. private _blurX;
  108825. private _blurY;
  108826. private _adaptiveBlurKernel;
  108827. private _blurKernelX;
  108828. private _blurKernelY;
  108829. private _blurRatio;
  108830. /**
  108831. * Instantiates a Mirror Texture.
  108832. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108833. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108834. * You can then easily use it as a reflectionTexture on a flat surface.
  108835. * In case the surface is not a plane, please consider relying on reflection probes.
  108836. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108837. * @param name
  108838. * @param size
  108839. * @param scene
  108840. * @param generateMipMaps
  108841. * @param type
  108842. * @param samplingMode
  108843. * @param generateDepthBuffer
  108844. */
  108845. constructor(name: string, size: number | {
  108846. width: number;
  108847. height: number;
  108848. } | {
  108849. ratio: number;
  108850. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  108851. private _preparePostProcesses;
  108852. /**
  108853. * Clone the mirror texture.
  108854. * @returns the cloned texture
  108855. */
  108856. clone(): MirrorTexture;
  108857. /**
  108858. * Serialize the texture to a JSON representation you could use in Parse later on
  108859. * @returns the serialized JSON representation
  108860. */
  108861. serialize(): any;
  108862. /**
  108863. * Dispose the texture and release its associated resources.
  108864. */
  108865. dispose(): void;
  108866. }
  108867. }
  108868. declare module BABYLON {
  108869. /**
  108870. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108871. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108872. */
  108873. export class Texture extends BaseTexture {
  108874. /**
  108875. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  108876. */
  108877. static SerializeBuffers: boolean;
  108878. /** @hidden */
  108879. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  108880. /** @hidden */
  108881. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  108882. /** @hidden */
  108883. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  108884. /** nearest is mag = nearest and min = nearest and mip = linear */
  108885. static readonly NEAREST_SAMPLINGMODE: number;
  108886. /** nearest is mag = nearest and min = nearest and mip = linear */
  108887. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  108888. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108889. static readonly BILINEAR_SAMPLINGMODE: number;
  108890. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108891. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  108892. /** Trilinear is mag = linear and min = linear and mip = linear */
  108893. static readonly TRILINEAR_SAMPLINGMODE: number;
  108894. /** Trilinear is mag = linear and min = linear and mip = linear */
  108895. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  108896. /** mag = nearest and min = nearest and mip = nearest */
  108897. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  108898. /** mag = nearest and min = linear and mip = nearest */
  108899. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  108900. /** mag = nearest and min = linear and mip = linear */
  108901. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  108902. /** mag = nearest and min = linear and mip = none */
  108903. static readonly NEAREST_LINEAR: number;
  108904. /** mag = nearest and min = nearest and mip = none */
  108905. static readonly NEAREST_NEAREST: number;
  108906. /** mag = linear and min = nearest and mip = nearest */
  108907. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  108908. /** mag = linear and min = nearest and mip = linear */
  108909. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  108910. /** mag = linear and min = linear and mip = none */
  108911. static readonly LINEAR_LINEAR: number;
  108912. /** mag = linear and min = nearest and mip = none */
  108913. static readonly LINEAR_NEAREST: number;
  108914. /** Explicit coordinates mode */
  108915. static readonly EXPLICIT_MODE: number;
  108916. /** Spherical coordinates mode */
  108917. static readonly SPHERICAL_MODE: number;
  108918. /** Planar coordinates mode */
  108919. static readonly PLANAR_MODE: number;
  108920. /** Cubic coordinates mode */
  108921. static readonly CUBIC_MODE: number;
  108922. /** Projection coordinates mode */
  108923. static readonly PROJECTION_MODE: number;
  108924. /** Inverse Cubic coordinates mode */
  108925. static readonly SKYBOX_MODE: number;
  108926. /** Inverse Cubic coordinates mode */
  108927. static readonly INVCUBIC_MODE: number;
  108928. /** Equirectangular coordinates mode */
  108929. static readonly EQUIRECTANGULAR_MODE: number;
  108930. /** Equirectangular Fixed coordinates mode */
  108931. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  108932. /** Equirectangular Fixed Mirrored coordinates mode */
  108933. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  108934. /** Texture is not repeating outside of 0..1 UVs */
  108935. static readonly CLAMP_ADDRESSMODE: number;
  108936. /** Texture is repeating outside of 0..1 UVs */
  108937. static readonly WRAP_ADDRESSMODE: number;
  108938. /** Texture is repeating and mirrored */
  108939. static readonly MIRROR_ADDRESSMODE: number;
  108940. /**
  108941. * 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
  108942. */
  108943. static UseSerializedUrlIfAny: boolean;
  108944. /**
  108945. * Define the url of the texture.
  108946. */
  108947. url: Nullable<string>;
  108948. /**
  108949. * Define an offset on the texture to offset the u coordinates of the UVs
  108950. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108951. */
  108952. uOffset: number;
  108953. /**
  108954. * Define an offset on the texture to offset the v coordinates of the UVs
  108955. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108956. */
  108957. vOffset: number;
  108958. /**
  108959. * Define an offset on the texture to scale the u coordinates of the UVs
  108960. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108961. */
  108962. uScale: number;
  108963. /**
  108964. * Define an offset on the texture to scale the v coordinates of the UVs
  108965. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108966. */
  108967. vScale: number;
  108968. /**
  108969. * Define an offset on the texture to rotate around the u coordinates of the UVs
  108970. * @see https://doc.babylonjs.com/how_to/more_materials
  108971. */
  108972. uAng: number;
  108973. /**
  108974. * Define an offset on the texture to rotate around the v coordinates of the UVs
  108975. * @see https://doc.babylonjs.com/how_to/more_materials
  108976. */
  108977. vAng: number;
  108978. /**
  108979. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  108980. * @see https://doc.babylonjs.com/how_to/more_materials
  108981. */
  108982. wAng: number;
  108983. /**
  108984. * Defines the center of rotation (U)
  108985. */
  108986. uRotationCenter: number;
  108987. /**
  108988. * Defines the center of rotation (V)
  108989. */
  108990. vRotationCenter: number;
  108991. /**
  108992. * Defines the center of rotation (W)
  108993. */
  108994. wRotationCenter: number;
  108995. /**
  108996. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  108997. */
  108998. homogeneousRotationInUVTransform: boolean;
  108999. /**
  109000. * Are mip maps generated for this texture or not.
  109001. */
  109002. get noMipmap(): boolean;
  109003. /**
  109004. * List of inspectable custom properties (used by the Inspector)
  109005. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109006. */
  109007. inspectableCustomProperties: Nullable<IInspectable[]>;
  109008. private _noMipmap;
  109009. /** @hidden */
  109010. _invertY: boolean;
  109011. private _rowGenerationMatrix;
  109012. private _cachedTextureMatrix;
  109013. private _projectionModeMatrix;
  109014. private _t0;
  109015. private _t1;
  109016. private _t2;
  109017. private _cachedUOffset;
  109018. private _cachedVOffset;
  109019. private _cachedUScale;
  109020. private _cachedVScale;
  109021. private _cachedUAng;
  109022. private _cachedVAng;
  109023. private _cachedWAng;
  109024. private _cachedProjectionMatrixId;
  109025. private _cachedURotationCenter;
  109026. private _cachedVRotationCenter;
  109027. private _cachedWRotationCenter;
  109028. private _cachedHomogeneousRotationInUVTransform;
  109029. private _cachedCoordinatesMode;
  109030. /** @hidden */
  109031. protected _initialSamplingMode: number;
  109032. /** @hidden */
  109033. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  109034. private _deleteBuffer;
  109035. protected _format: Nullable<number>;
  109036. private _delayedOnLoad;
  109037. private _delayedOnError;
  109038. private _mimeType?;
  109039. private _loaderOptions?;
  109040. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  109041. get mimeType(): string | undefined;
  109042. /**
  109043. * Observable triggered once the texture has been loaded.
  109044. */
  109045. onLoadObservable: Observable<Texture>;
  109046. protected _isBlocking: boolean;
  109047. /**
  109048. * Is the texture preventing material to render while loading.
  109049. * If false, a default texture will be used instead of the loading one during the preparation step.
  109050. */
  109051. set isBlocking(value: boolean);
  109052. get isBlocking(): boolean;
  109053. /**
  109054. * Get the current sampling mode associated with the texture.
  109055. */
  109056. get samplingMode(): number;
  109057. /**
  109058. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  109059. */
  109060. get invertY(): boolean;
  109061. /**
  109062. * Instantiates a new texture.
  109063. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  109064. * @see https://doc.babylonjs.com/babylon101/materials#texture
  109065. * @param url defines the url of the picture to load as a texture
  109066. * @param sceneOrEngine defines the scene or engine the texture will belong to
  109067. * @param noMipmap defines if the texture will require mip maps or not
  109068. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  109069. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109070. * @param onLoad defines a callback triggered when the texture has been loaded
  109071. * @param onError defines a callback triggered when an error occurred during the loading session
  109072. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  109073. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  109074. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109075. * @param mimeType defines an optional mime type information
  109076. * @param loaderOptions options to be passed to the loader
  109077. */
  109078. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string, loaderOptions?: any);
  109079. /**
  109080. * Update the url (and optional buffer) of this texture if url was null during construction.
  109081. * @param url the url of the texture
  109082. * @param buffer the buffer of the texture (defaults to null)
  109083. * @param onLoad callback called when the texture is loaded (defaults to null)
  109084. */
  109085. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  109086. /**
  109087. * Finish the loading sequence of a texture flagged as delayed load.
  109088. * @hidden
  109089. */
  109090. delayLoad(): void;
  109091. private _prepareRowForTextureGeneration;
  109092. /**
  109093. * Checks if the texture has the same transform matrix than another texture
  109094. * @param texture texture to check against
  109095. * @returns true if the transforms are the same, else false
  109096. */
  109097. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  109098. /**
  109099. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  109100. * @returns the transform matrix of the texture.
  109101. */
  109102. getTextureMatrix(uBase?: number): Matrix;
  109103. /**
  109104. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  109105. * @returns The reflection texture transform
  109106. */
  109107. getReflectionTextureMatrix(): Matrix;
  109108. /**
  109109. * Clones the texture.
  109110. * @returns the cloned texture
  109111. */
  109112. clone(): Texture;
  109113. /**
  109114. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  109115. * @returns The JSON representation of the texture
  109116. */
  109117. serialize(): any;
  109118. /**
  109119. * Get the current class name of the texture useful for serialization or dynamic coding.
  109120. * @returns "Texture"
  109121. */
  109122. getClassName(): string;
  109123. /**
  109124. * Dispose the texture and release its associated resources.
  109125. */
  109126. dispose(): void;
  109127. /**
  109128. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  109129. * @param parsedTexture Define the JSON representation of the texture
  109130. * @param scene Define the scene the parsed texture should be instantiated in
  109131. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  109132. * @returns The parsed texture if successful
  109133. */
  109134. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  109135. /**
  109136. * Creates a texture from its base 64 representation.
  109137. * @param data Define the base64 payload without the data: prefix
  109138. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  109139. * @param scene Define the scene the texture should belong to
  109140. * @param noMipmap Forces the texture to not create mip map information if true
  109141. * @param invertY define if the texture needs to be inverted on the y axis during loading
  109142. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109143. * @param onLoad define a callback triggered when the texture has been loaded
  109144. * @param onError define a callback triggered when an error occurred during the loading session
  109145. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109146. * @returns the created texture
  109147. */
  109148. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  109149. /**
  109150. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  109151. * @param data Define the base64 payload without the data: prefix
  109152. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  109153. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  109154. * @param scene Define the scene the texture should belong to
  109155. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  109156. * @param noMipmap Forces the texture to not create mip map information if true
  109157. * @param invertY define if the texture needs to be inverted on the y axis during loading
  109158. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109159. * @param onLoad define a callback triggered when the texture has been loaded
  109160. * @param onError define a callback triggered when an error occurred during the loading session
  109161. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109162. * @returns the created texture
  109163. */
  109164. 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;
  109165. }
  109166. }
  109167. declare module BABYLON {
  109168. /**
  109169. * PostProcessManager is used to manage one or more post processes or post process pipelines
  109170. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  109171. */
  109172. export class PostProcessManager {
  109173. private _scene;
  109174. private _indexBuffer;
  109175. private _vertexBuffers;
  109176. /**
  109177. * Creates a new instance PostProcess
  109178. * @param scene The scene that the post process is associated with.
  109179. */
  109180. constructor(scene: Scene);
  109181. private _prepareBuffers;
  109182. private _buildIndexBuffer;
  109183. /**
  109184. * Rebuilds the vertex buffers of the manager.
  109185. * @hidden
  109186. */
  109187. _rebuild(): void;
  109188. /**
  109189. * Prepares a frame to be run through a post process.
  109190. * @param sourceTexture The input texture to the post procesess. (default: null)
  109191. * @param postProcesses An array of post processes to be run. (default: null)
  109192. * @returns True if the post processes were able to be run.
  109193. * @hidden
  109194. */
  109195. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  109196. /**
  109197. * Manually render a set of post processes to a texture.
  109198. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  109199. * @param postProcesses An array of post processes to be run.
  109200. * @param targetTexture The target texture to render to.
  109201. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  109202. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  109203. * @param lodLevel defines which lod of the texture to render to
  109204. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  109205. */
  109206. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  109207. /**
  109208. * Finalize the result of the output of the postprocesses.
  109209. * @param doNotPresent If true the result will not be displayed to the screen.
  109210. * @param targetTexture The target texture to render to.
  109211. * @param faceIndex The index of the face to bind the target texture to.
  109212. * @param postProcesses The array of post processes to render.
  109213. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  109214. * @hidden
  109215. */
  109216. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  109217. /**
  109218. * Disposes of the post process manager.
  109219. */
  109220. dispose(): void;
  109221. }
  109222. }
  109223. declare module BABYLON {
  109224. /**
  109225. * This Helps creating a texture that will be created from a camera in your scene.
  109226. * It is basically a dynamic texture that could be used to create special effects for instance.
  109227. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  109228. */
  109229. export class RenderTargetTexture extends Texture {
  109230. /**
  109231. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  109232. */
  109233. static readonly REFRESHRATE_RENDER_ONCE: number;
  109234. /**
  109235. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  109236. */
  109237. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  109238. /**
  109239. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  109240. * the central point of your effect and can save a lot of performances.
  109241. */
  109242. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  109243. /**
  109244. * Use this predicate to dynamically define the list of mesh you want to render.
  109245. * If set, the renderList property will be overwritten.
  109246. */
  109247. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  109248. private _renderList;
  109249. /**
  109250. * Use this list to define the list of mesh you want to render.
  109251. */
  109252. get renderList(): Nullable<Array<AbstractMesh>>;
  109253. set renderList(value: Nullable<Array<AbstractMesh>>);
  109254. /**
  109255. * Use this function to overload the renderList array at rendering time.
  109256. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  109257. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  109258. * the cube (if the RTT is a cube, else layerOrFace=0).
  109259. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  109260. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  109261. * hold dummy elements!
  109262. */
  109263. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  109264. private _hookArray;
  109265. /**
  109266. * Define if particles should be rendered in your texture.
  109267. */
  109268. renderParticles: boolean;
  109269. /**
  109270. * Define if sprites should be rendered in your texture.
  109271. */
  109272. renderSprites: boolean;
  109273. /**
  109274. * Define the camera used to render the texture.
  109275. */
  109276. activeCamera: Nullable<Camera>;
  109277. /**
  109278. * Override the mesh isReady function with your own one.
  109279. */
  109280. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  109281. /**
  109282. * Override the render function of the texture with your own one.
  109283. */
  109284. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  109285. /**
  109286. * Define if camera post processes should be use while rendering the texture.
  109287. */
  109288. useCameraPostProcesses: boolean;
  109289. /**
  109290. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  109291. */
  109292. ignoreCameraViewport: boolean;
  109293. private _postProcessManager;
  109294. private _postProcesses;
  109295. private _resizeObserver;
  109296. /**
  109297. * An event triggered when the texture is unbind.
  109298. */
  109299. onBeforeBindObservable: Observable<RenderTargetTexture>;
  109300. /**
  109301. * An event triggered when the texture is unbind.
  109302. */
  109303. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  109304. private _onAfterUnbindObserver;
  109305. /**
  109306. * Set a after unbind callback in the texture.
  109307. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  109308. */
  109309. set onAfterUnbind(callback: () => void);
  109310. /**
  109311. * An event triggered before rendering the texture
  109312. */
  109313. onBeforeRenderObservable: Observable<number>;
  109314. private _onBeforeRenderObserver;
  109315. /**
  109316. * Set a before render callback in the texture.
  109317. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  109318. */
  109319. set onBeforeRender(callback: (faceIndex: number) => void);
  109320. /**
  109321. * An event triggered after rendering the texture
  109322. */
  109323. onAfterRenderObservable: Observable<number>;
  109324. private _onAfterRenderObserver;
  109325. /**
  109326. * Set a after render callback in the texture.
  109327. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  109328. */
  109329. set onAfterRender(callback: (faceIndex: number) => void);
  109330. /**
  109331. * An event triggered after the texture clear
  109332. */
  109333. onClearObservable: Observable<Engine>;
  109334. private _onClearObserver;
  109335. /**
  109336. * Set a clear callback in the texture.
  109337. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  109338. */
  109339. set onClear(callback: (Engine: Engine) => void);
  109340. /**
  109341. * An event triggered when the texture is resized.
  109342. */
  109343. onResizeObservable: Observable<RenderTargetTexture>;
  109344. /**
  109345. * Define the clear color of the Render Target if it should be different from the scene.
  109346. */
  109347. clearColor: Color4;
  109348. protected _size: number | {
  109349. width: number;
  109350. height: number;
  109351. layers?: number;
  109352. };
  109353. protected _initialSizeParameter: number | {
  109354. width: number;
  109355. height: number;
  109356. } | {
  109357. ratio: number;
  109358. };
  109359. protected _sizeRatio: Nullable<number>;
  109360. /** @hidden */
  109361. _generateMipMaps: boolean;
  109362. protected _renderingManager: RenderingManager;
  109363. /** @hidden */
  109364. _waitingRenderList?: string[];
  109365. protected _doNotChangeAspectRatio: boolean;
  109366. protected _currentRefreshId: number;
  109367. protected _refreshRate: number;
  109368. protected _textureMatrix: Matrix;
  109369. protected _samples: number;
  109370. protected _renderTargetOptions: RenderTargetCreationOptions;
  109371. /**
  109372. * Gets render target creation options that were used.
  109373. */
  109374. get renderTargetOptions(): RenderTargetCreationOptions;
  109375. protected _onRatioRescale(): void;
  109376. /**
  109377. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  109378. * It must define where the camera used to render the texture is set
  109379. */
  109380. boundingBoxPosition: Vector3;
  109381. private _boundingBoxSize;
  109382. /**
  109383. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  109384. * When defined, the cubemap will switch to local mode
  109385. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  109386. * @example https://www.babylonjs-playground.com/#RNASML
  109387. */
  109388. set boundingBoxSize(value: Vector3);
  109389. get boundingBoxSize(): Vector3;
  109390. /**
  109391. * In case the RTT has been created with a depth texture, get the associated
  109392. * depth texture.
  109393. * Otherwise, return null.
  109394. */
  109395. get depthStencilTexture(): Nullable<InternalTexture>;
  109396. /**
  109397. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  109398. * or used a shadow, depth texture...
  109399. * @param name The friendly name of the texture
  109400. * @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)
  109401. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  109402. * @param generateMipMaps True if mip maps need to be generated after render.
  109403. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  109404. * @param type The type of the buffer in the RTT (int, half float, float...)
  109405. * @param isCube True if a cube texture needs to be created
  109406. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  109407. * @param generateDepthBuffer True to generate a depth buffer
  109408. * @param generateStencilBuffer True to generate a stencil buffer
  109409. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  109410. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  109411. * @param delayAllocation if the texture allocation should be delayed (default: false)
  109412. */
  109413. constructor(name: string, size: number | {
  109414. width: number;
  109415. height: number;
  109416. layers?: number;
  109417. } | {
  109418. ratio: number;
  109419. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  109420. /**
  109421. * Creates a depth stencil texture.
  109422. * This is only available in WebGL 2 or with the depth texture extension available.
  109423. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  109424. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  109425. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  109426. */
  109427. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  109428. private _processSizeParameter;
  109429. /**
  109430. * Define the number of samples to use in case of MSAA.
  109431. * It defaults to one meaning no MSAA has been enabled.
  109432. */
  109433. get samples(): number;
  109434. set samples(value: number);
  109435. /**
  109436. * Resets the refresh counter of the texture and start bak from scratch.
  109437. * Could be useful to regenerate the texture if it is setup to render only once.
  109438. */
  109439. resetRefreshCounter(): void;
  109440. /**
  109441. * Define the refresh rate of the texture or the rendering frequency.
  109442. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  109443. */
  109444. get refreshRate(): number;
  109445. set refreshRate(value: number);
  109446. /**
  109447. * Adds a post process to the render target rendering passes.
  109448. * @param postProcess define the post process to add
  109449. */
  109450. addPostProcess(postProcess: PostProcess): void;
  109451. /**
  109452. * Clear all the post processes attached to the render target
  109453. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  109454. */
  109455. clearPostProcesses(dispose?: boolean): void;
  109456. /**
  109457. * Remove one of the post process from the list of attached post processes to the texture
  109458. * @param postProcess define the post process to remove from the list
  109459. */
  109460. removePostProcess(postProcess: PostProcess): void;
  109461. /** @hidden */
  109462. _shouldRender(): boolean;
  109463. /**
  109464. * Gets the actual render size of the texture.
  109465. * @returns the width of the render size
  109466. */
  109467. getRenderSize(): number;
  109468. /**
  109469. * Gets the actual render width of the texture.
  109470. * @returns the width of the render size
  109471. */
  109472. getRenderWidth(): number;
  109473. /**
  109474. * Gets the actual render height of the texture.
  109475. * @returns the height of the render size
  109476. */
  109477. getRenderHeight(): number;
  109478. /**
  109479. * Gets the actual number of layers of the texture.
  109480. * @returns the number of layers
  109481. */
  109482. getRenderLayers(): number;
  109483. /**
  109484. * Get if the texture can be rescaled or not.
  109485. */
  109486. get canRescale(): boolean;
  109487. /**
  109488. * Resize the texture using a ratio.
  109489. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  109490. */
  109491. scale(ratio: number): void;
  109492. /**
  109493. * Get the texture reflection matrix used to rotate/transform the reflection.
  109494. * @returns the reflection matrix
  109495. */
  109496. getReflectionTextureMatrix(): Matrix;
  109497. /**
  109498. * Resize the texture to a new desired size.
  109499. * Be carrefull as it will recreate all the data in the new texture.
  109500. * @param size Define the new size. It can be:
  109501. * - a number for squared texture,
  109502. * - an object containing { width: number, height: number }
  109503. * - or an object containing a ratio { ratio: number }
  109504. */
  109505. resize(size: number | {
  109506. width: number;
  109507. height: number;
  109508. } | {
  109509. ratio: number;
  109510. }): void;
  109511. private _defaultRenderListPrepared;
  109512. /**
  109513. * Renders all the objects from the render list into the texture.
  109514. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  109515. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  109516. */
  109517. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  109518. private _bestReflectionRenderTargetDimension;
  109519. private _prepareRenderingManager;
  109520. /**
  109521. * @hidden
  109522. * @param faceIndex face index to bind to if this is a cubetexture
  109523. * @param layer defines the index of the texture to bind in the array
  109524. */
  109525. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  109526. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109527. private renderToTarget;
  109528. /**
  109529. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  109530. * This allowed control for front to back rendering or reversly depending of the special needs.
  109531. *
  109532. * @param renderingGroupId The rendering group id corresponding to its index
  109533. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  109534. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  109535. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  109536. */
  109537. 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;
  109538. /**
  109539. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  109540. *
  109541. * @param renderingGroupId The rendering group id corresponding to its index
  109542. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  109543. */
  109544. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  109545. /**
  109546. * Clones the texture.
  109547. * @returns the cloned texture
  109548. */
  109549. clone(): RenderTargetTexture;
  109550. /**
  109551. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  109552. * @returns The JSON representation of the texture
  109553. */
  109554. serialize(): any;
  109555. /**
  109556. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  109557. */
  109558. disposeFramebufferObjects(): void;
  109559. /**
  109560. * Dispose the texture and release its associated resources.
  109561. */
  109562. dispose(): void;
  109563. /** @hidden */
  109564. _rebuild(): void;
  109565. /**
  109566. * Clear the info related to rendering groups preventing retention point in material dispose.
  109567. */
  109568. freeRenderingGroups(): void;
  109569. /**
  109570. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  109571. * @returns the view count
  109572. */
  109573. getViewCount(): number;
  109574. }
  109575. }
  109576. declare module BABYLON {
  109577. /**
  109578. * Class used to manipulate GUIDs
  109579. */
  109580. export class GUID {
  109581. /**
  109582. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  109583. * Be aware Math.random() could cause collisions, but:
  109584. * "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"
  109585. * @returns a pseudo random id
  109586. */
  109587. static RandomId(): string;
  109588. }
  109589. }
  109590. declare module BABYLON {
  109591. /**
  109592. * Options to be used when creating a shadow depth material
  109593. */
  109594. export interface IIOptionShadowDepthMaterial {
  109595. /** Variables in the vertex shader code that need to have their names remapped.
  109596. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  109597. * "var_name" should be either: worldPos or vNormalW
  109598. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  109599. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  109600. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  109601. */
  109602. remappedVariables?: string[];
  109603. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  109604. standalone?: boolean;
  109605. }
  109606. /**
  109607. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  109608. */
  109609. export class ShadowDepthWrapper {
  109610. private _scene;
  109611. private _options?;
  109612. private _baseMaterial;
  109613. private _onEffectCreatedObserver;
  109614. private _subMeshToEffect;
  109615. private _subMeshToDepthEffect;
  109616. private _meshes;
  109617. /** @hidden */
  109618. _matriceNames: any;
  109619. /** Gets the standalone status of the wrapper */
  109620. get standalone(): boolean;
  109621. /** Gets the base material the wrapper is built upon */
  109622. get baseMaterial(): Material;
  109623. /**
  109624. * Instantiate a new shadow depth wrapper.
  109625. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  109626. * generate the shadow depth map. For more information, please refer to the documentation:
  109627. * https://doc.babylonjs.com/babylon101/shadows
  109628. * @param baseMaterial Material to wrap
  109629. * @param scene Define the scene the material belongs to
  109630. * @param options Options used to create the wrapper
  109631. */
  109632. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  109633. /**
  109634. * Gets the effect to use to generate the depth map
  109635. * @param subMesh subMesh to get the effect for
  109636. * @param shadowGenerator shadow generator to get the effect for
  109637. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  109638. */
  109639. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  109640. /**
  109641. * Specifies that the submesh is ready to be used for depth rendering
  109642. * @param subMesh submesh to check
  109643. * @param defines the list of defines to take into account when checking the effect
  109644. * @param shadowGenerator combined with subMesh, it defines the effect to check
  109645. * @param useInstances specifies that instances should be used
  109646. * @returns a boolean indicating that the submesh is ready or not
  109647. */
  109648. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  109649. /**
  109650. * Disposes the resources
  109651. */
  109652. dispose(): void;
  109653. private _makeEffect;
  109654. }
  109655. }
  109656. declare module BABYLON {
  109657. /**
  109658. * Options for compiling materials.
  109659. */
  109660. export interface IMaterialCompilationOptions {
  109661. /**
  109662. * Defines whether clip planes are enabled.
  109663. */
  109664. clipPlane: boolean;
  109665. /**
  109666. * Defines whether instances are enabled.
  109667. */
  109668. useInstances: boolean;
  109669. }
  109670. /**
  109671. * Options passed when calling customShaderNameResolve
  109672. */
  109673. export interface ICustomShaderNameResolveOptions {
  109674. /**
  109675. * 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
  109676. */
  109677. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  109678. }
  109679. /**
  109680. * Base class for the main features of a material in Babylon.js
  109681. */
  109682. export class Material implements IAnimatable {
  109683. /**
  109684. * Returns the triangle fill mode
  109685. */
  109686. static readonly TriangleFillMode: number;
  109687. /**
  109688. * Returns the wireframe mode
  109689. */
  109690. static readonly WireFrameFillMode: number;
  109691. /**
  109692. * Returns the point fill mode
  109693. */
  109694. static readonly PointFillMode: number;
  109695. /**
  109696. * Returns the point list draw mode
  109697. */
  109698. static readonly PointListDrawMode: number;
  109699. /**
  109700. * Returns the line list draw mode
  109701. */
  109702. static readonly LineListDrawMode: number;
  109703. /**
  109704. * Returns the line loop draw mode
  109705. */
  109706. static readonly LineLoopDrawMode: number;
  109707. /**
  109708. * Returns the line strip draw mode
  109709. */
  109710. static readonly LineStripDrawMode: number;
  109711. /**
  109712. * Returns the triangle strip draw mode
  109713. */
  109714. static readonly TriangleStripDrawMode: number;
  109715. /**
  109716. * Returns the triangle fan draw mode
  109717. */
  109718. static readonly TriangleFanDrawMode: number;
  109719. /**
  109720. * Stores the clock-wise side orientation
  109721. */
  109722. static readonly ClockWiseSideOrientation: number;
  109723. /**
  109724. * Stores the counter clock-wise side orientation
  109725. */
  109726. static readonly CounterClockWiseSideOrientation: number;
  109727. /**
  109728. * The dirty texture flag value
  109729. */
  109730. static readonly TextureDirtyFlag: number;
  109731. /**
  109732. * The dirty light flag value
  109733. */
  109734. static readonly LightDirtyFlag: number;
  109735. /**
  109736. * The dirty fresnel flag value
  109737. */
  109738. static readonly FresnelDirtyFlag: number;
  109739. /**
  109740. * The dirty attribute flag value
  109741. */
  109742. static readonly AttributesDirtyFlag: number;
  109743. /**
  109744. * The dirty misc flag value
  109745. */
  109746. static readonly MiscDirtyFlag: number;
  109747. /**
  109748. * The dirty prepass flag value
  109749. */
  109750. static readonly PrePassDirtyFlag: number;
  109751. /**
  109752. * The all dirty flag value
  109753. */
  109754. static readonly AllDirtyFlag: number;
  109755. /**
  109756. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  109757. */
  109758. static readonly MATERIAL_OPAQUE: number;
  109759. /**
  109760. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  109761. */
  109762. static readonly MATERIAL_ALPHATEST: number;
  109763. /**
  109764. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109765. */
  109766. static readonly MATERIAL_ALPHABLEND: number;
  109767. /**
  109768. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109769. * They are also discarded below the alpha cutoff threshold to improve performances.
  109770. */
  109771. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  109772. /**
  109773. * The Whiteout method is used to blend normals.
  109774. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  109775. */
  109776. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  109777. /**
  109778. * The Reoriented Normal Mapping method is used to blend normals.
  109779. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  109780. */
  109781. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  109782. /**
  109783. * Custom callback helping to override the default shader used in the material.
  109784. */
  109785. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  109786. /**
  109787. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  109788. */
  109789. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  109790. /**
  109791. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  109792. * This means that the material can keep using a previous shader while a new one is being compiled.
  109793. * This is mostly used when shader parallel compilation is supported (true by default)
  109794. */
  109795. allowShaderHotSwapping: boolean;
  109796. /**
  109797. * The ID of the material
  109798. */
  109799. id: string;
  109800. /**
  109801. * Gets or sets the unique id of the material
  109802. */
  109803. uniqueId: number;
  109804. /**
  109805. * The name of the material
  109806. */
  109807. name: string;
  109808. /**
  109809. * Gets or sets user defined metadata
  109810. */
  109811. metadata: any;
  109812. /**
  109813. * For internal use only. Please do not use.
  109814. */
  109815. reservedDataStore: any;
  109816. /**
  109817. * Specifies if the ready state should be checked on each call
  109818. */
  109819. checkReadyOnEveryCall: boolean;
  109820. /**
  109821. * Specifies if the ready state should be checked once
  109822. */
  109823. checkReadyOnlyOnce: boolean;
  109824. /**
  109825. * The state of the material
  109826. */
  109827. state: string;
  109828. /**
  109829. * If the material can be rendered to several textures with MRT extension
  109830. */
  109831. get canRenderToMRT(): boolean;
  109832. /**
  109833. * The alpha value of the material
  109834. */
  109835. protected _alpha: number;
  109836. /**
  109837. * List of inspectable custom properties (used by the Inspector)
  109838. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109839. */
  109840. inspectableCustomProperties: IInspectable[];
  109841. /**
  109842. * Sets the alpha value of the material
  109843. */
  109844. set alpha(value: number);
  109845. /**
  109846. * Gets the alpha value of the material
  109847. */
  109848. get alpha(): number;
  109849. /**
  109850. * Specifies if back face culling is enabled
  109851. */
  109852. protected _backFaceCulling: boolean;
  109853. /**
  109854. * Sets the back-face culling state
  109855. */
  109856. set backFaceCulling(value: boolean);
  109857. /**
  109858. * Gets the back-face culling state
  109859. */
  109860. get backFaceCulling(): boolean;
  109861. /**
  109862. * Stores the value for side orientation
  109863. */
  109864. sideOrientation: number;
  109865. /**
  109866. * Callback triggered when the material is compiled
  109867. */
  109868. onCompiled: Nullable<(effect: Effect) => void>;
  109869. /**
  109870. * Callback triggered when an error occurs
  109871. */
  109872. onError: Nullable<(effect: Effect, errors: string) => void>;
  109873. /**
  109874. * Callback triggered to get the render target textures
  109875. */
  109876. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  109877. /**
  109878. * Gets a boolean indicating that current material needs to register RTT
  109879. */
  109880. get hasRenderTargetTextures(): boolean;
  109881. /**
  109882. * Specifies if the material should be serialized
  109883. */
  109884. doNotSerialize: boolean;
  109885. /**
  109886. * @hidden
  109887. */
  109888. _storeEffectOnSubMeshes: boolean;
  109889. /**
  109890. * Stores the animations for the material
  109891. */
  109892. animations: Nullable<Array<Animation>>;
  109893. /**
  109894. * An event triggered when the material is disposed
  109895. */
  109896. onDisposeObservable: Observable<Material>;
  109897. /**
  109898. * An observer which watches for dispose events
  109899. */
  109900. private _onDisposeObserver;
  109901. private _onUnBindObservable;
  109902. /**
  109903. * Called during a dispose event
  109904. */
  109905. set onDispose(callback: () => void);
  109906. private _onBindObservable;
  109907. /**
  109908. * An event triggered when the material is bound
  109909. */
  109910. get onBindObservable(): Observable<AbstractMesh>;
  109911. /**
  109912. * An observer which watches for bind events
  109913. */
  109914. private _onBindObserver;
  109915. /**
  109916. * Called during a bind event
  109917. */
  109918. set onBind(callback: (Mesh: AbstractMesh) => void);
  109919. /**
  109920. * An event triggered when the material is unbound
  109921. */
  109922. get onUnBindObservable(): Observable<Material>;
  109923. protected _onEffectCreatedObservable: Nullable<Observable<{
  109924. effect: Effect;
  109925. subMesh: Nullable<SubMesh>;
  109926. }>>;
  109927. /**
  109928. * An event triggered when the effect is (re)created
  109929. */
  109930. get onEffectCreatedObservable(): Observable<{
  109931. effect: Effect;
  109932. subMesh: Nullable<SubMesh>;
  109933. }>;
  109934. /**
  109935. * Stores the value of the alpha mode
  109936. */
  109937. private _alphaMode;
  109938. /**
  109939. * Sets the value of the alpha mode.
  109940. *
  109941. * | Value | Type | Description |
  109942. * | --- | --- | --- |
  109943. * | 0 | ALPHA_DISABLE | |
  109944. * | 1 | ALPHA_ADD | |
  109945. * | 2 | ALPHA_COMBINE | |
  109946. * | 3 | ALPHA_SUBTRACT | |
  109947. * | 4 | ALPHA_MULTIPLY | |
  109948. * | 5 | ALPHA_MAXIMIZED | |
  109949. * | 6 | ALPHA_ONEONE | |
  109950. * | 7 | ALPHA_PREMULTIPLIED | |
  109951. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  109952. * | 9 | ALPHA_INTERPOLATE | |
  109953. * | 10 | ALPHA_SCREENMODE | |
  109954. *
  109955. */
  109956. set alphaMode(value: number);
  109957. /**
  109958. * Gets the value of the alpha mode
  109959. */
  109960. get alphaMode(): number;
  109961. /**
  109962. * Stores the state of the need depth pre-pass value
  109963. */
  109964. private _needDepthPrePass;
  109965. /**
  109966. * Sets the need depth pre-pass value
  109967. */
  109968. set needDepthPrePass(value: boolean);
  109969. /**
  109970. * Gets the depth pre-pass value
  109971. */
  109972. get needDepthPrePass(): boolean;
  109973. /**
  109974. * Specifies if depth writing should be disabled
  109975. */
  109976. disableDepthWrite: boolean;
  109977. /**
  109978. * Specifies if color writing should be disabled
  109979. */
  109980. disableColorWrite: boolean;
  109981. /**
  109982. * Specifies if depth writing should be forced
  109983. */
  109984. forceDepthWrite: boolean;
  109985. /**
  109986. * Specifies the depth function that should be used. 0 means the default engine function
  109987. */
  109988. depthFunction: number;
  109989. /**
  109990. * Specifies if there should be a separate pass for culling
  109991. */
  109992. separateCullingPass: boolean;
  109993. /**
  109994. * Stores the state specifing if fog should be enabled
  109995. */
  109996. private _fogEnabled;
  109997. /**
  109998. * Sets the state for enabling fog
  109999. */
  110000. set fogEnabled(value: boolean);
  110001. /**
  110002. * Gets the value of the fog enabled state
  110003. */
  110004. get fogEnabled(): boolean;
  110005. /**
  110006. * Stores the size of points
  110007. */
  110008. pointSize: number;
  110009. /**
  110010. * Stores the z offset value
  110011. */
  110012. zOffset: number;
  110013. get wireframe(): boolean;
  110014. /**
  110015. * Sets the state of wireframe mode
  110016. */
  110017. set wireframe(value: boolean);
  110018. /**
  110019. * Gets the value specifying if point clouds are enabled
  110020. */
  110021. get pointsCloud(): boolean;
  110022. /**
  110023. * Sets the state of point cloud mode
  110024. */
  110025. set pointsCloud(value: boolean);
  110026. /**
  110027. * Gets the material fill mode
  110028. */
  110029. get fillMode(): number;
  110030. /**
  110031. * Sets the material fill mode
  110032. */
  110033. set fillMode(value: number);
  110034. /**
  110035. * @hidden
  110036. * Stores the effects for the material
  110037. */
  110038. _effect: Nullable<Effect>;
  110039. /**
  110040. * Specifies if uniform buffers should be used
  110041. */
  110042. private _useUBO;
  110043. /**
  110044. * Stores a reference to the scene
  110045. */
  110046. private _scene;
  110047. /**
  110048. * Stores the fill mode state
  110049. */
  110050. private _fillMode;
  110051. /**
  110052. * Specifies if the depth write state should be cached
  110053. */
  110054. private _cachedDepthWriteState;
  110055. /**
  110056. * Specifies if the color write state should be cached
  110057. */
  110058. private _cachedColorWriteState;
  110059. /**
  110060. * Specifies if the depth function state should be cached
  110061. */
  110062. private _cachedDepthFunctionState;
  110063. /**
  110064. * Stores the uniform buffer
  110065. */
  110066. protected _uniformBuffer: UniformBuffer;
  110067. /** @hidden */
  110068. _indexInSceneMaterialArray: number;
  110069. /** @hidden */
  110070. meshMap: Nullable<{
  110071. [id: string]: AbstractMesh | undefined;
  110072. }>;
  110073. /**
  110074. * Creates a material instance
  110075. * @param name defines the name of the material
  110076. * @param scene defines the scene to reference
  110077. * @param doNotAdd specifies if the material should be added to the scene
  110078. */
  110079. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  110080. /**
  110081. * Returns a string representation of the current material
  110082. * @param fullDetails defines a boolean indicating which levels of logging is desired
  110083. * @returns a string with material information
  110084. */
  110085. toString(fullDetails?: boolean): string;
  110086. /**
  110087. * Gets the class name of the material
  110088. * @returns a string with the class name of the material
  110089. */
  110090. getClassName(): string;
  110091. /**
  110092. * Specifies if updates for the material been locked
  110093. */
  110094. get isFrozen(): boolean;
  110095. /**
  110096. * Locks updates for the material
  110097. */
  110098. freeze(): void;
  110099. /**
  110100. * Unlocks updates for the material
  110101. */
  110102. unfreeze(): void;
  110103. /**
  110104. * Specifies if the material is ready to be used
  110105. * @param mesh defines the mesh to check
  110106. * @param useInstances specifies if instances should be used
  110107. * @returns a boolean indicating if the material is ready to be used
  110108. */
  110109. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  110110. /**
  110111. * Specifies that the submesh is ready to be used
  110112. * @param mesh defines the mesh to check
  110113. * @param subMesh defines which submesh to check
  110114. * @param useInstances specifies that instances should be used
  110115. * @returns a boolean indicating that the submesh is ready or not
  110116. */
  110117. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110118. /**
  110119. * Returns the material effect
  110120. * @returns the effect associated with the material
  110121. */
  110122. getEffect(): Nullable<Effect>;
  110123. /**
  110124. * Returns the current scene
  110125. * @returns a Scene
  110126. */
  110127. getScene(): Scene;
  110128. /**
  110129. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  110130. */
  110131. protected _forceAlphaTest: boolean;
  110132. /**
  110133. * The transparency mode of the material.
  110134. */
  110135. protected _transparencyMode: Nullable<number>;
  110136. /**
  110137. * Gets the current transparency mode.
  110138. */
  110139. get transparencyMode(): Nullable<number>;
  110140. /**
  110141. * Sets the transparency mode of the material.
  110142. *
  110143. * | Value | Type | Description |
  110144. * | ----- | ----------------------------------- | ----------- |
  110145. * | 0 | OPAQUE | |
  110146. * | 1 | ALPHATEST | |
  110147. * | 2 | ALPHABLEND | |
  110148. * | 3 | ALPHATESTANDBLEND | |
  110149. *
  110150. */
  110151. set transparencyMode(value: Nullable<number>);
  110152. /**
  110153. * Returns true if alpha blending should be disabled.
  110154. */
  110155. protected get _disableAlphaBlending(): boolean;
  110156. /**
  110157. * Specifies whether or not this material should be rendered in alpha blend mode.
  110158. * @returns a boolean specifying if alpha blending is needed
  110159. */
  110160. needAlphaBlending(): boolean;
  110161. /**
  110162. * Specifies if the mesh will require alpha blending
  110163. * @param mesh defines the mesh to check
  110164. * @returns a boolean specifying if alpha blending is needed for the mesh
  110165. */
  110166. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  110167. /**
  110168. * Specifies whether or not this material should be rendered in alpha test mode.
  110169. * @returns a boolean specifying if an alpha test is needed.
  110170. */
  110171. needAlphaTesting(): boolean;
  110172. /**
  110173. * Specifies if material alpha testing should be turned on for the mesh
  110174. * @param mesh defines the mesh to check
  110175. */
  110176. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  110177. /**
  110178. * Gets the texture used for the alpha test
  110179. * @returns the texture to use for alpha testing
  110180. */
  110181. getAlphaTestTexture(): Nullable<BaseTexture>;
  110182. /**
  110183. * Marks the material to indicate that it needs to be re-calculated
  110184. */
  110185. markDirty(): void;
  110186. /** @hidden */
  110187. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  110188. /**
  110189. * Binds the material to the mesh
  110190. * @param world defines the world transformation matrix
  110191. * @param mesh defines the mesh to bind the material to
  110192. */
  110193. bind(world: Matrix, mesh?: Mesh): void;
  110194. /**
  110195. * Binds the submesh to the material
  110196. * @param world defines the world transformation matrix
  110197. * @param mesh defines the mesh containing the submesh
  110198. * @param subMesh defines the submesh to bind the material to
  110199. */
  110200. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110201. /**
  110202. * Binds the world matrix to the material
  110203. * @param world defines the world transformation matrix
  110204. */
  110205. bindOnlyWorldMatrix(world: Matrix): void;
  110206. /**
  110207. * Binds the scene's uniform buffer to the effect.
  110208. * @param effect defines the effect to bind to the scene uniform buffer
  110209. * @param sceneUbo defines the uniform buffer storing scene data
  110210. */
  110211. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  110212. /**
  110213. * Binds the view matrix to the effect
  110214. * @param effect defines the effect to bind the view matrix to
  110215. */
  110216. bindView(effect: Effect): void;
  110217. /**
  110218. * Binds the view projection matrix to the effect
  110219. * @param effect defines the effect to bind the view projection matrix to
  110220. */
  110221. bindViewProjection(effect: Effect): void;
  110222. /**
  110223. * Processes to execute after binding the material to a mesh
  110224. * @param mesh defines the rendered mesh
  110225. */
  110226. protected _afterBind(mesh?: Mesh): void;
  110227. /**
  110228. * Unbinds the material from the mesh
  110229. */
  110230. unbind(): void;
  110231. /**
  110232. * Gets the active textures from the material
  110233. * @returns an array of textures
  110234. */
  110235. getActiveTextures(): BaseTexture[];
  110236. /**
  110237. * Specifies if the material uses a texture
  110238. * @param texture defines the texture to check against the material
  110239. * @returns a boolean specifying if the material uses the texture
  110240. */
  110241. hasTexture(texture: BaseTexture): boolean;
  110242. /**
  110243. * Makes a duplicate of the material, and gives it a new name
  110244. * @param name defines the new name for the duplicated material
  110245. * @returns the cloned material
  110246. */
  110247. clone(name: string): Nullable<Material>;
  110248. /**
  110249. * Gets the meshes bound to the material
  110250. * @returns an array of meshes bound to the material
  110251. */
  110252. getBindedMeshes(): AbstractMesh[];
  110253. /**
  110254. * Force shader compilation
  110255. * @param mesh defines the mesh associated with this material
  110256. * @param onCompiled defines a function to execute once the material is compiled
  110257. * @param options defines the options to configure the compilation
  110258. * @param onError defines a function to execute if the material fails compiling
  110259. */
  110260. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  110261. /**
  110262. * Force shader compilation
  110263. * @param mesh defines the mesh that will use this material
  110264. * @param options defines additional options for compiling the shaders
  110265. * @returns a promise that resolves when the compilation completes
  110266. */
  110267. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  110268. private static readonly _AllDirtyCallBack;
  110269. private static readonly _ImageProcessingDirtyCallBack;
  110270. private static readonly _TextureDirtyCallBack;
  110271. private static readonly _FresnelDirtyCallBack;
  110272. private static readonly _MiscDirtyCallBack;
  110273. private static readonly _PrePassDirtyCallBack;
  110274. private static readonly _LightsDirtyCallBack;
  110275. private static readonly _AttributeDirtyCallBack;
  110276. private static _FresnelAndMiscDirtyCallBack;
  110277. private static _TextureAndMiscDirtyCallBack;
  110278. private static readonly _DirtyCallbackArray;
  110279. private static readonly _RunDirtyCallBacks;
  110280. /**
  110281. * Marks a define in the material to indicate that it needs to be re-computed
  110282. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  110283. */
  110284. markAsDirty(flag: number): void;
  110285. /**
  110286. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  110287. * @param func defines a function which checks material defines against the submeshes
  110288. */
  110289. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  110290. /**
  110291. * Indicates that the scene should check if the rendering now needs a prepass
  110292. */
  110293. protected _markScenePrePassDirty(): void;
  110294. /**
  110295. * Indicates that we need to re-calculated for all submeshes
  110296. */
  110297. protected _markAllSubMeshesAsAllDirty(): void;
  110298. /**
  110299. * Indicates that image processing needs to be re-calculated for all submeshes
  110300. */
  110301. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  110302. /**
  110303. * Indicates that textures need to be re-calculated for all submeshes
  110304. */
  110305. protected _markAllSubMeshesAsTexturesDirty(): void;
  110306. /**
  110307. * Indicates that fresnel needs to be re-calculated for all submeshes
  110308. */
  110309. protected _markAllSubMeshesAsFresnelDirty(): void;
  110310. /**
  110311. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  110312. */
  110313. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  110314. /**
  110315. * Indicates that lights need to be re-calculated for all submeshes
  110316. */
  110317. protected _markAllSubMeshesAsLightsDirty(): void;
  110318. /**
  110319. * Indicates that attributes need to be re-calculated for all submeshes
  110320. */
  110321. protected _markAllSubMeshesAsAttributesDirty(): void;
  110322. /**
  110323. * Indicates that misc needs to be re-calculated for all submeshes
  110324. */
  110325. protected _markAllSubMeshesAsMiscDirty(): void;
  110326. /**
  110327. * Indicates that prepass needs to be re-calculated for all submeshes
  110328. */
  110329. protected _markAllSubMeshesAsPrePassDirty(): void;
  110330. /**
  110331. * Indicates that textures and misc need to be re-calculated for all submeshes
  110332. */
  110333. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  110334. /**
  110335. * Sets the required values to the prepass renderer.
  110336. * @param prePassRenderer defines the prepass renderer to setup.
  110337. * @returns true if the pre pass is needed.
  110338. */
  110339. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  110340. /**
  110341. * Disposes the material
  110342. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  110343. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  110344. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  110345. */
  110346. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  110347. /** @hidden */
  110348. private releaseVertexArrayObject;
  110349. /**
  110350. * Serializes this material
  110351. * @returns the serialized material object
  110352. */
  110353. serialize(): any;
  110354. /**
  110355. * Creates a material from parsed material data
  110356. * @param parsedMaterial defines parsed material data
  110357. * @param scene defines the hosting scene
  110358. * @param rootUrl defines the root URL to use to load textures
  110359. * @returns a new material
  110360. */
  110361. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  110362. }
  110363. }
  110364. declare module BABYLON {
  110365. /**
  110366. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110367. * separate meshes. This can be use to improve performances.
  110368. * @see https://doc.babylonjs.com/how_to/multi_materials
  110369. */
  110370. export class MultiMaterial extends Material {
  110371. private _subMaterials;
  110372. /**
  110373. * Gets or Sets the list of Materials used within the multi material.
  110374. * They need to be ordered according to the submeshes order in the associated mesh
  110375. */
  110376. get subMaterials(): Nullable<Material>[];
  110377. set subMaterials(value: Nullable<Material>[]);
  110378. /**
  110379. * Function used to align with Node.getChildren()
  110380. * @returns the list of Materials used within the multi material
  110381. */
  110382. getChildren(): Nullable<Material>[];
  110383. /**
  110384. * Instantiates a new Multi Material
  110385. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110386. * separate meshes. This can be use to improve performances.
  110387. * @see https://doc.babylonjs.com/how_to/multi_materials
  110388. * @param name Define the name in the scene
  110389. * @param scene Define the scene the material belongs to
  110390. */
  110391. constructor(name: string, scene: Scene);
  110392. private _hookArray;
  110393. /**
  110394. * Get one of the submaterial by its index in the submaterials array
  110395. * @param index The index to look the sub material at
  110396. * @returns The Material if the index has been defined
  110397. */
  110398. getSubMaterial(index: number): Nullable<Material>;
  110399. /**
  110400. * Get the list of active textures for the whole sub materials list.
  110401. * @returns All the textures that will be used during the rendering
  110402. */
  110403. getActiveTextures(): BaseTexture[];
  110404. /**
  110405. * Gets the current class name of the material e.g. "MultiMaterial"
  110406. * Mainly use in serialization.
  110407. * @returns the class name
  110408. */
  110409. getClassName(): string;
  110410. /**
  110411. * Checks if the material is ready to render the requested sub mesh
  110412. * @param mesh Define the mesh the submesh belongs to
  110413. * @param subMesh Define the sub mesh to look readyness for
  110414. * @param useInstances Define whether or not the material is used with instances
  110415. * @returns true if ready, otherwise false
  110416. */
  110417. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110418. /**
  110419. * Clones the current material and its related sub materials
  110420. * @param name Define the name of the newly cloned material
  110421. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  110422. * @returns the cloned material
  110423. */
  110424. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  110425. /**
  110426. * Serializes the materials into a JSON representation.
  110427. * @returns the JSON representation
  110428. */
  110429. serialize(): any;
  110430. /**
  110431. * Dispose the material and release its associated resources
  110432. * @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)
  110433. * @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)
  110434. * @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)
  110435. */
  110436. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  110437. /**
  110438. * Creates a MultiMaterial from parsed MultiMaterial data.
  110439. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  110440. * @param scene defines the hosting scene
  110441. * @returns a new MultiMaterial
  110442. */
  110443. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  110444. }
  110445. }
  110446. declare module BABYLON {
  110447. /**
  110448. * Defines a subdivision inside a mesh
  110449. */
  110450. export class SubMesh implements ICullable {
  110451. /** the material index to use */
  110452. materialIndex: number;
  110453. /** vertex index start */
  110454. verticesStart: number;
  110455. /** vertices count */
  110456. verticesCount: number;
  110457. /** index start */
  110458. indexStart: number;
  110459. /** indices count */
  110460. indexCount: number;
  110461. /** @hidden */
  110462. _materialDefines: Nullable<MaterialDefines>;
  110463. /** @hidden */
  110464. _materialEffect: Nullable<Effect>;
  110465. /** @hidden */
  110466. _effectOverride: Nullable<Effect>;
  110467. /**
  110468. * Gets material defines used by the effect associated to the sub mesh
  110469. */
  110470. get materialDefines(): Nullable<MaterialDefines>;
  110471. /**
  110472. * Sets material defines used by the effect associated to the sub mesh
  110473. */
  110474. set materialDefines(defines: Nullable<MaterialDefines>);
  110475. /**
  110476. * Gets associated effect
  110477. */
  110478. get effect(): Nullable<Effect>;
  110479. /**
  110480. * Sets associated effect (effect used to render this submesh)
  110481. * @param effect defines the effect to associate with
  110482. * @param defines defines the set of defines used to compile this effect
  110483. */
  110484. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  110485. /** @hidden */
  110486. _linesIndexCount: number;
  110487. private _mesh;
  110488. private _renderingMesh;
  110489. private _boundingInfo;
  110490. private _linesIndexBuffer;
  110491. /** @hidden */
  110492. _lastColliderWorldVertices: Nullable<Vector3[]>;
  110493. /** @hidden */
  110494. _trianglePlanes: Plane[];
  110495. /** @hidden */
  110496. _lastColliderTransformMatrix: Nullable<Matrix>;
  110497. /** @hidden */
  110498. _renderId: number;
  110499. /** @hidden */
  110500. _alphaIndex: number;
  110501. /** @hidden */
  110502. _distanceToCamera: number;
  110503. /** @hidden */
  110504. _id: number;
  110505. private _currentMaterial;
  110506. /**
  110507. * Add a new submesh to a mesh
  110508. * @param materialIndex defines the material index to use
  110509. * @param verticesStart defines vertex index start
  110510. * @param verticesCount defines vertices count
  110511. * @param indexStart defines index start
  110512. * @param indexCount defines indices count
  110513. * @param mesh defines the parent mesh
  110514. * @param renderingMesh defines an optional rendering mesh
  110515. * @param createBoundingBox defines if bounding box should be created for this submesh
  110516. * @returns the new submesh
  110517. */
  110518. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  110519. /**
  110520. * Creates a new submesh
  110521. * @param materialIndex defines the material index to use
  110522. * @param verticesStart defines vertex index start
  110523. * @param verticesCount defines vertices count
  110524. * @param indexStart defines index start
  110525. * @param indexCount defines indices count
  110526. * @param mesh defines the parent mesh
  110527. * @param renderingMesh defines an optional rendering mesh
  110528. * @param createBoundingBox defines if bounding box should be created for this submesh
  110529. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  110530. */
  110531. constructor(
  110532. /** the material index to use */
  110533. materialIndex: number,
  110534. /** vertex index start */
  110535. verticesStart: number,
  110536. /** vertices count */
  110537. verticesCount: number,
  110538. /** index start */
  110539. indexStart: number,
  110540. /** indices count */
  110541. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  110542. /**
  110543. * Returns true if this submesh covers the entire parent mesh
  110544. * @ignorenaming
  110545. */
  110546. get IsGlobal(): boolean;
  110547. /**
  110548. * Returns the submesh BoudingInfo object
  110549. * @returns current bounding info (or mesh's one if the submesh is global)
  110550. */
  110551. getBoundingInfo(): BoundingInfo;
  110552. /**
  110553. * Sets the submesh BoundingInfo
  110554. * @param boundingInfo defines the new bounding info to use
  110555. * @returns the SubMesh
  110556. */
  110557. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  110558. /**
  110559. * Returns the mesh of the current submesh
  110560. * @return the parent mesh
  110561. */
  110562. getMesh(): AbstractMesh;
  110563. /**
  110564. * Returns the rendering mesh of the submesh
  110565. * @returns the rendering mesh (could be different from parent mesh)
  110566. */
  110567. getRenderingMesh(): Mesh;
  110568. /**
  110569. * Returns the replacement mesh of the submesh
  110570. * @returns the replacement mesh (could be different from parent mesh)
  110571. */
  110572. getReplacementMesh(): Nullable<AbstractMesh>;
  110573. /**
  110574. * Returns the effective mesh of the submesh
  110575. * @returns the effective mesh (could be different from parent mesh)
  110576. */
  110577. getEffectiveMesh(): AbstractMesh;
  110578. /**
  110579. * Returns the submesh material
  110580. * @returns null or the current material
  110581. */
  110582. getMaterial(): Nullable<Material>;
  110583. private _IsMultiMaterial;
  110584. /**
  110585. * Sets a new updated BoundingInfo object to the submesh
  110586. * @param data defines an optional position array to use to determine the bounding info
  110587. * @returns the SubMesh
  110588. */
  110589. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  110590. /** @hidden */
  110591. _checkCollision(collider: Collider): boolean;
  110592. /**
  110593. * Updates the submesh BoundingInfo
  110594. * @param world defines the world matrix to use to update the bounding info
  110595. * @returns the submesh
  110596. */
  110597. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  110598. /**
  110599. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  110600. * @param frustumPlanes defines the frustum planes
  110601. * @returns true if the submesh is intersecting with the frustum
  110602. */
  110603. isInFrustum(frustumPlanes: Plane[]): boolean;
  110604. /**
  110605. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  110606. * @param frustumPlanes defines the frustum planes
  110607. * @returns true if the submesh is inside the frustum
  110608. */
  110609. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  110610. /**
  110611. * Renders the submesh
  110612. * @param enableAlphaMode defines if alpha needs to be used
  110613. * @returns the submesh
  110614. */
  110615. render(enableAlphaMode: boolean): SubMesh;
  110616. /**
  110617. * @hidden
  110618. */
  110619. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  110620. /**
  110621. * Checks if the submesh intersects with a ray
  110622. * @param ray defines the ray to test
  110623. * @returns true is the passed ray intersects the submesh bounding box
  110624. */
  110625. canIntersects(ray: Ray): boolean;
  110626. /**
  110627. * Intersects current submesh with a ray
  110628. * @param ray defines the ray to test
  110629. * @param positions defines mesh's positions array
  110630. * @param indices defines mesh's indices array
  110631. * @param fastCheck defines if the first intersection will be used (and not the closest)
  110632. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110633. * @returns intersection info or null if no intersection
  110634. */
  110635. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  110636. /** @hidden */
  110637. private _intersectLines;
  110638. /** @hidden */
  110639. private _intersectUnIndexedLines;
  110640. /** @hidden */
  110641. private _intersectTriangles;
  110642. /** @hidden */
  110643. private _intersectUnIndexedTriangles;
  110644. /** @hidden */
  110645. _rebuild(): void;
  110646. /**
  110647. * Creates a new submesh from the passed mesh
  110648. * @param newMesh defines the new hosting mesh
  110649. * @param newRenderingMesh defines an optional rendering mesh
  110650. * @returns the new submesh
  110651. */
  110652. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  110653. /**
  110654. * Release associated resources
  110655. */
  110656. dispose(): void;
  110657. /**
  110658. * Gets the class name
  110659. * @returns the string "SubMesh".
  110660. */
  110661. getClassName(): string;
  110662. /**
  110663. * Creates a new submesh from indices data
  110664. * @param materialIndex the index of the main mesh material
  110665. * @param startIndex the index where to start the copy in the mesh indices array
  110666. * @param indexCount the number of indices to copy then from the startIndex
  110667. * @param mesh the main mesh to create the submesh from
  110668. * @param renderingMesh the optional rendering mesh
  110669. * @returns a new submesh
  110670. */
  110671. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  110672. }
  110673. }
  110674. declare module BABYLON {
  110675. /**
  110676. * Class used to represent data loading progression
  110677. */
  110678. export class SceneLoaderFlags {
  110679. private static _ForceFullSceneLoadingForIncremental;
  110680. private static _ShowLoadingScreen;
  110681. private static _CleanBoneMatrixWeights;
  110682. private static _loggingLevel;
  110683. /**
  110684. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  110685. */
  110686. static get ForceFullSceneLoadingForIncremental(): boolean;
  110687. static set ForceFullSceneLoadingForIncremental(value: boolean);
  110688. /**
  110689. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  110690. */
  110691. static get ShowLoadingScreen(): boolean;
  110692. static set ShowLoadingScreen(value: boolean);
  110693. /**
  110694. * Defines the current logging level (while loading the scene)
  110695. * @ignorenaming
  110696. */
  110697. static get loggingLevel(): number;
  110698. static set loggingLevel(value: number);
  110699. /**
  110700. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  110701. */
  110702. static get CleanBoneMatrixWeights(): boolean;
  110703. static set CleanBoneMatrixWeights(value: boolean);
  110704. }
  110705. }
  110706. declare module BABYLON {
  110707. /**
  110708. * Class used to store geometry data (vertex buffers + index buffer)
  110709. */
  110710. export class Geometry implements IGetSetVerticesData {
  110711. /**
  110712. * Gets or sets the ID of the geometry
  110713. */
  110714. id: string;
  110715. /**
  110716. * Gets or sets the unique ID of the geometry
  110717. */
  110718. uniqueId: number;
  110719. /**
  110720. * Gets the delay loading state of the geometry (none by default which means not delayed)
  110721. */
  110722. delayLoadState: number;
  110723. /**
  110724. * Gets the file containing the data to load when running in delay load state
  110725. */
  110726. delayLoadingFile: Nullable<string>;
  110727. /**
  110728. * Callback called when the geometry is updated
  110729. */
  110730. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  110731. private _scene;
  110732. private _engine;
  110733. private _meshes;
  110734. private _totalVertices;
  110735. /** @hidden */
  110736. _indices: IndicesArray;
  110737. /** @hidden */
  110738. _vertexBuffers: {
  110739. [key: string]: VertexBuffer;
  110740. };
  110741. private _isDisposed;
  110742. private _extend;
  110743. private _boundingBias;
  110744. /** @hidden */
  110745. _delayInfo: Array<string>;
  110746. private _indexBuffer;
  110747. private _indexBufferIsUpdatable;
  110748. /** @hidden */
  110749. _boundingInfo: Nullable<BoundingInfo>;
  110750. /** @hidden */
  110751. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  110752. /** @hidden */
  110753. _softwareSkinningFrameId: number;
  110754. private _vertexArrayObjects;
  110755. private _updatable;
  110756. /** @hidden */
  110757. _positions: Nullable<Vector3[]>;
  110758. private _positionsCache;
  110759. /**
  110760. * 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
  110761. */
  110762. get boundingBias(): Vector2;
  110763. /**
  110764. * 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
  110765. */
  110766. set boundingBias(value: Vector2);
  110767. /**
  110768. * Static function used to attach a new empty geometry to a mesh
  110769. * @param mesh defines the mesh to attach the geometry to
  110770. * @returns the new Geometry
  110771. */
  110772. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  110773. /** Get the list of meshes using this geometry */
  110774. get meshes(): Mesh[];
  110775. /**
  110776. * 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
  110777. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  110778. */
  110779. useBoundingInfoFromGeometry: boolean;
  110780. /**
  110781. * Creates a new geometry
  110782. * @param id defines the unique ID
  110783. * @param scene defines the hosting scene
  110784. * @param vertexData defines the VertexData used to get geometry data
  110785. * @param updatable defines if geometry must be updatable (false by default)
  110786. * @param mesh defines the mesh that will be associated with the geometry
  110787. */
  110788. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  110789. /**
  110790. * Gets the current extend of the geometry
  110791. */
  110792. get extend(): {
  110793. minimum: Vector3;
  110794. maximum: Vector3;
  110795. };
  110796. /**
  110797. * Gets the hosting scene
  110798. * @returns the hosting Scene
  110799. */
  110800. getScene(): Scene;
  110801. /**
  110802. * Gets the hosting engine
  110803. * @returns the hosting Engine
  110804. */
  110805. getEngine(): Engine;
  110806. /**
  110807. * Defines if the geometry is ready to use
  110808. * @returns true if the geometry is ready to be used
  110809. */
  110810. isReady(): boolean;
  110811. /**
  110812. * Gets a value indicating that the geometry should not be serialized
  110813. */
  110814. get doNotSerialize(): boolean;
  110815. /** @hidden */
  110816. _rebuild(): void;
  110817. /**
  110818. * Affects all geometry data in one call
  110819. * @param vertexData defines the geometry data
  110820. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  110821. */
  110822. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  110823. /**
  110824. * Set specific vertex data
  110825. * @param kind defines the data kind (Position, normal, etc...)
  110826. * @param data defines the vertex data to use
  110827. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  110828. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  110829. */
  110830. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  110831. /**
  110832. * Removes a specific vertex data
  110833. * @param kind defines the data kind (Position, normal, etc...)
  110834. */
  110835. removeVerticesData(kind: string): void;
  110836. /**
  110837. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  110838. * @param buffer defines the vertex buffer to use
  110839. * @param totalVertices defines the total number of vertices for position kind (could be null)
  110840. */
  110841. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  110842. /**
  110843. * Update a specific vertex buffer
  110844. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  110845. * It will do nothing if the buffer is not updatable
  110846. * @param kind defines the data kind (Position, normal, etc...)
  110847. * @param data defines the data to use
  110848. * @param offset defines the offset in the target buffer where to store the data
  110849. * @param useBytes set to true if the offset is in bytes
  110850. */
  110851. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  110852. /**
  110853. * Update a specific vertex buffer
  110854. * This function will create a new buffer if the current one is not updatable
  110855. * @param kind defines the data kind (Position, normal, etc...)
  110856. * @param data defines the data to use
  110857. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  110858. */
  110859. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  110860. private _updateBoundingInfo;
  110861. /** @hidden */
  110862. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  110863. /**
  110864. * Gets total number of vertices
  110865. * @returns the total number of vertices
  110866. */
  110867. getTotalVertices(): number;
  110868. /**
  110869. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  110870. * @param kind defines the data kind (Position, normal, etc...)
  110871. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110872. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110873. * @returns a float array containing vertex data
  110874. */
  110875. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  110876. /**
  110877. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  110878. * @param kind defines the data kind (Position, normal, etc...)
  110879. * @returns true if the vertex buffer with the specified kind is updatable
  110880. */
  110881. isVertexBufferUpdatable(kind: string): boolean;
  110882. /**
  110883. * Gets a specific vertex buffer
  110884. * @param kind defines the data kind (Position, normal, etc...)
  110885. * @returns a VertexBuffer
  110886. */
  110887. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  110888. /**
  110889. * Returns all vertex buffers
  110890. * @return an object holding all vertex buffers indexed by kind
  110891. */
  110892. getVertexBuffers(): Nullable<{
  110893. [key: string]: VertexBuffer;
  110894. }>;
  110895. /**
  110896. * Gets a boolean indicating if specific vertex buffer is present
  110897. * @param kind defines the data kind (Position, normal, etc...)
  110898. * @returns true if data is present
  110899. */
  110900. isVerticesDataPresent(kind: string): boolean;
  110901. /**
  110902. * Gets a list of all attached data kinds (Position, normal, etc...)
  110903. * @returns a list of string containing all kinds
  110904. */
  110905. getVerticesDataKinds(): string[];
  110906. /**
  110907. * Update index buffer
  110908. * @param indices defines the indices to store in the index buffer
  110909. * @param offset defines the offset in the target buffer where to store the data
  110910. * @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)
  110911. */
  110912. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  110913. /**
  110914. * Creates a new index buffer
  110915. * @param indices defines the indices to store in the index buffer
  110916. * @param totalVertices defines the total number of vertices (could be null)
  110917. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  110918. */
  110919. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  110920. /**
  110921. * Return the total number of indices
  110922. * @returns the total number of indices
  110923. */
  110924. getTotalIndices(): number;
  110925. /**
  110926. * Gets the index buffer array
  110927. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110928. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110929. * @returns the index buffer array
  110930. */
  110931. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  110932. /**
  110933. * Gets the index buffer
  110934. * @return the index buffer
  110935. */
  110936. getIndexBuffer(): Nullable<DataBuffer>;
  110937. /** @hidden */
  110938. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  110939. /**
  110940. * Release the associated resources for a specific mesh
  110941. * @param mesh defines the source mesh
  110942. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  110943. */
  110944. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  110945. /**
  110946. * Apply current geometry to a given mesh
  110947. * @param mesh defines the mesh to apply geometry to
  110948. */
  110949. applyToMesh(mesh: Mesh): void;
  110950. private _updateExtend;
  110951. private _applyToMesh;
  110952. private notifyUpdate;
  110953. /**
  110954. * Load the geometry if it was flagged as delay loaded
  110955. * @param scene defines the hosting scene
  110956. * @param onLoaded defines a callback called when the geometry is loaded
  110957. */
  110958. load(scene: Scene, onLoaded?: () => void): void;
  110959. private _queueLoad;
  110960. /**
  110961. * Invert the geometry to move from a right handed system to a left handed one.
  110962. */
  110963. toLeftHanded(): void;
  110964. /** @hidden */
  110965. _resetPointsArrayCache(): void;
  110966. /** @hidden */
  110967. _generatePointsArray(): boolean;
  110968. /**
  110969. * Gets a value indicating if the geometry is disposed
  110970. * @returns true if the geometry was disposed
  110971. */
  110972. isDisposed(): boolean;
  110973. private _disposeVertexArrayObjects;
  110974. /**
  110975. * Free all associated resources
  110976. */
  110977. dispose(): void;
  110978. /**
  110979. * Clone the current geometry into a new geometry
  110980. * @param id defines the unique ID of the new geometry
  110981. * @returns a new geometry object
  110982. */
  110983. copy(id: string): Geometry;
  110984. /**
  110985. * Serialize the current geometry info (and not the vertices data) into a JSON object
  110986. * @return a JSON representation of the current geometry data (without the vertices data)
  110987. */
  110988. serialize(): any;
  110989. private toNumberArray;
  110990. /**
  110991. * Serialize all vertices data into a JSON oject
  110992. * @returns a JSON representation of the current geometry data
  110993. */
  110994. serializeVerticeData(): any;
  110995. /**
  110996. * Extracts a clone of a mesh geometry
  110997. * @param mesh defines the source mesh
  110998. * @param id defines the unique ID of the new geometry object
  110999. * @returns the new geometry object
  111000. */
  111001. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  111002. /**
  111003. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  111004. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  111005. * Be aware Math.random() could cause collisions, but:
  111006. * "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"
  111007. * @returns a string containing a new GUID
  111008. */
  111009. static RandomId(): string;
  111010. /** @hidden */
  111011. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  111012. private static _CleanMatricesWeights;
  111013. /**
  111014. * Create a new geometry from persisted data (Using .babylon file format)
  111015. * @param parsedVertexData defines the persisted data
  111016. * @param scene defines the hosting scene
  111017. * @param rootUrl defines the root url to use to load assets (like delayed data)
  111018. * @returns the new geometry object
  111019. */
  111020. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  111021. }
  111022. }
  111023. declare module BABYLON {
  111024. /**
  111025. * Define an interface for all classes that will get and set the data on vertices
  111026. */
  111027. export interface IGetSetVerticesData {
  111028. /**
  111029. * Gets a boolean indicating if specific vertex data is present
  111030. * @param kind defines the vertex data kind to use
  111031. * @returns true is data kind is present
  111032. */
  111033. isVerticesDataPresent(kind: string): boolean;
  111034. /**
  111035. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  111036. * @param kind defines the data kind (Position, normal, etc...)
  111037. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  111038. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111039. * @returns a float array containing vertex data
  111040. */
  111041. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  111042. /**
  111043. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  111044. * @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.
  111045. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111046. * @returns the indices array or an empty array if the mesh has no geometry
  111047. */
  111048. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  111049. /**
  111050. * Set specific vertex data
  111051. * @param kind defines the data kind (Position, normal, etc...)
  111052. * @param data defines the vertex data to use
  111053. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  111054. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  111055. */
  111056. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  111057. /**
  111058. * Update a specific associated vertex buffer
  111059. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  111060. * - VertexBuffer.PositionKind
  111061. * - VertexBuffer.UVKind
  111062. * - VertexBuffer.UV2Kind
  111063. * - VertexBuffer.UV3Kind
  111064. * - VertexBuffer.UV4Kind
  111065. * - VertexBuffer.UV5Kind
  111066. * - VertexBuffer.UV6Kind
  111067. * - VertexBuffer.ColorKind
  111068. * - VertexBuffer.MatricesIndicesKind
  111069. * - VertexBuffer.MatricesIndicesExtraKind
  111070. * - VertexBuffer.MatricesWeightsKind
  111071. * - VertexBuffer.MatricesWeightsExtraKind
  111072. * @param data defines the data source
  111073. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  111074. * @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)
  111075. */
  111076. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  111077. /**
  111078. * Creates a new index buffer
  111079. * @param indices defines the indices to store in the index buffer
  111080. * @param totalVertices defines the total number of vertices (could be null)
  111081. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  111082. */
  111083. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  111084. }
  111085. /**
  111086. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  111087. */
  111088. export class VertexData {
  111089. /**
  111090. * Mesh side orientation : usually the external or front surface
  111091. */
  111092. static readonly FRONTSIDE: number;
  111093. /**
  111094. * Mesh side orientation : usually the internal or back surface
  111095. */
  111096. static readonly BACKSIDE: number;
  111097. /**
  111098. * Mesh side orientation : both internal and external or front and back surfaces
  111099. */
  111100. static readonly DOUBLESIDE: number;
  111101. /**
  111102. * Mesh side orientation : by default, `FRONTSIDE`
  111103. */
  111104. static readonly DEFAULTSIDE: number;
  111105. /**
  111106. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  111107. */
  111108. positions: Nullable<FloatArray>;
  111109. /**
  111110. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  111111. */
  111112. normals: Nullable<FloatArray>;
  111113. /**
  111114. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  111115. */
  111116. tangents: Nullable<FloatArray>;
  111117. /**
  111118. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111119. */
  111120. uvs: Nullable<FloatArray>;
  111121. /**
  111122. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111123. */
  111124. uvs2: Nullable<FloatArray>;
  111125. /**
  111126. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111127. */
  111128. uvs3: Nullable<FloatArray>;
  111129. /**
  111130. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111131. */
  111132. uvs4: Nullable<FloatArray>;
  111133. /**
  111134. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111135. */
  111136. uvs5: Nullable<FloatArray>;
  111137. /**
  111138. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111139. */
  111140. uvs6: Nullable<FloatArray>;
  111141. /**
  111142. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  111143. */
  111144. colors: Nullable<FloatArray>;
  111145. /**
  111146. * 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).
  111147. */
  111148. matricesIndices: Nullable<FloatArray>;
  111149. /**
  111150. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  111151. */
  111152. matricesWeights: Nullable<FloatArray>;
  111153. /**
  111154. * An array extending the number of possible indices
  111155. */
  111156. matricesIndicesExtra: Nullable<FloatArray>;
  111157. /**
  111158. * An array extending the number of possible weights when the number of indices is extended
  111159. */
  111160. matricesWeightsExtra: Nullable<FloatArray>;
  111161. /**
  111162. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  111163. */
  111164. indices: Nullable<IndicesArray>;
  111165. /**
  111166. * Uses the passed data array to set the set the values for the specified kind of data
  111167. * @param data a linear array of floating numbers
  111168. * @param kind the type of data that is being set, eg positions, colors etc
  111169. */
  111170. set(data: FloatArray, kind: string): void;
  111171. /**
  111172. * Associates the vertexData to the passed Mesh.
  111173. * Sets it as updatable or not (default `false`)
  111174. * @param mesh the mesh the vertexData is applied to
  111175. * @param updatable when used and having the value true allows new data to update the vertexData
  111176. * @returns the VertexData
  111177. */
  111178. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  111179. /**
  111180. * Associates the vertexData to the passed Geometry.
  111181. * Sets it as updatable or not (default `false`)
  111182. * @param geometry the geometry the vertexData is applied to
  111183. * @param updatable when used and having the value true allows new data to update the vertexData
  111184. * @returns VertexData
  111185. */
  111186. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  111187. /**
  111188. * Updates the associated mesh
  111189. * @param mesh the mesh to be updated
  111190. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  111191. * @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
  111192. * @returns VertexData
  111193. */
  111194. updateMesh(mesh: Mesh): VertexData;
  111195. /**
  111196. * Updates the associated geometry
  111197. * @param geometry the geometry to be updated
  111198. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  111199. * @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
  111200. * @returns VertexData.
  111201. */
  111202. updateGeometry(geometry: Geometry): VertexData;
  111203. private _applyTo;
  111204. private _update;
  111205. /**
  111206. * Transforms each position and each normal of the vertexData according to the passed Matrix
  111207. * @param matrix the transforming matrix
  111208. * @returns the VertexData
  111209. */
  111210. transform(matrix: Matrix): VertexData;
  111211. /**
  111212. * Merges the passed VertexData into the current one
  111213. * @param other the VertexData to be merged into the current one
  111214. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  111215. * @returns the modified VertexData
  111216. */
  111217. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  111218. private _mergeElement;
  111219. private _validate;
  111220. /**
  111221. * Serializes the VertexData
  111222. * @returns a serialized object
  111223. */
  111224. serialize(): any;
  111225. /**
  111226. * Extracts the vertexData from a mesh
  111227. * @param mesh the mesh from which to extract the VertexData
  111228. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  111229. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  111230. * @returns the object VertexData associated to the passed mesh
  111231. */
  111232. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  111233. /**
  111234. * Extracts the vertexData from the geometry
  111235. * @param geometry the geometry from which to extract the VertexData
  111236. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  111237. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  111238. * @returns the object VertexData associated to the passed mesh
  111239. */
  111240. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  111241. private static _ExtractFrom;
  111242. /**
  111243. * Creates the VertexData for a Ribbon
  111244. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  111245. * * pathArray array of paths, each of which an array of successive Vector3
  111246. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  111247. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  111248. * * 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
  111249. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111250. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  111251. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  111252. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  111253. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  111254. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  111255. * @returns the VertexData of the ribbon
  111256. */
  111257. static CreateRibbon(options: {
  111258. pathArray: Vector3[][];
  111259. closeArray?: boolean;
  111260. closePath?: boolean;
  111261. offset?: number;
  111262. sideOrientation?: number;
  111263. frontUVs?: Vector4;
  111264. backUVs?: Vector4;
  111265. invertUV?: boolean;
  111266. uvs?: Vector2[];
  111267. colors?: Color4[];
  111268. }): VertexData;
  111269. /**
  111270. * Creates the VertexData for a box
  111271. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111272. * * size sets the width, height and depth of the box to the value of size, optional default 1
  111273. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  111274. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  111275. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  111276. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111277. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111278. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111279. * * 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)
  111280. * * 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)
  111281. * @returns the VertexData of the box
  111282. */
  111283. static CreateBox(options: {
  111284. size?: number;
  111285. width?: number;
  111286. height?: number;
  111287. depth?: number;
  111288. faceUV?: Vector4[];
  111289. faceColors?: Color4[];
  111290. sideOrientation?: number;
  111291. frontUVs?: Vector4;
  111292. backUVs?: Vector4;
  111293. }): VertexData;
  111294. /**
  111295. * Creates the VertexData for a tiled box
  111296. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111297. * * faceTiles sets the pattern, tile size and number of tiles for a face
  111298. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111299. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111300. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111301. * @returns the VertexData of the box
  111302. */
  111303. static CreateTiledBox(options: {
  111304. pattern?: number;
  111305. width?: number;
  111306. height?: number;
  111307. depth?: number;
  111308. tileSize?: number;
  111309. tileWidth?: number;
  111310. tileHeight?: number;
  111311. alignHorizontal?: number;
  111312. alignVertical?: number;
  111313. faceUV?: Vector4[];
  111314. faceColors?: Color4[];
  111315. sideOrientation?: number;
  111316. }): VertexData;
  111317. /**
  111318. * Creates the VertexData for a tiled plane
  111319. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111320. * * pattern a limited pattern arrangement depending on the number
  111321. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  111322. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  111323. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  111324. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111325. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  111326. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  111327. * @returns the VertexData of the tiled plane
  111328. */
  111329. static CreateTiledPlane(options: {
  111330. pattern?: number;
  111331. tileSize?: number;
  111332. tileWidth?: number;
  111333. tileHeight?: number;
  111334. size?: number;
  111335. width?: number;
  111336. height?: number;
  111337. alignHorizontal?: number;
  111338. alignVertical?: number;
  111339. sideOrientation?: number;
  111340. frontUVs?: Vector4;
  111341. backUVs?: Vector4;
  111342. }): VertexData;
  111343. /**
  111344. * Creates the VertexData for an ellipsoid, defaults to a sphere
  111345. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111346. * * segments sets the number of horizontal strips optional, default 32
  111347. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  111348. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  111349. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  111350. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  111351. * * 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
  111352. * * 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
  111353. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111354. * * 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)
  111355. * * 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)
  111356. * @returns the VertexData of the ellipsoid
  111357. */
  111358. static CreateSphere(options: {
  111359. segments?: number;
  111360. diameter?: number;
  111361. diameterX?: number;
  111362. diameterY?: number;
  111363. diameterZ?: number;
  111364. arc?: number;
  111365. slice?: number;
  111366. sideOrientation?: number;
  111367. frontUVs?: Vector4;
  111368. backUVs?: Vector4;
  111369. }): VertexData;
  111370. /**
  111371. * Creates the VertexData for a cylinder, cone or prism
  111372. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111373. * * height sets the height (y direction) of the cylinder, optional, default 2
  111374. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  111375. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  111376. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  111377. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111378. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  111379. * * 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
  111380. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111381. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111382. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  111383. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  111384. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111385. * * 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)
  111386. * * 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)
  111387. * @returns the VertexData of the cylinder, cone or prism
  111388. */
  111389. static CreateCylinder(options: {
  111390. height?: number;
  111391. diameterTop?: number;
  111392. diameterBottom?: number;
  111393. diameter?: number;
  111394. tessellation?: number;
  111395. subdivisions?: number;
  111396. arc?: number;
  111397. faceColors?: Color4[];
  111398. faceUV?: Vector4[];
  111399. hasRings?: boolean;
  111400. enclose?: boolean;
  111401. sideOrientation?: number;
  111402. frontUVs?: Vector4;
  111403. backUVs?: Vector4;
  111404. }): VertexData;
  111405. /**
  111406. * Creates the VertexData for a torus
  111407. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111408. * * diameter the diameter of the torus, optional default 1
  111409. * * thickness the diameter of the tube forming the torus, optional default 0.5
  111410. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111411. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111412. * * 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)
  111413. * * 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)
  111414. * @returns the VertexData of the torus
  111415. */
  111416. static CreateTorus(options: {
  111417. diameter?: number;
  111418. thickness?: number;
  111419. tessellation?: number;
  111420. sideOrientation?: number;
  111421. frontUVs?: Vector4;
  111422. backUVs?: Vector4;
  111423. }): VertexData;
  111424. /**
  111425. * Creates the VertexData of the LineSystem
  111426. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  111427. * - lines an array of lines, each line being an array of successive Vector3
  111428. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  111429. * @returns the VertexData of the LineSystem
  111430. */
  111431. static CreateLineSystem(options: {
  111432. lines: Vector3[][];
  111433. colors?: Nullable<Color4[][]>;
  111434. }): VertexData;
  111435. /**
  111436. * Create the VertexData for a DashedLines
  111437. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  111438. * - points an array successive Vector3
  111439. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  111440. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  111441. * - dashNb the intended total number of dashes, optional, default 200
  111442. * @returns the VertexData for the DashedLines
  111443. */
  111444. static CreateDashedLines(options: {
  111445. points: Vector3[];
  111446. dashSize?: number;
  111447. gapSize?: number;
  111448. dashNb?: number;
  111449. }): VertexData;
  111450. /**
  111451. * Creates the VertexData for a Ground
  111452. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  111453. * - width the width (x direction) of the ground, optional, default 1
  111454. * - height the height (z direction) of the ground, optional, default 1
  111455. * - subdivisions the number of subdivisions per side, optional, default 1
  111456. * @returns the VertexData of the Ground
  111457. */
  111458. static CreateGround(options: {
  111459. width?: number;
  111460. height?: number;
  111461. subdivisions?: number;
  111462. subdivisionsX?: number;
  111463. subdivisionsY?: number;
  111464. }): VertexData;
  111465. /**
  111466. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  111467. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  111468. * * xmin the ground minimum X coordinate, optional, default -1
  111469. * * zmin the ground minimum Z coordinate, optional, default -1
  111470. * * xmax the ground maximum X coordinate, optional, default 1
  111471. * * zmax the ground maximum Z coordinate, optional, default 1
  111472. * * 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}
  111473. * * 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}
  111474. * @returns the VertexData of the TiledGround
  111475. */
  111476. static CreateTiledGround(options: {
  111477. xmin: number;
  111478. zmin: number;
  111479. xmax: number;
  111480. zmax: number;
  111481. subdivisions?: {
  111482. w: number;
  111483. h: number;
  111484. };
  111485. precision?: {
  111486. w: number;
  111487. h: number;
  111488. };
  111489. }): VertexData;
  111490. /**
  111491. * Creates the VertexData of the Ground designed from a heightmap
  111492. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  111493. * * width the width (x direction) of the ground
  111494. * * height the height (z direction) of the ground
  111495. * * subdivisions the number of subdivisions per side
  111496. * * minHeight the minimum altitude on the ground, optional, default 0
  111497. * * maxHeight the maximum altitude on the ground, optional default 1
  111498. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  111499. * * buffer the array holding the image color data
  111500. * * bufferWidth the width of image
  111501. * * bufferHeight the height of image
  111502. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  111503. * @returns the VertexData of the Ground designed from a heightmap
  111504. */
  111505. static CreateGroundFromHeightMap(options: {
  111506. width: number;
  111507. height: number;
  111508. subdivisions: number;
  111509. minHeight: number;
  111510. maxHeight: number;
  111511. colorFilter: Color3;
  111512. buffer: Uint8Array;
  111513. bufferWidth: number;
  111514. bufferHeight: number;
  111515. alphaFilter: number;
  111516. }): VertexData;
  111517. /**
  111518. * Creates the VertexData for a Plane
  111519. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  111520. * * size sets the width and height of the plane to the value of size, optional default 1
  111521. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  111522. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  111523. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111524. * * 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)
  111525. * * 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)
  111526. * @returns the VertexData of the box
  111527. */
  111528. static CreatePlane(options: {
  111529. size?: number;
  111530. width?: number;
  111531. height?: number;
  111532. sideOrientation?: number;
  111533. frontUVs?: Vector4;
  111534. backUVs?: Vector4;
  111535. }): VertexData;
  111536. /**
  111537. * Creates the VertexData of the Disc or regular Polygon
  111538. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  111539. * * radius the radius of the disc, optional default 0.5
  111540. * * tessellation the number of polygon sides, optional, default 64
  111541. * * 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
  111542. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111543. * * 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)
  111544. * * 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)
  111545. * @returns the VertexData of the box
  111546. */
  111547. static CreateDisc(options: {
  111548. radius?: number;
  111549. tessellation?: number;
  111550. arc?: number;
  111551. sideOrientation?: number;
  111552. frontUVs?: Vector4;
  111553. backUVs?: Vector4;
  111554. }): VertexData;
  111555. /**
  111556. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  111557. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  111558. * @param polygon a mesh built from polygonTriangulation.build()
  111559. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111560. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111561. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111562. * @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)
  111563. * @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)
  111564. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  111565. * @returns the VertexData of the Polygon
  111566. */
  111567. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  111568. /**
  111569. * Creates the VertexData of the IcoSphere
  111570. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  111571. * * radius the radius of the IcoSphere, optional default 1
  111572. * * radiusX allows stretching in the x direction, optional, default radius
  111573. * * radiusY allows stretching in the y direction, optional, default radius
  111574. * * radiusZ allows stretching in the z direction, optional, default radius
  111575. * * flat when true creates a flat shaded mesh, optional, default true
  111576. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  111577. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111578. * * 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)
  111579. * * 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)
  111580. * @returns the VertexData of the IcoSphere
  111581. */
  111582. static CreateIcoSphere(options: {
  111583. radius?: number;
  111584. radiusX?: number;
  111585. radiusY?: number;
  111586. radiusZ?: number;
  111587. flat?: boolean;
  111588. subdivisions?: number;
  111589. sideOrientation?: number;
  111590. frontUVs?: Vector4;
  111591. backUVs?: Vector4;
  111592. }): VertexData;
  111593. /**
  111594. * Creates the VertexData for a Polyhedron
  111595. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  111596. * * type provided types are:
  111597. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  111598. * * 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)
  111599. * * size the size of the IcoSphere, optional default 1
  111600. * * sizeX allows stretching in the x direction, optional, default size
  111601. * * sizeY allows stretching in the y direction, optional, default size
  111602. * * sizeZ allows stretching in the z direction, optional, default size
  111603. * * 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
  111604. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111605. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111606. * * flat when true creates a flat shaded mesh, optional, default true
  111607. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  111608. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111609. * * 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)
  111610. * * 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)
  111611. * @returns the VertexData of the Polyhedron
  111612. */
  111613. static CreatePolyhedron(options: {
  111614. type?: number;
  111615. size?: number;
  111616. sizeX?: number;
  111617. sizeY?: number;
  111618. sizeZ?: number;
  111619. custom?: any;
  111620. faceUV?: Vector4[];
  111621. faceColors?: Color4[];
  111622. flat?: boolean;
  111623. sideOrientation?: number;
  111624. frontUVs?: Vector4;
  111625. backUVs?: Vector4;
  111626. }): VertexData;
  111627. /**
  111628. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  111629. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  111630. * @returns the VertexData of the Capsule
  111631. */
  111632. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  111633. /**
  111634. * Creates the VertexData for a TorusKnot
  111635. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  111636. * * radius the radius of the torus knot, optional, default 2
  111637. * * tube the thickness of the tube, optional, default 0.5
  111638. * * radialSegments the number of sides on each tube segments, optional, default 32
  111639. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  111640. * * p the number of windings around the z axis, optional, default 2
  111641. * * q the number of windings around the x axis, optional, default 3
  111642. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111643. * * 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)
  111644. * * 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)
  111645. * @returns the VertexData of the Torus Knot
  111646. */
  111647. static CreateTorusKnot(options: {
  111648. radius?: number;
  111649. tube?: number;
  111650. radialSegments?: number;
  111651. tubularSegments?: number;
  111652. p?: number;
  111653. q?: number;
  111654. sideOrientation?: number;
  111655. frontUVs?: Vector4;
  111656. backUVs?: Vector4;
  111657. }): VertexData;
  111658. /**
  111659. * Compute normals for given positions and indices
  111660. * @param positions an array of vertex positions, [...., x, y, z, ......]
  111661. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  111662. * @param normals an array of vertex normals, [...., x, y, z, ......]
  111663. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  111664. * * facetNormals : optional array of facet normals (vector3)
  111665. * * facetPositions : optional array of facet positions (vector3)
  111666. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  111667. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  111668. * * bInfo : optional bounding info, required for facetPartitioning computation
  111669. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  111670. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  111671. * * useRightHandedSystem: optional boolean to for right handed system computation
  111672. * * depthSort : optional boolean to enable the facet depth sort computation
  111673. * * distanceTo : optional Vector3 to compute the facet depth from this location
  111674. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  111675. */
  111676. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  111677. facetNormals?: any;
  111678. facetPositions?: any;
  111679. facetPartitioning?: any;
  111680. ratio?: number;
  111681. bInfo?: any;
  111682. bbSize?: Vector3;
  111683. subDiv?: any;
  111684. useRightHandedSystem?: boolean;
  111685. depthSort?: boolean;
  111686. distanceTo?: Vector3;
  111687. depthSortedFacets?: any;
  111688. }): void;
  111689. /** @hidden */
  111690. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  111691. /**
  111692. * Applies VertexData created from the imported parameters to the geometry
  111693. * @param parsedVertexData the parsed data from an imported file
  111694. * @param geometry the geometry to apply the VertexData to
  111695. */
  111696. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  111697. }
  111698. }
  111699. declare module BABYLON {
  111700. /**
  111701. * Defines a target to use with MorphTargetManager
  111702. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  111703. */
  111704. export class MorphTarget implements IAnimatable {
  111705. /** defines the name of the target */
  111706. name: string;
  111707. /**
  111708. * Gets or sets the list of animations
  111709. */
  111710. animations: Animation[];
  111711. private _scene;
  111712. private _positions;
  111713. private _normals;
  111714. private _tangents;
  111715. private _uvs;
  111716. private _influence;
  111717. private _uniqueId;
  111718. /**
  111719. * Observable raised when the influence changes
  111720. */
  111721. onInfluenceChanged: Observable<boolean>;
  111722. /** @hidden */
  111723. _onDataLayoutChanged: Observable<void>;
  111724. /**
  111725. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  111726. */
  111727. get influence(): number;
  111728. set influence(influence: number);
  111729. /**
  111730. * Gets or sets the id of the morph Target
  111731. */
  111732. id: string;
  111733. private _animationPropertiesOverride;
  111734. /**
  111735. * Gets or sets the animation properties override
  111736. */
  111737. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111738. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111739. /**
  111740. * Creates a new MorphTarget
  111741. * @param name defines the name of the target
  111742. * @param influence defines the influence to use
  111743. * @param scene defines the scene the morphtarget belongs to
  111744. */
  111745. constructor(
  111746. /** defines the name of the target */
  111747. name: string, influence?: number, scene?: Nullable<Scene>);
  111748. /**
  111749. * Gets the unique ID of this manager
  111750. */
  111751. get uniqueId(): number;
  111752. /**
  111753. * Gets a boolean defining if the target contains position data
  111754. */
  111755. get hasPositions(): boolean;
  111756. /**
  111757. * Gets a boolean defining if the target contains normal data
  111758. */
  111759. get hasNormals(): boolean;
  111760. /**
  111761. * Gets a boolean defining if the target contains tangent data
  111762. */
  111763. get hasTangents(): boolean;
  111764. /**
  111765. * Gets a boolean defining if the target contains texture coordinates data
  111766. */
  111767. get hasUVs(): boolean;
  111768. /**
  111769. * Affects position data to this target
  111770. * @param data defines the position data to use
  111771. */
  111772. setPositions(data: Nullable<FloatArray>): void;
  111773. /**
  111774. * Gets the position data stored in this target
  111775. * @returns a FloatArray containing the position data (or null if not present)
  111776. */
  111777. getPositions(): Nullable<FloatArray>;
  111778. /**
  111779. * Affects normal data to this target
  111780. * @param data defines the normal data to use
  111781. */
  111782. setNormals(data: Nullable<FloatArray>): void;
  111783. /**
  111784. * Gets the normal data stored in this target
  111785. * @returns a FloatArray containing the normal data (or null if not present)
  111786. */
  111787. getNormals(): Nullable<FloatArray>;
  111788. /**
  111789. * Affects tangent data to this target
  111790. * @param data defines the tangent data to use
  111791. */
  111792. setTangents(data: Nullable<FloatArray>): void;
  111793. /**
  111794. * Gets the tangent data stored in this target
  111795. * @returns a FloatArray containing the tangent data (or null if not present)
  111796. */
  111797. getTangents(): Nullable<FloatArray>;
  111798. /**
  111799. * Affects texture coordinates data to this target
  111800. * @param data defines the texture coordinates data to use
  111801. */
  111802. setUVs(data: Nullable<FloatArray>): void;
  111803. /**
  111804. * Gets the texture coordinates data stored in this target
  111805. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  111806. */
  111807. getUVs(): Nullable<FloatArray>;
  111808. /**
  111809. * Clone the current target
  111810. * @returns a new MorphTarget
  111811. */
  111812. clone(): MorphTarget;
  111813. /**
  111814. * Serializes the current target into a Serialization object
  111815. * @returns the serialized object
  111816. */
  111817. serialize(): any;
  111818. /**
  111819. * Returns the string "MorphTarget"
  111820. * @returns "MorphTarget"
  111821. */
  111822. getClassName(): string;
  111823. /**
  111824. * Creates a new target from serialized data
  111825. * @param serializationObject defines the serialized data to use
  111826. * @returns a new MorphTarget
  111827. */
  111828. static Parse(serializationObject: any): MorphTarget;
  111829. /**
  111830. * Creates a MorphTarget from mesh data
  111831. * @param mesh defines the source mesh
  111832. * @param name defines the name to use for the new target
  111833. * @param influence defines the influence to attach to the target
  111834. * @returns a new MorphTarget
  111835. */
  111836. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  111837. }
  111838. }
  111839. declare module BABYLON {
  111840. /**
  111841. * This class is used to deform meshes using morphing between different targets
  111842. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  111843. */
  111844. export class MorphTargetManager {
  111845. private _targets;
  111846. private _targetInfluenceChangedObservers;
  111847. private _targetDataLayoutChangedObservers;
  111848. private _activeTargets;
  111849. private _scene;
  111850. private _influences;
  111851. private _supportsNormals;
  111852. private _supportsTangents;
  111853. private _supportsUVs;
  111854. private _vertexCount;
  111855. private _uniqueId;
  111856. private _tempInfluences;
  111857. /**
  111858. * Gets or sets a boolean indicating if normals must be morphed
  111859. */
  111860. enableNormalMorphing: boolean;
  111861. /**
  111862. * Gets or sets a boolean indicating if tangents must be morphed
  111863. */
  111864. enableTangentMorphing: boolean;
  111865. /**
  111866. * Gets or sets a boolean indicating if UV must be morphed
  111867. */
  111868. enableUVMorphing: boolean;
  111869. /**
  111870. * Creates a new MorphTargetManager
  111871. * @param scene defines the current scene
  111872. */
  111873. constructor(scene?: Nullable<Scene>);
  111874. /**
  111875. * Gets the unique ID of this manager
  111876. */
  111877. get uniqueId(): number;
  111878. /**
  111879. * Gets the number of vertices handled by this manager
  111880. */
  111881. get vertexCount(): number;
  111882. /**
  111883. * Gets a boolean indicating if this manager supports morphing of normals
  111884. */
  111885. get supportsNormals(): boolean;
  111886. /**
  111887. * Gets a boolean indicating if this manager supports morphing of tangents
  111888. */
  111889. get supportsTangents(): boolean;
  111890. /**
  111891. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  111892. */
  111893. get supportsUVs(): boolean;
  111894. /**
  111895. * Gets the number of targets stored in this manager
  111896. */
  111897. get numTargets(): number;
  111898. /**
  111899. * Gets the number of influencers (ie. the number of targets with influences > 0)
  111900. */
  111901. get numInfluencers(): number;
  111902. /**
  111903. * Gets the list of influences (one per target)
  111904. */
  111905. get influences(): Float32Array;
  111906. /**
  111907. * Gets the active target at specified index. An active target is a target with an influence > 0
  111908. * @param index defines the index to check
  111909. * @returns the requested target
  111910. */
  111911. getActiveTarget(index: number): MorphTarget;
  111912. /**
  111913. * Gets the target at specified index
  111914. * @param index defines the index to check
  111915. * @returns the requested target
  111916. */
  111917. getTarget(index: number): MorphTarget;
  111918. /**
  111919. * Add a new target to this manager
  111920. * @param target defines the target to add
  111921. */
  111922. addTarget(target: MorphTarget): void;
  111923. /**
  111924. * Removes a target from the manager
  111925. * @param target defines the target to remove
  111926. */
  111927. removeTarget(target: MorphTarget): void;
  111928. /**
  111929. * Clone the current manager
  111930. * @returns a new MorphTargetManager
  111931. */
  111932. clone(): MorphTargetManager;
  111933. /**
  111934. * Serializes the current manager into a Serialization object
  111935. * @returns the serialized object
  111936. */
  111937. serialize(): any;
  111938. private _syncActiveTargets;
  111939. /**
  111940. * Syncrhonize the targets with all the meshes using this morph target manager
  111941. */
  111942. synchronize(): void;
  111943. /**
  111944. * Creates a new MorphTargetManager from serialized data
  111945. * @param serializationObject defines the serialized data
  111946. * @param scene defines the hosting scene
  111947. * @returns the new MorphTargetManager
  111948. */
  111949. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  111950. }
  111951. }
  111952. declare module BABYLON {
  111953. /**
  111954. * Class used to represent a specific level of detail of a mesh
  111955. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  111956. */
  111957. export class MeshLODLevel {
  111958. /** Defines the distance where this level should start being displayed */
  111959. distance: number;
  111960. /** Defines the mesh to use to render this level */
  111961. mesh: Nullable<Mesh>;
  111962. /**
  111963. * Creates a new LOD level
  111964. * @param distance defines the distance where this level should star being displayed
  111965. * @param mesh defines the mesh to use to render this level
  111966. */
  111967. constructor(
  111968. /** Defines the distance where this level should start being displayed */
  111969. distance: number,
  111970. /** Defines the mesh to use to render this level */
  111971. mesh: Nullable<Mesh>);
  111972. }
  111973. }
  111974. declare module BABYLON {
  111975. /**
  111976. * Helper class used to generate a canvas to manipulate images
  111977. */
  111978. export class CanvasGenerator {
  111979. /**
  111980. * Create a new canvas (or offscreen canvas depending on the context)
  111981. * @param width defines the expected width
  111982. * @param height defines the expected height
  111983. * @return a new canvas or offscreen canvas
  111984. */
  111985. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  111986. }
  111987. }
  111988. declare module BABYLON {
  111989. /**
  111990. * Mesh representing the gorund
  111991. */
  111992. export class GroundMesh extends Mesh {
  111993. /** If octree should be generated */
  111994. generateOctree: boolean;
  111995. private _heightQuads;
  111996. /** @hidden */
  111997. _subdivisionsX: number;
  111998. /** @hidden */
  111999. _subdivisionsY: number;
  112000. /** @hidden */
  112001. _width: number;
  112002. /** @hidden */
  112003. _height: number;
  112004. /** @hidden */
  112005. _minX: number;
  112006. /** @hidden */
  112007. _maxX: number;
  112008. /** @hidden */
  112009. _minZ: number;
  112010. /** @hidden */
  112011. _maxZ: number;
  112012. constructor(name: string, scene: Scene);
  112013. /**
  112014. * "GroundMesh"
  112015. * @returns "GroundMesh"
  112016. */
  112017. getClassName(): string;
  112018. /**
  112019. * The minimum of x and y subdivisions
  112020. */
  112021. get subdivisions(): number;
  112022. /**
  112023. * X subdivisions
  112024. */
  112025. get subdivisionsX(): number;
  112026. /**
  112027. * Y subdivisions
  112028. */
  112029. get subdivisionsY(): number;
  112030. /**
  112031. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  112032. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  112033. * @param chunksCount the number of subdivisions for x and y
  112034. * @param octreeBlocksSize (Default: 32)
  112035. */
  112036. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  112037. /**
  112038. * Returns a height (y) value in the Worl system :
  112039. * the ground altitude at the coordinates (x, z) expressed in the World system.
  112040. * @param x x coordinate
  112041. * @param z z coordinate
  112042. * @returns the ground y position if (x, z) are outside the ground surface.
  112043. */
  112044. getHeightAtCoordinates(x: number, z: number): number;
  112045. /**
  112046. * Returns a normalized vector (Vector3) orthogonal to the ground
  112047. * at the ground coordinates (x, z) expressed in the World system.
  112048. * @param x x coordinate
  112049. * @param z z coordinate
  112050. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  112051. */
  112052. getNormalAtCoordinates(x: number, z: number): Vector3;
  112053. /**
  112054. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  112055. * at the ground coordinates (x, z) expressed in the World system.
  112056. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  112057. * @param x x coordinate
  112058. * @param z z coordinate
  112059. * @param ref vector to store the result
  112060. * @returns the GroundMesh.
  112061. */
  112062. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  112063. /**
  112064. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  112065. * if the ground has been updated.
  112066. * This can be used in the render loop.
  112067. * @returns the GroundMesh.
  112068. */
  112069. updateCoordinateHeights(): GroundMesh;
  112070. private _getFacetAt;
  112071. private _initHeightQuads;
  112072. private _computeHeightQuads;
  112073. /**
  112074. * Serializes this ground mesh
  112075. * @param serializationObject object to write serialization to
  112076. */
  112077. serialize(serializationObject: any): void;
  112078. /**
  112079. * Parses a serialized ground mesh
  112080. * @param parsedMesh the serialized mesh
  112081. * @param scene the scene to create the ground mesh in
  112082. * @returns the created ground mesh
  112083. */
  112084. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  112085. }
  112086. }
  112087. declare module BABYLON {
  112088. /**
  112089. * Interface for Physics-Joint data
  112090. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112091. */
  112092. export interface PhysicsJointData {
  112093. /**
  112094. * The main pivot of the joint
  112095. */
  112096. mainPivot?: Vector3;
  112097. /**
  112098. * The connected pivot of the joint
  112099. */
  112100. connectedPivot?: Vector3;
  112101. /**
  112102. * The main axis of the joint
  112103. */
  112104. mainAxis?: Vector3;
  112105. /**
  112106. * The connected axis of the joint
  112107. */
  112108. connectedAxis?: Vector3;
  112109. /**
  112110. * The collision of the joint
  112111. */
  112112. collision?: boolean;
  112113. /**
  112114. * Native Oimo/Cannon/Energy data
  112115. */
  112116. nativeParams?: any;
  112117. }
  112118. /**
  112119. * This is a holder class for the physics joint created by the physics plugin
  112120. * It holds a set of functions to control the underlying joint
  112121. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112122. */
  112123. export class PhysicsJoint {
  112124. /**
  112125. * The type of the physics joint
  112126. */
  112127. type: number;
  112128. /**
  112129. * The data for the physics joint
  112130. */
  112131. jointData: PhysicsJointData;
  112132. private _physicsJoint;
  112133. protected _physicsPlugin: IPhysicsEnginePlugin;
  112134. /**
  112135. * Initializes the physics joint
  112136. * @param type The type of the physics joint
  112137. * @param jointData The data for the physics joint
  112138. */
  112139. constructor(
  112140. /**
  112141. * The type of the physics joint
  112142. */
  112143. type: number,
  112144. /**
  112145. * The data for the physics joint
  112146. */
  112147. jointData: PhysicsJointData);
  112148. /**
  112149. * Gets the physics joint
  112150. */
  112151. get physicsJoint(): any;
  112152. /**
  112153. * Sets the physics joint
  112154. */
  112155. set physicsJoint(newJoint: any);
  112156. /**
  112157. * Sets the physics plugin
  112158. */
  112159. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  112160. /**
  112161. * Execute a function that is physics-plugin specific.
  112162. * @param {Function} func the function that will be executed.
  112163. * It accepts two parameters: the physics world and the physics joint
  112164. */
  112165. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  112166. /**
  112167. * Distance-Joint type
  112168. */
  112169. static DistanceJoint: number;
  112170. /**
  112171. * Hinge-Joint type
  112172. */
  112173. static HingeJoint: number;
  112174. /**
  112175. * Ball-and-Socket joint type
  112176. */
  112177. static BallAndSocketJoint: number;
  112178. /**
  112179. * Wheel-Joint type
  112180. */
  112181. static WheelJoint: number;
  112182. /**
  112183. * Slider-Joint type
  112184. */
  112185. static SliderJoint: number;
  112186. /**
  112187. * Prismatic-Joint type
  112188. */
  112189. static PrismaticJoint: number;
  112190. /**
  112191. * Universal-Joint type
  112192. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  112193. */
  112194. static UniversalJoint: number;
  112195. /**
  112196. * Hinge-Joint 2 type
  112197. */
  112198. static Hinge2Joint: number;
  112199. /**
  112200. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  112201. */
  112202. static PointToPointJoint: number;
  112203. /**
  112204. * Spring-Joint type
  112205. */
  112206. static SpringJoint: number;
  112207. /**
  112208. * Lock-Joint type
  112209. */
  112210. static LockJoint: number;
  112211. }
  112212. /**
  112213. * A class representing a physics distance joint
  112214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112215. */
  112216. export class DistanceJoint extends PhysicsJoint {
  112217. /**
  112218. *
  112219. * @param jointData The data for the Distance-Joint
  112220. */
  112221. constructor(jointData: DistanceJointData);
  112222. /**
  112223. * Update the predefined distance.
  112224. * @param maxDistance The maximum preferred distance
  112225. * @param minDistance The minimum preferred distance
  112226. */
  112227. updateDistance(maxDistance: number, minDistance?: number): void;
  112228. }
  112229. /**
  112230. * Represents a Motor-Enabled Joint
  112231. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112232. */
  112233. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  112234. /**
  112235. * Initializes the Motor-Enabled Joint
  112236. * @param type The type of the joint
  112237. * @param jointData The physica joint data for the joint
  112238. */
  112239. constructor(type: number, jointData: PhysicsJointData);
  112240. /**
  112241. * Set the motor values.
  112242. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112243. * @param force the force to apply
  112244. * @param maxForce max force for this motor.
  112245. */
  112246. setMotor(force?: number, maxForce?: number): void;
  112247. /**
  112248. * Set the motor's limits.
  112249. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112250. * @param upperLimit The upper limit of the motor
  112251. * @param lowerLimit The lower limit of the motor
  112252. */
  112253. setLimit(upperLimit: number, lowerLimit?: number): void;
  112254. }
  112255. /**
  112256. * This class represents a single physics Hinge-Joint
  112257. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112258. */
  112259. export class HingeJoint extends MotorEnabledJoint {
  112260. /**
  112261. * Initializes the Hinge-Joint
  112262. * @param jointData The joint data for the Hinge-Joint
  112263. */
  112264. constructor(jointData: PhysicsJointData);
  112265. /**
  112266. * Set the motor values.
  112267. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112268. * @param {number} force the force to apply
  112269. * @param {number} maxForce max force for this motor.
  112270. */
  112271. setMotor(force?: number, maxForce?: number): void;
  112272. /**
  112273. * Set the motor's limits.
  112274. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112275. * @param upperLimit The upper limit of the motor
  112276. * @param lowerLimit The lower limit of the motor
  112277. */
  112278. setLimit(upperLimit: number, lowerLimit?: number): void;
  112279. }
  112280. /**
  112281. * This class represents a dual hinge physics joint (same as wheel joint)
  112282. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112283. */
  112284. export class Hinge2Joint extends MotorEnabledJoint {
  112285. /**
  112286. * Initializes the Hinge2-Joint
  112287. * @param jointData The joint data for the Hinge2-Joint
  112288. */
  112289. constructor(jointData: PhysicsJointData);
  112290. /**
  112291. * Set the motor values.
  112292. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112293. * @param {number} targetSpeed the speed the motor is to reach
  112294. * @param {number} maxForce max force for this motor.
  112295. * @param {motorIndex} the motor's index, 0 or 1.
  112296. */
  112297. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  112298. /**
  112299. * Set the motor limits.
  112300. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112301. * @param {number} upperLimit the upper limit
  112302. * @param {number} lowerLimit lower limit
  112303. * @param {motorIndex} the motor's index, 0 or 1.
  112304. */
  112305. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112306. }
  112307. /**
  112308. * Interface for a motor enabled joint
  112309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112310. */
  112311. export interface IMotorEnabledJoint {
  112312. /**
  112313. * Physics joint
  112314. */
  112315. physicsJoint: any;
  112316. /**
  112317. * Sets the motor of the motor-enabled joint
  112318. * @param force The force of the motor
  112319. * @param maxForce The maximum force of the motor
  112320. * @param motorIndex The index of the motor
  112321. */
  112322. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  112323. /**
  112324. * Sets the limit of the motor
  112325. * @param upperLimit The upper limit of the motor
  112326. * @param lowerLimit The lower limit of the motor
  112327. * @param motorIndex The index of the motor
  112328. */
  112329. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112330. }
  112331. /**
  112332. * Joint data for a Distance-Joint
  112333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112334. */
  112335. export interface DistanceJointData extends PhysicsJointData {
  112336. /**
  112337. * Max distance the 2 joint objects can be apart
  112338. */
  112339. maxDistance: number;
  112340. }
  112341. /**
  112342. * Joint data from a spring joint
  112343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112344. */
  112345. export interface SpringJointData extends PhysicsJointData {
  112346. /**
  112347. * Length of the spring
  112348. */
  112349. length: number;
  112350. /**
  112351. * Stiffness of the spring
  112352. */
  112353. stiffness: number;
  112354. /**
  112355. * Damping of the spring
  112356. */
  112357. damping: number;
  112358. /** this callback will be called when applying the force to the impostors. */
  112359. forceApplicationCallback: () => void;
  112360. }
  112361. }
  112362. declare module BABYLON {
  112363. /**
  112364. * Holds the data for the raycast result
  112365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112366. */
  112367. export class PhysicsRaycastResult {
  112368. private _hasHit;
  112369. private _hitDistance;
  112370. private _hitNormalWorld;
  112371. private _hitPointWorld;
  112372. private _rayFromWorld;
  112373. private _rayToWorld;
  112374. /**
  112375. * Gets if there was a hit
  112376. */
  112377. get hasHit(): boolean;
  112378. /**
  112379. * Gets the distance from the hit
  112380. */
  112381. get hitDistance(): number;
  112382. /**
  112383. * Gets the hit normal/direction in the world
  112384. */
  112385. get hitNormalWorld(): Vector3;
  112386. /**
  112387. * Gets the hit point in the world
  112388. */
  112389. get hitPointWorld(): Vector3;
  112390. /**
  112391. * Gets the ray "start point" of the ray in the world
  112392. */
  112393. get rayFromWorld(): Vector3;
  112394. /**
  112395. * Gets the ray "end point" of the ray in the world
  112396. */
  112397. get rayToWorld(): Vector3;
  112398. /**
  112399. * Sets the hit data (normal & point in world space)
  112400. * @param hitNormalWorld defines the normal in world space
  112401. * @param hitPointWorld defines the point in world space
  112402. */
  112403. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  112404. /**
  112405. * Sets the distance from the start point to the hit point
  112406. * @param distance
  112407. */
  112408. setHitDistance(distance: number): void;
  112409. /**
  112410. * Calculates the distance manually
  112411. */
  112412. calculateHitDistance(): void;
  112413. /**
  112414. * Resets all the values to default
  112415. * @param from The from point on world space
  112416. * @param to The to point on world space
  112417. */
  112418. reset(from?: Vector3, to?: Vector3): void;
  112419. }
  112420. /**
  112421. * Interface for the size containing width and height
  112422. */
  112423. interface IXYZ {
  112424. /**
  112425. * X
  112426. */
  112427. x: number;
  112428. /**
  112429. * Y
  112430. */
  112431. y: number;
  112432. /**
  112433. * Z
  112434. */
  112435. z: number;
  112436. }
  112437. }
  112438. declare module BABYLON {
  112439. /**
  112440. * Interface used to describe a physics joint
  112441. */
  112442. export interface PhysicsImpostorJoint {
  112443. /** Defines the main impostor to which the joint is linked */
  112444. mainImpostor: PhysicsImpostor;
  112445. /** Defines the impostor that is connected to the main impostor using this joint */
  112446. connectedImpostor: PhysicsImpostor;
  112447. /** Defines the joint itself */
  112448. joint: PhysicsJoint;
  112449. }
  112450. /** @hidden */
  112451. export interface IPhysicsEnginePlugin {
  112452. world: any;
  112453. name: string;
  112454. setGravity(gravity: Vector3): void;
  112455. setTimeStep(timeStep: number): void;
  112456. getTimeStep(): number;
  112457. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112458. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112459. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112460. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112461. removePhysicsBody(impostor: PhysicsImpostor): void;
  112462. generateJoint(joint: PhysicsImpostorJoint): void;
  112463. removeJoint(joint: PhysicsImpostorJoint): void;
  112464. isSupported(): boolean;
  112465. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112466. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112467. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112468. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112469. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112470. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112471. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112472. getBodyMass(impostor: PhysicsImpostor): number;
  112473. getBodyFriction(impostor: PhysicsImpostor): number;
  112474. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112475. getBodyRestitution(impostor: PhysicsImpostor): number;
  112476. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112477. getBodyPressure?(impostor: PhysicsImpostor): number;
  112478. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  112479. getBodyStiffness?(impostor: PhysicsImpostor): number;
  112480. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  112481. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  112482. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  112483. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  112484. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  112485. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112486. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112487. sleepBody(impostor: PhysicsImpostor): void;
  112488. wakeUpBody(impostor: PhysicsImpostor): void;
  112489. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112490. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112491. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  112492. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112493. getRadius(impostor: PhysicsImpostor): number;
  112494. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112495. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112496. dispose(): void;
  112497. }
  112498. /**
  112499. * Interface used to define a physics engine
  112500. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112501. */
  112502. export interface IPhysicsEngine {
  112503. /**
  112504. * Gets the gravity vector used by the simulation
  112505. */
  112506. gravity: Vector3;
  112507. /**
  112508. * Sets the gravity vector used by the simulation
  112509. * @param gravity defines the gravity vector to use
  112510. */
  112511. setGravity(gravity: Vector3): void;
  112512. /**
  112513. * Set the time step of the physics engine.
  112514. * Default is 1/60.
  112515. * To slow it down, enter 1/600 for example.
  112516. * To speed it up, 1/30
  112517. * @param newTimeStep the new timestep to apply to this world.
  112518. */
  112519. setTimeStep(newTimeStep: number): void;
  112520. /**
  112521. * Get the time step of the physics engine.
  112522. * @returns the current time step
  112523. */
  112524. getTimeStep(): number;
  112525. /**
  112526. * Set the sub time step of the physics engine.
  112527. * Default is 0 meaning there is no sub steps
  112528. * To increase physics resolution precision, set a small value (like 1 ms)
  112529. * @param subTimeStep defines the new sub timestep used for physics resolution.
  112530. */
  112531. setSubTimeStep(subTimeStep: number): void;
  112532. /**
  112533. * Get the sub time step of the physics engine.
  112534. * @returns the current sub time step
  112535. */
  112536. getSubTimeStep(): number;
  112537. /**
  112538. * Release all resources
  112539. */
  112540. dispose(): void;
  112541. /**
  112542. * Gets the name of the current physics plugin
  112543. * @returns the name of the plugin
  112544. */
  112545. getPhysicsPluginName(): string;
  112546. /**
  112547. * Adding a new impostor for the impostor tracking.
  112548. * This will be done by the impostor itself.
  112549. * @param impostor the impostor to add
  112550. */
  112551. addImpostor(impostor: PhysicsImpostor): void;
  112552. /**
  112553. * Remove an impostor from the engine.
  112554. * This impostor and its mesh will not longer be updated by the physics engine.
  112555. * @param impostor the impostor to remove
  112556. */
  112557. removeImpostor(impostor: PhysicsImpostor): void;
  112558. /**
  112559. * Add a joint to the physics engine
  112560. * @param mainImpostor defines the main impostor to which the joint is added.
  112561. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  112562. * @param joint defines the joint that will connect both impostors.
  112563. */
  112564. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112565. /**
  112566. * Removes a joint from the simulation
  112567. * @param mainImpostor defines the impostor used with the joint
  112568. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  112569. * @param joint defines the joint to remove
  112570. */
  112571. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112572. /**
  112573. * Gets the current plugin used to run the simulation
  112574. * @returns current plugin
  112575. */
  112576. getPhysicsPlugin(): IPhysicsEnginePlugin;
  112577. /**
  112578. * Gets the list of physic impostors
  112579. * @returns an array of PhysicsImpostor
  112580. */
  112581. getImpostors(): Array<PhysicsImpostor>;
  112582. /**
  112583. * Gets the impostor for a physics enabled object
  112584. * @param object defines the object impersonated by the impostor
  112585. * @returns the PhysicsImpostor or null if not found
  112586. */
  112587. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112588. /**
  112589. * Gets the impostor for a physics body object
  112590. * @param body defines physics body used by the impostor
  112591. * @returns the PhysicsImpostor or null if not found
  112592. */
  112593. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  112594. /**
  112595. * Does a raycast in the physics world
  112596. * @param from when should the ray start?
  112597. * @param to when should the ray end?
  112598. * @returns PhysicsRaycastResult
  112599. */
  112600. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112601. /**
  112602. * Called by the scene. No need to call it.
  112603. * @param delta defines the timespam between frames
  112604. */
  112605. _step(delta: number): void;
  112606. }
  112607. }
  112608. declare module BABYLON {
  112609. /**
  112610. * The interface for the physics imposter parameters
  112611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112612. */
  112613. export interface PhysicsImpostorParameters {
  112614. /**
  112615. * The mass of the physics imposter
  112616. */
  112617. mass: number;
  112618. /**
  112619. * The friction of the physics imposter
  112620. */
  112621. friction?: number;
  112622. /**
  112623. * The coefficient of restitution of the physics imposter
  112624. */
  112625. restitution?: number;
  112626. /**
  112627. * The native options of the physics imposter
  112628. */
  112629. nativeOptions?: any;
  112630. /**
  112631. * Specifies if the parent should be ignored
  112632. */
  112633. ignoreParent?: boolean;
  112634. /**
  112635. * Specifies if bi-directional transformations should be disabled
  112636. */
  112637. disableBidirectionalTransformation?: boolean;
  112638. /**
  112639. * The pressure inside the physics imposter, soft object only
  112640. */
  112641. pressure?: number;
  112642. /**
  112643. * The stiffness the physics imposter, soft object only
  112644. */
  112645. stiffness?: number;
  112646. /**
  112647. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  112648. */
  112649. velocityIterations?: number;
  112650. /**
  112651. * The number of iterations used in maintaining consistent vertex positions, soft object only
  112652. */
  112653. positionIterations?: number;
  112654. /**
  112655. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  112656. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  112657. * Add to fix multiple points
  112658. */
  112659. fixedPoints?: number;
  112660. /**
  112661. * The collision margin around a soft object
  112662. */
  112663. margin?: number;
  112664. /**
  112665. * The collision margin around a soft object
  112666. */
  112667. damping?: number;
  112668. /**
  112669. * The path for a rope based on an extrusion
  112670. */
  112671. path?: any;
  112672. /**
  112673. * The shape of an extrusion used for a rope based on an extrusion
  112674. */
  112675. shape?: any;
  112676. }
  112677. /**
  112678. * Interface for a physics-enabled object
  112679. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112680. */
  112681. export interface IPhysicsEnabledObject {
  112682. /**
  112683. * The position of the physics-enabled object
  112684. */
  112685. position: Vector3;
  112686. /**
  112687. * The rotation of the physics-enabled object
  112688. */
  112689. rotationQuaternion: Nullable<Quaternion>;
  112690. /**
  112691. * The scale of the physics-enabled object
  112692. */
  112693. scaling: Vector3;
  112694. /**
  112695. * The rotation of the physics-enabled object
  112696. */
  112697. rotation?: Vector3;
  112698. /**
  112699. * The parent of the physics-enabled object
  112700. */
  112701. parent?: any;
  112702. /**
  112703. * The bounding info of the physics-enabled object
  112704. * @returns The bounding info of the physics-enabled object
  112705. */
  112706. getBoundingInfo(): BoundingInfo;
  112707. /**
  112708. * Computes the world matrix
  112709. * @param force Specifies if the world matrix should be computed by force
  112710. * @returns A world matrix
  112711. */
  112712. computeWorldMatrix(force: boolean): Matrix;
  112713. /**
  112714. * Gets the world matrix
  112715. * @returns A world matrix
  112716. */
  112717. getWorldMatrix?(): Matrix;
  112718. /**
  112719. * Gets the child meshes
  112720. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  112721. * @returns An array of abstract meshes
  112722. */
  112723. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  112724. /**
  112725. * Gets the vertex data
  112726. * @param kind The type of vertex data
  112727. * @returns A nullable array of numbers, or a float32 array
  112728. */
  112729. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  112730. /**
  112731. * Gets the indices from the mesh
  112732. * @returns A nullable array of index arrays
  112733. */
  112734. getIndices?(): Nullable<IndicesArray>;
  112735. /**
  112736. * Gets the scene from the mesh
  112737. * @returns the indices array or null
  112738. */
  112739. getScene?(): Scene;
  112740. /**
  112741. * Gets the absolute position from the mesh
  112742. * @returns the absolute position
  112743. */
  112744. getAbsolutePosition(): Vector3;
  112745. /**
  112746. * Gets the absolute pivot point from the mesh
  112747. * @returns the absolute pivot point
  112748. */
  112749. getAbsolutePivotPoint(): Vector3;
  112750. /**
  112751. * Rotates the mesh
  112752. * @param axis The axis of rotation
  112753. * @param amount The amount of rotation
  112754. * @param space The space of the rotation
  112755. * @returns The rotation transform node
  112756. */
  112757. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  112758. /**
  112759. * Translates the mesh
  112760. * @param axis The axis of translation
  112761. * @param distance The distance of translation
  112762. * @param space The space of the translation
  112763. * @returns The transform node
  112764. */
  112765. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  112766. /**
  112767. * Sets the absolute position of the mesh
  112768. * @param absolutePosition The absolute position of the mesh
  112769. * @returns The transform node
  112770. */
  112771. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  112772. /**
  112773. * Gets the class name of the mesh
  112774. * @returns The class name
  112775. */
  112776. getClassName(): string;
  112777. }
  112778. /**
  112779. * Represents a physics imposter
  112780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112781. */
  112782. export class PhysicsImpostor {
  112783. /**
  112784. * The physics-enabled object used as the physics imposter
  112785. */
  112786. object: IPhysicsEnabledObject;
  112787. /**
  112788. * The type of the physics imposter
  112789. */
  112790. type: number;
  112791. private _options;
  112792. private _scene?;
  112793. /**
  112794. * The default object size of the imposter
  112795. */
  112796. static DEFAULT_OBJECT_SIZE: Vector3;
  112797. /**
  112798. * The identity quaternion of the imposter
  112799. */
  112800. static IDENTITY_QUATERNION: Quaternion;
  112801. /** @hidden */
  112802. _pluginData: any;
  112803. private _physicsEngine;
  112804. private _physicsBody;
  112805. private _bodyUpdateRequired;
  112806. private _onBeforePhysicsStepCallbacks;
  112807. private _onAfterPhysicsStepCallbacks;
  112808. /** @hidden */
  112809. _onPhysicsCollideCallbacks: Array<{
  112810. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  112811. otherImpostors: Array<PhysicsImpostor>;
  112812. }>;
  112813. private _deltaPosition;
  112814. private _deltaRotation;
  112815. private _deltaRotationConjugated;
  112816. /** @hidden */
  112817. _isFromLine: boolean;
  112818. private _parent;
  112819. private _isDisposed;
  112820. private static _tmpVecs;
  112821. private static _tmpQuat;
  112822. /**
  112823. * Specifies if the physics imposter is disposed
  112824. */
  112825. get isDisposed(): boolean;
  112826. /**
  112827. * Gets the mass of the physics imposter
  112828. */
  112829. get mass(): number;
  112830. set mass(value: number);
  112831. /**
  112832. * Gets the coefficient of friction
  112833. */
  112834. get friction(): number;
  112835. /**
  112836. * Sets the coefficient of friction
  112837. */
  112838. set friction(value: number);
  112839. /**
  112840. * Gets the coefficient of restitution
  112841. */
  112842. get restitution(): number;
  112843. /**
  112844. * Sets the coefficient of restitution
  112845. */
  112846. set restitution(value: number);
  112847. /**
  112848. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  112849. */
  112850. get pressure(): number;
  112851. /**
  112852. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  112853. */
  112854. set pressure(value: number);
  112855. /**
  112856. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  112857. */
  112858. get stiffness(): number;
  112859. /**
  112860. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  112861. */
  112862. set stiffness(value: number);
  112863. /**
  112864. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  112865. */
  112866. get velocityIterations(): number;
  112867. /**
  112868. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  112869. */
  112870. set velocityIterations(value: number);
  112871. /**
  112872. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  112873. */
  112874. get positionIterations(): number;
  112875. /**
  112876. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  112877. */
  112878. set positionIterations(value: number);
  112879. /**
  112880. * The unique id of the physics imposter
  112881. * set by the physics engine when adding this impostor to the array
  112882. */
  112883. uniqueId: number;
  112884. /**
  112885. * @hidden
  112886. */
  112887. soft: boolean;
  112888. /**
  112889. * @hidden
  112890. */
  112891. segments: number;
  112892. private _joints;
  112893. /**
  112894. * Initializes the physics imposter
  112895. * @param object The physics-enabled object used as the physics imposter
  112896. * @param type The type of the physics imposter
  112897. * @param _options The options for the physics imposter
  112898. * @param _scene The Babylon scene
  112899. */
  112900. constructor(
  112901. /**
  112902. * The physics-enabled object used as the physics imposter
  112903. */
  112904. object: IPhysicsEnabledObject,
  112905. /**
  112906. * The type of the physics imposter
  112907. */
  112908. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  112909. /**
  112910. * This function will completly initialize this impostor.
  112911. * It will create a new body - but only if this mesh has no parent.
  112912. * If it has, this impostor will not be used other than to define the impostor
  112913. * of the child mesh.
  112914. * @hidden
  112915. */
  112916. _init(): void;
  112917. private _getPhysicsParent;
  112918. /**
  112919. * Should a new body be generated.
  112920. * @returns boolean specifying if body initialization is required
  112921. */
  112922. isBodyInitRequired(): boolean;
  112923. /**
  112924. * Sets the updated scaling
  112925. * @param updated Specifies if the scaling is updated
  112926. */
  112927. setScalingUpdated(): void;
  112928. /**
  112929. * Force a regeneration of this or the parent's impostor's body.
  112930. * Use under cautious - This will remove all joints already implemented.
  112931. */
  112932. forceUpdate(): void;
  112933. /**
  112934. * Gets the body that holds this impostor. Either its own, or its parent.
  112935. */
  112936. get physicsBody(): any;
  112937. /**
  112938. * Get the parent of the physics imposter
  112939. * @returns Physics imposter or null
  112940. */
  112941. get parent(): Nullable<PhysicsImpostor>;
  112942. /**
  112943. * Sets the parent of the physics imposter
  112944. */
  112945. set parent(value: Nullable<PhysicsImpostor>);
  112946. /**
  112947. * Set the physics body. Used mainly by the physics engine/plugin
  112948. */
  112949. set physicsBody(physicsBody: any);
  112950. /**
  112951. * Resets the update flags
  112952. */
  112953. resetUpdateFlags(): void;
  112954. /**
  112955. * Gets the object extend size
  112956. * @returns the object extend size
  112957. */
  112958. getObjectExtendSize(): Vector3;
  112959. /**
  112960. * Gets the object center
  112961. * @returns The object center
  112962. */
  112963. getObjectCenter(): Vector3;
  112964. /**
  112965. * Get a specific parameter from the options parameters
  112966. * @param paramName The object parameter name
  112967. * @returns The object parameter
  112968. */
  112969. getParam(paramName: string): any;
  112970. /**
  112971. * Sets a specific parameter in the options given to the physics plugin
  112972. * @param paramName The parameter name
  112973. * @param value The value of the parameter
  112974. */
  112975. setParam(paramName: string, value: number): void;
  112976. /**
  112977. * Specifically change the body's mass option. Won't recreate the physics body object
  112978. * @param mass The mass of the physics imposter
  112979. */
  112980. setMass(mass: number): void;
  112981. /**
  112982. * Gets the linear velocity
  112983. * @returns linear velocity or null
  112984. */
  112985. getLinearVelocity(): Nullable<Vector3>;
  112986. /**
  112987. * Sets the linear velocity
  112988. * @param velocity linear velocity or null
  112989. */
  112990. setLinearVelocity(velocity: Nullable<Vector3>): void;
  112991. /**
  112992. * Gets the angular velocity
  112993. * @returns angular velocity or null
  112994. */
  112995. getAngularVelocity(): Nullable<Vector3>;
  112996. /**
  112997. * Sets the angular velocity
  112998. * @param velocity The velocity or null
  112999. */
  113000. setAngularVelocity(velocity: Nullable<Vector3>): void;
  113001. /**
  113002. * Execute a function with the physics plugin native code
  113003. * Provide a function the will have two variables - the world object and the physics body object
  113004. * @param func The function to execute with the physics plugin native code
  113005. */
  113006. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  113007. /**
  113008. * Register a function that will be executed before the physics world is stepping forward
  113009. * @param func The function to execute before the physics world is stepped forward
  113010. */
  113011. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113012. /**
  113013. * Unregister a function that will be executed before the physics world is stepping forward
  113014. * @param func The function to execute before the physics world is stepped forward
  113015. */
  113016. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113017. /**
  113018. * Register a function that will be executed after the physics step
  113019. * @param func The function to execute after physics step
  113020. */
  113021. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113022. /**
  113023. * Unregisters a function that will be executed after the physics step
  113024. * @param func The function to execute after physics step
  113025. */
  113026. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113027. /**
  113028. * register a function that will be executed when this impostor collides against a different body
  113029. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  113030. * @param func Callback that is executed on collision
  113031. */
  113032. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  113033. /**
  113034. * Unregisters the physics imposter on contact
  113035. * @param collideAgainst The physics object to collide against
  113036. * @param func Callback to execute on collision
  113037. */
  113038. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  113039. private _tmpQuat;
  113040. private _tmpQuat2;
  113041. /**
  113042. * Get the parent rotation
  113043. * @returns The parent rotation
  113044. */
  113045. getParentsRotation(): Quaternion;
  113046. /**
  113047. * this function is executed by the physics engine.
  113048. */
  113049. beforeStep: () => void;
  113050. /**
  113051. * this function is executed by the physics engine
  113052. */
  113053. afterStep: () => void;
  113054. /**
  113055. * Legacy collision detection event support
  113056. */
  113057. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  113058. /**
  113059. * event and body object due to cannon's event-based architecture.
  113060. */
  113061. onCollide: (e: {
  113062. body: any;
  113063. point: Nullable<Vector3>;
  113064. }) => void;
  113065. /**
  113066. * Apply a force
  113067. * @param force The force to apply
  113068. * @param contactPoint The contact point for the force
  113069. * @returns The physics imposter
  113070. */
  113071. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113072. /**
  113073. * Apply an impulse
  113074. * @param force The impulse force
  113075. * @param contactPoint The contact point for the impulse force
  113076. * @returns The physics imposter
  113077. */
  113078. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113079. /**
  113080. * A help function to create a joint
  113081. * @param otherImpostor A physics imposter used to create a joint
  113082. * @param jointType The type of joint
  113083. * @param jointData The data for the joint
  113084. * @returns The physics imposter
  113085. */
  113086. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  113087. /**
  113088. * Add a joint to this impostor with a different impostor
  113089. * @param otherImpostor A physics imposter used to add a joint
  113090. * @param joint The joint to add
  113091. * @returns The physics imposter
  113092. */
  113093. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  113094. /**
  113095. * Add an anchor to a cloth impostor
  113096. * @param otherImpostor rigid impostor to anchor to
  113097. * @param width ratio across width from 0 to 1
  113098. * @param height ratio up height from 0 to 1
  113099. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  113100. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  113101. * @returns impostor the soft imposter
  113102. */
  113103. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113104. /**
  113105. * Add a hook to a rope impostor
  113106. * @param otherImpostor rigid impostor to anchor to
  113107. * @param length ratio across rope from 0 to 1
  113108. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  113109. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113110. * @returns impostor the rope imposter
  113111. */
  113112. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113113. /**
  113114. * Will keep this body still, in a sleep mode.
  113115. * @returns the physics imposter
  113116. */
  113117. sleep(): PhysicsImpostor;
  113118. /**
  113119. * Wake the body up.
  113120. * @returns The physics imposter
  113121. */
  113122. wakeUp(): PhysicsImpostor;
  113123. /**
  113124. * Clones the physics imposter
  113125. * @param newObject The physics imposter clones to this physics-enabled object
  113126. * @returns A nullable physics imposter
  113127. */
  113128. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113129. /**
  113130. * Disposes the physics imposter
  113131. */
  113132. dispose(): void;
  113133. /**
  113134. * Sets the delta position
  113135. * @param position The delta position amount
  113136. */
  113137. setDeltaPosition(position: Vector3): void;
  113138. /**
  113139. * Sets the delta rotation
  113140. * @param rotation The delta rotation amount
  113141. */
  113142. setDeltaRotation(rotation: Quaternion): void;
  113143. /**
  113144. * Gets the box size of the physics imposter and stores the result in the input parameter
  113145. * @param result Stores the box size
  113146. * @returns The physics imposter
  113147. */
  113148. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  113149. /**
  113150. * Gets the radius of the physics imposter
  113151. * @returns Radius of the physics imposter
  113152. */
  113153. getRadius(): number;
  113154. /**
  113155. * Sync a bone with this impostor
  113156. * @param bone The bone to sync to the impostor.
  113157. * @param boneMesh The mesh that the bone is influencing.
  113158. * @param jointPivot The pivot of the joint / bone in local space.
  113159. * @param distToJoint Optional distance from the impostor to the joint.
  113160. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113161. */
  113162. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  113163. /**
  113164. * Sync impostor to a bone
  113165. * @param bone The bone that the impostor will be synced to.
  113166. * @param boneMesh The mesh that the bone is influencing.
  113167. * @param jointPivot The pivot of the joint / bone in local space.
  113168. * @param distToJoint Optional distance from the impostor to the joint.
  113169. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113170. * @param boneAxis Optional vector3 axis the bone is aligned with
  113171. */
  113172. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  113173. /**
  113174. * No-Imposter type
  113175. */
  113176. static NoImpostor: number;
  113177. /**
  113178. * Sphere-Imposter type
  113179. */
  113180. static SphereImpostor: number;
  113181. /**
  113182. * Box-Imposter type
  113183. */
  113184. static BoxImpostor: number;
  113185. /**
  113186. * Plane-Imposter type
  113187. */
  113188. static PlaneImpostor: number;
  113189. /**
  113190. * Mesh-imposter type
  113191. */
  113192. static MeshImpostor: number;
  113193. /**
  113194. * Capsule-Impostor type (Ammo.js plugin only)
  113195. */
  113196. static CapsuleImpostor: number;
  113197. /**
  113198. * Cylinder-Imposter type
  113199. */
  113200. static CylinderImpostor: number;
  113201. /**
  113202. * Particle-Imposter type
  113203. */
  113204. static ParticleImpostor: number;
  113205. /**
  113206. * Heightmap-Imposter type
  113207. */
  113208. static HeightmapImpostor: number;
  113209. /**
  113210. * ConvexHull-Impostor type (Ammo.js plugin only)
  113211. */
  113212. static ConvexHullImpostor: number;
  113213. /**
  113214. * Custom-Imposter type (Ammo.js plugin only)
  113215. */
  113216. static CustomImpostor: number;
  113217. /**
  113218. * Rope-Imposter type
  113219. */
  113220. static RopeImpostor: number;
  113221. /**
  113222. * Cloth-Imposter type
  113223. */
  113224. static ClothImpostor: number;
  113225. /**
  113226. * Softbody-Imposter type
  113227. */
  113228. static SoftbodyImpostor: number;
  113229. }
  113230. }
  113231. declare module BABYLON {
  113232. /**
  113233. * @hidden
  113234. **/
  113235. export class _CreationDataStorage {
  113236. closePath?: boolean;
  113237. closeArray?: boolean;
  113238. idx: number[];
  113239. dashSize: number;
  113240. gapSize: number;
  113241. path3D: Path3D;
  113242. pathArray: Vector3[][];
  113243. arc: number;
  113244. radius: number;
  113245. cap: number;
  113246. tessellation: number;
  113247. }
  113248. /**
  113249. * @hidden
  113250. **/
  113251. class _InstanceDataStorage {
  113252. visibleInstances: any;
  113253. batchCache: _InstancesBatch;
  113254. instancesBufferSize: number;
  113255. instancesBuffer: Nullable<Buffer>;
  113256. instancesData: Float32Array;
  113257. overridenInstanceCount: number;
  113258. isFrozen: boolean;
  113259. previousBatch: Nullable<_InstancesBatch>;
  113260. hardwareInstancedRendering: boolean;
  113261. sideOrientation: number;
  113262. manualUpdate: boolean;
  113263. previousRenderId: number;
  113264. }
  113265. /**
  113266. * @hidden
  113267. **/
  113268. export class _InstancesBatch {
  113269. mustReturn: boolean;
  113270. visibleInstances: Nullable<InstancedMesh[]>[];
  113271. renderSelf: boolean[];
  113272. hardwareInstancedRendering: boolean[];
  113273. }
  113274. /**
  113275. * @hidden
  113276. **/
  113277. class _ThinInstanceDataStorage {
  113278. instancesCount: number;
  113279. matrixBuffer: Nullable<Buffer>;
  113280. matrixBufferSize: number;
  113281. matrixData: Nullable<Float32Array>;
  113282. boundingVectors: Array<Vector3>;
  113283. worldMatrices: Nullable<Matrix[]>;
  113284. }
  113285. /**
  113286. * Class used to represent renderable models
  113287. */
  113288. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  113289. /**
  113290. * Mesh side orientation : usually the external or front surface
  113291. */
  113292. static readonly FRONTSIDE: number;
  113293. /**
  113294. * Mesh side orientation : usually the internal or back surface
  113295. */
  113296. static readonly BACKSIDE: number;
  113297. /**
  113298. * Mesh side orientation : both internal and external or front and back surfaces
  113299. */
  113300. static readonly DOUBLESIDE: number;
  113301. /**
  113302. * Mesh side orientation : by default, `FRONTSIDE`
  113303. */
  113304. static readonly DEFAULTSIDE: number;
  113305. /**
  113306. * Mesh cap setting : no cap
  113307. */
  113308. static readonly NO_CAP: number;
  113309. /**
  113310. * Mesh cap setting : one cap at the beginning of the mesh
  113311. */
  113312. static readonly CAP_START: number;
  113313. /**
  113314. * Mesh cap setting : one cap at the end of the mesh
  113315. */
  113316. static readonly CAP_END: number;
  113317. /**
  113318. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  113319. */
  113320. static readonly CAP_ALL: number;
  113321. /**
  113322. * Mesh pattern setting : no flip or rotate
  113323. */
  113324. static readonly NO_FLIP: number;
  113325. /**
  113326. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  113327. */
  113328. static readonly FLIP_TILE: number;
  113329. /**
  113330. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  113331. */
  113332. static readonly ROTATE_TILE: number;
  113333. /**
  113334. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  113335. */
  113336. static readonly FLIP_ROW: number;
  113337. /**
  113338. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  113339. */
  113340. static readonly ROTATE_ROW: number;
  113341. /**
  113342. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  113343. */
  113344. static readonly FLIP_N_ROTATE_TILE: number;
  113345. /**
  113346. * Mesh pattern setting : rotate pattern and rotate
  113347. */
  113348. static readonly FLIP_N_ROTATE_ROW: number;
  113349. /**
  113350. * Mesh tile positioning : part tiles same on left/right or top/bottom
  113351. */
  113352. static readonly CENTER: number;
  113353. /**
  113354. * Mesh tile positioning : part tiles on left
  113355. */
  113356. static readonly LEFT: number;
  113357. /**
  113358. * Mesh tile positioning : part tiles on right
  113359. */
  113360. static readonly RIGHT: number;
  113361. /**
  113362. * Mesh tile positioning : part tiles on top
  113363. */
  113364. static readonly TOP: number;
  113365. /**
  113366. * Mesh tile positioning : part tiles on bottom
  113367. */
  113368. static readonly BOTTOM: number;
  113369. /**
  113370. * Gets the default side orientation.
  113371. * @param orientation the orientation to value to attempt to get
  113372. * @returns the default orientation
  113373. * @hidden
  113374. */
  113375. static _GetDefaultSideOrientation(orientation?: number): number;
  113376. private _internalMeshDataInfo;
  113377. get computeBonesUsingShaders(): boolean;
  113378. set computeBonesUsingShaders(value: boolean);
  113379. /**
  113380. * An event triggered before rendering the mesh
  113381. */
  113382. get onBeforeRenderObservable(): Observable<Mesh>;
  113383. /**
  113384. * An event triggered before binding the mesh
  113385. */
  113386. get onBeforeBindObservable(): Observable<Mesh>;
  113387. /**
  113388. * An event triggered after rendering the mesh
  113389. */
  113390. get onAfterRenderObservable(): Observable<Mesh>;
  113391. /**
  113392. * An event triggered before drawing the mesh
  113393. */
  113394. get onBeforeDrawObservable(): Observable<Mesh>;
  113395. private _onBeforeDrawObserver;
  113396. /**
  113397. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  113398. */
  113399. set onBeforeDraw(callback: () => void);
  113400. get hasInstances(): boolean;
  113401. get hasThinInstances(): boolean;
  113402. /**
  113403. * Gets the delay loading state of the mesh (when delay loading is turned on)
  113404. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  113405. */
  113406. delayLoadState: number;
  113407. /**
  113408. * Gets the list of instances created from this mesh
  113409. * it is not supposed to be modified manually.
  113410. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  113411. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113412. */
  113413. instances: InstancedMesh[];
  113414. /**
  113415. * Gets the file containing delay loading data for this mesh
  113416. */
  113417. delayLoadingFile: string;
  113418. /** @hidden */
  113419. _binaryInfo: any;
  113420. /**
  113421. * User defined function used to change how LOD level selection is done
  113422. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113423. */
  113424. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  113425. /**
  113426. * Gets or sets the morph target manager
  113427. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  113428. */
  113429. get morphTargetManager(): Nullable<MorphTargetManager>;
  113430. set morphTargetManager(value: Nullable<MorphTargetManager>);
  113431. /** @hidden */
  113432. _creationDataStorage: Nullable<_CreationDataStorage>;
  113433. /** @hidden */
  113434. _geometry: Nullable<Geometry>;
  113435. /** @hidden */
  113436. _delayInfo: Array<string>;
  113437. /** @hidden */
  113438. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  113439. /** @hidden */
  113440. _instanceDataStorage: _InstanceDataStorage;
  113441. /** @hidden */
  113442. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  113443. private _effectiveMaterial;
  113444. /** @hidden */
  113445. _shouldGenerateFlatShading: boolean;
  113446. /** @hidden */
  113447. _originalBuilderSideOrientation: number;
  113448. /**
  113449. * Use this property to change the original side orientation defined at construction time
  113450. */
  113451. overrideMaterialSideOrientation: Nullable<number>;
  113452. /**
  113453. * Gets the source mesh (the one used to clone this one from)
  113454. */
  113455. get source(): Nullable<Mesh>;
  113456. /**
  113457. * Gets the list of clones of this mesh
  113458. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  113459. * Note that useClonedMeshMap=true is the default setting
  113460. */
  113461. get cloneMeshMap(): Nullable<{
  113462. [id: string]: Mesh | undefined;
  113463. }>;
  113464. /**
  113465. * Gets or sets a boolean indicating that this mesh does not use index buffer
  113466. */
  113467. get isUnIndexed(): boolean;
  113468. set isUnIndexed(value: boolean);
  113469. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  113470. get worldMatrixInstancedBuffer(): Float32Array;
  113471. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  113472. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  113473. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  113474. /**
  113475. * @constructor
  113476. * @param name The value used by scene.getMeshByName() to do a lookup.
  113477. * @param scene The scene to add this mesh to.
  113478. * @param parent The parent of this mesh, if it has one
  113479. * @param source An optional Mesh from which geometry is shared, cloned.
  113480. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  113481. * When false, achieved by calling a clone(), also passing False.
  113482. * This will make creation of children, recursive.
  113483. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  113484. */
  113485. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  113486. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  113487. doNotInstantiate: boolean;
  113488. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  113489. /**
  113490. * Gets the class name
  113491. * @returns the string "Mesh".
  113492. */
  113493. getClassName(): string;
  113494. /** @hidden */
  113495. get _isMesh(): boolean;
  113496. /**
  113497. * Returns a description of this mesh
  113498. * @param fullDetails define if full details about this mesh must be used
  113499. * @returns a descriptive string representing this mesh
  113500. */
  113501. toString(fullDetails?: boolean): string;
  113502. /** @hidden */
  113503. _unBindEffect(): void;
  113504. /**
  113505. * Gets a boolean indicating if this mesh has LOD
  113506. */
  113507. get hasLODLevels(): boolean;
  113508. /**
  113509. * Gets the list of MeshLODLevel associated with the current mesh
  113510. * @returns an array of MeshLODLevel
  113511. */
  113512. getLODLevels(): MeshLODLevel[];
  113513. private _sortLODLevels;
  113514. /**
  113515. * Add a mesh as LOD level triggered at the given distance.
  113516. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113517. * @param distance The distance from the center of the object to show this level
  113518. * @param mesh The mesh to be added as LOD level (can be null)
  113519. * @return This mesh (for chaining)
  113520. */
  113521. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  113522. /**
  113523. * Returns the LOD level mesh at the passed distance or null if not found.
  113524. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113525. * @param distance The distance from the center of the object to show this level
  113526. * @returns a Mesh or `null`
  113527. */
  113528. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  113529. /**
  113530. * Remove a mesh from the LOD array
  113531. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113532. * @param mesh defines the mesh to be removed
  113533. * @return This mesh (for chaining)
  113534. */
  113535. removeLODLevel(mesh: Mesh): Mesh;
  113536. /**
  113537. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  113538. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113539. * @param camera defines the camera to use to compute distance
  113540. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  113541. * @return This mesh (for chaining)
  113542. */
  113543. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  113544. /**
  113545. * Gets the mesh internal Geometry object
  113546. */
  113547. get geometry(): Nullable<Geometry>;
  113548. /**
  113549. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  113550. * @returns the total number of vertices
  113551. */
  113552. getTotalVertices(): number;
  113553. /**
  113554. * Returns the content of an associated vertex buffer
  113555. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113556. * - VertexBuffer.PositionKind
  113557. * - VertexBuffer.UVKind
  113558. * - VertexBuffer.UV2Kind
  113559. * - VertexBuffer.UV3Kind
  113560. * - VertexBuffer.UV4Kind
  113561. * - VertexBuffer.UV5Kind
  113562. * - VertexBuffer.UV6Kind
  113563. * - VertexBuffer.ColorKind
  113564. * - VertexBuffer.MatricesIndicesKind
  113565. * - VertexBuffer.MatricesIndicesExtraKind
  113566. * - VertexBuffer.MatricesWeightsKind
  113567. * - VertexBuffer.MatricesWeightsExtraKind
  113568. * @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
  113569. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  113570. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  113571. */
  113572. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  113573. /**
  113574. * Returns the mesh VertexBuffer object from the requested `kind`
  113575. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113576. * - VertexBuffer.PositionKind
  113577. * - VertexBuffer.NormalKind
  113578. * - VertexBuffer.UVKind
  113579. * - VertexBuffer.UV2Kind
  113580. * - VertexBuffer.UV3Kind
  113581. * - VertexBuffer.UV4Kind
  113582. * - VertexBuffer.UV5Kind
  113583. * - VertexBuffer.UV6Kind
  113584. * - VertexBuffer.ColorKind
  113585. * - VertexBuffer.MatricesIndicesKind
  113586. * - VertexBuffer.MatricesIndicesExtraKind
  113587. * - VertexBuffer.MatricesWeightsKind
  113588. * - VertexBuffer.MatricesWeightsExtraKind
  113589. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  113590. */
  113591. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  113592. /**
  113593. * Tests if a specific vertex buffer is associated with this mesh
  113594. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113595. * - VertexBuffer.PositionKind
  113596. * - VertexBuffer.NormalKind
  113597. * - VertexBuffer.UVKind
  113598. * - VertexBuffer.UV2Kind
  113599. * - VertexBuffer.UV3Kind
  113600. * - VertexBuffer.UV4Kind
  113601. * - VertexBuffer.UV5Kind
  113602. * - VertexBuffer.UV6Kind
  113603. * - VertexBuffer.ColorKind
  113604. * - VertexBuffer.MatricesIndicesKind
  113605. * - VertexBuffer.MatricesIndicesExtraKind
  113606. * - VertexBuffer.MatricesWeightsKind
  113607. * - VertexBuffer.MatricesWeightsExtraKind
  113608. * @returns a boolean
  113609. */
  113610. isVerticesDataPresent(kind: string): boolean;
  113611. /**
  113612. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  113613. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113614. * - VertexBuffer.PositionKind
  113615. * - VertexBuffer.UVKind
  113616. * - VertexBuffer.UV2Kind
  113617. * - VertexBuffer.UV3Kind
  113618. * - VertexBuffer.UV4Kind
  113619. * - VertexBuffer.UV5Kind
  113620. * - VertexBuffer.UV6Kind
  113621. * - VertexBuffer.ColorKind
  113622. * - VertexBuffer.MatricesIndicesKind
  113623. * - VertexBuffer.MatricesIndicesExtraKind
  113624. * - VertexBuffer.MatricesWeightsKind
  113625. * - VertexBuffer.MatricesWeightsExtraKind
  113626. * @returns a boolean
  113627. */
  113628. isVertexBufferUpdatable(kind: string): boolean;
  113629. /**
  113630. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  113631. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113632. * - VertexBuffer.PositionKind
  113633. * - VertexBuffer.NormalKind
  113634. * - VertexBuffer.UVKind
  113635. * - VertexBuffer.UV2Kind
  113636. * - VertexBuffer.UV3Kind
  113637. * - VertexBuffer.UV4Kind
  113638. * - VertexBuffer.UV5Kind
  113639. * - VertexBuffer.UV6Kind
  113640. * - VertexBuffer.ColorKind
  113641. * - VertexBuffer.MatricesIndicesKind
  113642. * - VertexBuffer.MatricesIndicesExtraKind
  113643. * - VertexBuffer.MatricesWeightsKind
  113644. * - VertexBuffer.MatricesWeightsExtraKind
  113645. * @returns an array of strings
  113646. */
  113647. getVerticesDataKinds(): string[];
  113648. /**
  113649. * Returns a positive integer : the total number of indices in this mesh geometry.
  113650. * @returns the numner of indices or zero if the mesh has no geometry.
  113651. */
  113652. getTotalIndices(): number;
  113653. /**
  113654. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  113655. * @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.
  113656. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  113657. * @returns the indices array or an empty array if the mesh has no geometry
  113658. */
  113659. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  113660. get isBlocked(): boolean;
  113661. /**
  113662. * Determine if the current mesh is ready to be rendered
  113663. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113664. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  113665. * @returns true if all associated assets are ready (material, textures, shaders)
  113666. */
  113667. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  113668. /**
  113669. * 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.
  113670. */
  113671. get areNormalsFrozen(): boolean;
  113672. /**
  113673. * 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.
  113674. * @returns the current mesh
  113675. */
  113676. freezeNormals(): Mesh;
  113677. /**
  113678. * 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
  113679. * @returns the current mesh
  113680. */
  113681. unfreezeNormals(): Mesh;
  113682. /**
  113683. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  113684. */
  113685. set overridenInstanceCount(count: number);
  113686. /** @hidden */
  113687. _preActivate(): Mesh;
  113688. /** @hidden */
  113689. _preActivateForIntermediateRendering(renderId: number): Mesh;
  113690. /** @hidden */
  113691. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  113692. protected _afterComputeWorldMatrix(): void;
  113693. /** @hidden */
  113694. _postActivate(): void;
  113695. /**
  113696. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  113697. * This means the mesh underlying bounding box and sphere are recomputed.
  113698. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  113699. * @returns the current mesh
  113700. */
  113701. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  113702. /** @hidden */
  113703. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  113704. /**
  113705. * This function will subdivide the mesh into multiple submeshes
  113706. * @param count defines the expected number of submeshes
  113707. */
  113708. subdivide(count: number): void;
  113709. /**
  113710. * Copy a FloatArray into a specific associated vertex buffer
  113711. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  113712. * - VertexBuffer.PositionKind
  113713. * - VertexBuffer.UVKind
  113714. * - VertexBuffer.UV2Kind
  113715. * - VertexBuffer.UV3Kind
  113716. * - VertexBuffer.UV4Kind
  113717. * - VertexBuffer.UV5Kind
  113718. * - VertexBuffer.UV6Kind
  113719. * - VertexBuffer.ColorKind
  113720. * - VertexBuffer.MatricesIndicesKind
  113721. * - VertexBuffer.MatricesIndicesExtraKind
  113722. * - VertexBuffer.MatricesWeightsKind
  113723. * - VertexBuffer.MatricesWeightsExtraKind
  113724. * @param data defines the data source
  113725. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  113726. * @param stride defines the data stride size (can be null)
  113727. * @returns the current mesh
  113728. */
  113729. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  113730. /**
  113731. * Delete a vertex buffer associated with this mesh
  113732. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  113733. * - VertexBuffer.PositionKind
  113734. * - VertexBuffer.UVKind
  113735. * - VertexBuffer.UV2Kind
  113736. * - VertexBuffer.UV3Kind
  113737. * - VertexBuffer.UV4Kind
  113738. * - VertexBuffer.UV5Kind
  113739. * - VertexBuffer.UV6Kind
  113740. * - VertexBuffer.ColorKind
  113741. * - VertexBuffer.MatricesIndicesKind
  113742. * - VertexBuffer.MatricesIndicesExtraKind
  113743. * - VertexBuffer.MatricesWeightsKind
  113744. * - VertexBuffer.MatricesWeightsExtraKind
  113745. */
  113746. removeVerticesData(kind: string): void;
  113747. /**
  113748. * Flags an associated vertex buffer as updatable
  113749. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  113750. * - VertexBuffer.PositionKind
  113751. * - VertexBuffer.UVKind
  113752. * - VertexBuffer.UV2Kind
  113753. * - VertexBuffer.UV3Kind
  113754. * - VertexBuffer.UV4Kind
  113755. * - VertexBuffer.UV5Kind
  113756. * - VertexBuffer.UV6Kind
  113757. * - VertexBuffer.ColorKind
  113758. * - VertexBuffer.MatricesIndicesKind
  113759. * - VertexBuffer.MatricesIndicesExtraKind
  113760. * - VertexBuffer.MatricesWeightsKind
  113761. * - VertexBuffer.MatricesWeightsExtraKind
  113762. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  113763. */
  113764. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  113765. /**
  113766. * Sets the mesh global Vertex Buffer
  113767. * @param buffer defines the buffer to use
  113768. * @returns the current mesh
  113769. */
  113770. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  113771. /**
  113772. * Update a specific associated vertex buffer
  113773. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  113774. * - VertexBuffer.PositionKind
  113775. * - VertexBuffer.UVKind
  113776. * - VertexBuffer.UV2Kind
  113777. * - VertexBuffer.UV3Kind
  113778. * - VertexBuffer.UV4Kind
  113779. * - VertexBuffer.UV5Kind
  113780. * - VertexBuffer.UV6Kind
  113781. * - VertexBuffer.ColorKind
  113782. * - VertexBuffer.MatricesIndicesKind
  113783. * - VertexBuffer.MatricesIndicesExtraKind
  113784. * - VertexBuffer.MatricesWeightsKind
  113785. * - VertexBuffer.MatricesWeightsExtraKind
  113786. * @param data defines the data source
  113787. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  113788. * @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)
  113789. * @returns the current mesh
  113790. */
  113791. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  113792. /**
  113793. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  113794. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  113795. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  113796. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  113797. * @returns the current mesh
  113798. */
  113799. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  113800. /**
  113801. * Creates a un-shared specific occurence of the geometry for the mesh.
  113802. * @returns the current mesh
  113803. */
  113804. makeGeometryUnique(): Mesh;
  113805. /**
  113806. * Set the index buffer of this mesh
  113807. * @param indices defines the source data
  113808. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  113809. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  113810. * @returns the current mesh
  113811. */
  113812. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  113813. /**
  113814. * Update the current index buffer
  113815. * @param indices defines the source data
  113816. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  113817. * @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)
  113818. * @returns the current mesh
  113819. */
  113820. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  113821. /**
  113822. * Invert the geometry to move from a right handed system to a left handed one.
  113823. * @returns the current mesh
  113824. */
  113825. toLeftHanded(): Mesh;
  113826. /** @hidden */
  113827. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  113828. /** @hidden */
  113829. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  113830. /**
  113831. * Registers for this mesh a javascript function called just before the rendering process
  113832. * @param func defines the function to call before rendering this mesh
  113833. * @returns the current mesh
  113834. */
  113835. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  113836. /**
  113837. * Disposes a previously registered javascript function called before the rendering
  113838. * @param func defines the function to remove
  113839. * @returns the current mesh
  113840. */
  113841. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  113842. /**
  113843. * Registers for this mesh a javascript function called just after the rendering is complete
  113844. * @param func defines the function to call after rendering this mesh
  113845. * @returns the current mesh
  113846. */
  113847. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  113848. /**
  113849. * Disposes a previously registered javascript function called after the rendering.
  113850. * @param func defines the function to remove
  113851. * @returns the current mesh
  113852. */
  113853. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  113854. /** @hidden */
  113855. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  113856. /** @hidden */
  113857. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  113858. /** @hidden */
  113859. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  113860. /** @hidden */
  113861. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  113862. /** @hidden */
  113863. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  113864. /** @hidden */
  113865. _rebuild(): void;
  113866. /** @hidden */
  113867. _freeze(): void;
  113868. /** @hidden */
  113869. _unFreeze(): void;
  113870. /**
  113871. * 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
  113872. * @param subMesh defines the subMesh to render
  113873. * @param enableAlphaMode defines if alpha mode can be changed
  113874. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  113875. * @returns the current mesh
  113876. */
  113877. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  113878. private _onBeforeDraw;
  113879. /**
  113880. * Renormalize the mesh and patch it up if there are no weights
  113881. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  113882. * However in the case of zero weights then we set just a single influence to 1.
  113883. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  113884. */
  113885. cleanMatrixWeights(): void;
  113886. private normalizeSkinFourWeights;
  113887. private normalizeSkinWeightsAndExtra;
  113888. /**
  113889. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  113890. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  113891. * the user know there was an issue with importing the mesh
  113892. * @returns a validation object with skinned, valid and report string
  113893. */
  113894. validateSkinning(): {
  113895. skinned: boolean;
  113896. valid: boolean;
  113897. report: string;
  113898. };
  113899. /** @hidden */
  113900. _checkDelayState(): Mesh;
  113901. private _queueLoad;
  113902. /**
  113903. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  113904. * A mesh is in the frustum if its bounding box intersects the frustum
  113905. * @param frustumPlanes defines the frustum to test
  113906. * @returns true if the mesh is in the frustum planes
  113907. */
  113908. isInFrustum(frustumPlanes: Plane[]): boolean;
  113909. /**
  113910. * Sets the mesh material by the material or multiMaterial `id` property
  113911. * @param id is a string identifying the material or the multiMaterial
  113912. * @returns the current mesh
  113913. */
  113914. setMaterialByID(id: string): Mesh;
  113915. /**
  113916. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  113917. * @returns an array of IAnimatable
  113918. */
  113919. getAnimatables(): IAnimatable[];
  113920. /**
  113921. * Modifies the mesh geometry according to the passed transformation matrix.
  113922. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  113923. * The mesh normals are modified using the same transformation.
  113924. * Note that, under the hood, this method sets a new VertexBuffer each call.
  113925. * @param transform defines the transform matrix to use
  113926. * @see https://doc.babylonjs.com/resources/baking_transformations
  113927. * @returns the current mesh
  113928. */
  113929. bakeTransformIntoVertices(transform: Matrix): Mesh;
  113930. /**
  113931. * Modifies the mesh geometry according to its own current World Matrix.
  113932. * The mesh World Matrix is then reset.
  113933. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  113934. * Note that, under the hood, this method sets a new VertexBuffer each call.
  113935. * @see https://doc.babylonjs.com/resources/baking_transformations
  113936. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  113937. * @returns the current mesh
  113938. */
  113939. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  113940. /** @hidden */
  113941. get _positions(): Nullable<Vector3[]>;
  113942. /** @hidden */
  113943. _resetPointsArrayCache(): Mesh;
  113944. /** @hidden */
  113945. _generatePointsArray(): boolean;
  113946. /**
  113947. * Returns a new Mesh object generated from the current mesh properties.
  113948. * This method must not get confused with createInstance()
  113949. * @param name is a string, the name given to the new mesh
  113950. * @param newParent can be any Node object (default `null`)
  113951. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  113952. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  113953. * @returns a new mesh
  113954. */
  113955. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  113956. /**
  113957. * Releases resources associated with this mesh.
  113958. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113959. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113960. */
  113961. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113962. /** @hidden */
  113963. _disposeInstanceSpecificData(): void;
  113964. /** @hidden */
  113965. _disposeThinInstanceSpecificData(): void;
  113966. /**
  113967. * Modifies the mesh geometry according to a displacement map.
  113968. * 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.
  113969. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  113970. * @param url is a string, the URL from the image file is to be downloaded.
  113971. * @param minHeight is the lower limit of the displacement.
  113972. * @param maxHeight is the upper limit of the displacement.
  113973. * @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.
  113974. * @param uvOffset is an optional vector2 used to offset UV.
  113975. * @param uvScale is an optional vector2 used to scale UV.
  113976. * @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.
  113977. * @returns the Mesh.
  113978. */
  113979. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  113980. /**
  113981. * Modifies the mesh geometry according to a displacementMap buffer.
  113982. * 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.
  113983. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  113984. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  113985. * @param heightMapWidth is the width of the buffer image.
  113986. * @param heightMapHeight is the height of the buffer image.
  113987. * @param minHeight is the lower limit of the displacement.
  113988. * @param maxHeight is the upper limit of the displacement.
  113989. * @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.
  113990. * @param uvOffset is an optional vector2 used to offset UV.
  113991. * @param uvScale is an optional vector2 used to scale UV.
  113992. * @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.
  113993. * @returns the Mesh.
  113994. */
  113995. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  113996. /**
  113997. * Modify the mesh to get a flat shading rendering.
  113998. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  113999. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  114000. * @returns current mesh
  114001. */
  114002. convertToFlatShadedMesh(): Mesh;
  114003. /**
  114004. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  114005. * In other words, more vertices, no more indices and a single bigger VBO.
  114006. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  114007. * @returns current mesh
  114008. */
  114009. convertToUnIndexedMesh(): Mesh;
  114010. /**
  114011. * Inverses facet orientations.
  114012. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114013. * @param flipNormals will also inverts the normals
  114014. * @returns current mesh
  114015. */
  114016. flipFaces(flipNormals?: boolean): Mesh;
  114017. /**
  114018. * Increase the number of facets and hence vertices in a mesh
  114019. * Vertex normals are interpolated from existing vertex normals
  114020. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114021. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  114022. */
  114023. increaseVertices(numberPerEdge: number): void;
  114024. /**
  114025. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  114026. * This will undo any application of covertToFlatShadedMesh
  114027. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114028. */
  114029. forceSharedVertices(): void;
  114030. /** @hidden */
  114031. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  114032. /** @hidden */
  114033. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  114034. /**
  114035. * Creates a new InstancedMesh object from the mesh model.
  114036. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114037. * @param name defines the name of the new instance
  114038. * @returns a new InstancedMesh
  114039. */
  114040. createInstance(name: string): InstancedMesh;
  114041. /**
  114042. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  114043. * After this call, all the mesh instances have the same submeshes than the current mesh.
  114044. * @returns the current mesh
  114045. */
  114046. synchronizeInstances(): Mesh;
  114047. /**
  114048. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  114049. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  114050. * This should be used together with the simplification to avoid disappearing triangles.
  114051. * @param successCallback an optional success callback to be called after the optimization finished.
  114052. * @returns the current mesh
  114053. */
  114054. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  114055. /**
  114056. * Serialize current mesh
  114057. * @param serializationObject defines the object which will receive the serialization data
  114058. */
  114059. serialize(serializationObject: any): void;
  114060. /** @hidden */
  114061. _syncGeometryWithMorphTargetManager(): void;
  114062. /** @hidden */
  114063. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  114064. /**
  114065. * Returns a new Mesh object parsed from the source provided.
  114066. * @param parsedMesh is the source
  114067. * @param scene defines the hosting scene
  114068. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  114069. * @returns a new Mesh
  114070. */
  114071. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  114072. /**
  114073. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  114074. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114075. * @param name defines the name of the mesh to create
  114076. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  114077. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  114078. * @param closePath creates a seam between the first and the last points of each path of the path array
  114079. * @param offset is taken in account only if the `pathArray` is containing a single path
  114080. * @param scene defines the hosting scene
  114081. * @param updatable defines if the mesh must be flagged as updatable
  114082. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114083. * @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)
  114084. * @returns a new Mesh
  114085. */
  114086. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114087. /**
  114088. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  114089. * @param name defines the name of the mesh to create
  114090. * @param radius sets the radius size (float) of the polygon (default 0.5)
  114091. * @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
  114092. * @param scene defines the hosting scene
  114093. * @param updatable defines if the mesh must be flagged as updatable
  114094. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114095. * @returns a new Mesh
  114096. */
  114097. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114098. /**
  114099. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  114100. * @param name defines the name of the mesh to create
  114101. * @param size sets the size (float) of each box side (default 1)
  114102. * @param scene defines the hosting scene
  114103. * @param updatable defines if the mesh must be flagged as updatable
  114104. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114105. * @returns a new Mesh
  114106. */
  114107. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114108. /**
  114109. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  114110. * @param name defines the name of the mesh to create
  114111. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114112. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114113. * @param scene defines the hosting scene
  114114. * @param updatable defines if the mesh must be flagged as updatable
  114115. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114116. * @returns a new Mesh
  114117. */
  114118. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114119. /**
  114120. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  114121. * @param name defines the name of the mesh to create
  114122. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114123. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114124. * @param scene defines the hosting scene
  114125. * @returns a new Mesh
  114126. */
  114127. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  114128. /**
  114129. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  114130. * @param name defines the name of the mesh to create
  114131. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  114132. * @param diameterTop set the top cap diameter (floats, default 1)
  114133. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  114134. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  114135. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  114136. * @param scene defines the hosting scene
  114137. * @param updatable defines if the mesh must be flagged as updatable
  114138. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114139. * @returns a new Mesh
  114140. */
  114141. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  114142. /**
  114143. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  114144. * @param name defines the name of the mesh to create
  114145. * @param diameter sets the diameter size (float) of the torus (default 1)
  114146. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  114147. * @param tessellation sets the number of torus sides (postive integer, default 16)
  114148. * @param scene defines the hosting scene
  114149. * @param updatable defines if the mesh must be flagged as updatable
  114150. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114151. * @returns a new Mesh
  114152. */
  114153. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114154. /**
  114155. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  114156. * @param name defines the name of the mesh to create
  114157. * @param radius sets the global radius size (float) of the torus knot (default 2)
  114158. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  114159. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  114160. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  114161. * @param p the number of windings on X axis (positive integers, default 2)
  114162. * @param q the number of windings on Y axis (positive integers, default 3)
  114163. * @param scene defines the hosting scene
  114164. * @param updatable defines if the mesh must be flagged as updatable
  114165. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114166. * @returns a new Mesh
  114167. */
  114168. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114169. /**
  114170. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  114171. * @param name defines the name of the mesh to create
  114172. * @param points is an array successive Vector3
  114173. * @param scene defines the hosting scene
  114174. * @param updatable defines if the mesh must be flagged as updatable
  114175. * @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).
  114176. * @returns a new Mesh
  114177. */
  114178. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  114179. /**
  114180. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  114181. * @param name defines the name of the mesh to create
  114182. * @param points is an array successive Vector3
  114183. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  114184. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  114185. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  114186. * @param scene defines the hosting scene
  114187. * @param updatable defines if the mesh must be flagged as updatable
  114188. * @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)
  114189. * @returns a new Mesh
  114190. */
  114191. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  114192. /**
  114193. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  114194. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  114195. * 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.
  114196. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114197. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114198. * Remember you can only change the shape positions, not their number when updating a polygon.
  114199. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114200. * @param name defines the name of the mesh to create
  114201. * @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
  114202. * @param scene defines the hosting scene
  114203. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114204. * @param updatable defines if the mesh must be flagged as updatable
  114205. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114206. * @param earcutInjection can be used to inject your own earcut reference
  114207. * @returns a new Mesh
  114208. */
  114209. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114210. /**
  114211. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  114212. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  114213. * @param name defines the name of the mesh to create
  114214. * @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
  114215. * @param depth defines the height of extrusion
  114216. * @param scene defines the hosting scene
  114217. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114218. * @param updatable defines if the mesh must be flagged as updatable
  114219. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114220. * @param earcutInjection can be used to inject your own earcut reference
  114221. * @returns a new Mesh
  114222. */
  114223. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114224. /**
  114225. * Creates an extruded shape mesh.
  114226. * 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
  114227. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114228. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114229. * @param name defines the name of the mesh to create
  114230. * @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
  114231. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114232. * @param scale is the value to scale the shape
  114233. * @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
  114234. * @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
  114235. * @param scene defines the hosting scene
  114236. * @param updatable defines if the mesh must be flagged as updatable
  114237. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114238. * @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)
  114239. * @returns a new Mesh
  114240. */
  114241. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114242. /**
  114243. * Creates an custom extruded shape mesh.
  114244. * The custom extrusion is a parametric shape.
  114245. * It has no predefined shape. Its final shape will depend on the input parameters.
  114246. * Please consider using the same method from the MeshBuilder class instead
  114247. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114248. * @param name defines the name of the mesh to create
  114249. * @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
  114250. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114251. * @param scaleFunction is a custom Javascript function called on each path point
  114252. * @param rotationFunction is a custom Javascript function called on each path point
  114253. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114254. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  114255. * @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
  114256. * @param scene defines the hosting scene
  114257. * @param updatable defines if the mesh must be flagged as updatable
  114258. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114259. * @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)
  114260. * @returns a new Mesh
  114261. */
  114262. 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;
  114263. /**
  114264. * Creates lathe mesh.
  114265. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  114266. * Please consider using the same method from the MeshBuilder class instead
  114267. * @param name defines the name of the mesh to create
  114268. * @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
  114269. * @param radius is the radius value of the lathe
  114270. * @param tessellation is the side number of the lathe.
  114271. * @param scene defines the hosting scene
  114272. * @param updatable defines if the mesh must be flagged as updatable
  114273. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114274. * @returns a new Mesh
  114275. */
  114276. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114277. /**
  114278. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  114279. * @param name defines the name of the mesh to create
  114280. * @param size sets the size (float) of both sides of the plane at once (default 1)
  114281. * @param scene defines the hosting scene
  114282. * @param updatable defines if the mesh must be flagged as updatable
  114283. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114284. * @returns a new Mesh
  114285. */
  114286. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114287. /**
  114288. * Creates a ground mesh.
  114289. * Please consider using the same method from the MeshBuilder class instead
  114290. * @param name defines the name of the mesh to create
  114291. * @param width set the width of the ground
  114292. * @param height set the height of the ground
  114293. * @param subdivisions sets the number of subdivisions per side
  114294. * @param scene defines the hosting scene
  114295. * @param updatable defines if the mesh must be flagged as updatable
  114296. * @returns a new Mesh
  114297. */
  114298. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  114299. /**
  114300. * Creates a tiled ground mesh.
  114301. * Please consider using the same method from the MeshBuilder class instead
  114302. * @param name defines the name of the mesh to create
  114303. * @param xmin set the ground minimum X coordinate
  114304. * @param zmin set the ground minimum Y coordinate
  114305. * @param xmax set the ground maximum X coordinate
  114306. * @param zmax set the ground maximum Z coordinate
  114307. * @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
  114308. * @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
  114309. * @param scene defines the hosting scene
  114310. * @param updatable defines if the mesh must be flagged as updatable
  114311. * @returns a new Mesh
  114312. */
  114313. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  114314. w: number;
  114315. h: number;
  114316. }, precision: {
  114317. w: number;
  114318. h: number;
  114319. }, scene: Scene, updatable?: boolean): Mesh;
  114320. /**
  114321. * Creates a ground mesh from a height map.
  114322. * Please consider using the same method from the MeshBuilder class instead
  114323. * @see https://doc.babylonjs.com/babylon101/height_map
  114324. * @param name defines the name of the mesh to create
  114325. * @param url sets the URL of the height map image resource
  114326. * @param width set the ground width size
  114327. * @param height set the ground height size
  114328. * @param subdivisions sets the number of subdivision per side
  114329. * @param minHeight is the minimum altitude on the ground
  114330. * @param maxHeight is the maximum altitude on the ground
  114331. * @param scene defines the hosting scene
  114332. * @param updatable defines if the mesh must be flagged as updatable
  114333. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  114334. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114335. * @returns a new Mesh
  114336. */
  114337. 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;
  114338. /**
  114339. * Creates a tube mesh.
  114340. * The tube is a parametric shape.
  114341. * It has no predefined shape. Its final shape will depend on the input parameters.
  114342. * Please consider using the same method from the MeshBuilder class instead
  114343. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114344. * @param name defines the name of the mesh to create
  114345. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  114346. * @param radius sets the tube radius size
  114347. * @param tessellation is the number of sides on the tubular surface
  114348. * @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
  114349. * @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
  114350. * @param scene defines the hosting scene
  114351. * @param updatable defines if the mesh must be flagged as updatable
  114352. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114353. * @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)
  114354. * @returns a new Mesh
  114355. */
  114356. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  114357. (i: number, distance: number): number;
  114358. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114359. /**
  114360. * Creates a polyhedron mesh.
  114361. * Please consider using the same method from the MeshBuilder class instead.
  114362. * * 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
  114363. * * The parameter `size` (positive float, default 1) sets the polygon size
  114364. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114365. * * 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`
  114366. * * 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
  114367. * * 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)`)
  114368. * * 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
  114369. * * 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
  114370. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114373. * @param name defines the name of the mesh to create
  114374. * @param options defines the options used to create the mesh
  114375. * @param scene defines the hosting scene
  114376. * @returns a new Mesh
  114377. */
  114378. static CreatePolyhedron(name: string, options: {
  114379. type?: number;
  114380. size?: number;
  114381. sizeX?: number;
  114382. sizeY?: number;
  114383. sizeZ?: number;
  114384. custom?: any;
  114385. faceUV?: Vector4[];
  114386. faceColors?: Color4[];
  114387. updatable?: boolean;
  114388. sideOrientation?: number;
  114389. }, scene: Scene): Mesh;
  114390. /**
  114391. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114392. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114393. * * 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`)
  114394. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114395. * * 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
  114396. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114397. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114399. * @param name defines the name of the mesh
  114400. * @param options defines the options used to create the mesh
  114401. * @param scene defines the hosting scene
  114402. * @returns a new Mesh
  114403. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114404. */
  114405. static CreateIcoSphere(name: string, options: {
  114406. radius?: number;
  114407. flat?: boolean;
  114408. subdivisions?: number;
  114409. sideOrientation?: number;
  114410. updatable?: boolean;
  114411. }, scene: Scene): Mesh;
  114412. /**
  114413. * Creates a decal mesh.
  114414. * Please consider using the same method from the MeshBuilder class instead.
  114415. * A decal is a mesh usually applied as a model onto the surface of another mesh
  114416. * @param name defines the name of the mesh
  114417. * @param sourceMesh defines the mesh receiving the decal
  114418. * @param position sets the position of the decal in world coordinates
  114419. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  114420. * @param size sets the decal scaling
  114421. * @param angle sets the angle to rotate the decal
  114422. * @returns a new Mesh
  114423. */
  114424. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  114425. /** Creates a Capsule Mesh
  114426. * @param name defines the name of the mesh.
  114427. * @param options the constructors options used to shape the mesh.
  114428. * @param scene defines the scene the mesh is scoped to.
  114429. * @returns the capsule mesh
  114430. * @see https://doc.babylonjs.com/how_to/capsule_shape
  114431. */
  114432. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  114433. /**
  114434. * Prepare internal position array for software CPU skinning
  114435. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  114436. */
  114437. setPositionsForCPUSkinning(): Float32Array;
  114438. /**
  114439. * Prepare internal normal array for software CPU skinning
  114440. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  114441. */
  114442. setNormalsForCPUSkinning(): Float32Array;
  114443. /**
  114444. * Updates the vertex buffer by applying transformation from the bones
  114445. * @param skeleton defines the skeleton to apply to current mesh
  114446. * @returns the current mesh
  114447. */
  114448. applySkeleton(skeleton: Skeleton): Mesh;
  114449. /**
  114450. * 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
  114451. * @param meshes defines the list of meshes to scan
  114452. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  114453. */
  114454. static MinMax(meshes: AbstractMesh[]): {
  114455. min: Vector3;
  114456. max: Vector3;
  114457. };
  114458. /**
  114459. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  114460. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  114461. * @returns a vector3
  114462. */
  114463. static Center(meshesOrMinMaxVector: {
  114464. min: Vector3;
  114465. max: Vector3;
  114466. } | AbstractMesh[]): Vector3;
  114467. /**
  114468. * Merge the array of meshes into a single mesh for performance reasons.
  114469. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  114470. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  114471. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  114472. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  114473. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  114474. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  114475. * @returns a new mesh
  114476. */
  114477. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  114478. /** @hidden */
  114479. addInstance(instance: InstancedMesh): void;
  114480. /** @hidden */
  114481. removeInstance(instance: InstancedMesh): void;
  114482. }
  114483. }
  114484. declare module BABYLON {
  114485. /**
  114486. * This is the base class of all the camera used in the application.
  114487. * @see https://doc.babylonjs.com/features/cameras
  114488. */
  114489. export class Camera extends Node {
  114490. /** @hidden */
  114491. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  114492. /**
  114493. * This is the default projection mode used by the cameras.
  114494. * It helps recreating a feeling of perspective and better appreciate depth.
  114495. * This is the best way to simulate real life cameras.
  114496. */
  114497. static readonly PERSPECTIVE_CAMERA: number;
  114498. /**
  114499. * This helps creating camera with an orthographic mode.
  114500. * 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.
  114501. */
  114502. static readonly ORTHOGRAPHIC_CAMERA: number;
  114503. /**
  114504. * This is the default FOV mode for perspective cameras.
  114505. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  114506. */
  114507. static readonly FOVMODE_VERTICAL_FIXED: number;
  114508. /**
  114509. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  114510. */
  114511. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  114512. /**
  114513. * This specifies ther is no need for a camera rig.
  114514. * Basically only one eye is rendered corresponding to the camera.
  114515. */
  114516. static readonly RIG_MODE_NONE: number;
  114517. /**
  114518. * Simulates a camera Rig with one blue eye and one red eye.
  114519. * This can be use with 3d blue and red glasses.
  114520. */
  114521. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  114522. /**
  114523. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  114524. */
  114525. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  114526. /**
  114527. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  114528. */
  114529. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  114530. /**
  114531. * Defines that both eyes of the camera will be rendered over under each other.
  114532. */
  114533. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  114534. /**
  114535. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  114536. */
  114537. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  114538. /**
  114539. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  114540. */
  114541. static readonly RIG_MODE_VR: number;
  114542. /**
  114543. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  114544. */
  114545. static readonly RIG_MODE_WEBVR: number;
  114546. /**
  114547. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  114548. */
  114549. static readonly RIG_MODE_CUSTOM: number;
  114550. /**
  114551. * Defines if by default attaching controls should prevent the default javascript event to continue.
  114552. */
  114553. static ForceAttachControlToAlwaysPreventDefault: boolean;
  114554. /**
  114555. * Define the input manager associated with the camera.
  114556. */
  114557. inputs: CameraInputsManager<Camera>;
  114558. /** @hidden */
  114559. _position: Vector3;
  114560. /**
  114561. * Define the current local position of the camera in the scene
  114562. */
  114563. get position(): Vector3;
  114564. set position(newPosition: Vector3);
  114565. protected _upVector: Vector3;
  114566. /**
  114567. * The vector the camera should consider as up.
  114568. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  114569. */
  114570. set upVector(vec: Vector3);
  114571. get upVector(): Vector3;
  114572. /**
  114573. * Define the current limit on the left side for an orthographic camera
  114574. * In scene unit
  114575. */
  114576. orthoLeft: Nullable<number>;
  114577. /**
  114578. * Define the current limit on the right side for an orthographic camera
  114579. * In scene unit
  114580. */
  114581. orthoRight: Nullable<number>;
  114582. /**
  114583. * Define the current limit on the bottom side for an orthographic camera
  114584. * In scene unit
  114585. */
  114586. orthoBottom: Nullable<number>;
  114587. /**
  114588. * Define the current limit on the top side for an orthographic camera
  114589. * In scene unit
  114590. */
  114591. orthoTop: Nullable<number>;
  114592. /**
  114593. * Field Of View is set in Radians. (default is 0.8)
  114594. */
  114595. fov: number;
  114596. /**
  114597. * Define the minimum distance the camera can see from.
  114598. * This is important to note that the depth buffer are not infinite and the closer it starts
  114599. * the more your scene might encounter depth fighting issue.
  114600. */
  114601. minZ: number;
  114602. /**
  114603. * Define the maximum distance the camera can see to.
  114604. * This is important to note that the depth buffer are not infinite and the further it end
  114605. * the more your scene might encounter depth fighting issue.
  114606. */
  114607. maxZ: number;
  114608. /**
  114609. * Define the default inertia of the camera.
  114610. * This helps giving a smooth feeling to the camera movement.
  114611. */
  114612. inertia: number;
  114613. /**
  114614. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  114615. */
  114616. mode: number;
  114617. /**
  114618. * Define whether the camera is intermediate.
  114619. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  114620. */
  114621. isIntermediate: boolean;
  114622. /**
  114623. * Define the viewport of the camera.
  114624. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  114625. */
  114626. viewport: Viewport;
  114627. /**
  114628. * Restricts the camera to viewing objects with the same layerMask.
  114629. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  114630. */
  114631. layerMask: number;
  114632. /**
  114633. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  114634. */
  114635. fovMode: number;
  114636. /**
  114637. * Rig mode of the camera.
  114638. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  114639. * This is normally controlled byt the camera themselves as internal use.
  114640. */
  114641. cameraRigMode: number;
  114642. /**
  114643. * Defines the distance between both "eyes" in case of a RIG
  114644. */
  114645. interaxialDistance: number;
  114646. /**
  114647. * Defines if stereoscopic rendering is done side by side or over under.
  114648. */
  114649. isStereoscopicSideBySide: boolean;
  114650. /**
  114651. * 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
  114652. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  114653. * else in the scene. (Eg. security camera)
  114654. *
  114655. * 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)
  114656. */
  114657. customRenderTargets: RenderTargetTexture[];
  114658. /**
  114659. * When set, the camera will render to this render target instead of the default canvas
  114660. *
  114661. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  114662. */
  114663. outputRenderTarget: Nullable<RenderTargetTexture>;
  114664. /**
  114665. * Observable triggered when the camera view matrix has changed.
  114666. */
  114667. onViewMatrixChangedObservable: Observable<Camera>;
  114668. /**
  114669. * Observable triggered when the camera Projection matrix has changed.
  114670. */
  114671. onProjectionMatrixChangedObservable: Observable<Camera>;
  114672. /**
  114673. * Observable triggered when the inputs have been processed.
  114674. */
  114675. onAfterCheckInputsObservable: Observable<Camera>;
  114676. /**
  114677. * Observable triggered when reset has been called and applied to the camera.
  114678. */
  114679. onRestoreStateObservable: Observable<Camera>;
  114680. /**
  114681. * Is this camera a part of a rig system?
  114682. */
  114683. isRigCamera: boolean;
  114684. /**
  114685. * If isRigCamera set to true this will be set with the parent camera.
  114686. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  114687. */
  114688. rigParent?: Camera;
  114689. /** @hidden */
  114690. _cameraRigParams: any;
  114691. /** @hidden */
  114692. _rigCameras: Camera[];
  114693. /** @hidden */
  114694. _rigPostProcess: Nullable<PostProcess>;
  114695. protected _webvrViewMatrix: Matrix;
  114696. /** @hidden */
  114697. _skipRendering: boolean;
  114698. /** @hidden */
  114699. _projectionMatrix: Matrix;
  114700. /** @hidden */
  114701. _postProcesses: Nullable<PostProcess>[];
  114702. /** @hidden */
  114703. _activeMeshes: SmartArray<AbstractMesh>;
  114704. protected _globalPosition: Vector3;
  114705. /** @hidden */
  114706. _computedViewMatrix: Matrix;
  114707. private _doNotComputeProjectionMatrix;
  114708. private _transformMatrix;
  114709. private _frustumPlanes;
  114710. private _refreshFrustumPlanes;
  114711. private _storedFov;
  114712. private _stateStored;
  114713. /**
  114714. * Instantiates a new camera object.
  114715. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  114716. * @see https://doc.babylonjs.com/features/cameras
  114717. * @param name Defines the name of the camera in the scene
  114718. * @param position Defines the position of the camera
  114719. * @param scene Defines the scene the camera belongs too
  114720. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  114721. */
  114722. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  114723. /**
  114724. * Store current camera state (fov, position, etc..)
  114725. * @returns the camera
  114726. */
  114727. storeState(): Camera;
  114728. /**
  114729. * Restores the camera state values if it has been stored. You must call storeState() first
  114730. */
  114731. protected _restoreStateValues(): boolean;
  114732. /**
  114733. * Restored camera state. You must call storeState() first.
  114734. * @returns true if restored and false otherwise
  114735. */
  114736. restoreState(): boolean;
  114737. /**
  114738. * Gets the class name of the camera.
  114739. * @returns the class name
  114740. */
  114741. getClassName(): string;
  114742. /** @hidden */
  114743. readonly _isCamera: boolean;
  114744. /**
  114745. * Gets a string representation of the camera useful for debug purpose.
  114746. * @param fullDetails Defines that a more verboe level of logging is required
  114747. * @returns the string representation
  114748. */
  114749. toString(fullDetails?: boolean): string;
  114750. /**
  114751. * Gets the current world space position of the camera.
  114752. */
  114753. get globalPosition(): Vector3;
  114754. /**
  114755. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  114756. * @returns the active meshe list
  114757. */
  114758. getActiveMeshes(): SmartArray<AbstractMesh>;
  114759. /**
  114760. * Check whether a mesh is part of the current active mesh list of the camera
  114761. * @param mesh Defines the mesh to check
  114762. * @returns true if active, false otherwise
  114763. */
  114764. isActiveMesh(mesh: Mesh): boolean;
  114765. /**
  114766. * Is this camera ready to be used/rendered
  114767. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  114768. * @return true if the camera is ready
  114769. */
  114770. isReady(completeCheck?: boolean): boolean;
  114771. /** @hidden */
  114772. _initCache(): void;
  114773. /** @hidden */
  114774. _updateCache(ignoreParentClass?: boolean): void;
  114775. /** @hidden */
  114776. _isSynchronized(): boolean;
  114777. /** @hidden */
  114778. _isSynchronizedViewMatrix(): boolean;
  114779. /** @hidden */
  114780. _isSynchronizedProjectionMatrix(): boolean;
  114781. /**
  114782. * Attach the input controls to a specific dom element to get the input from.
  114783. * @param element Defines the element the controls should be listened from
  114784. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114785. */
  114786. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114787. /**
  114788. * Detach the current controls from the specified dom element.
  114789. * @param element Defines the element to stop listening the inputs from
  114790. */
  114791. detachControl(element: HTMLElement): void;
  114792. /**
  114793. * Update the camera state according to the different inputs gathered during the frame.
  114794. */
  114795. update(): void;
  114796. /** @hidden */
  114797. _checkInputs(): void;
  114798. /** @hidden */
  114799. get rigCameras(): Camera[];
  114800. /**
  114801. * Gets the post process used by the rig cameras
  114802. */
  114803. get rigPostProcess(): Nullable<PostProcess>;
  114804. /**
  114805. * Internal, gets the first post proces.
  114806. * @returns the first post process to be run on this camera.
  114807. */
  114808. _getFirstPostProcess(): Nullable<PostProcess>;
  114809. private _cascadePostProcessesToRigCams;
  114810. /**
  114811. * Attach a post process to the camera.
  114812. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  114813. * @param postProcess The post process to attach to the camera
  114814. * @param insertAt The position of the post process in case several of them are in use in the scene
  114815. * @returns the position the post process has been inserted at
  114816. */
  114817. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  114818. /**
  114819. * Detach a post process to the camera.
  114820. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  114821. * @param postProcess The post process to detach from the camera
  114822. */
  114823. detachPostProcess(postProcess: PostProcess): void;
  114824. /**
  114825. * Gets the current world matrix of the camera
  114826. */
  114827. getWorldMatrix(): Matrix;
  114828. /** @hidden */
  114829. _getViewMatrix(): Matrix;
  114830. /**
  114831. * Gets the current view matrix of the camera.
  114832. * @param force forces the camera to recompute the matrix without looking at the cached state
  114833. * @returns the view matrix
  114834. */
  114835. getViewMatrix(force?: boolean): Matrix;
  114836. /**
  114837. * Freeze the projection matrix.
  114838. * It will prevent the cache check of the camera projection compute and can speed up perf
  114839. * if no parameter of the camera are meant to change
  114840. * @param projection Defines manually a projection if necessary
  114841. */
  114842. freezeProjectionMatrix(projection?: Matrix): void;
  114843. /**
  114844. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  114845. */
  114846. unfreezeProjectionMatrix(): void;
  114847. /**
  114848. * Gets the current projection matrix of the camera.
  114849. * @param force forces the camera to recompute the matrix without looking at the cached state
  114850. * @returns the projection matrix
  114851. */
  114852. getProjectionMatrix(force?: boolean): Matrix;
  114853. /**
  114854. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  114855. * @returns a Matrix
  114856. */
  114857. getTransformationMatrix(): Matrix;
  114858. private _updateFrustumPlanes;
  114859. /**
  114860. * Checks if a cullable object (mesh...) is in the camera frustum
  114861. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  114862. * @param target The object to check
  114863. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  114864. * @returns true if the object is in frustum otherwise false
  114865. */
  114866. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  114867. /**
  114868. * Checks if a cullable object (mesh...) is in the camera frustum
  114869. * Unlike isInFrustum this cheks the full bounding box
  114870. * @param target The object to check
  114871. * @returns true if the object is in frustum otherwise false
  114872. */
  114873. isCompletelyInFrustum(target: ICullable): boolean;
  114874. /**
  114875. * Gets a ray in the forward direction from the camera.
  114876. * @param length Defines the length of the ray to create
  114877. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  114878. * @param origin Defines the start point of the ray which defaults to the camera position
  114879. * @returns the forward ray
  114880. */
  114881. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  114882. /**
  114883. * Gets a ray in the forward direction from the camera.
  114884. * @param refRay the ray to (re)use when setting the values
  114885. * @param length Defines the length of the ray to create
  114886. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  114887. * @param origin Defines the start point of the ray which defaults to the camera position
  114888. * @returns the forward ray
  114889. */
  114890. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  114891. /**
  114892. * Releases resources associated with this node.
  114893. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114894. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114895. */
  114896. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114897. /** @hidden */
  114898. _isLeftCamera: boolean;
  114899. /**
  114900. * Gets the left camera of a rig setup in case of Rigged Camera
  114901. */
  114902. get isLeftCamera(): boolean;
  114903. /** @hidden */
  114904. _isRightCamera: boolean;
  114905. /**
  114906. * Gets the right camera of a rig setup in case of Rigged Camera
  114907. */
  114908. get isRightCamera(): boolean;
  114909. /**
  114910. * Gets the left camera of a rig setup in case of Rigged Camera
  114911. */
  114912. get leftCamera(): Nullable<FreeCamera>;
  114913. /**
  114914. * Gets the right camera of a rig setup in case of Rigged Camera
  114915. */
  114916. get rightCamera(): Nullable<FreeCamera>;
  114917. /**
  114918. * Gets the left camera target of a rig setup in case of Rigged Camera
  114919. * @returns the target position
  114920. */
  114921. getLeftTarget(): Nullable<Vector3>;
  114922. /**
  114923. * Gets the right camera target of a rig setup in case of Rigged Camera
  114924. * @returns the target position
  114925. */
  114926. getRightTarget(): Nullable<Vector3>;
  114927. /**
  114928. * @hidden
  114929. */
  114930. setCameraRigMode(mode: number, rigParams: any): void;
  114931. /** @hidden */
  114932. static _setStereoscopicRigMode(camera: Camera): void;
  114933. /** @hidden */
  114934. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  114935. /** @hidden */
  114936. static _setVRRigMode(camera: Camera, rigParams: any): void;
  114937. /** @hidden */
  114938. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  114939. /** @hidden */
  114940. _getVRProjectionMatrix(): Matrix;
  114941. protected _updateCameraRotationMatrix(): void;
  114942. protected _updateWebVRCameraRotationMatrix(): void;
  114943. /**
  114944. * This function MUST be overwritten by the different WebVR cameras available.
  114945. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  114946. * @hidden
  114947. */
  114948. _getWebVRProjectionMatrix(): Matrix;
  114949. /**
  114950. * This function MUST be overwritten by the different WebVR cameras available.
  114951. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  114952. * @hidden
  114953. */
  114954. _getWebVRViewMatrix(): Matrix;
  114955. /** @hidden */
  114956. setCameraRigParameter(name: string, value: any): void;
  114957. /**
  114958. * needs to be overridden by children so sub has required properties to be copied
  114959. * @hidden
  114960. */
  114961. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  114962. /**
  114963. * May need to be overridden by children
  114964. * @hidden
  114965. */
  114966. _updateRigCameras(): void;
  114967. /** @hidden */
  114968. _setupInputs(): void;
  114969. /**
  114970. * Serialiaze the camera setup to a json represention
  114971. * @returns the JSON representation
  114972. */
  114973. serialize(): any;
  114974. /**
  114975. * Clones the current camera.
  114976. * @param name The cloned camera name
  114977. * @returns the cloned camera
  114978. */
  114979. clone(name: string): Camera;
  114980. /**
  114981. * Gets the direction of the camera relative to a given local axis.
  114982. * @param localAxis Defines the reference axis to provide a relative direction.
  114983. * @return the direction
  114984. */
  114985. getDirection(localAxis: Vector3): Vector3;
  114986. /**
  114987. * Returns the current camera absolute rotation
  114988. */
  114989. get absoluteRotation(): Quaternion;
  114990. /**
  114991. * Gets the direction of the camera relative to a given local axis into a passed vector.
  114992. * @param localAxis Defines the reference axis to provide a relative direction.
  114993. * @param result Defines the vector to store the result in
  114994. */
  114995. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  114996. /**
  114997. * Gets a camera constructor for a given camera type
  114998. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  114999. * @param name The name of the camera the result will be able to instantiate
  115000. * @param scene The scene the result will construct the camera in
  115001. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  115002. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  115003. * @returns a factory method to construc the camera
  115004. */
  115005. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  115006. /**
  115007. * Compute the world matrix of the camera.
  115008. * @returns the camera world matrix
  115009. */
  115010. computeWorldMatrix(): Matrix;
  115011. /**
  115012. * Parse a JSON and creates the camera from the parsed information
  115013. * @param parsedCamera The JSON to parse
  115014. * @param scene The scene to instantiate the camera in
  115015. * @returns the newly constructed camera
  115016. */
  115017. static Parse(parsedCamera: any, scene: Scene): Camera;
  115018. }
  115019. }
  115020. declare module BABYLON {
  115021. /**
  115022. * Class containing static functions to help procedurally build meshes
  115023. */
  115024. export class DiscBuilder {
  115025. /**
  115026. * Creates a plane polygonal mesh. By default, this is a disc
  115027. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  115028. * * 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
  115029. * * 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
  115030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115031. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115033. * @param name defines the name of the mesh
  115034. * @param options defines the options used to create the mesh
  115035. * @param scene defines the hosting scene
  115036. * @returns the plane polygonal mesh
  115037. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  115038. */
  115039. static CreateDisc(name: string, options: {
  115040. radius?: number;
  115041. tessellation?: number;
  115042. arc?: number;
  115043. updatable?: boolean;
  115044. sideOrientation?: number;
  115045. frontUVs?: Vector4;
  115046. backUVs?: Vector4;
  115047. }, scene?: Nullable<Scene>): Mesh;
  115048. }
  115049. }
  115050. declare module BABYLON {
  115051. /**
  115052. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  115053. *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.
  115054. * The SPS is also a particle system. It provides some methods to manage the particles.
  115055. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  115056. *
  115057. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  115058. */
  115059. export class SolidParticleSystem implements IDisposable {
  115060. /**
  115061. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  115062. * Example : var p = SPS.particles[i];
  115063. */
  115064. particles: SolidParticle[];
  115065. /**
  115066. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  115067. */
  115068. nbParticles: number;
  115069. /**
  115070. * If the particles must ever face the camera (default false). Useful for planar particles.
  115071. */
  115072. billboard: boolean;
  115073. /**
  115074. * Recompute normals when adding a shape
  115075. */
  115076. recomputeNormals: boolean;
  115077. /**
  115078. * This a counter ofr your own usage. It's not set by any SPS functions.
  115079. */
  115080. counter: number;
  115081. /**
  115082. * The SPS name. This name is also given to the underlying mesh.
  115083. */
  115084. name: string;
  115085. /**
  115086. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  115087. */
  115088. mesh: Mesh;
  115089. /**
  115090. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  115091. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  115092. */
  115093. vars: any;
  115094. /**
  115095. * This array is populated when the SPS is set as 'pickable'.
  115096. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  115097. * Each element of this array is an object `{idx: int, faceId: int}`.
  115098. * `idx` is the picked particle index in the `SPS.particles` array
  115099. * `faceId` is the picked face index counted within this particle.
  115100. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  115101. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  115102. * Use the method SPS.pickedParticle(pickingInfo) instead.
  115103. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115104. */
  115105. pickedParticles: {
  115106. idx: number;
  115107. faceId: number;
  115108. }[];
  115109. /**
  115110. * This array is populated when the SPS is set as 'pickable'
  115111. * Each key of this array is a submesh index.
  115112. * Each element of this array is a second array defined like this :
  115113. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  115114. * Each element of this second array is an object `{idx: int, faceId: int}`.
  115115. * `idx` is the picked particle index in the `SPS.particles` array
  115116. * `faceId` is the picked face index counted within this particle.
  115117. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  115118. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115119. */
  115120. pickedBySubMesh: {
  115121. idx: number;
  115122. faceId: number;
  115123. }[][];
  115124. /**
  115125. * This array is populated when `enableDepthSort` is set to true.
  115126. * Each element of this array is an instance of the class DepthSortedParticle.
  115127. */
  115128. depthSortedParticles: DepthSortedParticle[];
  115129. /**
  115130. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  115131. * @hidden
  115132. */
  115133. _bSphereOnly: boolean;
  115134. /**
  115135. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  115136. * @hidden
  115137. */
  115138. _bSphereRadiusFactor: number;
  115139. private _scene;
  115140. private _positions;
  115141. private _indices;
  115142. private _normals;
  115143. private _colors;
  115144. private _uvs;
  115145. private _indices32;
  115146. private _positions32;
  115147. private _normals32;
  115148. private _fixedNormal32;
  115149. private _colors32;
  115150. private _uvs32;
  115151. private _index;
  115152. private _updatable;
  115153. private _pickable;
  115154. private _isVisibilityBoxLocked;
  115155. private _alwaysVisible;
  115156. private _depthSort;
  115157. private _expandable;
  115158. private _shapeCounter;
  115159. private _copy;
  115160. private _color;
  115161. private _computeParticleColor;
  115162. private _computeParticleTexture;
  115163. private _computeParticleRotation;
  115164. private _computeParticleVertex;
  115165. private _computeBoundingBox;
  115166. private _depthSortParticles;
  115167. private _camera;
  115168. private _mustUnrotateFixedNormals;
  115169. private _particlesIntersect;
  115170. private _needs32Bits;
  115171. private _isNotBuilt;
  115172. private _lastParticleId;
  115173. private _idxOfId;
  115174. private _multimaterialEnabled;
  115175. private _useModelMaterial;
  115176. private _indicesByMaterial;
  115177. private _materialIndexes;
  115178. private _depthSortFunction;
  115179. private _materialSortFunction;
  115180. private _materials;
  115181. private _multimaterial;
  115182. private _materialIndexesById;
  115183. private _defaultMaterial;
  115184. private _autoUpdateSubMeshes;
  115185. private _tmpVertex;
  115186. /**
  115187. * Creates a SPS (Solid Particle System) object.
  115188. * @param name (String) is the SPS name, this will be the underlying mesh name.
  115189. * @param scene (Scene) is the scene in which the SPS is added.
  115190. * @param options defines the options of the sps e.g.
  115191. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  115192. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  115193. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  115194. * * 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.
  115195. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  115196. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  115197. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  115198. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  115199. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  115200. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  115201. */
  115202. constructor(name: string, scene: Scene, options?: {
  115203. updatable?: boolean;
  115204. isPickable?: boolean;
  115205. enableDepthSort?: boolean;
  115206. particleIntersection?: boolean;
  115207. boundingSphereOnly?: boolean;
  115208. bSphereRadiusFactor?: number;
  115209. expandable?: boolean;
  115210. useModelMaterial?: boolean;
  115211. enableMultiMaterial?: boolean;
  115212. });
  115213. /**
  115214. * Builds the SPS underlying mesh. Returns a standard Mesh.
  115215. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  115216. * @returns the created mesh
  115217. */
  115218. buildMesh(): Mesh;
  115219. /**
  115220. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  115221. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  115222. * Thus the particles generated from `digest()` have their property `position` set yet.
  115223. * @param mesh ( Mesh ) is the mesh to be digested
  115224. * @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
  115225. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  115226. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  115227. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115228. * @returns the current SPS
  115229. */
  115230. digest(mesh: Mesh, options?: {
  115231. facetNb?: number;
  115232. number?: number;
  115233. delta?: number;
  115234. storage?: [];
  115235. }): SolidParticleSystem;
  115236. /**
  115237. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  115238. * @hidden
  115239. */
  115240. private _unrotateFixedNormals;
  115241. /**
  115242. * Resets the temporary working copy particle
  115243. * @hidden
  115244. */
  115245. private _resetCopy;
  115246. /**
  115247. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  115248. * @param p the current index in the positions array to be updated
  115249. * @param ind the current index in the indices array
  115250. * @param shape a Vector3 array, the shape geometry
  115251. * @param positions the positions array to be updated
  115252. * @param meshInd the shape indices array
  115253. * @param indices the indices array to be updated
  115254. * @param meshUV the shape uv array
  115255. * @param uvs the uv array to be updated
  115256. * @param meshCol the shape color array
  115257. * @param colors the color array to be updated
  115258. * @param meshNor the shape normals array
  115259. * @param normals the normals array to be updated
  115260. * @param idx the particle index
  115261. * @param idxInShape the particle index in its shape
  115262. * @param options the addShape() method passed options
  115263. * @model the particle model
  115264. * @hidden
  115265. */
  115266. private _meshBuilder;
  115267. /**
  115268. * Returns a shape Vector3 array from positions float array
  115269. * @param positions float array
  115270. * @returns a vector3 array
  115271. * @hidden
  115272. */
  115273. private _posToShape;
  115274. /**
  115275. * Returns a shapeUV array from a float uvs (array deep copy)
  115276. * @param uvs as a float array
  115277. * @returns a shapeUV array
  115278. * @hidden
  115279. */
  115280. private _uvsToShapeUV;
  115281. /**
  115282. * Adds a new particle object in the particles array
  115283. * @param idx particle index in particles array
  115284. * @param id particle id
  115285. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  115286. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  115287. * @param model particle ModelShape object
  115288. * @param shapeId model shape identifier
  115289. * @param idxInShape index of the particle in the current model
  115290. * @param bInfo model bounding info object
  115291. * @param storage target storage array, if any
  115292. * @hidden
  115293. */
  115294. private _addParticle;
  115295. /**
  115296. * Adds some particles to the SPS from the model shape. Returns the shape id.
  115297. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  115298. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  115299. * @param nb (positive integer) the number of particles to be created from this model
  115300. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  115301. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  115302. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115303. * @returns the number of shapes in the system
  115304. */
  115305. addShape(mesh: Mesh, nb: number, options?: {
  115306. positionFunction?: any;
  115307. vertexFunction?: any;
  115308. storage?: [];
  115309. }): number;
  115310. /**
  115311. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  115312. * @hidden
  115313. */
  115314. private _rebuildParticle;
  115315. /**
  115316. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  115317. * @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.
  115318. * @returns the SPS.
  115319. */
  115320. rebuildMesh(reset?: boolean): SolidParticleSystem;
  115321. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  115322. * Returns an array with the removed particles.
  115323. * 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.
  115324. * The SPS can't be empty so at least one particle needs to remain in place.
  115325. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  115326. * @param start index of the first particle to remove
  115327. * @param end index of the last particle to remove (included)
  115328. * @returns an array populated with the removed particles
  115329. */
  115330. removeParticles(start: number, end: number): SolidParticle[];
  115331. /**
  115332. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  115333. * @param solidParticleArray an array populated with Solid Particles objects
  115334. * @returns the SPS
  115335. */
  115336. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  115337. /**
  115338. * Creates a new particle and modifies the SPS mesh geometry :
  115339. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  115340. * - calls _addParticle() to populate the particle array
  115341. * factorized code from addShape() and insertParticlesFromArray()
  115342. * @param idx particle index in the particles array
  115343. * @param i particle index in its shape
  115344. * @param modelShape particle ModelShape object
  115345. * @param shape shape vertex array
  115346. * @param meshInd shape indices array
  115347. * @param meshUV shape uv array
  115348. * @param meshCol shape color array
  115349. * @param meshNor shape normals array
  115350. * @param bbInfo shape bounding info
  115351. * @param storage target particle storage
  115352. * @options addShape() passed options
  115353. * @hidden
  115354. */
  115355. private _insertNewParticle;
  115356. /**
  115357. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  115358. * This method calls `updateParticle()` for each particle of the SPS.
  115359. * For an animated SPS, it is usually called within the render loop.
  115360. * 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.
  115361. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  115362. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  115363. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  115364. * @returns the SPS.
  115365. */
  115366. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  115367. /**
  115368. * Disposes the SPS.
  115369. */
  115370. dispose(): void;
  115371. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  115372. * idx is the particle index in the SPS
  115373. * faceId is the picked face index counted within this particle.
  115374. * Returns null if the pickInfo can't identify a picked particle.
  115375. * @param pickingInfo (PickingInfo object)
  115376. * @returns {idx: number, faceId: number} or null
  115377. */
  115378. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  115379. idx: number;
  115380. faceId: number;
  115381. }>;
  115382. /**
  115383. * Returns a SolidParticle object from its identifier : particle.id
  115384. * @param id (integer) the particle Id
  115385. * @returns the searched particle or null if not found in the SPS.
  115386. */
  115387. getParticleById(id: number): Nullable<SolidParticle>;
  115388. /**
  115389. * Returns a new array populated with the particles having the passed shapeId.
  115390. * @param shapeId (integer) the shape identifier
  115391. * @returns a new solid particle array
  115392. */
  115393. getParticlesByShapeId(shapeId: number): SolidParticle[];
  115394. /**
  115395. * Populates the passed array "ref" with the particles having the passed shapeId.
  115396. * @param shapeId the shape identifier
  115397. * @returns the SPS
  115398. * @param ref
  115399. */
  115400. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  115401. /**
  115402. * Computes the required SubMeshes according the materials assigned to the particles.
  115403. * @returns the solid particle system.
  115404. * Does nothing if called before the SPS mesh is built.
  115405. */
  115406. computeSubMeshes(): SolidParticleSystem;
  115407. /**
  115408. * Sorts the solid particles by material when MultiMaterial is enabled.
  115409. * Updates the indices32 array.
  115410. * Updates the indicesByMaterial array.
  115411. * Updates the mesh indices array.
  115412. * @returns the SPS
  115413. * @hidden
  115414. */
  115415. private _sortParticlesByMaterial;
  115416. /**
  115417. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  115418. * @hidden
  115419. */
  115420. private _setMaterialIndexesById;
  115421. /**
  115422. * Returns an array with unique values of Materials from the passed array
  115423. * @param array the material array to be checked and filtered
  115424. * @hidden
  115425. */
  115426. private _filterUniqueMaterialId;
  115427. /**
  115428. * Sets a new Standard Material as _defaultMaterial if not already set.
  115429. * @hidden
  115430. */
  115431. private _setDefaultMaterial;
  115432. /**
  115433. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  115434. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115435. * @returns the SPS.
  115436. */
  115437. refreshVisibleSize(): SolidParticleSystem;
  115438. /**
  115439. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  115440. * @param size the size (float) of the visibility box
  115441. * note : this doesn't lock the SPS mesh bounding box.
  115442. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115443. */
  115444. setVisibilityBox(size: number): void;
  115445. /**
  115446. * Gets whether the SPS as always visible or not
  115447. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115448. */
  115449. get isAlwaysVisible(): boolean;
  115450. /**
  115451. * Sets the SPS as always visible or not
  115452. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115453. */
  115454. set isAlwaysVisible(val: boolean);
  115455. /**
  115456. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115457. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115458. */
  115459. set isVisibilityBoxLocked(val: boolean);
  115460. /**
  115461. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115462. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115463. */
  115464. get isVisibilityBoxLocked(): boolean;
  115465. /**
  115466. * Tells to `setParticles()` to compute the particle rotations or not.
  115467. * Default value : true. The SPS is faster when it's set to false.
  115468. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115469. */
  115470. set computeParticleRotation(val: boolean);
  115471. /**
  115472. * Tells to `setParticles()` to compute the particle colors or not.
  115473. * Default value : true. The SPS is faster when it's set to false.
  115474. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115475. */
  115476. set computeParticleColor(val: boolean);
  115477. set computeParticleTexture(val: boolean);
  115478. /**
  115479. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  115480. * Default value : false. The SPS is faster when it's set to false.
  115481. * Note : the particle custom vertex positions aren't stored values.
  115482. */
  115483. set computeParticleVertex(val: boolean);
  115484. /**
  115485. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  115486. */
  115487. set computeBoundingBox(val: boolean);
  115488. /**
  115489. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  115490. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  115491. * Default : `true`
  115492. */
  115493. set depthSortParticles(val: boolean);
  115494. /**
  115495. * Gets if `setParticles()` computes the particle rotations or not.
  115496. * Default value : true. The SPS is faster when it's set to false.
  115497. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115498. */
  115499. get computeParticleRotation(): boolean;
  115500. /**
  115501. * Gets if `setParticles()` computes the particle colors or not.
  115502. * Default value : true. The SPS is faster when it's set to false.
  115503. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115504. */
  115505. get computeParticleColor(): boolean;
  115506. /**
  115507. * Gets if `setParticles()` computes the particle textures or not.
  115508. * Default value : true. The SPS is faster when it's set to false.
  115509. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  115510. */
  115511. get computeParticleTexture(): boolean;
  115512. /**
  115513. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  115514. * Default value : false. The SPS is faster when it's set to false.
  115515. * Note : the particle custom vertex positions aren't stored values.
  115516. */
  115517. get computeParticleVertex(): boolean;
  115518. /**
  115519. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  115520. */
  115521. get computeBoundingBox(): boolean;
  115522. /**
  115523. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  115524. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  115525. * Default : `true`
  115526. */
  115527. get depthSortParticles(): boolean;
  115528. /**
  115529. * Gets if the SPS is created as expandable at construction time.
  115530. * Default : `false`
  115531. */
  115532. get expandable(): boolean;
  115533. /**
  115534. * Gets if the SPS supports the Multi Materials
  115535. */
  115536. get multimaterialEnabled(): boolean;
  115537. /**
  115538. * Gets if the SPS uses the model materials for its own multimaterial.
  115539. */
  115540. get useModelMaterial(): boolean;
  115541. /**
  115542. * The SPS used material array.
  115543. */
  115544. get materials(): Material[];
  115545. /**
  115546. * Sets the SPS MultiMaterial from the passed materials.
  115547. * Note : the passed array is internally copied and not used then by reference.
  115548. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  115549. */
  115550. setMultiMaterial(materials: Material[]): void;
  115551. /**
  115552. * The SPS computed multimaterial object
  115553. */
  115554. get multimaterial(): MultiMaterial;
  115555. set multimaterial(mm: MultiMaterial);
  115556. /**
  115557. * If the subMeshes must be updated on the next call to setParticles()
  115558. */
  115559. get autoUpdateSubMeshes(): boolean;
  115560. set autoUpdateSubMeshes(val: boolean);
  115561. /**
  115562. * This function does nothing. It may be overwritten to set all the particle first values.
  115563. * The SPS doesn't call this function, you may have to call it by your own.
  115564. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115565. */
  115566. initParticles(): void;
  115567. /**
  115568. * This function does nothing. It may be overwritten to recycle a particle.
  115569. * The SPS doesn't call this function, you may have to call it by your own.
  115570. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115571. * @param particle The particle to recycle
  115572. * @returns the recycled particle
  115573. */
  115574. recycleParticle(particle: SolidParticle): SolidParticle;
  115575. /**
  115576. * Updates a particle : this function should be overwritten by the user.
  115577. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  115578. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115579. * @example : just set a particle position or velocity and recycle conditions
  115580. * @param particle The particle to update
  115581. * @returns the updated particle
  115582. */
  115583. updateParticle(particle: SolidParticle): SolidParticle;
  115584. /**
  115585. * Updates a vertex of a particle : it can be overwritten by the user.
  115586. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  115587. * @param particle the current particle
  115588. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  115589. * @param pt the index of the current vertex in the particle shape
  115590. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  115591. * @example : just set a vertex particle position or color
  115592. * @returns the sps
  115593. */
  115594. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  115595. /**
  115596. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  115597. * This does nothing and may be overwritten by the user.
  115598. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115599. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115600. * @param update the boolean update value actually passed to setParticles()
  115601. */
  115602. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  115603. /**
  115604. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  115605. * This will be passed three parameters.
  115606. * This does nothing and may be overwritten by the user.
  115607. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115608. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115609. * @param update the boolean update value actually passed to setParticles()
  115610. */
  115611. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  115612. }
  115613. }
  115614. declare module BABYLON {
  115615. /**
  115616. * Represents one particle of a solid particle system.
  115617. */
  115618. export class SolidParticle {
  115619. /**
  115620. * particle global index
  115621. */
  115622. idx: number;
  115623. /**
  115624. * particle identifier
  115625. */
  115626. id: number;
  115627. /**
  115628. * The color of the particle
  115629. */
  115630. color: Nullable<Color4>;
  115631. /**
  115632. * The world space position of the particle.
  115633. */
  115634. position: Vector3;
  115635. /**
  115636. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  115637. */
  115638. rotation: Vector3;
  115639. /**
  115640. * The world space rotation quaternion of the particle.
  115641. */
  115642. rotationQuaternion: Nullable<Quaternion>;
  115643. /**
  115644. * The scaling of the particle.
  115645. */
  115646. scaling: Vector3;
  115647. /**
  115648. * The uvs of the particle.
  115649. */
  115650. uvs: Vector4;
  115651. /**
  115652. * The current speed of the particle.
  115653. */
  115654. velocity: Vector3;
  115655. /**
  115656. * The pivot point in the particle local space.
  115657. */
  115658. pivot: Vector3;
  115659. /**
  115660. * Must the particle be translated from its pivot point in its local space ?
  115661. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  115662. * Default : false
  115663. */
  115664. translateFromPivot: boolean;
  115665. /**
  115666. * Is the particle active or not ?
  115667. */
  115668. alive: boolean;
  115669. /**
  115670. * Is the particle visible or not ?
  115671. */
  115672. isVisible: boolean;
  115673. /**
  115674. * Index of this particle in the global "positions" array (Internal use)
  115675. * @hidden
  115676. */
  115677. _pos: number;
  115678. /**
  115679. * @hidden Index of this particle in the global "indices" array (Internal use)
  115680. */
  115681. _ind: number;
  115682. /**
  115683. * @hidden ModelShape of this particle (Internal use)
  115684. */
  115685. _model: ModelShape;
  115686. /**
  115687. * ModelShape id of this particle
  115688. */
  115689. shapeId: number;
  115690. /**
  115691. * Index of the particle in its shape id
  115692. */
  115693. idxInShape: number;
  115694. /**
  115695. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  115696. */
  115697. _modelBoundingInfo: BoundingInfo;
  115698. /**
  115699. * @hidden Particle BoundingInfo object (Internal use)
  115700. */
  115701. _boundingInfo: BoundingInfo;
  115702. /**
  115703. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  115704. */
  115705. _sps: SolidParticleSystem;
  115706. /**
  115707. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  115708. */
  115709. _stillInvisible: boolean;
  115710. /**
  115711. * @hidden Last computed particle rotation matrix
  115712. */
  115713. _rotationMatrix: number[];
  115714. /**
  115715. * Parent particle Id, if any.
  115716. * Default null.
  115717. */
  115718. parentId: Nullable<number>;
  115719. /**
  115720. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  115721. */
  115722. materialIndex: Nullable<number>;
  115723. /**
  115724. * Custom object or properties.
  115725. */
  115726. props: Nullable<any>;
  115727. /**
  115728. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  115729. * The possible values are :
  115730. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  115731. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115732. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  115733. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  115734. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115735. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  115736. * */
  115737. cullingStrategy: number;
  115738. /**
  115739. * @hidden Internal global position in the SPS.
  115740. */
  115741. _globalPosition: Vector3;
  115742. /**
  115743. * Creates a Solid Particle object.
  115744. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  115745. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  115746. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  115747. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  115748. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  115749. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  115750. * @param shapeId (integer) is the model shape identifier in the SPS.
  115751. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  115752. * @param sps defines the sps it is associated to
  115753. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  115754. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  115755. */
  115756. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  115757. /**
  115758. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  115759. * @param target the particle target
  115760. * @returns the current particle
  115761. */
  115762. copyToRef(target: SolidParticle): SolidParticle;
  115763. /**
  115764. * Legacy support, changed scale to scaling
  115765. */
  115766. get scale(): Vector3;
  115767. /**
  115768. * Legacy support, changed scale to scaling
  115769. */
  115770. set scale(scale: Vector3);
  115771. /**
  115772. * Legacy support, changed quaternion to rotationQuaternion
  115773. */
  115774. get quaternion(): Nullable<Quaternion>;
  115775. /**
  115776. * Legacy support, changed quaternion to rotationQuaternion
  115777. */
  115778. set quaternion(q: Nullable<Quaternion>);
  115779. /**
  115780. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  115781. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  115782. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  115783. * @returns true if it intersects
  115784. */
  115785. intersectsMesh(target: Mesh | SolidParticle): boolean;
  115786. /**
  115787. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  115788. * A particle is in the frustum if its bounding box intersects the frustum
  115789. * @param frustumPlanes defines the frustum to test
  115790. * @returns true if the particle is in the frustum planes
  115791. */
  115792. isInFrustum(frustumPlanes: Plane[]): boolean;
  115793. /**
  115794. * get the rotation matrix of the particle
  115795. * @hidden
  115796. */
  115797. getRotationMatrix(m: Matrix): void;
  115798. }
  115799. /**
  115800. * Represents the shape of the model used by one particle of a solid particle system.
  115801. * SPS internal tool, don't use it manually.
  115802. */
  115803. export class ModelShape {
  115804. /**
  115805. * The shape id
  115806. * @hidden
  115807. */
  115808. shapeID: number;
  115809. /**
  115810. * flat array of model positions (internal use)
  115811. * @hidden
  115812. */
  115813. _shape: Vector3[];
  115814. /**
  115815. * flat array of model UVs (internal use)
  115816. * @hidden
  115817. */
  115818. _shapeUV: number[];
  115819. /**
  115820. * color array of the model
  115821. * @hidden
  115822. */
  115823. _shapeColors: number[];
  115824. /**
  115825. * indices array of the model
  115826. * @hidden
  115827. */
  115828. _indices: number[];
  115829. /**
  115830. * normals array of the model
  115831. * @hidden
  115832. */
  115833. _normals: number[];
  115834. /**
  115835. * length of the shape in the model indices array (internal use)
  115836. * @hidden
  115837. */
  115838. _indicesLength: number;
  115839. /**
  115840. * Custom position function (internal use)
  115841. * @hidden
  115842. */
  115843. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  115844. /**
  115845. * Custom vertex function (internal use)
  115846. * @hidden
  115847. */
  115848. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  115849. /**
  115850. * Model material (internal use)
  115851. * @hidden
  115852. */
  115853. _material: Nullable<Material>;
  115854. /**
  115855. * 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.
  115856. * SPS internal tool, don't use it manually.
  115857. * @hidden
  115858. */
  115859. 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>);
  115860. }
  115861. /**
  115862. * Represents a Depth Sorted Particle in the solid particle system.
  115863. * @hidden
  115864. */
  115865. export class DepthSortedParticle {
  115866. /**
  115867. * Particle index
  115868. */
  115869. idx: number;
  115870. /**
  115871. * Index of the particle in the "indices" array
  115872. */
  115873. ind: number;
  115874. /**
  115875. * Length of the particle shape in the "indices" array
  115876. */
  115877. indicesLength: number;
  115878. /**
  115879. * Squared distance from the particle to the camera
  115880. */
  115881. sqDistance: number;
  115882. /**
  115883. * Material index when used with MultiMaterials
  115884. */
  115885. materialIndex: number;
  115886. /**
  115887. * Creates a new sorted particle
  115888. * @param materialIndex
  115889. */
  115890. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  115891. }
  115892. /**
  115893. * Represents a solid particle vertex
  115894. */
  115895. export class SolidParticleVertex {
  115896. /**
  115897. * Vertex position
  115898. */
  115899. position: Vector3;
  115900. /**
  115901. * Vertex color
  115902. */
  115903. color: Color4;
  115904. /**
  115905. * Vertex UV
  115906. */
  115907. uv: Vector2;
  115908. /**
  115909. * Creates a new solid particle vertex
  115910. */
  115911. constructor();
  115912. /** Vertex x coordinate */
  115913. get x(): number;
  115914. set x(val: number);
  115915. /** Vertex y coordinate */
  115916. get y(): number;
  115917. set y(val: number);
  115918. /** Vertex z coordinate */
  115919. get z(): number;
  115920. set z(val: number);
  115921. }
  115922. }
  115923. declare module BABYLON {
  115924. /**
  115925. * @hidden
  115926. */
  115927. export class _MeshCollisionData {
  115928. _checkCollisions: boolean;
  115929. _collisionMask: number;
  115930. _collisionGroup: number;
  115931. _surroundingMeshes: Nullable<AbstractMesh[]>;
  115932. _collider: Nullable<Collider>;
  115933. _oldPositionForCollisions: Vector3;
  115934. _diffPositionForCollisions: Vector3;
  115935. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  115936. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  115937. _collisionResponse: boolean;
  115938. }
  115939. }
  115940. declare module BABYLON {
  115941. /** @hidden */
  115942. class _FacetDataStorage {
  115943. facetPositions: Vector3[];
  115944. facetNormals: Vector3[];
  115945. facetPartitioning: number[][];
  115946. facetNb: number;
  115947. partitioningSubdivisions: number;
  115948. partitioningBBoxRatio: number;
  115949. facetDataEnabled: boolean;
  115950. facetParameters: any;
  115951. bbSize: Vector3;
  115952. subDiv: {
  115953. max: number;
  115954. X: number;
  115955. Y: number;
  115956. Z: number;
  115957. };
  115958. facetDepthSort: boolean;
  115959. facetDepthSortEnabled: boolean;
  115960. depthSortedIndices: IndicesArray;
  115961. depthSortedFacets: {
  115962. ind: number;
  115963. sqDistance: number;
  115964. }[];
  115965. facetDepthSortFunction: (f1: {
  115966. ind: number;
  115967. sqDistance: number;
  115968. }, f2: {
  115969. ind: number;
  115970. sqDistance: number;
  115971. }) => number;
  115972. facetDepthSortFrom: Vector3;
  115973. facetDepthSortOrigin: Vector3;
  115974. invertedMatrix: Matrix;
  115975. }
  115976. /**
  115977. * @hidden
  115978. **/
  115979. class _InternalAbstractMeshDataInfo {
  115980. _hasVertexAlpha: boolean;
  115981. _useVertexColors: boolean;
  115982. _numBoneInfluencers: number;
  115983. _applyFog: boolean;
  115984. _receiveShadows: boolean;
  115985. _facetData: _FacetDataStorage;
  115986. _visibility: number;
  115987. _skeleton: Nullable<Skeleton>;
  115988. _layerMask: number;
  115989. _computeBonesUsingShaders: boolean;
  115990. _isActive: boolean;
  115991. _onlyForInstances: boolean;
  115992. _isActiveIntermediate: boolean;
  115993. _onlyForInstancesIntermediate: boolean;
  115994. _actAsRegularMesh: boolean;
  115995. _currentLOD: Nullable<AbstractMesh>;
  115996. }
  115997. /**
  115998. * Class used to store all common mesh properties
  115999. */
  116000. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  116001. /** No occlusion */
  116002. static OCCLUSION_TYPE_NONE: number;
  116003. /** Occlusion set to optimisitic */
  116004. static OCCLUSION_TYPE_OPTIMISTIC: number;
  116005. /** Occlusion set to strict */
  116006. static OCCLUSION_TYPE_STRICT: number;
  116007. /** Use an accurante occlusion algorithm */
  116008. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  116009. /** Use a conservative occlusion algorithm */
  116010. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  116011. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  116012. * Test order :
  116013. * Is the bounding sphere outside the frustum ?
  116014. * If not, are the bounding box vertices outside the frustum ?
  116015. * It not, then the cullable object is in the frustum.
  116016. */
  116017. static readonly CULLINGSTRATEGY_STANDARD: number;
  116018. /** Culling strategy : Bounding Sphere Only.
  116019. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  116020. * It's also less accurate than the standard because some not visible objects can still be selected.
  116021. * Test : is the bounding sphere outside the frustum ?
  116022. * If not, then the cullable object is in the frustum.
  116023. */
  116024. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  116025. /** Culling strategy : Optimistic Inclusion.
  116026. * This in an inclusion test first, then the standard exclusion test.
  116027. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  116028. * 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.
  116029. * Anyway, it's as accurate as the standard strategy.
  116030. * Test :
  116031. * Is the cullable object bounding sphere center in the frustum ?
  116032. * If not, apply the default culling strategy.
  116033. */
  116034. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  116035. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  116036. * This in an inclusion test first, then the bounding sphere only exclusion test.
  116037. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  116038. * 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.
  116039. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  116040. * Test :
  116041. * Is the cullable object bounding sphere center in the frustum ?
  116042. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  116043. */
  116044. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  116045. /**
  116046. * No billboard
  116047. */
  116048. static get BILLBOARDMODE_NONE(): number;
  116049. /** Billboard on X axis */
  116050. static get BILLBOARDMODE_X(): number;
  116051. /** Billboard on Y axis */
  116052. static get BILLBOARDMODE_Y(): number;
  116053. /** Billboard on Z axis */
  116054. static get BILLBOARDMODE_Z(): number;
  116055. /** Billboard on all axes */
  116056. static get BILLBOARDMODE_ALL(): number;
  116057. /** Billboard on using position instead of orientation */
  116058. static get BILLBOARDMODE_USE_POSITION(): number;
  116059. /** @hidden */
  116060. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  116061. /**
  116062. * The culling strategy to use to check whether the mesh must be rendered or not.
  116063. * This value can be changed at any time and will be used on the next render mesh selection.
  116064. * The possible values are :
  116065. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116066. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116067. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116068. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116069. * Please read each static variable documentation to get details about the culling process.
  116070. * */
  116071. cullingStrategy: number;
  116072. /**
  116073. * Gets the number of facets in the mesh
  116074. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116075. */
  116076. get facetNb(): number;
  116077. /**
  116078. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  116079. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116080. */
  116081. get partitioningSubdivisions(): number;
  116082. set partitioningSubdivisions(nb: number);
  116083. /**
  116084. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  116085. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  116086. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116087. */
  116088. get partitioningBBoxRatio(): number;
  116089. set partitioningBBoxRatio(ratio: number);
  116090. /**
  116091. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  116092. * Works only for updatable meshes.
  116093. * Doesn't work with multi-materials
  116094. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116095. */
  116096. get mustDepthSortFacets(): boolean;
  116097. set mustDepthSortFacets(sort: boolean);
  116098. /**
  116099. * The location (Vector3) where the facet depth sort must be computed from.
  116100. * By default, the active camera position.
  116101. * Used only when facet depth sort is enabled
  116102. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116103. */
  116104. get facetDepthSortFrom(): Vector3;
  116105. set facetDepthSortFrom(location: Vector3);
  116106. /**
  116107. * gets a boolean indicating if facetData is enabled
  116108. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116109. */
  116110. get isFacetDataEnabled(): boolean;
  116111. /** @hidden */
  116112. _updateNonUniformScalingState(value: boolean): boolean;
  116113. /**
  116114. * An event triggered when this mesh collides with another one
  116115. */
  116116. onCollideObservable: Observable<AbstractMesh>;
  116117. /** Set a function to call when this mesh collides with another one */
  116118. set onCollide(callback: () => void);
  116119. /**
  116120. * An event triggered when the collision's position changes
  116121. */
  116122. onCollisionPositionChangeObservable: Observable<Vector3>;
  116123. /** Set a function to call when the collision's position changes */
  116124. set onCollisionPositionChange(callback: () => void);
  116125. /**
  116126. * An event triggered when material is changed
  116127. */
  116128. onMaterialChangedObservable: Observable<AbstractMesh>;
  116129. /**
  116130. * Gets or sets the orientation for POV movement & rotation
  116131. */
  116132. definedFacingForward: boolean;
  116133. /** @hidden */
  116134. _occlusionQuery: Nullable<WebGLQuery>;
  116135. /** @hidden */
  116136. _renderingGroup: Nullable<RenderingGroup>;
  116137. /**
  116138. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116139. */
  116140. get visibility(): number;
  116141. /**
  116142. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116143. */
  116144. set visibility(value: number);
  116145. /** Gets or sets the alpha index used to sort transparent meshes
  116146. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  116147. */
  116148. alphaIndex: number;
  116149. /**
  116150. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  116151. */
  116152. isVisible: boolean;
  116153. /**
  116154. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  116155. */
  116156. isPickable: boolean;
  116157. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  116158. showSubMeshesBoundingBox: boolean;
  116159. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  116160. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116161. */
  116162. isBlocker: boolean;
  116163. /**
  116164. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  116165. */
  116166. enablePointerMoveEvents: boolean;
  116167. private _renderingGroupId;
  116168. /**
  116169. * Specifies the rendering group id for this mesh (0 by default)
  116170. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  116171. */
  116172. get renderingGroupId(): number;
  116173. set renderingGroupId(value: number);
  116174. private _material;
  116175. /** Gets or sets current material */
  116176. get material(): Nullable<Material>;
  116177. set material(value: Nullable<Material>);
  116178. /**
  116179. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  116180. * @see https://doc.babylonjs.com/babylon101/shadows
  116181. */
  116182. get receiveShadows(): boolean;
  116183. set receiveShadows(value: boolean);
  116184. /** Defines color to use when rendering outline */
  116185. outlineColor: Color3;
  116186. /** Define width to use when rendering outline */
  116187. outlineWidth: number;
  116188. /** Defines color to use when rendering overlay */
  116189. overlayColor: Color3;
  116190. /** Defines alpha to use when rendering overlay */
  116191. overlayAlpha: number;
  116192. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  116193. get hasVertexAlpha(): boolean;
  116194. set hasVertexAlpha(value: boolean);
  116195. /** 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) */
  116196. get useVertexColors(): boolean;
  116197. set useVertexColors(value: boolean);
  116198. /**
  116199. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  116200. */
  116201. get computeBonesUsingShaders(): boolean;
  116202. set computeBonesUsingShaders(value: boolean);
  116203. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  116204. get numBoneInfluencers(): number;
  116205. set numBoneInfluencers(value: number);
  116206. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  116207. get applyFog(): boolean;
  116208. set applyFog(value: boolean);
  116209. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  116210. useOctreeForRenderingSelection: boolean;
  116211. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  116212. useOctreeForPicking: boolean;
  116213. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  116214. useOctreeForCollisions: boolean;
  116215. /**
  116216. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  116217. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  116218. */
  116219. get layerMask(): number;
  116220. set layerMask(value: number);
  116221. /**
  116222. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  116223. */
  116224. alwaysSelectAsActiveMesh: boolean;
  116225. /**
  116226. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  116227. */
  116228. doNotSyncBoundingInfo: boolean;
  116229. /**
  116230. * Gets or sets the current action manager
  116231. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116232. */
  116233. actionManager: Nullable<AbstractActionManager>;
  116234. private _meshCollisionData;
  116235. /**
  116236. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  116237. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116238. */
  116239. ellipsoid: Vector3;
  116240. /**
  116241. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  116242. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116243. */
  116244. ellipsoidOffset: Vector3;
  116245. /**
  116246. * Gets or sets a collision mask used to mask collisions (default is -1).
  116247. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116248. */
  116249. get collisionMask(): number;
  116250. set collisionMask(mask: number);
  116251. /**
  116252. * Gets or sets a collision response flag (default is true).
  116253. * when collisionResponse is false, events are still triggered but colliding entity has no response
  116254. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  116255. * to respond to the collision.
  116256. */
  116257. get collisionResponse(): boolean;
  116258. set collisionResponse(response: boolean);
  116259. /**
  116260. * Gets or sets the current collision group mask (-1 by default).
  116261. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116262. */
  116263. get collisionGroup(): number;
  116264. set collisionGroup(mask: number);
  116265. /**
  116266. * Gets or sets current surrounding meshes (null by default).
  116267. *
  116268. * By default collision detection is tested against every mesh in the scene.
  116269. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  116270. * meshes will be tested for the collision.
  116271. *
  116272. * Note: if set to an empty array no collision will happen when this mesh is moved.
  116273. */
  116274. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  116275. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  116276. /**
  116277. * Defines edge width used when edgesRenderer is enabled
  116278. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116279. */
  116280. edgesWidth: number;
  116281. /**
  116282. * Defines edge color used when edgesRenderer is enabled
  116283. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116284. */
  116285. edgesColor: Color4;
  116286. /** @hidden */
  116287. _edgesRenderer: Nullable<IEdgesRenderer>;
  116288. /** @hidden */
  116289. _masterMesh: Nullable<AbstractMesh>;
  116290. /** @hidden */
  116291. _boundingInfo: Nullable<BoundingInfo>;
  116292. /** @hidden */
  116293. _renderId: number;
  116294. /**
  116295. * Gets or sets the list of subMeshes
  116296. * @see https://doc.babylonjs.com/how_to/multi_materials
  116297. */
  116298. subMeshes: SubMesh[];
  116299. /** @hidden */
  116300. _intersectionsInProgress: AbstractMesh[];
  116301. /** @hidden */
  116302. _unIndexed: boolean;
  116303. /** @hidden */
  116304. _lightSources: Light[];
  116305. /** Gets the list of lights affecting that mesh */
  116306. get lightSources(): Light[];
  116307. /** @hidden */
  116308. get _positions(): Nullable<Vector3[]>;
  116309. /** @hidden */
  116310. _waitingData: {
  116311. lods: Nullable<any>;
  116312. actions: Nullable<any>;
  116313. freezeWorldMatrix: Nullable<boolean>;
  116314. };
  116315. /** @hidden */
  116316. _bonesTransformMatrices: Nullable<Float32Array>;
  116317. /** @hidden */
  116318. _transformMatrixTexture: Nullable<RawTexture>;
  116319. /**
  116320. * Gets or sets a skeleton to apply skining transformations
  116321. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  116322. */
  116323. set skeleton(value: Nullable<Skeleton>);
  116324. get skeleton(): Nullable<Skeleton>;
  116325. /**
  116326. * An event triggered when the mesh is rebuilt.
  116327. */
  116328. onRebuildObservable: Observable<AbstractMesh>;
  116329. /**
  116330. * Creates a new AbstractMesh
  116331. * @param name defines the name of the mesh
  116332. * @param scene defines the hosting scene
  116333. */
  116334. constructor(name: string, scene?: Nullable<Scene>);
  116335. /**
  116336. * Returns the string "AbstractMesh"
  116337. * @returns "AbstractMesh"
  116338. */
  116339. getClassName(): string;
  116340. /**
  116341. * Gets a string representation of the current mesh
  116342. * @param fullDetails defines a boolean indicating if full details must be included
  116343. * @returns a string representation of the current mesh
  116344. */
  116345. toString(fullDetails?: boolean): string;
  116346. /**
  116347. * @hidden
  116348. */
  116349. protected _getEffectiveParent(): Nullable<Node>;
  116350. /** @hidden */
  116351. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  116352. /** @hidden */
  116353. _rebuild(): void;
  116354. /** @hidden */
  116355. _resyncLightSources(): void;
  116356. /** @hidden */
  116357. _resyncLightSource(light: Light): void;
  116358. /** @hidden */
  116359. _unBindEffect(): void;
  116360. /** @hidden */
  116361. _removeLightSource(light: Light, dispose: boolean): void;
  116362. private _markSubMeshesAsDirty;
  116363. /** @hidden */
  116364. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  116365. /** @hidden */
  116366. _markSubMeshesAsAttributesDirty(): void;
  116367. /** @hidden */
  116368. _markSubMeshesAsMiscDirty(): void;
  116369. /**
  116370. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  116371. */
  116372. get scaling(): Vector3;
  116373. set scaling(newScaling: Vector3);
  116374. /**
  116375. * Returns true if the mesh is blocked. Implemented by child classes
  116376. */
  116377. get isBlocked(): boolean;
  116378. /**
  116379. * Returns the mesh itself by default. Implemented by child classes
  116380. * @param camera defines the camera to use to pick the right LOD level
  116381. * @returns the currentAbstractMesh
  116382. */
  116383. getLOD(camera: Camera): Nullable<AbstractMesh>;
  116384. /**
  116385. * Returns 0 by default. Implemented by child classes
  116386. * @returns an integer
  116387. */
  116388. getTotalVertices(): number;
  116389. /**
  116390. * Returns a positive integer : the total number of indices in this mesh geometry.
  116391. * @returns the numner of indices or zero if the mesh has no geometry.
  116392. */
  116393. getTotalIndices(): number;
  116394. /**
  116395. * Returns null by default. Implemented by child classes
  116396. * @returns null
  116397. */
  116398. getIndices(): Nullable<IndicesArray>;
  116399. /**
  116400. * Returns the array of the requested vertex data kind. Implemented by child classes
  116401. * @param kind defines the vertex data kind to use
  116402. * @returns null
  116403. */
  116404. getVerticesData(kind: string): Nullable<FloatArray>;
  116405. /**
  116406. * Sets the vertex data of the mesh geometry for the requested `kind`.
  116407. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  116408. * Note that a new underlying VertexBuffer object is created each call.
  116409. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  116410. * @param kind defines vertex data kind:
  116411. * * VertexBuffer.PositionKind
  116412. * * VertexBuffer.UVKind
  116413. * * VertexBuffer.UV2Kind
  116414. * * VertexBuffer.UV3Kind
  116415. * * VertexBuffer.UV4Kind
  116416. * * VertexBuffer.UV5Kind
  116417. * * VertexBuffer.UV6Kind
  116418. * * VertexBuffer.ColorKind
  116419. * * VertexBuffer.MatricesIndicesKind
  116420. * * VertexBuffer.MatricesIndicesExtraKind
  116421. * * VertexBuffer.MatricesWeightsKind
  116422. * * VertexBuffer.MatricesWeightsExtraKind
  116423. * @param data defines the data source
  116424. * @param updatable defines if the data must be flagged as updatable (or static)
  116425. * @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
  116426. * @returns the current mesh
  116427. */
  116428. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  116429. /**
  116430. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  116431. * If the mesh has no geometry, it is simply returned as it is.
  116432. * @param kind defines vertex data kind:
  116433. * * VertexBuffer.PositionKind
  116434. * * VertexBuffer.UVKind
  116435. * * VertexBuffer.UV2Kind
  116436. * * VertexBuffer.UV3Kind
  116437. * * VertexBuffer.UV4Kind
  116438. * * VertexBuffer.UV5Kind
  116439. * * VertexBuffer.UV6Kind
  116440. * * VertexBuffer.ColorKind
  116441. * * VertexBuffer.MatricesIndicesKind
  116442. * * VertexBuffer.MatricesIndicesExtraKind
  116443. * * VertexBuffer.MatricesWeightsKind
  116444. * * VertexBuffer.MatricesWeightsExtraKind
  116445. * @param data defines the data source
  116446. * @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
  116447. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  116448. * @returns the current mesh
  116449. */
  116450. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  116451. /**
  116452. * Sets the mesh indices,
  116453. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  116454. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  116455. * @param totalVertices Defines the total number of vertices
  116456. * @returns the current mesh
  116457. */
  116458. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  116459. /**
  116460. * Gets a boolean indicating if specific vertex data is present
  116461. * @param kind defines the vertex data kind to use
  116462. * @returns true is data kind is present
  116463. */
  116464. isVerticesDataPresent(kind: string): boolean;
  116465. /**
  116466. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  116467. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  116468. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  116469. * @returns a BoundingInfo
  116470. */
  116471. getBoundingInfo(): BoundingInfo;
  116472. /**
  116473. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  116474. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  116475. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  116476. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  116477. * @returns the current mesh
  116478. */
  116479. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  116480. /**
  116481. * Overwrite the current bounding info
  116482. * @param boundingInfo defines the new bounding info
  116483. * @returns the current mesh
  116484. */
  116485. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  116486. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  116487. get useBones(): boolean;
  116488. /** @hidden */
  116489. _preActivate(): void;
  116490. /** @hidden */
  116491. _preActivateForIntermediateRendering(renderId: number): void;
  116492. /** @hidden */
  116493. _activate(renderId: number, intermediateRendering: boolean): boolean;
  116494. /** @hidden */
  116495. _postActivate(): void;
  116496. /** @hidden */
  116497. _freeze(): void;
  116498. /** @hidden */
  116499. _unFreeze(): void;
  116500. /**
  116501. * Gets the current world matrix
  116502. * @returns a Matrix
  116503. */
  116504. getWorldMatrix(): Matrix;
  116505. /** @hidden */
  116506. _getWorldMatrixDeterminant(): number;
  116507. /**
  116508. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  116509. */
  116510. get isAnInstance(): boolean;
  116511. /**
  116512. * Gets a boolean indicating if this mesh has instances
  116513. */
  116514. get hasInstances(): boolean;
  116515. /**
  116516. * Gets a boolean indicating if this mesh has thin instances
  116517. */
  116518. get hasThinInstances(): boolean;
  116519. /**
  116520. * Perform relative position change from the point of view of behind the front of the mesh.
  116521. * This is performed taking into account the meshes current rotation, so you do not have to care.
  116522. * Supports definition of mesh facing forward or backward
  116523. * @param amountRight defines the distance on the right axis
  116524. * @param amountUp defines the distance on the up axis
  116525. * @param amountForward defines the distance on the forward axis
  116526. * @returns the current mesh
  116527. */
  116528. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  116529. /**
  116530. * Calculate relative position change from the point of view of behind the front of the mesh.
  116531. * This is performed taking into account the meshes current rotation, so you do not have to care.
  116532. * Supports definition of mesh facing forward or backward
  116533. * @param amountRight defines the distance on the right axis
  116534. * @param amountUp defines the distance on the up axis
  116535. * @param amountForward defines the distance on the forward axis
  116536. * @returns the new displacement vector
  116537. */
  116538. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  116539. /**
  116540. * Perform relative rotation change from the point of view of behind the front of the mesh.
  116541. * Supports definition of mesh facing forward or backward
  116542. * @param flipBack defines the flip
  116543. * @param twirlClockwise defines the twirl
  116544. * @param tiltRight defines the tilt
  116545. * @returns the current mesh
  116546. */
  116547. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  116548. /**
  116549. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  116550. * Supports definition of mesh facing forward or backward.
  116551. * @param flipBack defines the flip
  116552. * @param twirlClockwise defines the twirl
  116553. * @param tiltRight defines the tilt
  116554. * @returns the new rotation vector
  116555. */
  116556. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  116557. /**
  116558. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  116559. * This means the mesh underlying bounding box and sphere are recomputed.
  116560. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  116561. * @returns the current mesh
  116562. */
  116563. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  116564. /** @hidden */
  116565. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  116566. /** @hidden */
  116567. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  116568. /** @hidden */
  116569. _updateBoundingInfo(): AbstractMesh;
  116570. /** @hidden */
  116571. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  116572. /** @hidden */
  116573. protected _afterComputeWorldMatrix(): void;
  116574. /** @hidden */
  116575. get _effectiveMesh(): AbstractMesh;
  116576. /**
  116577. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  116578. * A mesh is in the frustum if its bounding box intersects the frustum
  116579. * @param frustumPlanes defines the frustum to test
  116580. * @returns true if the mesh is in the frustum planes
  116581. */
  116582. isInFrustum(frustumPlanes: Plane[]): boolean;
  116583. /**
  116584. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  116585. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  116586. * @param frustumPlanes defines the frustum to test
  116587. * @returns true if the mesh is completely in the frustum planes
  116588. */
  116589. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  116590. /**
  116591. * True if the mesh intersects another mesh or a SolidParticle object
  116592. * @param mesh defines a target mesh or SolidParticle to test
  116593. * @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)
  116594. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  116595. * @returns true if there is an intersection
  116596. */
  116597. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  116598. /**
  116599. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  116600. * @param point defines the point to test
  116601. * @returns true if there is an intersection
  116602. */
  116603. intersectsPoint(point: Vector3): boolean;
  116604. /**
  116605. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  116606. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116607. */
  116608. get checkCollisions(): boolean;
  116609. set checkCollisions(collisionEnabled: boolean);
  116610. /**
  116611. * Gets Collider object used to compute collisions (not physics)
  116612. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116613. */
  116614. get collider(): Nullable<Collider>;
  116615. /**
  116616. * Move the mesh using collision engine
  116617. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116618. * @param displacement defines the requested displacement vector
  116619. * @returns the current mesh
  116620. */
  116621. moveWithCollisions(displacement: Vector3): AbstractMesh;
  116622. private _onCollisionPositionChange;
  116623. /** @hidden */
  116624. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  116625. /** @hidden */
  116626. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  116627. /** @hidden */
  116628. _checkCollision(collider: Collider): AbstractMesh;
  116629. /** @hidden */
  116630. _generatePointsArray(): boolean;
  116631. /**
  116632. * Checks if the passed Ray intersects with the mesh
  116633. * @param ray defines the ray to use
  116634. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  116635. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  116636. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  116637. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  116638. * @returns the picking info
  116639. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  116640. */
  116641. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  116642. /**
  116643. * Clones the current mesh
  116644. * @param name defines the mesh name
  116645. * @param newParent defines the new mesh parent
  116646. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  116647. * @returns the new mesh
  116648. */
  116649. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  116650. /**
  116651. * Disposes all the submeshes of the current meshnp
  116652. * @returns the current mesh
  116653. */
  116654. releaseSubMeshes(): AbstractMesh;
  116655. /**
  116656. * Releases resources associated with this abstract mesh.
  116657. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116658. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116659. */
  116660. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116661. /**
  116662. * Adds the passed mesh as a child to the current mesh
  116663. * @param mesh defines the child mesh
  116664. * @returns the current mesh
  116665. */
  116666. addChild(mesh: AbstractMesh): AbstractMesh;
  116667. /**
  116668. * Removes the passed mesh from the current mesh children list
  116669. * @param mesh defines the child mesh
  116670. * @returns the current mesh
  116671. */
  116672. removeChild(mesh: AbstractMesh): AbstractMesh;
  116673. /** @hidden */
  116674. private _initFacetData;
  116675. /**
  116676. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  116677. * This method can be called within the render loop.
  116678. * 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
  116679. * @returns the current mesh
  116680. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116681. */
  116682. updateFacetData(): AbstractMesh;
  116683. /**
  116684. * Returns the facetLocalNormals array.
  116685. * The normals are expressed in the mesh local spac
  116686. * @returns an array of Vector3
  116687. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116688. */
  116689. getFacetLocalNormals(): Vector3[];
  116690. /**
  116691. * Returns the facetLocalPositions array.
  116692. * The facet positions are expressed in the mesh local space
  116693. * @returns an array of Vector3
  116694. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116695. */
  116696. getFacetLocalPositions(): Vector3[];
  116697. /**
  116698. * Returns the facetLocalPartioning array
  116699. * @returns an array of array of numbers
  116700. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116701. */
  116702. getFacetLocalPartitioning(): number[][];
  116703. /**
  116704. * Returns the i-th facet position in the world system.
  116705. * This method allocates a new Vector3 per call
  116706. * @param i defines the facet index
  116707. * @returns a new Vector3
  116708. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116709. */
  116710. getFacetPosition(i: number): Vector3;
  116711. /**
  116712. * Sets the reference Vector3 with the i-th facet position in the world system
  116713. * @param i defines the facet index
  116714. * @param ref defines the target vector
  116715. * @returns the current mesh
  116716. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116717. */
  116718. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  116719. /**
  116720. * Returns the i-th facet normal in the world system.
  116721. * This method allocates a new Vector3 per call
  116722. * @param i defines the facet index
  116723. * @returns a new Vector3
  116724. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116725. */
  116726. getFacetNormal(i: number): Vector3;
  116727. /**
  116728. * Sets the reference Vector3 with the i-th facet normal in the world system
  116729. * @param i defines the facet index
  116730. * @param ref defines the target vector
  116731. * @returns the current mesh
  116732. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116733. */
  116734. getFacetNormalToRef(i: number, ref: Vector3): this;
  116735. /**
  116736. * 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)
  116737. * @param x defines x coordinate
  116738. * @param y defines y coordinate
  116739. * @param z defines z coordinate
  116740. * @returns the array of facet indexes
  116741. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116742. */
  116743. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  116744. /**
  116745. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  116746. * @param projected sets as the (x,y,z) world projection on the facet
  116747. * @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
  116748. * @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
  116749. * @param x defines x coordinate
  116750. * @param y defines y coordinate
  116751. * @param z defines z coordinate
  116752. * @returns the face index if found (or null instead)
  116753. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116754. */
  116755. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  116756. /**
  116757. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  116758. * @param projected sets as the (x,y,z) local projection on the facet
  116759. * @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
  116760. * @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
  116761. * @param x defines x coordinate
  116762. * @param y defines y coordinate
  116763. * @param z defines z coordinate
  116764. * @returns the face index if found (or null instead)
  116765. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116766. */
  116767. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  116768. /**
  116769. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  116770. * @returns the parameters
  116771. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116772. */
  116773. getFacetDataParameters(): any;
  116774. /**
  116775. * Disables the feature FacetData and frees the related memory
  116776. * @returns the current mesh
  116777. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116778. */
  116779. disableFacetData(): AbstractMesh;
  116780. /**
  116781. * Updates the AbstractMesh indices array
  116782. * @param indices defines the data source
  116783. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  116784. * @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)
  116785. * @returns the current mesh
  116786. */
  116787. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  116788. /**
  116789. * Creates new normals data for the mesh
  116790. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  116791. * @returns the current mesh
  116792. */
  116793. createNormals(updatable: boolean): AbstractMesh;
  116794. /**
  116795. * Align the mesh with a normal
  116796. * @param normal defines the normal to use
  116797. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  116798. * @returns the current mesh
  116799. */
  116800. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  116801. /** @hidden */
  116802. _checkOcclusionQuery(): boolean;
  116803. /**
  116804. * Disables the mesh edge rendering mode
  116805. * @returns the currentAbstractMesh
  116806. */
  116807. disableEdgesRendering(): AbstractMesh;
  116808. /**
  116809. * Enables the edge rendering mode on the mesh.
  116810. * This mode makes the mesh edges visible
  116811. * @param epsilon defines the maximal distance between two angles to detect a face
  116812. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  116813. * @returns the currentAbstractMesh
  116814. * @see https://www.babylonjs-playground.com/#19O9TU#0
  116815. */
  116816. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  116817. /**
  116818. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  116819. * @returns an array of particle systems in the scene that use the mesh as an emitter
  116820. */
  116821. getConnectedParticleSystems(): IParticleSystem[];
  116822. }
  116823. }
  116824. declare module BABYLON {
  116825. /**
  116826. * Interface used to define ActionEvent
  116827. */
  116828. export interface IActionEvent {
  116829. /** The mesh or sprite that triggered the action */
  116830. source: any;
  116831. /** The X mouse cursor position at the time of the event */
  116832. pointerX: number;
  116833. /** The Y mouse cursor position at the time of the event */
  116834. pointerY: number;
  116835. /** The mesh that is currently pointed at (can be null) */
  116836. meshUnderPointer: Nullable<AbstractMesh>;
  116837. /** the original (browser) event that triggered the ActionEvent */
  116838. sourceEvent?: any;
  116839. /** additional data for the event */
  116840. additionalData?: any;
  116841. }
  116842. /**
  116843. * ActionEvent is the event being sent when an action is triggered.
  116844. */
  116845. export class ActionEvent implements IActionEvent {
  116846. /** The mesh or sprite that triggered the action */
  116847. source: any;
  116848. /** The X mouse cursor position at the time of the event */
  116849. pointerX: number;
  116850. /** The Y mouse cursor position at the time of the event */
  116851. pointerY: number;
  116852. /** The mesh that is currently pointed at (can be null) */
  116853. meshUnderPointer: Nullable<AbstractMesh>;
  116854. /** the original (browser) event that triggered the ActionEvent */
  116855. sourceEvent?: any;
  116856. /** additional data for the event */
  116857. additionalData?: any;
  116858. /**
  116859. * Creates a new ActionEvent
  116860. * @param source The mesh or sprite that triggered the action
  116861. * @param pointerX The X mouse cursor position at the time of the event
  116862. * @param pointerY The Y mouse cursor position at the time of the event
  116863. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  116864. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  116865. * @param additionalData additional data for the event
  116866. */
  116867. constructor(
  116868. /** The mesh or sprite that triggered the action */
  116869. source: any,
  116870. /** The X mouse cursor position at the time of the event */
  116871. pointerX: number,
  116872. /** The Y mouse cursor position at the time of the event */
  116873. pointerY: number,
  116874. /** The mesh that is currently pointed at (can be null) */
  116875. meshUnderPointer: Nullable<AbstractMesh>,
  116876. /** the original (browser) event that triggered the ActionEvent */
  116877. sourceEvent?: any,
  116878. /** additional data for the event */
  116879. additionalData?: any);
  116880. /**
  116881. * Helper function to auto-create an ActionEvent from a source mesh.
  116882. * @param source The source mesh that triggered the event
  116883. * @param evt The original (browser) event
  116884. * @param additionalData additional data for the event
  116885. * @returns the new ActionEvent
  116886. */
  116887. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  116888. /**
  116889. * Helper function to auto-create an ActionEvent from a source sprite
  116890. * @param source The source sprite that triggered the event
  116891. * @param scene Scene associated with the sprite
  116892. * @param evt The original (browser) event
  116893. * @param additionalData additional data for the event
  116894. * @returns the new ActionEvent
  116895. */
  116896. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  116897. /**
  116898. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  116899. * @param scene the scene where the event occurred
  116900. * @param evt The original (browser) event
  116901. * @returns the new ActionEvent
  116902. */
  116903. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  116904. /**
  116905. * Helper function to auto-create an ActionEvent from a primitive
  116906. * @param prim defines the target primitive
  116907. * @param pointerPos defines the pointer position
  116908. * @param evt The original (browser) event
  116909. * @param additionalData additional data for the event
  116910. * @returns the new ActionEvent
  116911. */
  116912. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  116913. }
  116914. }
  116915. declare module BABYLON {
  116916. /**
  116917. * Abstract class used to decouple action Manager from scene and meshes.
  116918. * Do not instantiate.
  116919. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116920. */
  116921. export abstract class AbstractActionManager implements IDisposable {
  116922. /** Gets the list of active triggers */
  116923. static Triggers: {
  116924. [key: string]: number;
  116925. };
  116926. /** Gets the cursor to use when hovering items */
  116927. hoverCursor: string;
  116928. /** Gets the list of actions */
  116929. actions: IAction[];
  116930. /**
  116931. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  116932. */
  116933. isRecursive: boolean;
  116934. /**
  116935. * Releases all associated resources
  116936. */
  116937. abstract dispose(): void;
  116938. /**
  116939. * Does this action manager has pointer triggers
  116940. */
  116941. abstract get hasPointerTriggers(): boolean;
  116942. /**
  116943. * Does this action manager has pick triggers
  116944. */
  116945. abstract get hasPickTriggers(): boolean;
  116946. /**
  116947. * Process a specific trigger
  116948. * @param trigger defines the trigger to process
  116949. * @param evt defines the event details to be processed
  116950. */
  116951. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  116952. /**
  116953. * Does this action manager handles actions of any of the given triggers
  116954. * @param triggers defines the triggers to be tested
  116955. * @return a boolean indicating whether one (or more) of the triggers is handled
  116956. */
  116957. abstract hasSpecificTriggers(triggers: number[]): boolean;
  116958. /**
  116959. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  116960. * speed.
  116961. * @param triggerA defines the trigger to be tested
  116962. * @param triggerB defines the trigger to be tested
  116963. * @return a boolean indicating whether one (or more) of the triggers is handled
  116964. */
  116965. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  116966. /**
  116967. * Does this action manager handles actions of a given trigger
  116968. * @param trigger defines the trigger to be tested
  116969. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  116970. * @return whether the trigger is handled
  116971. */
  116972. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  116973. /**
  116974. * Serialize this manager to a JSON object
  116975. * @param name defines the property name to store this manager
  116976. * @returns a JSON representation of this manager
  116977. */
  116978. abstract serialize(name: string): any;
  116979. /**
  116980. * Registers an action to this action manager
  116981. * @param action defines the action to be registered
  116982. * @return the action amended (prepared) after registration
  116983. */
  116984. abstract registerAction(action: IAction): Nullable<IAction>;
  116985. /**
  116986. * Unregisters an action to this action manager
  116987. * @param action defines the action to be unregistered
  116988. * @return a boolean indicating whether the action has been unregistered
  116989. */
  116990. abstract unregisterAction(action: IAction): Boolean;
  116991. /**
  116992. * Does exist one action manager with at least one trigger
  116993. **/
  116994. static get HasTriggers(): boolean;
  116995. /**
  116996. * Does exist one action manager with at least one pick trigger
  116997. **/
  116998. static get HasPickTriggers(): boolean;
  116999. /**
  117000. * Does exist one action manager that handles actions of a given trigger
  117001. * @param trigger defines the trigger to be tested
  117002. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  117003. **/
  117004. static HasSpecificTrigger(trigger: number): boolean;
  117005. }
  117006. }
  117007. declare module BABYLON {
  117008. /**
  117009. * Defines how a node can be built from a string name.
  117010. */
  117011. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  117012. /**
  117013. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  117014. */
  117015. export class Node implements IBehaviorAware<Node> {
  117016. /** @hidden */
  117017. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  117018. private static _NodeConstructors;
  117019. /**
  117020. * Add a new node constructor
  117021. * @param type defines the type name of the node to construct
  117022. * @param constructorFunc defines the constructor function
  117023. */
  117024. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  117025. /**
  117026. * Returns a node constructor based on type name
  117027. * @param type defines the type name
  117028. * @param name defines the new node name
  117029. * @param scene defines the hosting scene
  117030. * @param options defines optional options to transmit to constructors
  117031. * @returns the new constructor or null
  117032. */
  117033. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  117034. /**
  117035. * Gets or sets the name of the node
  117036. */
  117037. name: string;
  117038. /**
  117039. * Gets or sets the id of the node
  117040. */
  117041. id: string;
  117042. /**
  117043. * Gets or sets the unique id of the node
  117044. */
  117045. uniqueId: number;
  117046. /**
  117047. * Gets or sets a string used to store user defined state for the node
  117048. */
  117049. state: string;
  117050. /**
  117051. * Gets or sets an object used to store user defined information for the node
  117052. */
  117053. metadata: any;
  117054. /**
  117055. * For internal use only. Please do not use.
  117056. */
  117057. reservedDataStore: any;
  117058. /**
  117059. * List of inspectable custom properties (used by the Inspector)
  117060. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  117061. */
  117062. inspectableCustomProperties: IInspectable[];
  117063. private _doNotSerialize;
  117064. /**
  117065. * Gets or sets a boolean used to define if the node must be serialized
  117066. */
  117067. get doNotSerialize(): boolean;
  117068. set doNotSerialize(value: boolean);
  117069. /** @hidden */
  117070. _isDisposed: boolean;
  117071. /**
  117072. * Gets a list of Animations associated with the node
  117073. */
  117074. animations: Animation[];
  117075. protected _ranges: {
  117076. [name: string]: Nullable<AnimationRange>;
  117077. };
  117078. /**
  117079. * Callback raised when the node is ready to be used
  117080. */
  117081. onReady: Nullable<(node: Node) => void>;
  117082. private _isEnabled;
  117083. private _isParentEnabled;
  117084. private _isReady;
  117085. /** @hidden */
  117086. _currentRenderId: number;
  117087. private _parentUpdateId;
  117088. /** @hidden */
  117089. _childUpdateId: number;
  117090. /** @hidden */
  117091. _waitingParentId: Nullable<string>;
  117092. /** @hidden */
  117093. _scene: Scene;
  117094. /** @hidden */
  117095. _cache: any;
  117096. private _parentNode;
  117097. private _children;
  117098. /** @hidden */
  117099. _worldMatrix: Matrix;
  117100. /** @hidden */
  117101. _worldMatrixDeterminant: number;
  117102. /** @hidden */
  117103. _worldMatrixDeterminantIsDirty: boolean;
  117104. /** @hidden */
  117105. private _sceneRootNodesIndex;
  117106. /**
  117107. * Gets a boolean indicating if the node has been disposed
  117108. * @returns true if the node was disposed
  117109. */
  117110. isDisposed(): boolean;
  117111. /**
  117112. * Gets or sets the parent of the node (without keeping the current position in the scene)
  117113. * @see https://doc.babylonjs.com/how_to/parenting
  117114. */
  117115. set parent(parent: Nullable<Node>);
  117116. get parent(): Nullable<Node>;
  117117. /** @hidden */
  117118. _addToSceneRootNodes(): void;
  117119. /** @hidden */
  117120. _removeFromSceneRootNodes(): void;
  117121. private _animationPropertiesOverride;
  117122. /**
  117123. * Gets or sets the animation properties override
  117124. */
  117125. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  117126. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  117127. /**
  117128. * Gets a string identifying the name of the class
  117129. * @returns "Node" string
  117130. */
  117131. getClassName(): string;
  117132. /** @hidden */
  117133. readonly _isNode: boolean;
  117134. /**
  117135. * An event triggered when the mesh is disposed
  117136. */
  117137. onDisposeObservable: Observable<Node>;
  117138. private _onDisposeObserver;
  117139. /**
  117140. * Sets a callback that will be raised when the node will be disposed
  117141. */
  117142. set onDispose(callback: () => void);
  117143. /**
  117144. * Creates a new Node
  117145. * @param name the name and id to be given to this node
  117146. * @param scene the scene this node will be added to
  117147. */
  117148. constructor(name: string, scene?: Nullable<Scene>);
  117149. /**
  117150. * Gets the scene of the node
  117151. * @returns a scene
  117152. */
  117153. getScene(): Scene;
  117154. /**
  117155. * Gets the engine of the node
  117156. * @returns a Engine
  117157. */
  117158. getEngine(): Engine;
  117159. private _behaviors;
  117160. /**
  117161. * Attach a behavior to the node
  117162. * @see https://doc.babylonjs.com/features/behaviour
  117163. * @param behavior defines the behavior to attach
  117164. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  117165. * @returns the current Node
  117166. */
  117167. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  117168. /**
  117169. * Remove an attached behavior
  117170. * @see https://doc.babylonjs.com/features/behaviour
  117171. * @param behavior defines the behavior to attach
  117172. * @returns the current Node
  117173. */
  117174. removeBehavior(behavior: Behavior<Node>): Node;
  117175. /**
  117176. * Gets the list of attached behaviors
  117177. * @see https://doc.babylonjs.com/features/behaviour
  117178. */
  117179. get behaviors(): Behavior<Node>[];
  117180. /**
  117181. * Gets an attached behavior by name
  117182. * @param name defines the name of the behavior to look for
  117183. * @see https://doc.babylonjs.com/features/behaviour
  117184. * @returns null if behavior was not found else the requested behavior
  117185. */
  117186. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  117187. /**
  117188. * Returns the latest update of the World matrix
  117189. * @returns a Matrix
  117190. */
  117191. getWorldMatrix(): Matrix;
  117192. /** @hidden */
  117193. _getWorldMatrixDeterminant(): number;
  117194. /**
  117195. * Returns directly the latest state of the mesh World matrix.
  117196. * A Matrix is returned.
  117197. */
  117198. get worldMatrixFromCache(): Matrix;
  117199. /** @hidden */
  117200. _initCache(): void;
  117201. /** @hidden */
  117202. updateCache(force?: boolean): void;
  117203. /** @hidden */
  117204. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  117205. /** @hidden */
  117206. _updateCache(ignoreParentClass?: boolean): void;
  117207. /** @hidden */
  117208. _isSynchronized(): boolean;
  117209. /** @hidden */
  117210. _markSyncedWithParent(): void;
  117211. /** @hidden */
  117212. isSynchronizedWithParent(): boolean;
  117213. /** @hidden */
  117214. isSynchronized(): boolean;
  117215. /**
  117216. * Is this node ready to be used/rendered
  117217. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  117218. * @return true if the node is ready
  117219. */
  117220. isReady(completeCheck?: boolean): boolean;
  117221. /**
  117222. * Is this node enabled?
  117223. * 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
  117224. * @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
  117225. * @return whether this node (and its parent) is enabled
  117226. */
  117227. isEnabled(checkAncestors?: boolean): boolean;
  117228. /** @hidden */
  117229. protected _syncParentEnabledState(): void;
  117230. /**
  117231. * Set the enabled state of this node
  117232. * @param value defines the new enabled state
  117233. */
  117234. setEnabled(value: boolean): void;
  117235. /**
  117236. * Is this node a descendant of the given node?
  117237. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  117238. * @param ancestor defines the parent node to inspect
  117239. * @returns a boolean indicating if this node is a descendant of the given node
  117240. */
  117241. isDescendantOf(ancestor: Node): boolean;
  117242. /** @hidden */
  117243. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  117244. /**
  117245. * Will return all nodes that have this node as ascendant
  117246. * @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
  117247. * @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
  117248. * @return all children nodes of all types
  117249. */
  117250. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  117251. /**
  117252. * Get all child-meshes of this node
  117253. * @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)
  117254. * @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
  117255. * @returns an array of AbstractMesh
  117256. */
  117257. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  117258. /**
  117259. * Get all direct children of this node
  117260. * @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
  117261. * @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)
  117262. * @returns an array of Node
  117263. */
  117264. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  117265. /** @hidden */
  117266. _setReady(state: boolean): void;
  117267. /**
  117268. * Get an animation by name
  117269. * @param name defines the name of the animation to look for
  117270. * @returns null if not found else the requested animation
  117271. */
  117272. getAnimationByName(name: string): Nullable<Animation>;
  117273. /**
  117274. * Creates an animation range for this node
  117275. * @param name defines the name of the range
  117276. * @param from defines the starting key
  117277. * @param to defines the end key
  117278. */
  117279. createAnimationRange(name: string, from: number, to: number): void;
  117280. /**
  117281. * Delete a specific animation range
  117282. * @param name defines the name of the range to delete
  117283. * @param deleteFrames defines if animation frames from the range must be deleted as well
  117284. */
  117285. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  117286. /**
  117287. * Get an animation range by name
  117288. * @param name defines the name of the animation range to look for
  117289. * @returns null if not found else the requested animation range
  117290. */
  117291. getAnimationRange(name: string): Nullable<AnimationRange>;
  117292. /**
  117293. * Gets the list of all animation ranges defined on this node
  117294. * @returns an array
  117295. */
  117296. getAnimationRanges(): Nullable<AnimationRange>[];
  117297. /**
  117298. * Will start the animation sequence
  117299. * @param name defines the range frames for animation sequence
  117300. * @param loop defines if the animation should loop (false by default)
  117301. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  117302. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  117303. * @returns the object created for this animation. If range does not exist, it will return null
  117304. */
  117305. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  117306. /**
  117307. * Serialize animation ranges into a JSON compatible object
  117308. * @returns serialization object
  117309. */
  117310. serializeAnimationRanges(): any;
  117311. /**
  117312. * Computes the world matrix of the node
  117313. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  117314. * @returns the world matrix
  117315. */
  117316. computeWorldMatrix(force?: boolean): Matrix;
  117317. /**
  117318. * Releases resources associated with this node.
  117319. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117320. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117321. */
  117322. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117323. /**
  117324. * Parse animation range data from a serialization object and store them into a given node
  117325. * @param node defines where to store the animation ranges
  117326. * @param parsedNode defines the serialization object to read data from
  117327. * @param scene defines the hosting scene
  117328. */
  117329. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  117330. /**
  117331. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  117332. * @param includeDescendants Include bounding info from descendants as well (true by default)
  117333. * @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
  117334. * @returns the new bounding vectors
  117335. */
  117336. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  117337. min: Vector3;
  117338. max: Vector3;
  117339. };
  117340. }
  117341. }
  117342. declare module BABYLON {
  117343. /**
  117344. * @hidden
  117345. */
  117346. export class _IAnimationState {
  117347. key: number;
  117348. repeatCount: number;
  117349. workValue?: any;
  117350. loopMode?: number;
  117351. offsetValue?: any;
  117352. highLimitValue?: any;
  117353. }
  117354. /**
  117355. * Class used to store any kind of animation
  117356. */
  117357. export class Animation {
  117358. /**Name of the animation */
  117359. name: string;
  117360. /**Property to animate */
  117361. targetProperty: string;
  117362. /**The frames per second of the animation */
  117363. framePerSecond: number;
  117364. /**The data type of the animation */
  117365. dataType: number;
  117366. /**The loop mode of the animation */
  117367. loopMode?: number | undefined;
  117368. /**Specifies if blending should be enabled */
  117369. enableBlending?: boolean | undefined;
  117370. /**
  117371. * Use matrix interpolation instead of using direct key value when animating matrices
  117372. */
  117373. static AllowMatricesInterpolation: boolean;
  117374. /**
  117375. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  117376. */
  117377. static AllowMatrixDecomposeForInterpolation: boolean;
  117378. /** Define the Url to load snippets */
  117379. static SnippetUrl: string;
  117380. /** Snippet ID if the animation was created from the snippet server */
  117381. snippetId: string;
  117382. /**
  117383. * Stores the key frames of the animation
  117384. */
  117385. private _keys;
  117386. /**
  117387. * Stores the easing function of the animation
  117388. */
  117389. private _easingFunction;
  117390. /**
  117391. * @hidden Internal use only
  117392. */
  117393. _runtimeAnimations: RuntimeAnimation[];
  117394. /**
  117395. * The set of event that will be linked to this animation
  117396. */
  117397. private _events;
  117398. /**
  117399. * Stores an array of target property paths
  117400. */
  117401. targetPropertyPath: string[];
  117402. /**
  117403. * Stores the blending speed of the animation
  117404. */
  117405. blendingSpeed: number;
  117406. /**
  117407. * Stores the animation ranges for the animation
  117408. */
  117409. private _ranges;
  117410. /**
  117411. * @hidden Internal use
  117412. */
  117413. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  117414. /**
  117415. * Sets up an animation
  117416. * @param property The property to animate
  117417. * @param animationType The animation type to apply
  117418. * @param framePerSecond The frames per second of the animation
  117419. * @param easingFunction The easing function used in the animation
  117420. * @returns The created animation
  117421. */
  117422. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  117423. /**
  117424. * Create and start an animation on a node
  117425. * @param name defines the name of the global animation that will be run on all nodes
  117426. * @param node defines the root node where the animation will take place
  117427. * @param targetProperty defines property to animate
  117428. * @param framePerSecond defines the number of frame per second yo use
  117429. * @param totalFrame defines the number of frames in total
  117430. * @param from defines the initial value
  117431. * @param to defines the final value
  117432. * @param loopMode defines which loop mode you want to use (off by default)
  117433. * @param easingFunction defines the easing function to use (linear by default)
  117434. * @param onAnimationEnd defines the callback to call when animation end
  117435. * @returns the animatable created for this animation
  117436. */
  117437. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  117438. /**
  117439. * Create and start an animation on a node and its descendants
  117440. * @param name defines the name of the global animation that will be run on all nodes
  117441. * @param node defines the root node where the animation will take place
  117442. * @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
  117443. * @param targetProperty defines property to animate
  117444. * @param framePerSecond defines the number of frame per second to use
  117445. * @param totalFrame defines the number of frames in total
  117446. * @param from defines the initial value
  117447. * @param to defines the final value
  117448. * @param loopMode defines which loop mode you want to use (off by default)
  117449. * @param easingFunction defines the easing function to use (linear by default)
  117450. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  117451. * @returns the list of animatables created for all nodes
  117452. * @example https://www.babylonjs-playground.com/#MH0VLI
  117453. */
  117454. 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[]>;
  117455. /**
  117456. * Creates a new animation, merges it with the existing animations and starts it
  117457. * @param name Name of the animation
  117458. * @param node Node which contains the scene that begins the animations
  117459. * @param targetProperty Specifies which property to animate
  117460. * @param framePerSecond The frames per second of the animation
  117461. * @param totalFrame The total number of frames
  117462. * @param from The frame at the beginning of the animation
  117463. * @param to The frame at the end of the animation
  117464. * @param loopMode Specifies the loop mode of the animation
  117465. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  117466. * @param onAnimationEnd Callback to run once the animation is complete
  117467. * @returns Nullable animation
  117468. */
  117469. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  117470. /**
  117471. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  117472. * @param sourceAnimation defines the Animation containing keyframes to convert
  117473. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  117474. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  117475. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  117476. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  117477. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  117478. */
  117479. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  117480. /**
  117481. * Transition property of an host to the target Value
  117482. * @param property The property to transition
  117483. * @param targetValue The target Value of the property
  117484. * @param host The object where the property to animate belongs
  117485. * @param scene Scene used to run the animation
  117486. * @param frameRate Framerate (in frame/s) to use
  117487. * @param transition The transition type we want to use
  117488. * @param duration The duration of the animation, in milliseconds
  117489. * @param onAnimationEnd Callback trigger at the end of the animation
  117490. * @returns Nullable animation
  117491. */
  117492. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  117493. /**
  117494. * Return the array of runtime animations currently using this animation
  117495. */
  117496. get runtimeAnimations(): RuntimeAnimation[];
  117497. /**
  117498. * Specifies if any of the runtime animations are currently running
  117499. */
  117500. get hasRunningRuntimeAnimations(): boolean;
  117501. /**
  117502. * Initializes the animation
  117503. * @param name Name of the animation
  117504. * @param targetProperty Property to animate
  117505. * @param framePerSecond The frames per second of the animation
  117506. * @param dataType The data type of the animation
  117507. * @param loopMode The loop mode of the animation
  117508. * @param enableBlending Specifies if blending should be enabled
  117509. */
  117510. constructor(
  117511. /**Name of the animation */
  117512. name: string,
  117513. /**Property to animate */
  117514. targetProperty: string,
  117515. /**The frames per second of the animation */
  117516. framePerSecond: number,
  117517. /**The data type of the animation */
  117518. dataType: number,
  117519. /**The loop mode of the animation */
  117520. loopMode?: number | undefined,
  117521. /**Specifies if blending should be enabled */
  117522. enableBlending?: boolean | undefined);
  117523. /**
  117524. * Converts the animation to a string
  117525. * @param fullDetails support for multiple levels of logging within scene loading
  117526. * @returns String form of the animation
  117527. */
  117528. toString(fullDetails?: boolean): string;
  117529. /**
  117530. * Add an event to this animation
  117531. * @param event Event to add
  117532. */
  117533. addEvent(event: AnimationEvent): void;
  117534. /**
  117535. * Remove all events found at the given frame
  117536. * @param frame The frame to remove events from
  117537. */
  117538. removeEvents(frame: number): void;
  117539. /**
  117540. * Retrieves all the events from the animation
  117541. * @returns Events from the animation
  117542. */
  117543. getEvents(): AnimationEvent[];
  117544. /**
  117545. * Creates an animation range
  117546. * @param name Name of the animation range
  117547. * @param from Starting frame of the animation range
  117548. * @param to Ending frame of the animation
  117549. */
  117550. createRange(name: string, from: number, to: number): void;
  117551. /**
  117552. * Deletes an animation range by name
  117553. * @param name Name of the animation range to delete
  117554. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  117555. */
  117556. deleteRange(name: string, deleteFrames?: boolean): void;
  117557. /**
  117558. * Gets the animation range by name, or null if not defined
  117559. * @param name Name of the animation range
  117560. * @returns Nullable animation range
  117561. */
  117562. getRange(name: string): Nullable<AnimationRange>;
  117563. /**
  117564. * Gets the key frames from the animation
  117565. * @returns The key frames of the animation
  117566. */
  117567. getKeys(): Array<IAnimationKey>;
  117568. /**
  117569. * Gets the highest frame rate of the animation
  117570. * @returns Highest frame rate of the animation
  117571. */
  117572. getHighestFrame(): number;
  117573. /**
  117574. * Gets the easing function of the animation
  117575. * @returns Easing function of the animation
  117576. */
  117577. getEasingFunction(): IEasingFunction;
  117578. /**
  117579. * Sets the easing function of the animation
  117580. * @param easingFunction A custom mathematical formula for animation
  117581. */
  117582. setEasingFunction(easingFunction: EasingFunction): void;
  117583. /**
  117584. * Interpolates a scalar linearly
  117585. * @param startValue Start value of the animation curve
  117586. * @param endValue End value of the animation curve
  117587. * @param gradient Scalar amount to interpolate
  117588. * @returns Interpolated scalar value
  117589. */
  117590. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  117591. /**
  117592. * Interpolates a scalar cubically
  117593. * @param startValue Start value of the animation curve
  117594. * @param outTangent End tangent of the animation
  117595. * @param endValue End value of the animation curve
  117596. * @param inTangent Start tangent of the animation curve
  117597. * @param gradient Scalar amount to interpolate
  117598. * @returns Interpolated scalar value
  117599. */
  117600. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  117601. /**
  117602. * Interpolates a quaternion using a spherical linear interpolation
  117603. * @param startValue Start value of the animation curve
  117604. * @param endValue End value of the animation curve
  117605. * @param gradient Scalar amount to interpolate
  117606. * @returns Interpolated quaternion value
  117607. */
  117608. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  117609. /**
  117610. * Interpolates a quaternion cubically
  117611. * @param startValue Start value of the animation curve
  117612. * @param outTangent End tangent of the animation curve
  117613. * @param endValue End value of the animation curve
  117614. * @param inTangent Start tangent of the animation curve
  117615. * @param gradient Scalar amount to interpolate
  117616. * @returns Interpolated quaternion value
  117617. */
  117618. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  117619. /**
  117620. * Interpolates a Vector3 linearl
  117621. * @param startValue Start value of the animation curve
  117622. * @param endValue End value of the animation curve
  117623. * @param gradient Scalar amount to interpolate
  117624. * @returns Interpolated scalar value
  117625. */
  117626. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  117627. /**
  117628. * Interpolates a Vector3 cubically
  117629. * @param startValue Start value of the animation curve
  117630. * @param outTangent End tangent of the animation
  117631. * @param endValue End value of the animation curve
  117632. * @param inTangent Start tangent of the animation curve
  117633. * @param gradient Scalar amount to interpolate
  117634. * @returns InterpolatedVector3 value
  117635. */
  117636. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  117637. /**
  117638. * Interpolates a Vector2 linearly
  117639. * @param startValue Start value of the animation curve
  117640. * @param endValue End value of the animation curve
  117641. * @param gradient Scalar amount to interpolate
  117642. * @returns Interpolated Vector2 value
  117643. */
  117644. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  117645. /**
  117646. * Interpolates a Vector2 cubically
  117647. * @param startValue Start value of the animation curve
  117648. * @param outTangent End tangent of the animation
  117649. * @param endValue End value of the animation curve
  117650. * @param inTangent Start tangent of the animation curve
  117651. * @param gradient Scalar amount to interpolate
  117652. * @returns Interpolated Vector2 value
  117653. */
  117654. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  117655. /**
  117656. * Interpolates a size linearly
  117657. * @param startValue Start value of the animation curve
  117658. * @param endValue End value of the animation curve
  117659. * @param gradient Scalar amount to interpolate
  117660. * @returns Interpolated Size value
  117661. */
  117662. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  117663. /**
  117664. * Interpolates a Color3 linearly
  117665. * @param startValue Start value of the animation curve
  117666. * @param endValue End value of the animation curve
  117667. * @param gradient Scalar amount to interpolate
  117668. * @returns Interpolated Color3 value
  117669. */
  117670. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  117671. /**
  117672. * Interpolates a Color4 linearly
  117673. * @param startValue Start value of the animation curve
  117674. * @param endValue End value of the animation curve
  117675. * @param gradient Scalar amount to interpolate
  117676. * @returns Interpolated Color3 value
  117677. */
  117678. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  117679. /**
  117680. * @hidden Internal use only
  117681. */
  117682. _getKeyValue(value: any): any;
  117683. /**
  117684. * @hidden Internal use only
  117685. */
  117686. _interpolate(currentFrame: number, state: _IAnimationState): any;
  117687. /**
  117688. * Defines the function to use to interpolate matrices
  117689. * @param startValue defines the start matrix
  117690. * @param endValue defines the end matrix
  117691. * @param gradient defines the gradient between both matrices
  117692. * @param result defines an optional target matrix where to store the interpolation
  117693. * @returns the interpolated matrix
  117694. */
  117695. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  117696. /**
  117697. * Makes a copy of the animation
  117698. * @returns Cloned animation
  117699. */
  117700. clone(): Animation;
  117701. /**
  117702. * Sets the key frames of the animation
  117703. * @param values The animation key frames to set
  117704. */
  117705. setKeys(values: Array<IAnimationKey>): void;
  117706. /**
  117707. * Serializes the animation to an object
  117708. * @returns Serialized object
  117709. */
  117710. serialize(): any;
  117711. /**
  117712. * Float animation type
  117713. */
  117714. static readonly ANIMATIONTYPE_FLOAT: number;
  117715. /**
  117716. * Vector3 animation type
  117717. */
  117718. static readonly ANIMATIONTYPE_VECTOR3: number;
  117719. /**
  117720. * Quaternion animation type
  117721. */
  117722. static readonly ANIMATIONTYPE_QUATERNION: number;
  117723. /**
  117724. * Matrix animation type
  117725. */
  117726. static readonly ANIMATIONTYPE_MATRIX: number;
  117727. /**
  117728. * Color3 animation type
  117729. */
  117730. static readonly ANIMATIONTYPE_COLOR3: number;
  117731. /**
  117732. * Color3 animation type
  117733. */
  117734. static readonly ANIMATIONTYPE_COLOR4: number;
  117735. /**
  117736. * Vector2 animation type
  117737. */
  117738. static readonly ANIMATIONTYPE_VECTOR2: number;
  117739. /**
  117740. * Size animation type
  117741. */
  117742. static readonly ANIMATIONTYPE_SIZE: number;
  117743. /**
  117744. * Relative Loop Mode
  117745. */
  117746. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  117747. /**
  117748. * Cycle Loop Mode
  117749. */
  117750. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  117751. /**
  117752. * Constant Loop Mode
  117753. */
  117754. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  117755. /** @hidden */
  117756. static _UniversalLerp(left: any, right: any, amount: number): any;
  117757. /**
  117758. * Parses an animation object and creates an animation
  117759. * @param parsedAnimation Parsed animation object
  117760. * @returns Animation object
  117761. */
  117762. static Parse(parsedAnimation: any): Animation;
  117763. /**
  117764. * Appends the serialized animations from the source animations
  117765. * @param source Source containing the animations
  117766. * @param destination Target to store the animations
  117767. */
  117768. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  117769. /**
  117770. * Creates a new animation or an array of animations from a snippet saved in a remote file
  117771. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  117772. * @param url defines the url to load from
  117773. * @returns a promise that will resolve to the new animation or an array of animations
  117774. */
  117775. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  117776. /**
  117777. * Creates an animation or an array of animations from a snippet saved by the Inspector
  117778. * @param snippetId defines the snippet to load
  117779. * @returns a promise that will resolve to the new animation or a new array of animations
  117780. */
  117781. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  117782. }
  117783. }
  117784. declare module BABYLON {
  117785. /**
  117786. * Interface containing an array of animations
  117787. */
  117788. export interface IAnimatable {
  117789. /**
  117790. * Array of animations
  117791. */
  117792. animations: Nullable<Array<Animation>>;
  117793. }
  117794. }
  117795. declare module BABYLON {
  117796. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  117797. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117798. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117799. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117800. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117801. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117802. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117803. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117804. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117805. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117806. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117807. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117808. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117809. /**
  117810. * Decorator used to define property that can be serialized as reference to a camera
  117811. * @param sourceName defines the name of the property to decorate
  117812. */
  117813. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117814. /**
  117815. * Class used to help serialization objects
  117816. */
  117817. export class SerializationHelper {
  117818. /** @hidden */
  117819. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  117820. /** @hidden */
  117821. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  117822. /** @hidden */
  117823. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  117824. /** @hidden */
  117825. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  117826. /**
  117827. * Appends the serialized animations from the source animations
  117828. * @param source Source containing the animations
  117829. * @param destination Target to store the animations
  117830. */
  117831. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  117832. /**
  117833. * Static function used to serialized a specific entity
  117834. * @param entity defines the entity to serialize
  117835. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  117836. * @returns a JSON compatible object representing the serialization of the entity
  117837. */
  117838. static Serialize<T>(entity: T, serializationObject?: any): any;
  117839. /**
  117840. * Creates a new entity from a serialization data object
  117841. * @param creationFunction defines a function used to instanciated the new entity
  117842. * @param source defines the source serialization data
  117843. * @param scene defines the hosting scene
  117844. * @param rootUrl defines the root url for resources
  117845. * @returns a new entity
  117846. */
  117847. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  117848. /**
  117849. * Clones an object
  117850. * @param creationFunction defines the function used to instanciate the new object
  117851. * @param source defines the source object
  117852. * @returns the cloned object
  117853. */
  117854. static Clone<T>(creationFunction: () => T, source: T): T;
  117855. /**
  117856. * Instanciates a new object based on a source one (some data will be shared between both object)
  117857. * @param creationFunction defines the function used to instanciate the new object
  117858. * @param source defines the source object
  117859. * @returns the new object
  117860. */
  117861. static Instanciate<T>(creationFunction: () => T, source: T): T;
  117862. }
  117863. }
  117864. declare module BABYLON {
  117865. /**
  117866. * Base class of all the textures in babylon.
  117867. * It groups all the common properties the materials, post process, lights... might need
  117868. * in order to make a correct use of the texture.
  117869. */
  117870. export class BaseTexture implements IAnimatable {
  117871. /**
  117872. * Default anisotropic filtering level for the application.
  117873. * It is set to 4 as a good tradeoff between perf and quality.
  117874. */
  117875. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  117876. /**
  117877. * Gets or sets the unique id of the texture
  117878. */
  117879. uniqueId: number;
  117880. /**
  117881. * Define the name of the texture.
  117882. */
  117883. name: string;
  117884. /**
  117885. * Gets or sets an object used to store user defined information.
  117886. */
  117887. metadata: any;
  117888. /**
  117889. * For internal use only. Please do not use.
  117890. */
  117891. reservedDataStore: any;
  117892. private _hasAlpha;
  117893. /**
  117894. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  117895. */
  117896. set hasAlpha(value: boolean);
  117897. get hasAlpha(): boolean;
  117898. /**
  117899. * Defines if the alpha value should be determined via the rgb values.
  117900. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  117901. */
  117902. getAlphaFromRGB: boolean;
  117903. /**
  117904. * Intensity or strength of the texture.
  117905. * It is commonly used by materials to fine tune the intensity of the texture
  117906. */
  117907. level: number;
  117908. /**
  117909. * Define the UV chanel to use starting from 0 and defaulting to 0.
  117910. * This is part of the texture as textures usually maps to one uv set.
  117911. */
  117912. coordinatesIndex: number;
  117913. protected _coordinatesMode: number;
  117914. /**
  117915. * How a texture is mapped.
  117916. *
  117917. * | Value | Type | Description |
  117918. * | ----- | ----------------------------------- | ----------- |
  117919. * | 0 | EXPLICIT_MODE | |
  117920. * | 1 | SPHERICAL_MODE | |
  117921. * | 2 | PLANAR_MODE | |
  117922. * | 3 | CUBIC_MODE | |
  117923. * | 4 | PROJECTION_MODE | |
  117924. * | 5 | SKYBOX_MODE | |
  117925. * | 6 | INVCUBIC_MODE | |
  117926. * | 7 | EQUIRECTANGULAR_MODE | |
  117927. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  117928. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  117929. */
  117930. set coordinatesMode(value: number);
  117931. get coordinatesMode(): number;
  117932. private _wrapU;
  117933. /**
  117934. * | Value | Type | Description |
  117935. * | ----- | ------------------ | ----------- |
  117936. * | 0 | CLAMP_ADDRESSMODE | |
  117937. * | 1 | WRAP_ADDRESSMODE | |
  117938. * | 2 | MIRROR_ADDRESSMODE | |
  117939. */
  117940. get wrapU(): number;
  117941. set wrapU(value: number);
  117942. private _wrapV;
  117943. /**
  117944. * | Value | Type | Description |
  117945. * | ----- | ------------------ | ----------- |
  117946. * | 0 | CLAMP_ADDRESSMODE | |
  117947. * | 1 | WRAP_ADDRESSMODE | |
  117948. * | 2 | MIRROR_ADDRESSMODE | |
  117949. */
  117950. get wrapV(): number;
  117951. set wrapV(value: number);
  117952. /**
  117953. * | Value | Type | Description |
  117954. * | ----- | ------------------ | ----------- |
  117955. * | 0 | CLAMP_ADDRESSMODE | |
  117956. * | 1 | WRAP_ADDRESSMODE | |
  117957. * | 2 | MIRROR_ADDRESSMODE | |
  117958. */
  117959. wrapR: number;
  117960. /**
  117961. * With compliant hardware and browser (supporting anisotropic filtering)
  117962. * this defines the level of anisotropic filtering in the texture.
  117963. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  117964. */
  117965. anisotropicFilteringLevel: number;
  117966. /**
  117967. * Define if the texture is a cube texture or if false a 2d texture.
  117968. */
  117969. get isCube(): boolean;
  117970. set isCube(value: boolean);
  117971. /**
  117972. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  117973. */
  117974. get is3D(): boolean;
  117975. set is3D(value: boolean);
  117976. /**
  117977. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  117978. */
  117979. get is2DArray(): boolean;
  117980. set is2DArray(value: boolean);
  117981. private _gammaSpace;
  117982. /**
  117983. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  117984. * HDR texture are usually stored in linear space.
  117985. * This only impacts the PBR and Background materials
  117986. */
  117987. get gammaSpace(): boolean;
  117988. set gammaSpace(gamma: boolean);
  117989. /**
  117990. * Gets or sets whether or not the texture contains RGBD data.
  117991. */
  117992. get isRGBD(): boolean;
  117993. set isRGBD(value: boolean);
  117994. /**
  117995. * Is Z inverted in the texture (useful in a cube texture).
  117996. */
  117997. invertZ: boolean;
  117998. /**
  117999. * Are mip maps generated for this texture or not.
  118000. */
  118001. get noMipmap(): boolean;
  118002. /**
  118003. * @hidden
  118004. */
  118005. lodLevelInAlpha: boolean;
  118006. /**
  118007. * With prefiltered texture, defined the offset used during the prefiltering steps.
  118008. */
  118009. get lodGenerationOffset(): number;
  118010. set lodGenerationOffset(value: number);
  118011. /**
  118012. * With prefiltered texture, defined the scale used during the prefiltering steps.
  118013. */
  118014. get lodGenerationScale(): number;
  118015. set lodGenerationScale(value: number);
  118016. /**
  118017. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  118018. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  118019. * average roughness values.
  118020. */
  118021. get linearSpecularLOD(): boolean;
  118022. set linearSpecularLOD(value: boolean);
  118023. /**
  118024. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  118025. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  118026. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  118027. */
  118028. get irradianceTexture(): Nullable<BaseTexture>;
  118029. set irradianceTexture(value: Nullable<BaseTexture>);
  118030. /**
  118031. * Define if the texture is a render target.
  118032. */
  118033. isRenderTarget: boolean;
  118034. /**
  118035. * Define the unique id of the texture in the scene.
  118036. */
  118037. get uid(): string;
  118038. /** @hidden */
  118039. _prefiltered: boolean;
  118040. /**
  118041. * Return a string representation of the texture.
  118042. * @returns the texture as a string
  118043. */
  118044. toString(): string;
  118045. /**
  118046. * Get the class name of the texture.
  118047. * @returns "BaseTexture"
  118048. */
  118049. getClassName(): string;
  118050. /**
  118051. * Define the list of animation attached to the texture.
  118052. */
  118053. animations: Animation[];
  118054. /**
  118055. * An event triggered when the texture is disposed.
  118056. */
  118057. onDisposeObservable: Observable<BaseTexture>;
  118058. private _onDisposeObserver;
  118059. /**
  118060. * Callback triggered when the texture has been disposed.
  118061. * Kept for back compatibility, you can use the onDisposeObservable instead.
  118062. */
  118063. set onDispose(callback: () => void);
  118064. /**
  118065. * Define the current state of the loading sequence when in delayed load mode.
  118066. */
  118067. delayLoadState: number;
  118068. protected _scene: Nullable<Scene>;
  118069. protected _engine: Nullable<ThinEngine>;
  118070. /** @hidden */
  118071. _texture: Nullable<InternalTexture>;
  118072. private _uid;
  118073. /**
  118074. * Define if the texture is preventinga material to render or not.
  118075. * If not and the texture is not ready, the engine will use a default black texture instead.
  118076. */
  118077. get isBlocking(): boolean;
  118078. /**
  118079. * Instantiates a new BaseTexture.
  118080. * Base class of all the textures in babylon.
  118081. * It groups all the common properties the materials, post process, lights... might need
  118082. * in order to make a correct use of the texture.
  118083. * @param sceneOrEngine Define the scene or engine the texture blongs to
  118084. */
  118085. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  118086. /**
  118087. * Get the scene the texture belongs to.
  118088. * @returns the scene or null if undefined
  118089. */
  118090. getScene(): Nullable<Scene>;
  118091. /** @hidden */
  118092. protected _getEngine(): Nullable<ThinEngine>;
  118093. /**
  118094. * Checks if the texture has the same transform matrix than another texture
  118095. * @param texture texture to check against
  118096. * @returns true if the transforms are the same, else false
  118097. */
  118098. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  118099. /**
  118100. * Get the texture transform matrix used to offset tile the texture for istance.
  118101. * @returns the transformation matrix
  118102. */
  118103. getTextureMatrix(): Matrix;
  118104. /**
  118105. * Get the texture reflection matrix used to rotate/transform the reflection.
  118106. * @returns the reflection matrix
  118107. */
  118108. getReflectionTextureMatrix(): Matrix;
  118109. /**
  118110. * Get the underlying lower level texture from Babylon.
  118111. * @returns the insternal texture
  118112. */
  118113. getInternalTexture(): Nullable<InternalTexture>;
  118114. /**
  118115. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  118116. * @returns true if ready or not blocking
  118117. */
  118118. isReadyOrNotBlocking(): boolean;
  118119. /**
  118120. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  118121. * @returns true if fully ready
  118122. */
  118123. isReady(): boolean;
  118124. private _cachedSize;
  118125. /**
  118126. * Get the size of the texture.
  118127. * @returns the texture size.
  118128. */
  118129. getSize(): ISize;
  118130. /**
  118131. * Get the base size of the texture.
  118132. * It can be different from the size if the texture has been resized for POT for instance
  118133. * @returns the base size
  118134. */
  118135. getBaseSize(): ISize;
  118136. /**
  118137. * Update the sampling mode of the texture.
  118138. * Default is Trilinear mode.
  118139. *
  118140. * | Value | Type | Description |
  118141. * | ----- | ------------------ | ----------- |
  118142. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  118143. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  118144. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  118145. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  118146. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  118147. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  118148. * | 7 | NEAREST_LINEAR | |
  118149. * | 8 | NEAREST_NEAREST | |
  118150. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  118151. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  118152. * | 11 | LINEAR_LINEAR | |
  118153. * | 12 | LINEAR_NEAREST | |
  118154. *
  118155. * > _mag_: magnification filter (close to the viewer)
  118156. * > _min_: minification filter (far from the viewer)
  118157. * > _mip_: filter used between mip map levels
  118158. *@param samplingMode Define the new sampling mode of the texture
  118159. */
  118160. updateSamplingMode(samplingMode: number): void;
  118161. /**
  118162. * Scales the texture if is `canRescale()`
  118163. * @param ratio the resize factor we want to use to rescale
  118164. */
  118165. scale(ratio: number): void;
  118166. /**
  118167. * Get if the texture can rescale.
  118168. */
  118169. get canRescale(): boolean;
  118170. /** @hidden */
  118171. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  118172. /** @hidden */
  118173. _rebuild(): void;
  118174. /**
  118175. * Triggers the load sequence in delayed load mode.
  118176. */
  118177. delayLoad(): void;
  118178. /**
  118179. * Clones the texture.
  118180. * @returns the cloned texture
  118181. */
  118182. clone(): Nullable<BaseTexture>;
  118183. /**
  118184. * Get the texture underlying type (INT, FLOAT...)
  118185. */
  118186. get textureType(): number;
  118187. /**
  118188. * Get the texture underlying format (RGB, RGBA...)
  118189. */
  118190. get textureFormat(): number;
  118191. /**
  118192. * Indicates that textures need to be re-calculated for all materials
  118193. */
  118194. protected _markAllSubMeshesAsTexturesDirty(): void;
  118195. /**
  118196. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  118197. * This will returns an RGBA array buffer containing either in values (0-255) or
  118198. * float values (0-1) depending of the underlying buffer type.
  118199. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  118200. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  118201. * @param buffer defines a user defined buffer to fill with data (can be null)
  118202. * @returns The Array buffer containing the pixels data.
  118203. */
  118204. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  118205. /**
  118206. * Release and destroy the underlying lower level texture aka internalTexture.
  118207. */
  118208. releaseInternalTexture(): void;
  118209. /** @hidden */
  118210. get _lodTextureHigh(): Nullable<BaseTexture>;
  118211. /** @hidden */
  118212. get _lodTextureMid(): Nullable<BaseTexture>;
  118213. /** @hidden */
  118214. get _lodTextureLow(): Nullable<BaseTexture>;
  118215. /**
  118216. * Dispose the texture and release its associated resources.
  118217. */
  118218. dispose(): void;
  118219. /**
  118220. * Serialize the texture into a JSON representation that can be parsed later on.
  118221. * @returns the JSON representation of the texture
  118222. */
  118223. serialize(): any;
  118224. /**
  118225. * Helper function to be called back once a list of texture contains only ready textures.
  118226. * @param textures Define the list of textures to wait for
  118227. * @param callback Define the callback triggered once the entire list will be ready
  118228. */
  118229. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  118230. private static _isScene;
  118231. }
  118232. }
  118233. declare module BABYLON {
  118234. /**
  118235. * Options to be used when creating an effect.
  118236. */
  118237. export interface IEffectCreationOptions {
  118238. /**
  118239. * Atrributes that will be used in the shader.
  118240. */
  118241. attributes: string[];
  118242. /**
  118243. * Uniform varible names that will be set in the shader.
  118244. */
  118245. uniformsNames: string[];
  118246. /**
  118247. * Uniform buffer variable names that will be set in the shader.
  118248. */
  118249. uniformBuffersNames: string[];
  118250. /**
  118251. * Sampler texture variable names that will be set in the shader.
  118252. */
  118253. samplers: string[];
  118254. /**
  118255. * Define statements that will be set in the shader.
  118256. */
  118257. defines: any;
  118258. /**
  118259. * Possible fallbacks for this effect to improve performance when needed.
  118260. */
  118261. fallbacks: Nullable<IEffectFallbacks>;
  118262. /**
  118263. * Callback that will be called when the shader is compiled.
  118264. */
  118265. onCompiled: Nullable<(effect: Effect) => void>;
  118266. /**
  118267. * Callback that will be called if an error occurs during shader compilation.
  118268. */
  118269. onError: Nullable<(effect: Effect, errors: string) => void>;
  118270. /**
  118271. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  118272. */
  118273. indexParameters?: any;
  118274. /**
  118275. * Max number of lights that can be used in the shader.
  118276. */
  118277. maxSimultaneousLights?: number;
  118278. /**
  118279. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  118280. */
  118281. transformFeedbackVaryings?: Nullable<string[]>;
  118282. /**
  118283. * 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
  118284. */
  118285. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  118286. /**
  118287. * Is this effect rendering to several color attachments ?
  118288. */
  118289. multiTarget?: boolean;
  118290. }
  118291. /**
  118292. * Effect containing vertex and fragment shader that can be executed on an object.
  118293. */
  118294. export class Effect implements IDisposable {
  118295. /**
  118296. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  118297. */
  118298. static ShadersRepository: string;
  118299. /**
  118300. * Enable logging of the shader code when a compilation error occurs
  118301. */
  118302. static LogShaderCodeOnCompilationError: boolean;
  118303. /**
  118304. * Name of the effect.
  118305. */
  118306. name: any;
  118307. /**
  118308. * String container all the define statements that should be set on the shader.
  118309. */
  118310. defines: string;
  118311. /**
  118312. * Callback that will be called when the shader is compiled.
  118313. */
  118314. onCompiled: Nullable<(effect: Effect) => void>;
  118315. /**
  118316. * Callback that will be called if an error occurs during shader compilation.
  118317. */
  118318. onError: Nullable<(effect: Effect, errors: string) => void>;
  118319. /**
  118320. * Callback that will be called when effect is bound.
  118321. */
  118322. onBind: Nullable<(effect: Effect) => void>;
  118323. /**
  118324. * Unique ID of the effect.
  118325. */
  118326. uniqueId: number;
  118327. /**
  118328. * Observable that will be called when the shader is compiled.
  118329. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  118330. */
  118331. onCompileObservable: Observable<Effect>;
  118332. /**
  118333. * Observable that will be called if an error occurs during shader compilation.
  118334. */
  118335. onErrorObservable: Observable<Effect>;
  118336. /** @hidden */
  118337. _onBindObservable: Nullable<Observable<Effect>>;
  118338. /**
  118339. * @hidden
  118340. * Specifies if the effect was previously ready
  118341. */
  118342. _wasPreviouslyReady: boolean;
  118343. /**
  118344. * Observable that will be called when effect is bound.
  118345. */
  118346. get onBindObservable(): Observable<Effect>;
  118347. /** @hidden */
  118348. _bonesComputationForcedToCPU: boolean;
  118349. /** @hidden */
  118350. _multiTarget: boolean;
  118351. private static _uniqueIdSeed;
  118352. private _engine;
  118353. private _uniformBuffersNames;
  118354. private _uniformBuffersNamesList;
  118355. private _uniformsNames;
  118356. private _samplerList;
  118357. private _samplers;
  118358. private _isReady;
  118359. private _compilationError;
  118360. private _allFallbacksProcessed;
  118361. private _attributesNames;
  118362. private _attributes;
  118363. private _attributeLocationByName;
  118364. private _uniforms;
  118365. /**
  118366. * Key for the effect.
  118367. * @hidden
  118368. */
  118369. _key: string;
  118370. private _indexParameters;
  118371. private _fallbacks;
  118372. private _vertexSourceCode;
  118373. private _fragmentSourceCode;
  118374. private _vertexSourceCodeOverride;
  118375. private _fragmentSourceCodeOverride;
  118376. private _transformFeedbackVaryings;
  118377. /**
  118378. * Compiled shader to webGL program.
  118379. * @hidden
  118380. */
  118381. _pipelineContext: Nullable<IPipelineContext>;
  118382. private _valueCache;
  118383. private static _baseCache;
  118384. /**
  118385. * Instantiates an effect.
  118386. * An effect can be used to create/manage/execute vertex and fragment shaders.
  118387. * @param baseName Name of the effect.
  118388. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  118389. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  118390. * @param samplers List of sampler variables that will be passed to the shader.
  118391. * @param engine Engine to be used to render the effect
  118392. * @param defines Define statements to be added to the shader.
  118393. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  118394. * @param onCompiled Callback that will be called when the shader is compiled.
  118395. * @param onError Callback that will be called if an error occurs during shader compilation.
  118396. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  118397. */
  118398. 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);
  118399. private _useFinalCode;
  118400. /**
  118401. * Unique key for this effect
  118402. */
  118403. get key(): string;
  118404. /**
  118405. * If the effect has been compiled and prepared.
  118406. * @returns if the effect is compiled and prepared.
  118407. */
  118408. isReady(): boolean;
  118409. private _isReadyInternal;
  118410. /**
  118411. * The engine the effect was initialized with.
  118412. * @returns the engine.
  118413. */
  118414. getEngine(): Engine;
  118415. /**
  118416. * The pipeline context for this effect
  118417. * @returns the associated pipeline context
  118418. */
  118419. getPipelineContext(): Nullable<IPipelineContext>;
  118420. /**
  118421. * The set of names of attribute variables for the shader.
  118422. * @returns An array of attribute names.
  118423. */
  118424. getAttributesNames(): string[];
  118425. /**
  118426. * Returns the attribute at the given index.
  118427. * @param index The index of the attribute.
  118428. * @returns The location of the attribute.
  118429. */
  118430. getAttributeLocation(index: number): number;
  118431. /**
  118432. * Returns the attribute based on the name of the variable.
  118433. * @param name of the attribute to look up.
  118434. * @returns the attribute location.
  118435. */
  118436. getAttributeLocationByName(name: string): number;
  118437. /**
  118438. * The number of attributes.
  118439. * @returns the numnber of attributes.
  118440. */
  118441. getAttributesCount(): number;
  118442. /**
  118443. * Gets the index of a uniform variable.
  118444. * @param uniformName of the uniform to look up.
  118445. * @returns the index.
  118446. */
  118447. getUniformIndex(uniformName: string): number;
  118448. /**
  118449. * Returns the attribute based on the name of the variable.
  118450. * @param uniformName of the uniform to look up.
  118451. * @returns the location of the uniform.
  118452. */
  118453. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  118454. /**
  118455. * Returns an array of sampler variable names
  118456. * @returns The array of sampler variable names.
  118457. */
  118458. getSamplers(): string[];
  118459. /**
  118460. * Returns an array of uniform variable names
  118461. * @returns The array of uniform variable names.
  118462. */
  118463. getUniformNames(): string[];
  118464. /**
  118465. * Returns an array of uniform buffer variable names
  118466. * @returns The array of uniform buffer variable names.
  118467. */
  118468. getUniformBuffersNames(): string[];
  118469. /**
  118470. * Returns the index parameters used to create the effect
  118471. * @returns The index parameters object
  118472. */
  118473. getIndexParameters(): any;
  118474. /**
  118475. * The error from the last compilation.
  118476. * @returns the error string.
  118477. */
  118478. getCompilationError(): string;
  118479. /**
  118480. * Gets a boolean indicating that all fallbacks were used during compilation
  118481. * @returns true if all fallbacks were used
  118482. */
  118483. allFallbacksProcessed(): boolean;
  118484. /**
  118485. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  118486. * @param func The callback to be used.
  118487. */
  118488. executeWhenCompiled(func: (effect: Effect) => void): void;
  118489. private _checkIsReady;
  118490. private _loadShader;
  118491. /**
  118492. * Gets the vertex shader source code of this effect
  118493. */
  118494. get vertexSourceCode(): string;
  118495. /**
  118496. * Gets the fragment shader source code of this effect
  118497. */
  118498. get fragmentSourceCode(): string;
  118499. /**
  118500. * Recompiles the webGL program
  118501. * @param vertexSourceCode The source code for the vertex shader.
  118502. * @param fragmentSourceCode The source code for the fragment shader.
  118503. * @param onCompiled Callback called when completed.
  118504. * @param onError Callback called on error.
  118505. * @hidden
  118506. */
  118507. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  118508. /**
  118509. * Prepares the effect
  118510. * @hidden
  118511. */
  118512. _prepareEffect(): void;
  118513. private _getShaderCodeAndErrorLine;
  118514. private _processCompilationErrors;
  118515. /**
  118516. * Checks if the effect is supported. (Must be called after compilation)
  118517. */
  118518. get isSupported(): boolean;
  118519. /**
  118520. * Binds a texture to the engine to be used as output of the shader.
  118521. * @param channel Name of the output variable.
  118522. * @param texture Texture to bind.
  118523. * @hidden
  118524. */
  118525. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  118526. /**
  118527. * Sets a texture on the engine to be used in the shader.
  118528. * @param channel Name of the sampler variable.
  118529. * @param texture Texture to set.
  118530. */
  118531. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  118532. /**
  118533. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  118534. * @param channel Name of the sampler variable.
  118535. * @param texture Texture to set.
  118536. */
  118537. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  118538. /**
  118539. * Sets an array of textures on the engine to be used in the shader.
  118540. * @param channel Name of the variable.
  118541. * @param textures Textures to set.
  118542. */
  118543. setTextureArray(channel: string, textures: BaseTexture[]): void;
  118544. /**
  118545. * 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)
  118546. * @param channel Name of the sampler variable.
  118547. * @param postProcess Post process to get the input texture from.
  118548. */
  118549. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  118550. /**
  118551. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  118552. * 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)
  118553. * @param channel Name of the sampler variable.
  118554. * @param postProcess Post process to get the output texture from.
  118555. */
  118556. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  118557. /** @hidden */
  118558. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  118559. /** @hidden */
  118560. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  118561. /** @hidden */
  118562. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  118563. /** @hidden */
  118564. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  118565. /**
  118566. * Binds a buffer to a uniform.
  118567. * @param buffer Buffer to bind.
  118568. * @param name Name of the uniform variable to bind to.
  118569. */
  118570. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  118571. /**
  118572. * Binds block to a uniform.
  118573. * @param blockName Name of the block to bind.
  118574. * @param index Index to bind.
  118575. */
  118576. bindUniformBlock(blockName: string, index: number): void;
  118577. /**
  118578. * Sets an interger value on a uniform variable.
  118579. * @param uniformName Name of the variable.
  118580. * @param value Value to be set.
  118581. * @returns this effect.
  118582. */
  118583. setInt(uniformName: string, value: number): Effect;
  118584. /**
  118585. * Sets an int array on a uniform variable.
  118586. * @param uniformName Name of the variable.
  118587. * @param array array to be set.
  118588. * @returns this effect.
  118589. */
  118590. setIntArray(uniformName: string, array: Int32Array): Effect;
  118591. /**
  118592. * 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)
  118593. * @param uniformName Name of the variable.
  118594. * @param array array to be set.
  118595. * @returns this effect.
  118596. */
  118597. setIntArray2(uniformName: string, array: Int32Array): Effect;
  118598. /**
  118599. * 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)
  118600. * @param uniformName Name of the variable.
  118601. * @param array array to be set.
  118602. * @returns this effect.
  118603. */
  118604. setIntArray3(uniformName: string, array: Int32Array): Effect;
  118605. /**
  118606. * 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)
  118607. * @param uniformName Name of the variable.
  118608. * @param array array to be set.
  118609. * @returns this effect.
  118610. */
  118611. setIntArray4(uniformName: string, array: Int32Array): Effect;
  118612. /**
  118613. * Sets an float array on a uniform variable.
  118614. * @param uniformName Name of the variable.
  118615. * @param array array to be set.
  118616. * @returns this effect.
  118617. */
  118618. setFloatArray(uniformName: string, array: Float32Array): Effect;
  118619. /**
  118620. * 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)
  118621. * @param uniformName Name of the variable.
  118622. * @param array array to be set.
  118623. * @returns this effect.
  118624. */
  118625. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  118626. /**
  118627. * 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)
  118628. * @param uniformName Name of the variable.
  118629. * @param array array to be set.
  118630. * @returns this effect.
  118631. */
  118632. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  118633. /**
  118634. * 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)
  118635. * @param uniformName Name of the variable.
  118636. * @param array array to be set.
  118637. * @returns this effect.
  118638. */
  118639. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  118640. /**
  118641. * Sets an array on a uniform variable.
  118642. * @param uniformName Name of the variable.
  118643. * @param array array to be set.
  118644. * @returns this effect.
  118645. */
  118646. setArray(uniformName: string, array: number[]): Effect;
  118647. /**
  118648. * 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)
  118649. * @param uniformName Name of the variable.
  118650. * @param array array to be set.
  118651. * @returns this effect.
  118652. */
  118653. setArray2(uniformName: string, array: number[]): Effect;
  118654. /**
  118655. * 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)
  118656. * @param uniformName Name of the variable.
  118657. * @param array array to be set.
  118658. * @returns this effect.
  118659. */
  118660. setArray3(uniformName: string, array: number[]): Effect;
  118661. /**
  118662. * 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)
  118663. * @param uniformName Name of the variable.
  118664. * @param array array to be set.
  118665. * @returns this effect.
  118666. */
  118667. setArray4(uniformName: string, array: number[]): Effect;
  118668. /**
  118669. * Sets matrices on a uniform variable.
  118670. * @param uniformName Name of the variable.
  118671. * @param matrices matrices to be set.
  118672. * @returns this effect.
  118673. */
  118674. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  118675. /**
  118676. * Sets matrix on a uniform variable.
  118677. * @param uniformName Name of the variable.
  118678. * @param matrix matrix to be set.
  118679. * @returns this effect.
  118680. */
  118681. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  118682. /**
  118683. * 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)
  118684. * @param uniformName Name of the variable.
  118685. * @param matrix matrix to be set.
  118686. * @returns this effect.
  118687. */
  118688. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  118689. /**
  118690. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  118691. * @param uniformName Name of the variable.
  118692. * @param matrix matrix to be set.
  118693. * @returns this effect.
  118694. */
  118695. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  118696. /**
  118697. * Sets a float on a uniform variable.
  118698. * @param uniformName Name of the variable.
  118699. * @param value value to be set.
  118700. * @returns this effect.
  118701. */
  118702. setFloat(uniformName: string, value: number): Effect;
  118703. /**
  118704. * Sets a boolean on a uniform variable.
  118705. * @param uniformName Name of the variable.
  118706. * @param bool value to be set.
  118707. * @returns this effect.
  118708. */
  118709. setBool(uniformName: string, bool: boolean): Effect;
  118710. /**
  118711. * Sets a Vector2 on a uniform variable.
  118712. * @param uniformName Name of the variable.
  118713. * @param vector2 vector2 to be set.
  118714. * @returns this effect.
  118715. */
  118716. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  118717. /**
  118718. * Sets a float2 on a uniform variable.
  118719. * @param uniformName Name of the variable.
  118720. * @param x First float in float2.
  118721. * @param y Second float in float2.
  118722. * @returns this effect.
  118723. */
  118724. setFloat2(uniformName: string, x: number, y: number): Effect;
  118725. /**
  118726. * Sets a Vector3 on a uniform variable.
  118727. * @param uniformName Name of the variable.
  118728. * @param vector3 Value to be set.
  118729. * @returns this effect.
  118730. */
  118731. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  118732. /**
  118733. * Sets a float3 on a uniform variable.
  118734. * @param uniformName Name of the variable.
  118735. * @param x First float in float3.
  118736. * @param y Second float in float3.
  118737. * @param z Third float in float3.
  118738. * @returns this effect.
  118739. */
  118740. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  118741. /**
  118742. * Sets a Vector4 on a uniform variable.
  118743. * @param uniformName Name of the variable.
  118744. * @param vector4 Value to be set.
  118745. * @returns this effect.
  118746. */
  118747. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  118748. /**
  118749. * Sets a float4 on a uniform variable.
  118750. * @param uniformName Name of the variable.
  118751. * @param x First float in float4.
  118752. * @param y Second float in float4.
  118753. * @param z Third float in float4.
  118754. * @param w Fourth float in float4.
  118755. * @returns this effect.
  118756. */
  118757. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  118758. /**
  118759. * Sets a Color3 on a uniform variable.
  118760. * @param uniformName Name of the variable.
  118761. * @param color3 Value to be set.
  118762. * @returns this effect.
  118763. */
  118764. setColor3(uniformName: string, color3: IColor3Like): Effect;
  118765. /**
  118766. * Sets a Color4 on a uniform variable.
  118767. * @param uniformName Name of the variable.
  118768. * @param color3 Value to be set.
  118769. * @param alpha Alpha value to be set.
  118770. * @returns this effect.
  118771. */
  118772. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  118773. /**
  118774. * Sets a Color4 on a uniform variable
  118775. * @param uniformName defines the name of the variable
  118776. * @param color4 defines the value to be set
  118777. * @returns this effect.
  118778. */
  118779. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  118780. /** Release all associated resources */
  118781. dispose(): void;
  118782. /**
  118783. * This function will add a new shader to the shader store
  118784. * @param name the name of the shader
  118785. * @param pixelShader optional pixel shader content
  118786. * @param vertexShader optional vertex shader content
  118787. */
  118788. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  118789. /**
  118790. * Store of each shader (The can be looked up using effect.key)
  118791. */
  118792. static ShadersStore: {
  118793. [key: string]: string;
  118794. };
  118795. /**
  118796. * Store of each included file for a shader (The can be looked up using effect.key)
  118797. */
  118798. static IncludesShadersStore: {
  118799. [key: string]: string;
  118800. };
  118801. /**
  118802. * Resets the cache of effects.
  118803. */
  118804. static ResetCache(): void;
  118805. }
  118806. }
  118807. declare module BABYLON {
  118808. /**
  118809. * Interface used to describe the capabilities of the engine relatively to the current browser
  118810. */
  118811. export interface EngineCapabilities {
  118812. /** Maximum textures units per fragment shader */
  118813. maxTexturesImageUnits: number;
  118814. /** Maximum texture units per vertex shader */
  118815. maxVertexTextureImageUnits: number;
  118816. /** Maximum textures units in the entire pipeline */
  118817. maxCombinedTexturesImageUnits: number;
  118818. /** Maximum texture size */
  118819. maxTextureSize: number;
  118820. /** Maximum texture samples */
  118821. maxSamples?: number;
  118822. /** Maximum cube texture size */
  118823. maxCubemapTextureSize: number;
  118824. /** Maximum render texture size */
  118825. maxRenderTextureSize: number;
  118826. /** Maximum number of vertex attributes */
  118827. maxVertexAttribs: number;
  118828. /** Maximum number of varyings */
  118829. maxVaryingVectors: number;
  118830. /** Maximum number of uniforms per vertex shader */
  118831. maxVertexUniformVectors: number;
  118832. /** Maximum number of uniforms per fragment shader */
  118833. maxFragmentUniformVectors: number;
  118834. /** Defines if standard derivates (dx/dy) are supported */
  118835. standardDerivatives: boolean;
  118836. /** Defines if s3tc texture compression is supported */
  118837. s3tc?: WEBGL_compressed_texture_s3tc;
  118838. /** Defines if pvrtc texture compression is supported */
  118839. pvrtc: any;
  118840. /** Defines if etc1 texture compression is supported */
  118841. etc1: any;
  118842. /** Defines if etc2 texture compression is supported */
  118843. etc2: any;
  118844. /** Defines if astc texture compression is supported */
  118845. astc: any;
  118846. /** Defines if bptc texture compression is supported */
  118847. bptc: any;
  118848. /** Defines if float textures are supported */
  118849. textureFloat: boolean;
  118850. /** Defines if vertex array objects are supported */
  118851. vertexArrayObject: boolean;
  118852. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  118853. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  118854. /** Gets the maximum level of anisotropy supported */
  118855. maxAnisotropy: number;
  118856. /** Defines if instancing is supported */
  118857. instancedArrays: boolean;
  118858. /** Defines if 32 bits indices are supported */
  118859. uintIndices: boolean;
  118860. /** Defines if high precision shaders are supported */
  118861. highPrecisionShaderSupported: boolean;
  118862. /** Defines if depth reading in the fragment shader is supported */
  118863. fragmentDepthSupported: boolean;
  118864. /** Defines if float texture linear filtering is supported*/
  118865. textureFloatLinearFiltering: boolean;
  118866. /** Defines if rendering to float textures is supported */
  118867. textureFloatRender: boolean;
  118868. /** Defines if half float textures are supported*/
  118869. textureHalfFloat: boolean;
  118870. /** Defines if half float texture linear filtering is supported*/
  118871. textureHalfFloatLinearFiltering: boolean;
  118872. /** Defines if rendering to half float textures is supported */
  118873. textureHalfFloatRender: boolean;
  118874. /** Defines if textureLOD shader command is supported */
  118875. textureLOD: boolean;
  118876. /** Defines if draw buffers extension is supported */
  118877. drawBuffersExtension: boolean;
  118878. /** Defines if depth textures are supported */
  118879. depthTextureExtension: boolean;
  118880. /** Defines if float color buffer are supported */
  118881. colorBufferFloat: boolean;
  118882. /** Gets disjoint timer query extension (null if not supported) */
  118883. timerQuery?: EXT_disjoint_timer_query;
  118884. /** Defines if timestamp can be used with timer query */
  118885. canUseTimestampForTimerQuery: boolean;
  118886. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  118887. multiview?: any;
  118888. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  118889. oculusMultiview?: any;
  118890. /** Function used to let the system compiles shaders in background */
  118891. parallelShaderCompile?: {
  118892. COMPLETION_STATUS_KHR: number;
  118893. };
  118894. /** Max number of texture samples for MSAA */
  118895. maxMSAASamples: number;
  118896. /** Defines if the blend min max extension is supported */
  118897. blendMinMax: boolean;
  118898. }
  118899. }
  118900. declare module BABYLON {
  118901. /**
  118902. * @hidden
  118903. **/
  118904. export class DepthCullingState {
  118905. private _isDepthTestDirty;
  118906. private _isDepthMaskDirty;
  118907. private _isDepthFuncDirty;
  118908. private _isCullFaceDirty;
  118909. private _isCullDirty;
  118910. private _isZOffsetDirty;
  118911. private _isFrontFaceDirty;
  118912. private _depthTest;
  118913. private _depthMask;
  118914. private _depthFunc;
  118915. private _cull;
  118916. private _cullFace;
  118917. private _zOffset;
  118918. private _frontFace;
  118919. /**
  118920. * Initializes the state.
  118921. */
  118922. constructor();
  118923. get isDirty(): boolean;
  118924. get zOffset(): number;
  118925. set zOffset(value: number);
  118926. get cullFace(): Nullable<number>;
  118927. set cullFace(value: Nullable<number>);
  118928. get cull(): Nullable<boolean>;
  118929. set cull(value: Nullable<boolean>);
  118930. get depthFunc(): Nullable<number>;
  118931. set depthFunc(value: Nullable<number>);
  118932. get depthMask(): boolean;
  118933. set depthMask(value: boolean);
  118934. get depthTest(): boolean;
  118935. set depthTest(value: boolean);
  118936. get frontFace(): Nullable<number>;
  118937. set frontFace(value: Nullable<number>);
  118938. reset(): void;
  118939. apply(gl: WebGLRenderingContext): void;
  118940. }
  118941. }
  118942. declare module BABYLON {
  118943. /**
  118944. * @hidden
  118945. **/
  118946. export class StencilState {
  118947. /** 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 */
  118948. static readonly ALWAYS: number;
  118949. /** Passed to stencilOperation to specify that stencil value must be kept */
  118950. static readonly KEEP: number;
  118951. /** Passed to stencilOperation to specify that stencil value must be replaced */
  118952. static readonly REPLACE: number;
  118953. private _isStencilTestDirty;
  118954. private _isStencilMaskDirty;
  118955. private _isStencilFuncDirty;
  118956. private _isStencilOpDirty;
  118957. private _stencilTest;
  118958. private _stencilMask;
  118959. private _stencilFunc;
  118960. private _stencilFuncRef;
  118961. private _stencilFuncMask;
  118962. private _stencilOpStencilFail;
  118963. private _stencilOpDepthFail;
  118964. private _stencilOpStencilDepthPass;
  118965. get isDirty(): boolean;
  118966. get stencilFunc(): number;
  118967. set stencilFunc(value: number);
  118968. get stencilFuncRef(): number;
  118969. set stencilFuncRef(value: number);
  118970. get stencilFuncMask(): number;
  118971. set stencilFuncMask(value: number);
  118972. get stencilOpStencilFail(): number;
  118973. set stencilOpStencilFail(value: number);
  118974. get stencilOpDepthFail(): number;
  118975. set stencilOpDepthFail(value: number);
  118976. get stencilOpStencilDepthPass(): number;
  118977. set stencilOpStencilDepthPass(value: number);
  118978. get stencilMask(): number;
  118979. set stencilMask(value: number);
  118980. get stencilTest(): boolean;
  118981. set stencilTest(value: boolean);
  118982. constructor();
  118983. reset(): void;
  118984. apply(gl: WebGLRenderingContext): void;
  118985. }
  118986. }
  118987. declare module BABYLON {
  118988. /**
  118989. * @hidden
  118990. **/
  118991. export class AlphaState {
  118992. private _isAlphaBlendDirty;
  118993. private _isBlendFunctionParametersDirty;
  118994. private _isBlendEquationParametersDirty;
  118995. private _isBlendConstantsDirty;
  118996. private _alphaBlend;
  118997. private _blendFunctionParameters;
  118998. private _blendEquationParameters;
  118999. private _blendConstants;
  119000. /**
  119001. * Initializes the state.
  119002. */
  119003. constructor();
  119004. get isDirty(): boolean;
  119005. get alphaBlend(): boolean;
  119006. set alphaBlend(value: boolean);
  119007. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  119008. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  119009. setAlphaEquationParameters(rgb: number, alpha: number): void;
  119010. reset(): void;
  119011. apply(gl: WebGLRenderingContext): void;
  119012. }
  119013. }
  119014. declare module BABYLON {
  119015. /** @hidden */
  119016. export class WebGLShaderProcessor implements IShaderProcessor {
  119017. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  119018. }
  119019. }
  119020. declare module BABYLON {
  119021. /** @hidden */
  119022. export class WebGL2ShaderProcessor implements IShaderProcessor {
  119023. attributeProcessor(attribute: string): string;
  119024. varyingProcessor(varying: string, isFragment: boolean): string;
  119025. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  119026. }
  119027. }
  119028. declare module BABYLON {
  119029. /**
  119030. * Interface for attribute information associated with buffer instanciation
  119031. */
  119032. export interface InstancingAttributeInfo {
  119033. /**
  119034. * Name of the GLSL attribute
  119035. * if attribute index is not specified, this is used to retrieve the index from the effect
  119036. */
  119037. attributeName: string;
  119038. /**
  119039. * Index/offset of the attribute in the vertex shader
  119040. * if not specified, this will be computes from the name.
  119041. */
  119042. index?: number;
  119043. /**
  119044. * size of the attribute, 1, 2, 3 or 4
  119045. */
  119046. attributeSize: number;
  119047. /**
  119048. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  119049. */
  119050. offset: number;
  119051. /**
  119052. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  119053. * default to 1
  119054. */
  119055. divisor?: number;
  119056. /**
  119057. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  119058. * default is FLOAT
  119059. */
  119060. attributeType?: number;
  119061. /**
  119062. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  119063. */
  119064. normalized?: boolean;
  119065. }
  119066. }
  119067. declare module BABYLON {
  119068. interface ThinEngine {
  119069. /**
  119070. * Update a video texture
  119071. * @param texture defines the texture to update
  119072. * @param video defines the video element to use
  119073. * @param invertY defines if data must be stored with Y axis inverted
  119074. */
  119075. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  119076. }
  119077. }
  119078. declare module BABYLON {
  119079. interface ThinEngine {
  119080. /**
  119081. * Creates a dynamic texture
  119082. * @param width defines the width of the texture
  119083. * @param height defines the height of the texture
  119084. * @param generateMipMaps defines if the engine should generate the mip levels
  119085. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  119086. * @returns the dynamic texture inside an InternalTexture
  119087. */
  119088. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  119089. /**
  119090. * Update the content of a dynamic texture
  119091. * @param texture defines the texture to update
  119092. * @param canvas defines the canvas containing the source
  119093. * @param invertY defines if data must be stored with Y axis inverted
  119094. * @param premulAlpha defines if alpha is stored as premultiplied
  119095. * @param format defines the format of the data
  119096. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  119097. */
  119098. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  119099. }
  119100. }
  119101. declare module BABYLON {
  119102. /**
  119103. * Settings for finer control over video usage
  119104. */
  119105. export interface VideoTextureSettings {
  119106. /**
  119107. * Applies `autoplay` to video, if specified
  119108. */
  119109. autoPlay?: boolean;
  119110. /**
  119111. * Applies `muted` to video, if specified
  119112. */
  119113. muted?: boolean;
  119114. /**
  119115. * Applies `loop` to video, if specified
  119116. */
  119117. loop?: boolean;
  119118. /**
  119119. * Automatically updates internal texture from video at every frame in the render loop
  119120. */
  119121. autoUpdateTexture: boolean;
  119122. /**
  119123. * Image src displayed during the video loading or until the user interacts with the video.
  119124. */
  119125. poster?: string;
  119126. }
  119127. /**
  119128. * If you want to display a video in your scene, this is the special texture for that.
  119129. * This special texture works similar to other textures, with the exception of a few parameters.
  119130. * @see https://doc.babylonjs.com/how_to/video_texture
  119131. */
  119132. export class VideoTexture extends Texture {
  119133. /**
  119134. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  119135. */
  119136. readonly autoUpdateTexture: boolean;
  119137. /**
  119138. * The video instance used by the texture internally
  119139. */
  119140. readonly video: HTMLVideoElement;
  119141. private _onUserActionRequestedObservable;
  119142. /**
  119143. * Event triggerd when a dom action is required by the user to play the video.
  119144. * This happens due to recent changes in browser policies preventing video to auto start.
  119145. */
  119146. get onUserActionRequestedObservable(): Observable<Texture>;
  119147. private _generateMipMaps;
  119148. private _stillImageCaptured;
  119149. private _displayingPosterTexture;
  119150. private _settings;
  119151. private _createInternalTextureOnEvent;
  119152. private _frameId;
  119153. private _currentSrc;
  119154. /**
  119155. * Creates a video texture.
  119156. * If you want to display a video in your scene, this is the special texture for that.
  119157. * This special texture works similar to other textures, with the exception of a few parameters.
  119158. * @see https://doc.babylonjs.com/how_to/video_texture
  119159. * @param name optional name, will detect from video source, if not defined
  119160. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  119161. * @param scene is obviously the current scene.
  119162. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  119163. * @param invertY is false by default but can be used to invert video on Y axis
  119164. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  119165. * @param settings allows finer control over video usage
  119166. */
  119167. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  119168. private _getName;
  119169. private _getVideo;
  119170. private _createInternalTexture;
  119171. private reset;
  119172. /**
  119173. * @hidden Internal method to initiate `update`.
  119174. */
  119175. _rebuild(): void;
  119176. /**
  119177. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  119178. */
  119179. update(): void;
  119180. /**
  119181. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  119182. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  119183. */
  119184. updateTexture(isVisible: boolean): void;
  119185. protected _updateInternalTexture: () => void;
  119186. /**
  119187. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  119188. * @param url New url.
  119189. */
  119190. updateURL(url: string): void;
  119191. /**
  119192. * Clones the texture.
  119193. * @returns the cloned texture
  119194. */
  119195. clone(): VideoTexture;
  119196. /**
  119197. * Dispose the texture and release its associated resources.
  119198. */
  119199. dispose(): void;
  119200. /**
  119201. * Creates a video texture straight from a stream.
  119202. * @param scene Define the scene the texture should be created in
  119203. * @param stream Define the stream the texture should be created from
  119204. * @returns The created video texture as a promise
  119205. */
  119206. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  119207. /**
  119208. * Creates a video texture straight from your WebCam video feed.
  119209. * @param scene Define the scene the texture should be created in
  119210. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  119211. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  119212. * @returns The created video texture as a promise
  119213. */
  119214. static CreateFromWebCamAsync(scene: Scene, constraints: {
  119215. minWidth: number;
  119216. maxWidth: number;
  119217. minHeight: number;
  119218. maxHeight: number;
  119219. deviceId: string;
  119220. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  119221. /**
  119222. * Creates a video texture straight from your WebCam video feed.
  119223. * @param scene Define the scene the texture should be created in
  119224. * @param onReady Define a callback to triggered once the texture will be ready
  119225. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  119226. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  119227. */
  119228. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  119229. minWidth: number;
  119230. maxWidth: number;
  119231. minHeight: number;
  119232. maxHeight: number;
  119233. deviceId: string;
  119234. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  119235. }
  119236. }
  119237. declare module BABYLON {
  119238. /**
  119239. * Defines the interface used by objects working like Scene
  119240. * @hidden
  119241. */
  119242. export interface ISceneLike {
  119243. _addPendingData(data: any): void;
  119244. _removePendingData(data: any): void;
  119245. offlineProvider: IOfflineProvider;
  119246. }
  119247. /**
  119248. * Information about the current host
  119249. */
  119250. export interface HostInformation {
  119251. /**
  119252. * Defines if the current host is a mobile
  119253. */
  119254. isMobile: boolean;
  119255. }
  119256. /** Interface defining initialization parameters for Engine class */
  119257. export interface EngineOptions extends WebGLContextAttributes {
  119258. /**
  119259. * Defines if the engine should no exceed a specified device ratio
  119260. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  119261. */
  119262. limitDeviceRatio?: number;
  119263. /**
  119264. * Defines if webvr should be enabled automatically
  119265. * @see https://doc.babylonjs.com/how_to/webvr_camera
  119266. */
  119267. autoEnableWebVR?: boolean;
  119268. /**
  119269. * Defines if webgl2 should be turned off even if supported
  119270. * @see https://doc.babylonjs.com/features/webgl2
  119271. */
  119272. disableWebGL2Support?: boolean;
  119273. /**
  119274. * Defines if webaudio should be initialized as well
  119275. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119276. */
  119277. audioEngine?: boolean;
  119278. /**
  119279. * Defines if animations should run using a deterministic lock step
  119280. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119281. */
  119282. deterministicLockstep?: boolean;
  119283. /** Defines the maximum steps to use with deterministic lock step mode */
  119284. lockstepMaxSteps?: number;
  119285. /** Defines the seconds between each deterministic lock step */
  119286. timeStep?: number;
  119287. /**
  119288. * Defines that engine should ignore context lost events
  119289. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  119290. */
  119291. doNotHandleContextLost?: boolean;
  119292. /**
  119293. * Defines that engine should ignore modifying touch action attribute and style
  119294. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  119295. */
  119296. doNotHandleTouchAction?: boolean;
  119297. /**
  119298. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  119299. */
  119300. useHighPrecisionFloats?: boolean;
  119301. /**
  119302. * Make the canvas XR Compatible for XR sessions
  119303. */
  119304. xrCompatible?: boolean;
  119305. /**
  119306. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  119307. */
  119308. useHighPrecisionMatrix?: boolean;
  119309. /**
  119310. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  119311. */
  119312. failIfMajorPerformanceCaveat?: boolean;
  119313. }
  119314. /**
  119315. * The base engine class (root of all engines)
  119316. */
  119317. export class ThinEngine {
  119318. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  119319. static ExceptionList: ({
  119320. key: string;
  119321. capture: string;
  119322. captureConstraint: number;
  119323. targets: string[];
  119324. } | {
  119325. key: string;
  119326. capture: null;
  119327. captureConstraint: null;
  119328. targets: string[];
  119329. })[];
  119330. /** @hidden */
  119331. static _TextureLoaders: IInternalTextureLoader[];
  119332. /**
  119333. * Returns the current npm package of the sdk
  119334. */
  119335. static get NpmPackage(): string;
  119336. /**
  119337. * Returns the current version of the framework
  119338. */
  119339. static get Version(): string;
  119340. /**
  119341. * Returns a string describing the current engine
  119342. */
  119343. get description(): string;
  119344. /**
  119345. * Gets or sets the epsilon value used by collision engine
  119346. */
  119347. static CollisionsEpsilon: number;
  119348. /**
  119349. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  119350. */
  119351. static get ShadersRepository(): string;
  119352. static set ShadersRepository(value: string);
  119353. /** @hidden */
  119354. _shaderProcessor: IShaderProcessor;
  119355. /**
  119356. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  119357. */
  119358. forcePOTTextures: boolean;
  119359. /**
  119360. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  119361. */
  119362. isFullscreen: boolean;
  119363. /**
  119364. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  119365. */
  119366. cullBackFaces: boolean;
  119367. /**
  119368. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  119369. */
  119370. renderEvenInBackground: boolean;
  119371. /**
  119372. * Gets or sets a boolean indicating that cache can be kept between frames
  119373. */
  119374. preventCacheWipeBetweenFrames: boolean;
  119375. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  119376. validateShaderPrograms: boolean;
  119377. /**
  119378. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  119379. * This can provide greater z depth for distant objects.
  119380. */
  119381. useReverseDepthBuffer: boolean;
  119382. /**
  119383. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  119384. */
  119385. disableUniformBuffers: boolean;
  119386. /** @hidden */
  119387. _uniformBuffers: UniformBuffer[];
  119388. /**
  119389. * Gets a boolean indicating that the engine supports uniform buffers
  119390. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  119391. */
  119392. get supportsUniformBuffers(): boolean;
  119393. /** @hidden */
  119394. _gl: WebGLRenderingContext;
  119395. /** @hidden */
  119396. _webGLVersion: number;
  119397. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  119398. protected _windowIsBackground: boolean;
  119399. protected _creationOptions: EngineOptions;
  119400. protected _highPrecisionShadersAllowed: boolean;
  119401. /** @hidden */
  119402. get _shouldUseHighPrecisionShader(): boolean;
  119403. /**
  119404. * Gets a boolean indicating that only power of 2 textures are supported
  119405. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  119406. */
  119407. get needPOTTextures(): boolean;
  119408. /** @hidden */
  119409. _badOS: boolean;
  119410. /** @hidden */
  119411. _badDesktopOS: boolean;
  119412. private _hardwareScalingLevel;
  119413. /** @hidden */
  119414. _caps: EngineCapabilities;
  119415. private _isStencilEnable;
  119416. private _glVersion;
  119417. private _glRenderer;
  119418. private _glVendor;
  119419. /** @hidden */
  119420. _videoTextureSupported: boolean;
  119421. protected _renderingQueueLaunched: boolean;
  119422. protected _activeRenderLoops: (() => void)[];
  119423. /**
  119424. * Observable signaled when a context lost event is raised
  119425. */
  119426. onContextLostObservable: Observable<ThinEngine>;
  119427. /**
  119428. * Observable signaled when a context restored event is raised
  119429. */
  119430. onContextRestoredObservable: Observable<ThinEngine>;
  119431. private _onContextLost;
  119432. private _onContextRestored;
  119433. protected _contextWasLost: boolean;
  119434. /** @hidden */
  119435. _doNotHandleContextLost: boolean;
  119436. /**
  119437. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  119438. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  119439. */
  119440. get doNotHandleContextLost(): boolean;
  119441. set doNotHandleContextLost(value: boolean);
  119442. /**
  119443. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  119444. */
  119445. disableVertexArrayObjects: boolean;
  119446. /** @hidden */
  119447. protected _colorWrite: boolean;
  119448. /** @hidden */
  119449. protected _colorWriteChanged: boolean;
  119450. /** @hidden */
  119451. protected _depthCullingState: DepthCullingState;
  119452. /** @hidden */
  119453. protected _stencilState: StencilState;
  119454. /** @hidden */
  119455. _alphaState: AlphaState;
  119456. /** @hidden */
  119457. _alphaMode: number;
  119458. /** @hidden */
  119459. _alphaEquation: number;
  119460. /** @hidden */
  119461. _internalTexturesCache: InternalTexture[];
  119462. /** @hidden */
  119463. protected _activeChannel: number;
  119464. private _currentTextureChannel;
  119465. /** @hidden */
  119466. protected _boundTexturesCache: {
  119467. [key: string]: Nullable<InternalTexture>;
  119468. };
  119469. /** @hidden */
  119470. protected _currentEffect: Nullable<Effect>;
  119471. /** @hidden */
  119472. protected _currentProgram: Nullable<WebGLProgram>;
  119473. private _compiledEffects;
  119474. private _vertexAttribArraysEnabled;
  119475. /** @hidden */
  119476. protected _cachedViewport: Nullable<IViewportLike>;
  119477. private _cachedVertexArrayObject;
  119478. /** @hidden */
  119479. protected _cachedVertexBuffers: any;
  119480. /** @hidden */
  119481. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  119482. /** @hidden */
  119483. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  119484. /** @hidden */
  119485. _currentRenderTarget: Nullable<InternalTexture>;
  119486. private _uintIndicesCurrentlySet;
  119487. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  119488. /** @hidden */
  119489. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  119490. /** @hidden */
  119491. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  119492. private _currentBufferPointers;
  119493. private _currentInstanceLocations;
  119494. private _currentInstanceBuffers;
  119495. private _textureUnits;
  119496. /** @hidden */
  119497. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  119498. /** @hidden */
  119499. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  119500. /** @hidden */
  119501. _boundRenderFunction: any;
  119502. private _vaoRecordInProgress;
  119503. private _mustWipeVertexAttributes;
  119504. private _emptyTexture;
  119505. private _emptyCubeTexture;
  119506. private _emptyTexture3D;
  119507. private _emptyTexture2DArray;
  119508. /** @hidden */
  119509. _frameHandler: number;
  119510. private _nextFreeTextureSlots;
  119511. private _maxSimultaneousTextures;
  119512. private _activeRequests;
  119513. /** @hidden */
  119514. _transformTextureUrl: Nullable<(url: string) => string>;
  119515. /**
  119516. * Gets information about the current host
  119517. */
  119518. hostInformation: HostInformation;
  119519. protected get _supportsHardwareTextureRescaling(): boolean;
  119520. private _framebufferDimensionsObject;
  119521. /**
  119522. * sets the object from which width and height will be taken from when getting render width and height
  119523. * Will fallback to the gl object
  119524. * @param dimensions the framebuffer width and height that will be used.
  119525. */
  119526. set framebufferDimensionsObject(dimensions: Nullable<{
  119527. framebufferWidth: number;
  119528. framebufferHeight: number;
  119529. }>);
  119530. /**
  119531. * Gets the current viewport
  119532. */
  119533. get currentViewport(): Nullable<IViewportLike>;
  119534. /**
  119535. * Gets the default empty texture
  119536. */
  119537. get emptyTexture(): InternalTexture;
  119538. /**
  119539. * Gets the default empty 3D texture
  119540. */
  119541. get emptyTexture3D(): InternalTexture;
  119542. /**
  119543. * Gets the default empty 2D array texture
  119544. */
  119545. get emptyTexture2DArray(): InternalTexture;
  119546. /**
  119547. * Gets the default empty cube texture
  119548. */
  119549. get emptyCubeTexture(): InternalTexture;
  119550. /**
  119551. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  119552. */
  119553. readonly premultipliedAlpha: boolean;
  119554. /**
  119555. * Observable event triggered before each texture is initialized
  119556. */
  119557. onBeforeTextureInitObservable: Observable<Texture>;
  119558. /**
  119559. * Creates a new engine
  119560. * @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
  119561. * @param antialias defines enable antialiasing (default: false)
  119562. * @param options defines further options to be sent to the getContext() function
  119563. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  119564. */
  119565. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  119566. private _rebuildInternalTextures;
  119567. private _rebuildEffects;
  119568. /**
  119569. * Gets a boolean indicating if all created effects are ready
  119570. * @returns true if all effects are ready
  119571. */
  119572. areAllEffectsReady(): boolean;
  119573. protected _rebuildBuffers(): void;
  119574. protected _initGLContext(): void;
  119575. /**
  119576. * Gets version of the current webGL context
  119577. */
  119578. get webGLVersion(): number;
  119579. /**
  119580. * Gets a string identifying the name of the class
  119581. * @returns "Engine" string
  119582. */
  119583. getClassName(): string;
  119584. /**
  119585. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  119586. */
  119587. get isStencilEnable(): boolean;
  119588. /** @hidden */
  119589. _prepareWorkingCanvas(): void;
  119590. /**
  119591. * Reset the texture cache to empty state
  119592. */
  119593. resetTextureCache(): void;
  119594. /**
  119595. * Gets an object containing information about the current webGL context
  119596. * @returns an object containing the vender, the renderer and the version of the current webGL context
  119597. */
  119598. getGlInfo(): {
  119599. vendor: string;
  119600. renderer: string;
  119601. version: string;
  119602. };
  119603. /**
  119604. * Defines the hardware scaling level.
  119605. * By default the hardware scaling level is computed from the window device ratio.
  119606. * 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.
  119607. * @param level defines the level to use
  119608. */
  119609. setHardwareScalingLevel(level: number): void;
  119610. /**
  119611. * Gets the current hardware scaling level.
  119612. * By default the hardware scaling level is computed from the window device ratio.
  119613. * 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.
  119614. * @returns a number indicating the current hardware scaling level
  119615. */
  119616. getHardwareScalingLevel(): number;
  119617. /**
  119618. * Gets the list of loaded textures
  119619. * @returns an array containing all loaded textures
  119620. */
  119621. getLoadedTexturesCache(): InternalTexture[];
  119622. /**
  119623. * Gets the object containing all engine capabilities
  119624. * @returns the EngineCapabilities object
  119625. */
  119626. getCaps(): EngineCapabilities;
  119627. /**
  119628. * stop executing a render loop function and remove it from the execution array
  119629. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  119630. */
  119631. stopRenderLoop(renderFunction?: () => void): void;
  119632. /** @hidden */
  119633. _renderLoop(): void;
  119634. /**
  119635. * Gets the HTML canvas attached with the current webGL context
  119636. * @returns a HTML canvas
  119637. */
  119638. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  119639. /**
  119640. * Gets host window
  119641. * @returns the host window object
  119642. */
  119643. getHostWindow(): Nullable<Window>;
  119644. /**
  119645. * Gets the current render width
  119646. * @param useScreen defines if screen size must be used (or the current render target if any)
  119647. * @returns a number defining the current render width
  119648. */
  119649. getRenderWidth(useScreen?: boolean): number;
  119650. /**
  119651. * Gets the current render height
  119652. * @param useScreen defines if screen size must be used (or the current render target if any)
  119653. * @returns a number defining the current render height
  119654. */
  119655. getRenderHeight(useScreen?: boolean): number;
  119656. /**
  119657. * Can be used to override the current requestAnimationFrame requester.
  119658. * @hidden
  119659. */
  119660. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  119661. /**
  119662. * Register and execute a render loop. The engine can have more than one render function
  119663. * @param renderFunction defines the function to continuously execute
  119664. */
  119665. runRenderLoop(renderFunction: () => void): void;
  119666. /**
  119667. * Clear the current render buffer or the current render target (if any is set up)
  119668. * @param color defines the color to use
  119669. * @param backBuffer defines if the back buffer must be cleared
  119670. * @param depth defines if the depth buffer must be cleared
  119671. * @param stencil defines if the stencil buffer must be cleared
  119672. */
  119673. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119674. private _viewportCached;
  119675. /** @hidden */
  119676. _viewport(x: number, y: number, width: number, height: number): void;
  119677. /**
  119678. * Set the WebGL's viewport
  119679. * @param viewport defines the viewport element to be used
  119680. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119681. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119682. */
  119683. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119684. /**
  119685. * Begin a new frame
  119686. */
  119687. beginFrame(): void;
  119688. /**
  119689. * Enf the current frame
  119690. */
  119691. endFrame(): void;
  119692. /**
  119693. * Resize the view according to the canvas' size
  119694. */
  119695. resize(): void;
  119696. /**
  119697. * Force a specific size of the canvas
  119698. * @param width defines the new canvas' width
  119699. * @param height defines the new canvas' height
  119700. * @returns true if the size was changed
  119701. */
  119702. setSize(width: number, height: number): boolean;
  119703. /**
  119704. * Binds the frame buffer to the specified texture.
  119705. * @param texture The texture to render to or null for the default canvas
  119706. * @param faceIndex The face of the texture to render to in case of cube texture
  119707. * @param requiredWidth The width of the target to render to
  119708. * @param requiredHeight The height of the target to render to
  119709. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  119710. * @param lodLevel defines the lod level to bind to the frame buffer
  119711. * @param layer defines the 2d array index to bind to frame buffer to
  119712. */
  119713. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  119714. /** @hidden */
  119715. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  119716. /**
  119717. * Unbind the current render target texture from the webGL context
  119718. * @param texture defines the render target texture to unbind
  119719. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119720. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119721. */
  119722. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  119723. /**
  119724. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  119725. */
  119726. flushFramebuffer(): void;
  119727. /**
  119728. * Unbind the current render target and bind the default framebuffer
  119729. */
  119730. restoreDefaultFramebuffer(): void;
  119731. /** @hidden */
  119732. protected _resetVertexBufferBinding(): void;
  119733. /**
  119734. * Creates a vertex buffer
  119735. * @param data the data for the vertex buffer
  119736. * @returns the new WebGL static buffer
  119737. */
  119738. createVertexBuffer(data: DataArray): DataBuffer;
  119739. private _createVertexBuffer;
  119740. /**
  119741. * Creates a dynamic vertex buffer
  119742. * @param data the data for the dynamic vertex buffer
  119743. * @returns the new WebGL dynamic buffer
  119744. */
  119745. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  119746. protected _resetIndexBufferBinding(): void;
  119747. /**
  119748. * Creates a new index buffer
  119749. * @param indices defines the content of the index buffer
  119750. * @param updatable defines if the index buffer must be updatable
  119751. * @returns a new webGL buffer
  119752. */
  119753. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  119754. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  119755. /**
  119756. * Bind a webGL buffer to the webGL context
  119757. * @param buffer defines the buffer to bind
  119758. */
  119759. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  119760. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  119761. private bindBuffer;
  119762. /**
  119763. * update the bound buffer with the given data
  119764. * @param data defines the data to update
  119765. */
  119766. updateArrayBuffer(data: Float32Array): void;
  119767. private _vertexAttribPointer;
  119768. /** @hidden */
  119769. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  119770. private _bindVertexBuffersAttributes;
  119771. /**
  119772. * Records a vertex array object
  119773. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  119774. * @param vertexBuffers defines the list of vertex buffers to store
  119775. * @param indexBuffer defines the index buffer to store
  119776. * @param effect defines the effect to store
  119777. * @returns the new vertex array object
  119778. */
  119779. recordVertexArrayObject(vertexBuffers: {
  119780. [key: string]: VertexBuffer;
  119781. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  119782. /**
  119783. * Bind a specific vertex array object
  119784. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  119785. * @param vertexArrayObject defines the vertex array object to bind
  119786. * @param indexBuffer defines the index buffer to bind
  119787. */
  119788. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  119789. /**
  119790. * Bind webGl buffers directly to the webGL context
  119791. * @param vertexBuffer defines the vertex buffer to bind
  119792. * @param indexBuffer defines the index buffer to bind
  119793. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119794. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119795. * @param effect defines the effect associated with the vertex buffer
  119796. */
  119797. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  119798. private _unbindVertexArrayObject;
  119799. /**
  119800. * Bind a list of vertex buffers to the webGL context
  119801. * @param vertexBuffers defines the list of vertex buffers to bind
  119802. * @param indexBuffer defines the index buffer to bind
  119803. * @param effect defines the effect associated with the vertex buffers
  119804. */
  119805. bindBuffers(vertexBuffers: {
  119806. [key: string]: Nullable<VertexBuffer>;
  119807. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  119808. /**
  119809. * Unbind all instance attributes
  119810. */
  119811. unbindInstanceAttributes(): void;
  119812. /**
  119813. * Release and free the memory of a vertex array object
  119814. * @param vao defines the vertex array object to delete
  119815. */
  119816. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  119817. /** @hidden */
  119818. _releaseBuffer(buffer: DataBuffer): boolean;
  119819. protected _deleteBuffer(buffer: DataBuffer): void;
  119820. /**
  119821. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  119822. * @param instancesBuffer defines the webGL buffer to update and bind
  119823. * @param data defines the data to store in the buffer
  119824. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  119825. */
  119826. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  119827. /**
  119828. * Bind the content of a webGL buffer used with instantiation
  119829. * @param instancesBuffer defines the webGL buffer to bind
  119830. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  119831. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  119832. */
  119833. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  119834. /**
  119835. * Disable the instance attribute corresponding to the name in parameter
  119836. * @param name defines the name of the attribute to disable
  119837. */
  119838. disableInstanceAttributeByName(name: string): void;
  119839. /**
  119840. * Disable the instance attribute corresponding to the location in parameter
  119841. * @param attributeLocation defines the attribute location of the attribute to disable
  119842. */
  119843. disableInstanceAttribute(attributeLocation: number): void;
  119844. /**
  119845. * Disable the attribute corresponding to the location in parameter
  119846. * @param attributeLocation defines the attribute location of the attribute to disable
  119847. */
  119848. disableAttributeByIndex(attributeLocation: number): void;
  119849. /**
  119850. * Send a draw order
  119851. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119852. * @param indexStart defines the starting index
  119853. * @param indexCount defines the number of index to draw
  119854. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119855. */
  119856. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119857. /**
  119858. * Draw a list of points
  119859. * @param verticesStart defines the index of first vertex to draw
  119860. * @param verticesCount defines the count of vertices to draw
  119861. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119862. */
  119863. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119864. /**
  119865. * Draw a list of unindexed primitives
  119866. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119867. * @param verticesStart defines the index of first vertex to draw
  119868. * @param verticesCount defines the count of vertices to draw
  119869. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119870. */
  119871. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119872. /**
  119873. * Draw a list of indexed primitives
  119874. * @param fillMode defines the primitive to use
  119875. * @param indexStart defines the starting index
  119876. * @param indexCount defines the number of index to draw
  119877. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119878. */
  119879. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119880. /**
  119881. * Draw a list of unindexed primitives
  119882. * @param fillMode defines the primitive to use
  119883. * @param verticesStart defines the index of first vertex to draw
  119884. * @param verticesCount defines the count of vertices to draw
  119885. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119886. */
  119887. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119888. private _drawMode;
  119889. /** @hidden */
  119890. protected _reportDrawCall(): void;
  119891. /** @hidden */
  119892. _releaseEffect(effect: Effect): void;
  119893. /** @hidden */
  119894. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  119895. /**
  119896. * Create a new effect (used to store vertex/fragment shaders)
  119897. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  119898. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  119899. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  119900. * @param samplers defines an array of string used to represent textures
  119901. * @param defines defines the string containing the defines to use to compile the shaders
  119902. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  119903. * @param onCompiled defines a function to call when the effect creation is successful
  119904. * @param onError defines a function to call when the effect creation has failed
  119905. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  119906. * @returns the new Effect
  119907. */
  119908. 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;
  119909. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  119910. private _compileShader;
  119911. private _compileRawShader;
  119912. /** @hidden */
  119913. _getShaderSource(shader: WebGLShader): Nullable<string>;
  119914. /**
  119915. * Directly creates a webGL program
  119916. * @param pipelineContext defines the pipeline context to attach to
  119917. * @param vertexCode defines the vertex shader code to use
  119918. * @param fragmentCode defines the fragment shader code to use
  119919. * @param context defines the webGL context to use (if not set, the current one will be used)
  119920. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  119921. * @returns the new webGL program
  119922. */
  119923. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119924. /**
  119925. * Creates a webGL program
  119926. * @param pipelineContext defines the pipeline context to attach to
  119927. * @param vertexCode defines the vertex shader code to use
  119928. * @param fragmentCode defines the fragment shader code to use
  119929. * @param defines defines the string containing the defines to use to compile the shaders
  119930. * @param context defines the webGL context to use (if not set, the current one will be used)
  119931. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  119932. * @returns the new webGL program
  119933. */
  119934. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119935. /**
  119936. * Creates a new pipeline context
  119937. * @returns the new pipeline
  119938. */
  119939. createPipelineContext(): IPipelineContext;
  119940. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119941. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  119942. /** @hidden */
  119943. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  119944. /** @hidden */
  119945. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  119946. /** @hidden */
  119947. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  119948. /**
  119949. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119950. * @param pipelineContext defines the pipeline context to use
  119951. * @param uniformsNames defines the list of uniform names
  119952. * @returns an array of webGL uniform locations
  119953. */
  119954. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119955. /**
  119956. * Gets the lsit of active attributes for a given webGL program
  119957. * @param pipelineContext defines the pipeline context to use
  119958. * @param attributesNames defines the list of attribute names to get
  119959. * @returns an array of indices indicating the offset of each attribute
  119960. */
  119961. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119962. /**
  119963. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119964. * @param effect defines the effect to activate
  119965. */
  119966. enableEffect(effect: Nullable<Effect>): void;
  119967. /**
  119968. * Set the value of an uniform to a number (int)
  119969. * @param uniform defines the webGL uniform location where to store the value
  119970. * @param value defines the int number to store
  119971. * @returns true if the value was set
  119972. */
  119973. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  119974. /**
  119975. * Set the value of an uniform to an array of int32
  119976. * @param uniform defines the webGL uniform location where to store the value
  119977. * @param array defines the array of int32 to store
  119978. * @returns true if the value was set
  119979. */
  119980. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119981. /**
  119982. * Set the value of an uniform to an array of int32 (stored as vec2)
  119983. * @param uniform defines the webGL uniform location where to store the value
  119984. * @param array defines the array of int32 to store
  119985. * @returns true if the value was set
  119986. */
  119987. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119988. /**
  119989. * Set the value of an uniform to an array of int32 (stored as vec3)
  119990. * @param uniform defines the webGL uniform location where to store the value
  119991. * @param array defines the array of int32 to store
  119992. * @returns true if the value was set
  119993. */
  119994. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119995. /**
  119996. * Set the value of an uniform to an array of int32 (stored as vec4)
  119997. * @param uniform defines the webGL uniform location where to store the value
  119998. * @param array defines the array of int32 to store
  119999. * @returns true if the value was set
  120000. */
  120001. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  120002. /**
  120003. * Set the value of an uniform to an array of number
  120004. * @param uniform defines the webGL uniform location where to store the value
  120005. * @param array defines the array of number to store
  120006. * @returns true if the value was set
  120007. */
  120008. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  120009. /**
  120010. * Set the value of an uniform to an array of number (stored as vec2)
  120011. * @param uniform defines the webGL uniform location where to store the value
  120012. * @param array defines the array of number to store
  120013. * @returns true if the value was set
  120014. */
  120015. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  120016. /**
  120017. * Set the value of an uniform to an array of number (stored as vec3)
  120018. * @param uniform defines the webGL uniform location where to store the value
  120019. * @param array defines the array of number to store
  120020. * @returns true if the value was set
  120021. */
  120022. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  120023. /**
  120024. * Set the value of an uniform to an array of number (stored as vec4)
  120025. * @param uniform defines the webGL uniform location where to store the value
  120026. * @param array defines the array of number to store
  120027. * @returns true if the value was set
  120028. */
  120029. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  120030. /**
  120031. * Set the value of an uniform to an array of float32 (stored as matrices)
  120032. * @param uniform defines the webGL uniform location where to store the value
  120033. * @param matrices defines the array of float32 to store
  120034. * @returns true if the value was set
  120035. */
  120036. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  120037. /**
  120038. * Set the value of an uniform to a matrix (3x3)
  120039. * @param uniform defines the webGL uniform location where to store the value
  120040. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  120041. * @returns true if the value was set
  120042. */
  120043. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  120044. /**
  120045. * Set the value of an uniform to a matrix (2x2)
  120046. * @param uniform defines the webGL uniform location where to store the value
  120047. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  120048. * @returns true if the value was set
  120049. */
  120050. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  120051. /**
  120052. * Set the value of an uniform to a number (float)
  120053. * @param uniform defines the webGL uniform location where to store the value
  120054. * @param value defines the float number to store
  120055. * @returns true if the value was transfered
  120056. */
  120057. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  120058. /**
  120059. * Set the value of an uniform to a vec2
  120060. * @param uniform defines the webGL uniform location where to store the value
  120061. * @param x defines the 1st component of the value
  120062. * @param y defines the 2nd component of the value
  120063. * @returns true if the value was set
  120064. */
  120065. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  120066. /**
  120067. * Set the value of an uniform to a vec3
  120068. * @param uniform defines the webGL uniform location where to store the value
  120069. * @param x defines the 1st component of the value
  120070. * @param y defines the 2nd component of the value
  120071. * @param z defines the 3rd component of the value
  120072. * @returns true if the value was set
  120073. */
  120074. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  120075. /**
  120076. * Set the value of an uniform to a vec4
  120077. * @param uniform defines the webGL uniform location where to store the value
  120078. * @param x defines the 1st component of the value
  120079. * @param y defines the 2nd component of the value
  120080. * @param z defines the 3rd component of the value
  120081. * @param w defines the 4th component of the value
  120082. * @returns true if the value was set
  120083. */
  120084. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  120085. /**
  120086. * Apply all cached states (depth, culling, stencil and alpha)
  120087. */
  120088. applyStates(): void;
  120089. /**
  120090. * Enable or disable color writing
  120091. * @param enable defines the state to set
  120092. */
  120093. setColorWrite(enable: boolean): void;
  120094. /**
  120095. * Gets a boolean indicating if color writing is enabled
  120096. * @returns the current color writing state
  120097. */
  120098. getColorWrite(): boolean;
  120099. /**
  120100. * Gets the depth culling state manager
  120101. */
  120102. get depthCullingState(): DepthCullingState;
  120103. /**
  120104. * Gets the alpha state manager
  120105. */
  120106. get alphaState(): AlphaState;
  120107. /**
  120108. * Gets the stencil state manager
  120109. */
  120110. get stencilState(): StencilState;
  120111. /**
  120112. * Clears the list of texture accessible through engine.
  120113. * This can help preventing texture load conflict due to name collision.
  120114. */
  120115. clearInternalTexturesCache(): void;
  120116. /**
  120117. * Force the entire cache to be cleared
  120118. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  120119. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  120120. */
  120121. wipeCaches(bruteForce?: boolean): void;
  120122. /** @hidden */
  120123. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  120124. min: number;
  120125. mag: number;
  120126. };
  120127. /** @hidden */
  120128. _createTexture(): WebGLTexture;
  120129. /**
  120130. * Usually called from Texture.ts.
  120131. * Passed information to create a WebGLTexture
  120132. * @param url defines a value which contains one of the following:
  120133. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120134. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120135. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120136. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120137. * @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)
  120138. * @param scene needed for loading to the correct scene
  120139. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120140. * @param onLoad optional callback to be called upon successful completion
  120141. * @param onError optional callback to be called upon failure
  120142. * @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
  120143. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120144. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120145. * @param forcedExtension defines the extension to use to pick the right loader
  120146. * @param mimeType defines an optional mime type
  120147. * @param loaderOptions options to be passed to the loader
  120148. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120149. */
  120150. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  120151. /**
  120152. * Loads an image as an HTMLImageElement.
  120153. * @param input url string, ArrayBuffer, or Blob to load
  120154. * @param onLoad callback called when the image successfully loads
  120155. * @param onError callback called when the image fails to load
  120156. * @param offlineProvider offline provider for caching
  120157. * @param mimeType optional mime type
  120158. * @returns the HTMLImageElement of the loaded image
  120159. * @hidden
  120160. */
  120161. 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>;
  120162. /**
  120163. * @hidden
  120164. */
  120165. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  120166. private _unpackFlipYCached;
  120167. /**
  120168. * In case you are sharing the context with other applications, it might
  120169. * be interested to not cache the unpack flip y state to ensure a consistent
  120170. * value would be set.
  120171. */
  120172. enableUnpackFlipYCached: boolean;
  120173. /** @hidden */
  120174. _unpackFlipY(value: boolean): void;
  120175. /** @hidden */
  120176. _getUnpackAlignement(): number;
  120177. private _getTextureTarget;
  120178. /**
  120179. * Update the sampling mode of a given texture
  120180. * @param samplingMode defines the required sampling mode
  120181. * @param texture defines the texture to update
  120182. * @param generateMipMaps defines whether to generate mipmaps for the texture
  120183. */
  120184. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  120185. /**
  120186. * Update the sampling mode of a given texture
  120187. * @param texture defines the texture to update
  120188. * @param wrapU defines the texture wrap mode of the u coordinates
  120189. * @param wrapV defines the texture wrap mode of the v coordinates
  120190. * @param wrapR defines the texture wrap mode of the r coordinates
  120191. */
  120192. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  120193. /** @hidden */
  120194. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  120195. width: number;
  120196. height: number;
  120197. layers?: number;
  120198. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  120199. /** @hidden */
  120200. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120201. /** @hidden */
  120202. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  120203. /**
  120204. * Update a portion of an internal texture
  120205. * @param texture defines the texture to update
  120206. * @param imageData defines the data to store into the texture
  120207. * @param xOffset defines the x coordinates of the update rectangle
  120208. * @param yOffset defines the y coordinates of the update rectangle
  120209. * @param width defines the width of the update rectangle
  120210. * @param height defines the height of the update rectangle
  120211. * @param faceIndex defines the face index if texture is a cube (0 by default)
  120212. * @param lod defines the lod level to update (0 by default)
  120213. */
  120214. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  120215. /** @hidden */
  120216. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120217. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  120218. private _prepareWebGLTexture;
  120219. /** @hidden */
  120220. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  120221. private _getDepthStencilBuffer;
  120222. /** @hidden */
  120223. _releaseFramebufferObjects(texture: InternalTexture): void;
  120224. /** @hidden */
  120225. _releaseTexture(texture: InternalTexture): void;
  120226. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120227. protected _setProgram(program: WebGLProgram): void;
  120228. protected _boundUniforms: {
  120229. [key: number]: WebGLUniformLocation;
  120230. };
  120231. /**
  120232. * Binds an effect to the webGL context
  120233. * @param effect defines the effect to bind
  120234. */
  120235. bindSamplers(effect: Effect): void;
  120236. private _activateCurrentTexture;
  120237. /** @hidden */
  120238. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  120239. /** @hidden */
  120240. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  120241. /**
  120242. * Unbind all textures from the webGL context
  120243. */
  120244. unbindAllTextures(): void;
  120245. /**
  120246. * Sets a texture to the according uniform.
  120247. * @param channel The texture channel
  120248. * @param uniform The uniform to set
  120249. * @param texture The texture to apply
  120250. */
  120251. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  120252. private _bindSamplerUniformToChannel;
  120253. private _getTextureWrapMode;
  120254. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120255. /**
  120256. * Sets an array of texture to the webGL context
  120257. * @param channel defines the channel where the texture array must be set
  120258. * @param uniform defines the associated uniform location
  120259. * @param textures defines the array of textures to bind
  120260. */
  120261. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  120262. /** @hidden */
  120263. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  120264. private _setTextureParameterFloat;
  120265. private _setTextureParameterInteger;
  120266. /**
  120267. * Unbind all vertex attributes from the webGL context
  120268. */
  120269. unbindAllAttributes(): void;
  120270. /**
  120271. * 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
  120272. */
  120273. releaseEffects(): void;
  120274. /**
  120275. * Dispose and release all associated resources
  120276. */
  120277. dispose(): void;
  120278. /**
  120279. * Attach a new callback raised when context lost event is fired
  120280. * @param callback defines the callback to call
  120281. */
  120282. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  120283. /**
  120284. * Attach a new callback raised when context restored event is fired
  120285. * @param callback defines the callback to call
  120286. */
  120287. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  120288. /**
  120289. * Get the current error code of the webGL context
  120290. * @returns the error code
  120291. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120292. */
  120293. getError(): number;
  120294. private _canRenderToFloatFramebuffer;
  120295. private _canRenderToHalfFloatFramebuffer;
  120296. private _canRenderToFramebuffer;
  120297. /** @hidden */
  120298. _getWebGLTextureType(type: number): number;
  120299. /** @hidden */
  120300. _getInternalFormat(format: number): number;
  120301. /** @hidden */
  120302. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  120303. /** @hidden */
  120304. _getRGBAMultiSampleBufferFormat(type: number): number;
  120305. /** @hidden */
  120306. _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;
  120307. /**
  120308. * Loads a file from a url
  120309. * @param url url to load
  120310. * @param onSuccess callback called when the file successfully loads
  120311. * @param onProgress callback called while file is loading (if the server supports this mode)
  120312. * @param offlineProvider defines the offline provider for caching
  120313. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  120314. * @param onError callback called when the file fails to load
  120315. * @returns a file request object
  120316. * @hidden
  120317. */
  120318. 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;
  120319. /**
  120320. * Reads pixels from the current frame buffer. Please note that this function can be slow
  120321. * @param x defines the x coordinate of the rectangle where pixels must be read
  120322. * @param y defines the y coordinate of the rectangle where pixels must be read
  120323. * @param width defines the width of the rectangle where pixels must be read
  120324. * @param height defines the height of the rectangle where pixels must be read
  120325. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  120326. * @returns a Uint8Array containing RGBA colors
  120327. */
  120328. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  120329. private static _IsSupported;
  120330. private static _HasMajorPerformanceCaveat;
  120331. /**
  120332. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120333. */
  120334. static get IsSupported(): boolean;
  120335. /**
  120336. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120337. * @returns true if the engine can be created
  120338. * @ignorenaming
  120339. */
  120340. static isSupported(): boolean;
  120341. /**
  120342. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  120343. */
  120344. static get HasMajorPerformanceCaveat(): boolean;
  120345. /**
  120346. * Find the next highest power of two.
  120347. * @param x Number to start search from.
  120348. * @return Next highest power of two.
  120349. */
  120350. static CeilingPOT(x: number): number;
  120351. /**
  120352. * Find the next lowest power of two.
  120353. * @param x Number to start search from.
  120354. * @return Next lowest power of two.
  120355. */
  120356. static FloorPOT(x: number): number;
  120357. /**
  120358. * Find the nearest power of two.
  120359. * @param x Number to start search from.
  120360. * @return Next nearest power of two.
  120361. */
  120362. static NearestPOT(x: number): number;
  120363. /**
  120364. * Get the closest exponent of two
  120365. * @param value defines the value to approximate
  120366. * @param max defines the maximum value to return
  120367. * @param mode defines how to define the closest value
  120368. * @returns closest exponent of two of the given value
  120369. */
  120370. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  120371. /**
  120372. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  120373. * @param func - the function to be called
  120374. * @param requester - the object that will request the next frame. Falls back to window.
  120375. * @returns frame number
  120376. */
  120377. static QueueNewFrame(func: () => void, requester?: any): number;
  120378. /**
  120379. * Gets host document
  120380. * @returns the host document object
  120381. */
  120382. getHostDocument(): Nullable<Document>;
  120383. }
  120384. }
  120385. declare module BABYLON {
  120386. /**
  120387. * Defines the source of the internal texture
  120388. */
  120389. export enum InternalTextureSource {
  120390. /**
  120391. * The source of the texture data is unknown
  120392. */
  120393. Unknown = 0,
  120394. /**
  120395. * Texture data comes from an URL
  120396. */
  120397. Url = 1,
  120398. /**
  120399. * Texture data is only used for temporary storage
  120400. */
  120401. Temp = 2,
  120402. /**
  120403. * Texture data comes from raw data (ArrayBuffer)
  120404. */
  120405. Raw = 3,
  120406. /**
  120407. * Texture content is dynamic (video or dynamic texture)
  120408. */
  120409. Dynamic = 4,
  120410. /**
  120411. * Texture content is generated by rendering to it
  120412. */
  120413. RenderTarget = 5,
  120414. /**
  120415. * Texture content is part of a multi render target process
  120416. */
  120417. MultiRenderTarget = 6,
  120418. /**
  120419. * Texture data comes from a cube data file
  120420. */
  120421. Cube = 7,
  120422. /**
  120423. * Texture data comes from a raw cube data
  120424. */
  120425. CubeRaw = 8,
  120426. /**
  120427. * Texture data come from a prefiltered cube data file
  120428. */
  120429. CubePrefiltered = 9,
  120430. /**
  120431. * Texture content is raw 3D data
  120432. */
  120433. Raw3D = 10,
  120434. /**
  120435. * Texture content is raw 2D array data
  120436. */
  120437. Raw2DArray = 11,
  120438. /**
  120439. * Texture content is a depth texture
  120440. */
  120441. Depth = 12,
  120442. /**
  120443. * Texture data comes from a raw cube data encoded with RGBD
  120444. */
  120445. CubeRawRGBD = 13
  120446. }
  120447. /**
  120448. * Class used to store data associated with WebGL texture data for the engine
  120449. * This class should not be used directly
  120450. */
  120451. export class InternalTexture {
  120452. /** @hidden */
  120453. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  120454. /**
  120455. * Defines if the texture is ready
  120456. */
  120457. isReady: boolean;
  120458. /**
  120459. * Defines if the texture is a cube texture
  120460. */
  120461. isCube: boolean;
  120462. /**
  120463. * Defines if the texture contains 3D data
  120464. */
  120465. is3D: boolean;
  120466. /**
  120467. * Defines if the texture contains 2D array data
  120468. */
  120469. is2DArray: boolean;
  120470. /**
  120471. * Defines if the texture contains multiview data
  120472. */
  120473. isMultiview: boolean;
  120474. /**
  120475. * Gets the URL used to load this texture
  120476. */
  120477. url: string;
  120478. /**
  120479. * Gets the sampling mode of the texture
  120480. */
  120481. samplingMode: number;
  120482. /**
  120483. * Gets a boolean indicating if the texture needs mipmaps generation
  120484. */
  120485. generateMipMaps: boolean;
  120486. /**
  120487. * Gets the number of samples used by the texture (WebGL2+ only)
  120488. */
  120489. samples: number;
  120490. /**
  120491. * Gets the type of the texture (int, float...)
  120492. */
  120493. type: number;
  120494. /**
  120495. * Gets the format of the texture (RGB, RGBA...)
  120496. */
  120497. format: number;
  120498. /**
  120499. * Observable called when the texture is loaded
  120500. */
  120501. onLoadedObservable: Observable<InternalTexture>;
  120502. /**
  120503. * Gets the width of the texture
  120504. */
  120505. width: number;
  120506. /**
  120507. * Gets the height of the texture
  120508. */
  120509. height: number;
  120510. /**
  120511. * Gets the depth of the texture
  120512. */
  120513. depth: number;
  120514. /**
  120515. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  120516. */
  120517. baseWidth: number;
  120518. /**
  120519. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  120520. */
  120521. baseHeight: number;
  120522. /**
  120523. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  120524. */
  120525. baseDepth: number;
  120526. /**
  120527. * Gets a boolean indicating if the texture is inverted on Y axis
  120528. */
  120529. invertY: boolean;
  120530. /** @hidden */
  120531. _invertVScale: boolean;
  120532. /** @hidden */
  120533. _associatedChannel: number;
  120534. /** @hidden */
  120535. _source: InternalTextureSource;
  120536. /** @hidden */
  120537. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  120538. /** @hidden */
  120539. _bufferView: Nullable<ArrayBufferView>;
  120540. /** @hidden */
  120541. _bufferViewArray: Nullable<ArrayBufferView[]>;
  120542. /** @hidden */
  120543. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  120544. /** @hidden */
  120545. _size: number;
  120546. /** @hidden */
  120547. _extension: string;
  120548. /** @hidden */
  120549. _files: Nullable<string[]>;
  120550. /** @hidden */
  120551. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  120552. /** @hidden */
  120553. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  120554. /** @hidden */
  120555. _framebuffer: Nullable<WebGLFramebuffer>;
  120556. /** @hidden */
  120557. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  120558. /** @hidden */
  120559. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  120560. /** @hidden */
  120561. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  120562. /** @hidden */
  120563. _attachments: Nullable<number[]>;
  120564. /** @hidden */
  120565. _textureArray: Nullable<InternalTexture[]>;
  120566. /** @hidden */
  120567. _cachedCoordinatesMode: Nullable<number>;
  120568. /** @hidden */
  120569. _cachedWrapU: Nullable<number>;
  120570. /** @hidden */
  120571. _cachedWrapV: Nullable<number>;
  120572. /** @hidden */
  120573. _cachedWrapR: Nullable<number>;
  120574. /** @hidden */
  120575. _cachedAnisotropicFilteringLevel: Nullable<number>;
  120576. /** @hidden */
  120577. _isDisabled: boolean;
  120578. /** @hidden */
  120579. _compression: Nullable<string>;
  120580. /** @hidden */
  120581. _generateStencilBuffer: boolean;
  120582. /** @hidden */
  120583. _generateDepthBuffer: boolean;
  120584. /** @hidden */
  120585. _comparisonFunction: number;
  120586. /** @hidden */
  120587. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  120588. /** @hidden */
  120589. _lodGenerationScale: number;
  120590. /** @hidden */
  120591. _lodGenerationOffset: number;
  120592. /** @hidden */
  120593. _depthStencilTexture: Nullable<InternalTexture>;
  120594. /** @hidden */
  120595. _colorTextureArray: Nullable<WebGLTexture>;
  120596. /** @hidden */
  120597. _depthStencilTextureArray: Nullable<WebGLTexture>;
  120598. /** @hidden */
  120599. _lodTextureHigh: Nullable<BaseTexture>;
  120600. /** @hidden */
  120601. _lodTextureMid: Nullable<BaseTexture>;
  120602. /** @hidden */
  120603. _lodTextureLow: Nullable<BaseTexture>;
  120604. /** @hidden */
  120605. _isRGBD: boolean;
  120606. /** @hidden */
  120607. _linearSpecularLOD: boolean;
  120608. /** @hidden */
  120609. _irradianceTexture: Nullable<BaseTexture>;
  120610. /** @hidden */
  120611. _webGLTexture: Nullable<WebGLTexture>;
  120612. /** @hidden */
  120613. _references: number;
  120614. /** @hidden */
  120615. _gammaSpace: Nullable<boolean>;
  120616. private _engine;
  120617. /**
  120618. * Gets the Engine the texture belongs to.
  120619. * @returns The babylon engine
  120620. */
  120621. getEngine(): ThinEngine;
  120622. /**
  120623. * Gets the data source type of the texture
  120624. */
  120625. get source(): InternalTextureSource;
  120626. /**
  120627. * Creates a new InternalTexture
  120628. * @param engine defines the engine to use
  120629. * @param source defines the type of data that will be used
  120630. * @param delayAllocation if the texture allocation should be delayed (default: false)
  120631. */
  120632. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  120633. /**
  120634. * Increments the number of references (ie. the number of Texture that point to it)
  120635. */
  120636. incrementReferences(): void;
  120637. /**
  120638. * Change the size of the texture (not the size of the content)
  120639. * @param width defines the new width
  120640. * @param height defines the new height
  120641. * @param depth defines the new depth (1 by default)
  120642. */
  120643. updateSize(width: int, height: int, depth?: int): void;
  120644. /** @hidden */
  120645. _rebuild(): void;
  120646. /** @hidden */
  120647. _swapAndDie(target: InternalTexture): void;
  120648. /**
  120649. * Dispose the current allocated resources
  120650. */
  120651. dispose(): void;
  120652. }
  120653. }
  120654. declare module BABYLON {
  120655. /**
  120656. * Class used to work with sound analyzer using fast fourier transform (FFT)
  120657. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120658. */
  120659. export class Analyser {
  120660. /**
  120661. * Gets or sets the smoothing
  120662. * @ignorenaming
  120663. */
  120664. SMOOTHING: number;
  120665. /**
  120666. * Gets or sets the FFT table size
  120667. * @ignorenaming
  120668. */
  120669. FFT_SIZE: number;
  120670. /**
  120671. * Gets or sets the bar graph amplitude
  120672. * @ignorenaming
  120673. */
  120674. BARGRAPHAMPLITUDE: number;
  120675. /**
  120676. * Gets or sets the position of the debug canvas
  120677. * @ignorenaming
  120678. */
  120679. DEBUGCANVASPOS: {
  120680. x: number;
  120681. y: number;
  120682. };
  120683. /**
  120684. * Gets or sets the debug canvas size
  120685. * @ignorenaming
  120686. */
  120687. DEBUGCANVASSIZE: {
  120688. width: number;
  120689. height: number;
  120690. };
  120691. private _byteFreqs;
  120692. private _byteTime;
  120693. private _floatFreqs;
  120694. private _webAudioAnalyser;
  120695. private _debugCanvas;
  120696. private _debugCanvasContext;
  120697. private _scene;
  120698. private _registerFunc;
  120699. private _audioEngine;
  120700. /**
  120701. * Creates a new analyser
  120702. * @param scene defines hosting scene
  120703. */
  120704. constructor(scene: Scene);
  120705. /**
  120706. * Get the number of data values you will have to play with for the visualization
  120707. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  120708. * @returns a number
  120709. */
  120710. getFrequencyBinCount(): number;
  120711. /**
  120712. * Gets the current frequency data as a byte array
  120713. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  120714. * @returns a Uint8Array
  120715. */
  120716. getByteFrequencyData(): Uint8Array;
  120717. /**
  120718. * Gets the current waveform as a byte array
  120719. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  120720. * @returns a Uint8Array
  120721. */
  120722. getByteTimeDomainData(): Uint8Array;
  120723. /**
  120724. * Gets the current frequency data as a float array
  120725. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  120726. * @returns a Float32Array
  120727. */
  120728. getFloatFrequencyData(): Float32Array;
  120729. /**
  120730. * Renders the debug canvas
  120731. */
  120732. drawDebugCanvas(): void;
  120733. /**
  120734. * Stops rendering the debug canvas and removes it
  120735. */
  120736. stopDebugCanvas(): void;
  120737. /**
  120738. * Connects two audio nodes
  120739. * @param inputAudioNode defines first node to connect
  120740. * @param outputAudioNode defines second node to connect
  120741. */
  120742. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  120743. /**
  120744. * Releases all associated resources
  120745. */
  120746. dispose(): void;
  120747. }
  120748. }
  120749. declare module BABYLON {
  120750. /**
  120751. * This represents an audio engine and it is responsible
  120752. * to play, synchronize and analyse sounds throughout the application.
  120753. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120754. */
  120755. export interface IAudioEngine extends IDisposable {
  120756. /**
  120757. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  120758. */
  120759. readonly canUseWebAudio: boolean;
  120760. /**
  120761. * Gets the current AudioContext if available.
  120762. */
  120763. readonly audioContext: Nullable<AudioContext>;
  120764. /**
  120765. * The master gain node defines the global audio volume of your audio engine.
  120766. */
  120767. readonly masterGain: GainNode;
  120768. /**
  120769. * Gets whether or not mp3 are supported by your browser.
  120770. */
  120771. readonly isMP3supported: boolean;
  120772. /**
  120773. * Gets whether or not ogg are supported by your browser.
  120774. */
  120775. readonly isOGGsupported: boolean;
  120776. /**
  120777. * Defines if Babylon should emit a warning if WebAudio is not supported.
  120778. * @ignoreNaming
  120779. */
  120780. WarnedWebAudioUnsupported: boolean;
  120781. /**
  120782. * Defines if the audio engine relies on a custom unlocked button.
  120783. * In this case, the embedded button will not be displayed.
  120784. */
  120785. useCustomUnlockedButton: boolean;
  120786. /**
  120787. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  120788. */
  120789. readonly unlocked: boolean;
  120790. /**
  120791. * Event raised when audio has been unlocked on the browser.
  120792. */
  120793. onAudioUnlockedObservable: Observable<AudioEngine>;
  120794. /**
  120795. * Event raised when audio has been locked on the browser.
  120796. */
  120797. onAudioLockedObservable: Observable<AudioEngine>;
  120798. /**
  120799. * Flags the audio engine in Locked state.
  120800. * This happens due to new browser policies preventing audio to autoplay.
  120801. */
  120802. lock(): void;
  120803. /**
  120804. * Unlocks the audio engine once a user action has been done on the dom.
  120805. * This is helpful to resume play once browser policies have been satisfied.
  120806. */
  120807. unlock(): void;
  120808. /**
  120809. * Gets the global volume sets on the master gain.
  120810. * @returns the global volume if set or -1 otherwise
  120811. */
  120812. getGlobalVolume(): number;
  120813. /**
  120814. * Sets the global volume of your experience (sets on the master gain).
  120815. * @param newVolume Defines the new global volume of the application
  120816. */
  120817. setGlobalVolume(newVolume: number): void;
  120818. /**
  120819. * Connect the audio engine to an audio analyser allowing some amazing
  120820. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120821. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120822. * @param analyser The analyser to connect to the engine
  120823. */
  120824. connectToAnalyser(analyser: Analyser): void;
  120825. }
  120826. /**
  120827. * This represents the default audio engine used in babylon.
  120828. * It is responsible to play, synchronize and analyse sounds throughout the application.
  120829. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120830. */
  120831. export class AudioEngine implements IAudioEngine {
  120832. private _audioContext;
  120833. private _audioContextInitialized;
  120834. private _muteButton;
  120835. private _hostElement;
  120836. /**
  120837. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  120838. */
  120839. canUseWebAudio: boolean;
  120840. /**
  120841. * The master gain node defines the global audio volume of your audio engine.
  120842. */
  120843. masterGain: GainNode;
  120844. /**
  120845. * Defines if Babylon should emit a warning if WebAudio is not supported.
  120846. * @ignoreNaming
  120847. */
  120848. WarnedWebAudioUnsupported: boolean;
  120849. /**
  120850. * Gets whether or not mp3 are supported by your browser.
  120851. */
  120852. isMP3supported: boolean;
  120853. /**
  120854. * Gets whether or not ogg are supported by your browser.
  120855. */
  120856. isOGGsupported: boolean;
  120857. /**
  120858. * Gets whether audio has been unlocked on the device.
  120859. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  120860. * a user interaction has happened.
  120861. */
  120862. unlocked: boolean;
  120863. /**
  120864. * Defines if the audio engine relies on a custom unlocked button.
  120865. * In this case, the embedded button will not be displayed.
  120866. */
  120867. useCustomUnlockedButton: boolean;
  120868. /**
  120869. * Event raised when audio has been unlocked on the browser.
  120870. */
  120871. onAudioUnlockedObservable: Observable<AudioEngine>;
  120872. /**
  120873. * Event raised when audio has been locked on the browser.
  120874. */
  120875. onAudioLockedObservable: Observable<AudioEngine>;
  120876. /**
  120877. * Gets the current AudioContext if available.
  120878. */
  120879. get audioContext(): Nullable<AudioContext>;
  120880. private _connectedAnalyser;
  120881. /**
  120882. * Instantiates a new audio engine.
  120883. *
  120884. * There should be only one per page as some browsers restrict the number
  120885. * of audio contexts you can create.
  120886. * @param hostElement defines the host element where to display the mute icon if necessary
  120887. */
  120888. constructor(hostElement?: Nullable<HTMLElement>);
  120889. /**
  120890. * Flags the audio engine in Locked state.
  120891. * This happens due to new browser policies preventing audio to autoplay.
  120892. */
  120893. lock(): void;
  120894. /**
  120895. * Unlocks the audio engine once a user action has been done on the dom.
  120896. * This is helpful to resume play once browser policies have been satisfied.
  120897. */
  120898. unlock(): void;
  120899. private _resumeAudioContext;
  120900. private _initializeAudioContext;
  120901. private _tryToRun;
  120902. private _triggerRunningState;
  120903. private _triggerSuspendedState;
  120904. private _displayMuteButton;
  120905. private _moveButtonToTopLeft;
  120906. private _onResize;
  120907. private _hideMuteButton;
  120908. /**
  120909. * Destroy and release the resources associated with the audio ccontext.
  120910. */
  120911. dispose(): void;
  120912. /**
  120913. * Gets the global volume sets on the master gain.
  120914. * @returns the global volume if set or -1 otherwise
  120915. */
  120916. getGlobalVolume(): number;
  120917. /**
  120918. * Sets the global volume of your experience (sets on the master gain).
  120919. * @param newVolume Defines the new global volume of the application
  120920. */
  120921. setGlobalVolume(newVolume: number): void;
  120922. /**
  120923. * Connect the audio engine to an audio analyser allowing some amazing
  120924. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120925. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120926. * @param analyser The analyser to connect to the engine
  120927. */
  120928. connectToAnalyser(analyser: Analyser): void;
  120929. }
  120930. }
  120931. declare module BABYLON {
  120932. /**
  120933. * Interface used to present a loading screen while loading a scene
  120934. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120935. */
  120936. export interface ILoadingScreen {
  120937. /**
  120938. * Function called to display the loading screen
  120939. */
  120940. displayLoadingUI: () => void;
  120941. /**
  120942. * Function called to hide the loading screen
  120943. */
  120944. hideLoadingUI: () => void;
  120945. /**
  120946. * Gets or sets the color to use for the background
  120947. */
  120948. loadingUIBackgroundColor: string;
  120949. /**
  120950. * Gets or sets the text to display while loading
  120951. */
  120952. loadingUIText: string;
  120953. }
  120954. /**
  120955. * Class used for the default loading screen
  120956. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120957. */
  120958. export class DefaultLoadingScreen implements ILoadingScreen {
  120959. private _renderingCanvas;
  120960. private _loadingText;
  120961. private _loadingDivBackgroundColor;
  120962. private _loadingDiv;
  120963. private _loadingTextDiv;
  120964. /** Gets or sets the logo url to use for the default loading screen */
  120965. static DefaultLogoUrl: string;
  120966. /** Gets or sets the spinner url to use for the default loading screen */
  120967. static DefaultSpinnerUrl: string;
  120968. /**
  120969. * Creates a new default loading screen
  120970. * @param _renderingCanvas defines the canvas used to render the scene
  120971. * @param _loadingText defines the default text to display
  120972. * @param _loadingDivBackgroundColor defines the default background color
  120973. */
  120974. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  120975. /**
  120976. * Function called to display the loading screen
  120977. */
  120978. displayLoadingUI(): void;
  120979. /**
  120980. * Function called to hide the loading screen
  120981. */
  120982. hideLoadingUI(): void;
  120983. /**
  120984. * Gets or sets the text to display while loading
  120985. */
  120986. set loadingUIText(text: string);
  120987. get loadingUIText(): string;
  120988. /**
  120989. * Gets or sets the color to use for the background
  120990. */
  120991. get loadingUIBackgroundColor(): string;
  120992. set loadingUIBackgroundColor(color: string);
  120993. private _resizeLoadingUI;
  120994. }
  120995. }
  120996. declare module BABYLON {
  120997. /**
  120998. * Interface for any object that can request an animation frame
  120999. */
  121000. export interface ICustomAnimationFrameRequester {
  121001. /**
  121002. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  121003. */
  121004. renderFunction?: Function;
  121005. /**
  121006. * Called to request the next frame to render to
  121007. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  121008. */
  121009. requestAnimationFrame: Function;
  121010. /**
  121011. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  121012. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  121013. */
  121014. requestID?: number;
  121015. }
  121016. }
  121017. declare module BABYLON {
  121018. /**
  121019. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  121020. */
  121021. export class PerformanceMonitor {
  121022. private _enabled;
  121023. private _rollingFrameTime;
  121024. private _lastFrameTimeMs;
  121025. /**
  121026. * constructor
  121027. * @param frameSampleSize The number of samples required to saturate the sliding window
  121028. */
  121029. constructor(frameSampleSize?: number);
  121030. /**
  121031. * Samples current frame
  121032. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  121033. */
  121034. sampleFrame(timeMs?: number): void;
  121035. /**
  121036. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  121037. */
  121038. get averageFrameTime(): number;
  121039. /**
  121040. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  121041. */
  121042. get averageFrameTimeVariance(): number;
  121043. /**
  121044. * Returns the frame time of the most recent frame
  121045. */
  121046. get instantaneousFrameTime(): number;
  121047. /**
  121048. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  121049. */
  121050. get averageFPS(): number;
  121051. /**
  121052. * Returns the average framerate in frames per second using the most recent frame time
  121053. */
  121054. get instantaneousFPS(): number;
  121055. /**
  121056. * Returns true if enough samples have been taken to completely fill the sliding window
  121057. */
  121058. get isSaturated(): boolean;
  121059. /**
  121060. * Enables contributions to the sliding window sample set
  121061. */
  121062. enable(): void;
  121063. /**
  121064. * Disables contributions to the sliding window sample set
  121065. * Samples will not be interpolated over the disabled period
  121066. */
  121067. disable(): void;
  121068. /**
  121069. * Returns true if sampling is enabled
  121070. */
  121071. get isEnabled(): boolean;
  121072. /**
  121073. * Resets performance monitor
  121074. */
  121075. reset(): void;
  121076. }
  121077. /**
  121078. * RollingAverage
  121079. *
  121080. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  121081. */
  121082. export class RollingAverage {
  121083. /**
  121084. * Current average
  121085. */
  121086. average: number;
  121087. /**
  121088. * Current variance
  121089. */
  121090. variance: number;
  121091. protected _samples: Array<number>;
  121092. protected _sampleCount: number;
  121093. protected _pos: number;
  121094. protected _m2: number;
  121095. /**
  121096. * constructor
  121097. * @param length The number of samples required to saturate the sliding window
  121098. */
  121099. constructor(length: number);
  121100. /**
  121101. * Adds a sample to the sample set
  121102. * @param v The sample value
  121103. */
  121104. add(v: number): void;
  121105. /**
  121106. * Returns previously added values or null if outside of history or outside the sliding window domain
  121107. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  121108. * @return Value previously recorded with add() or null if outside of range
  121109. */
  121110. history(i: number): number;
  121111. /**
  121112. * Returns true if enough samples have been taken to completely fill the sliding window
  121113. * @return true if sample-set saturated
  121114. */
  121115. isSaturated(): boolean;
  121116. /**
  121117. * Resets the rolling average (equivalent to 0 samples taken so far)
  121118. */
  121119. reset(): void;
  121120. /**
  121121. * Wraps a value around the sample range boundaries
  121122. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  121123. * @return Wrapped position in sample range
  121124. */
  121125. protected _wrapPosition(i: number): number;
  121126. }
  121127. }
  121128. declare module BABYLON {
  121129. /**
  121130. * This class is used to track a performance counter which is number based.
  121131. * The user has access to many properties which give statistics of different nature.
  121132. *
  121133. * The implementer can track two kinds of Performance Counter: time and count.
  121134. * 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.
  121135. * 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.
  121136. */
  121137. export class PerfCounter {
  121138. /**
  121139. * Gets or sets a global boolean to turn on and off all the counters
  121140. */
  121141. static Enabled: boolean;
  121142. /**
  121143. * Returns the smallest value ever
  121144. */
  121145. get min(): number;
  121146. /**
  121147. * Returns the biggest value ever
  121148. */
  121149. get max(): number;
  121150. /**
  121151. * Returns the average value since the performance counter is running
  121152. */
  121153. get average(): number;
  121154. /**
  121155. * Returns the average value of the last second the counter was monitored
  121156. */
  121157. get lastSecAverage(): number;
  121158. /**
  121159. * Returns the current value
  121160. */
  121161. get current(): number;
  121162. /**
  121163. * Gets the accumulated total
  121164. */
  121165. get total(): number;
  121166. /**
  121167. * Gets the total value count
  121168. */
  121169. get count(): number;
  121170. /**
  121171. * Creates a new counter
  121172. */
  121173. constructor();
  121174. /**
  121175. * Call this method to start monitoring a new frame.
  121176. * 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.
  121177. */
  121178. fetchNewFrame(): void;
  121179. /**
  121180. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  121181. * @param newCount the count value to add to the monitored count
  121182. * @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.
  121183. */
  121184. addCount(newCount: number, fetchResult: boolean): void;
  121185. /**
  121186. * Start monitoring this performance counter
  121187. */
  121188. beginMonitoring(): void;
  121189. /**
  121190. * Compute the time lapsed since the previous beginMonitoring() call.
  121191. * @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
  121192. */
  121193. endMonitoring(newFrame?: boolean): void;
  121194. private _fetchResult;
  121195. private _startMonitoringTime;
  121196. private _min;
  121197. private _max;
  121198. private _average;
  121199. private _current;
  121200. private _totalValueCount;
  121201. private _totalAccumulated;
  121202. private _lastSecAverage;
  121203. private _lastSecAccumulated;
  121204. private _lastSecTime;
  121205. private _lastSecValueCount;
  121206. }
  121207. }
  121208. declare module BABYLON {
  121209. interface ThinEngine {
  121210. /** @hidden */
  121211. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  121212. }
  121213. }
  121214. declare module BABYLON {
  121215. /**
  121216. * Defines the interface used by display changed events
  121217. */
  121218. export interface IDisplayChangedEventArgs {
  121219. /** Gets the vrDisplay object (if any) */
  121220. vrDisplay: Nullable<any>;
  121221. /** Gets a boolean indicating if webVR is supported */
  121222. vrSupported: boolean;
  121223. }
  121224. /**
  121225. * Defines the interface used by objects containing a viewport (like a camera)
  121226. */
  121227. interface IViewportOwnerLike {
  121228. /**
  121229. * Gets or sets the viewport
  121230. */
  121231. viewport: IViewportLike;
  121232. }
  121233. /**
  121234. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  121235. */
  121236. export class Engine extends ThinEngine {
  121237. /** Defines that alpha blending is disabled */
  121238. static readonly ALPHA_DISABLE: number;
  121239. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  121240. static readonly ALPHA_ADD: number;
  121241. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  121242. static readonly ALPHA_COMBINE: number;
  121243. /** Defines that alpha blending to DEST - SRC * DEST */
  121244. static readonly ALPHA_SUBTRACT: number;
  121245. /** Defines that alpha blending to SRC * DEST */
  121246. static readonly ALPHA_MULTIPLY: number;
  121247. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  121248. static readonly ALPHA_MAXIMIZED: number;
  121249. /** Defines that alpha blending to SRC + DEST */
  121250. static readonly ALPHA_ONEONE: number;
  121251. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  121252. static readonly ALPHA_PREMULTIPLIED: number;
  121253. /**
  121254. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  121255. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  121256. */
  121257. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  121258. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  121259. static readonly ALPHA_INTERPOLATE: number;
  121260. /**
  121261. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  121262. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  121263. */
  121264. static readonly ALPHA_SCREENMODE: number;
  121265. /** Defines that the ressource is not delayed*/
  121266. static readonly DELAYLOADSTATE_NONE: number;
  121267. /** Defines that the ressource was successfully delay loaded */
  121268. static readonly DELAYLOADSTATE_LOADED: number;
  121269. /** Defines that the ressource is currently delay loading */
  121270. static readonly DELAYLOADSTATE_LOADING: number;
  121271. /** Defines that the ressource is delayed and has not started loading */
  121272. static readonly DELAYLOADSTATE_NOTLOADED: number;
  121273. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  121274. static readonly NEVER: number;
  121275. /** 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 */
  121276. static readonly ALWAYS: number;
  121277. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  121278. static readonly LESS: number;
  121279. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  121280. static readonly EQUAL: number;
  121281. /** 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 */
  121282. static readonly LEQUAL: number;
  121283. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  121284. static readonly GREATER: number;
  121285. /** 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 */
  121286. static readonly GEQUAL: number;
  121287. /** 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 */
  121288. static readonly NOTEQUAL: number;
  121289. /** Passed to stencilOperation to specify that stencil value must be kept */
  121290. static readonly KEEP: number;
  121291. /** Passed to stencilOperation to specify that stencil value must be replaced */
  121292. static readonly REPLACE: number;
  121293. /** Passed to stencilOperation to specify that stencil value must be incremented */
  121294. static readonly INCR: number;
  121295. /** Passed to stencilOperation to specify that stencil value must be decremented */
  121296. static readonly DECR: number;
  121297. /** Passed to stencilOperation to specify that stencil value must be inverted */
  121298. static readonly INVERT: number;
  121299. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  121300. static readonly INCR_WRAP: number;
  121301. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  121302. static readonly DECR_WRAP: number;
  121303. /** Texture is not repeating outside of 0..1 UVs */
  121304. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  121305. /** Texture is repeating outside of 0..1 UVs */
  121306. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  121307. /** Texture is repeating and mirrored */
  121308. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  121309. /** ALPHA */
  121310. static readonly TEXTUREFORMAT_ALPHA: number;
  121311. /** LUMINANCE */
  121312. static readonly TEXTUREFORMAT_LUMINANCE: number;
  121313. /** LUMINANCE_ALPHA */
  121314. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  121315. /** RGB */
  121316. static readonly TEXTUREFORMAT_RGB: number;
  121317. /** RGBA */
  121318. static readonly TEXTUREFORMAT_RGBA: number;
  121319. /** RED */
  121320. static readonly TEXTUREFORMAT_RED: number;
  121321. /** RED (2nd reference) */
  121322. static readonly TEXTUREFORMAT_R: number;
  121323. /** RG */
  121324. static readonly TEXTUREFORMAT_RG: number;
  121325. /** RED_INTEGER */
  121326. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  121327. /** RED_INTEGER (2nd reference) */
  121328. static readonly TEXTUREFORMAT_R_INTEGER: number;
  121329. /** RG_INTEGER */
  121330. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  121331. /** RGB_INTEGER */
  121332. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  121333. /** RGBA_INTEGER */
  121334. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  121335. /** UNSIGNED_BYTE */
  121336. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  121337. /** UNSIGNED_BYTE (2nd reference) */
  121338. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  121339. /** FLOAT */
  121340. static readonly TEXTURETYPE_FLOAT: number;
  121341. /** HALF_FLOAT */
  121342. static readonly TEXTURETYPE_HALF_FLOAT: number;
  121343. /** BYTE */
  121344. static readonly TEXTURETYPE_BYTE: number;
  121345. /** SHORT */
  121346. static readonly TEXTURETYPE_SHORT: number;
  121347. /** UNSIGNED_SHORT */
  121348. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  121349. /** INT */
  121350. static readonly TEXTURETYPE_INT: number;
  121351. /** UNSIGNED_INT */
  121352. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  121353. /** UNSIGNED_SHORT_4_4_4_4 */
  121354. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  121355. /** UNSIGNED_SHORT_5_5_5_1 */
  121356. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  121357. /** UNSIGNED_SHORT_5_6_5 */
  121358. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  121359. /** UNSIGNED_INT_2_10_10_10_REV */
  121360. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  121361. /** UNSIGNED_INT_24_8 */
  121362. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  121363. /** UNSIGNED_INT_10F_11F_11F_REV */
  121364. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  121365. /** UNSIGNED_INT_5_9_9_9_REV */
  121366. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  121367. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  121368. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  121369. /** nearest is mag = nearest and min = nearest and mip = linear */
  121370. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  121371. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121372. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  121373. /** Trilinear is mag = linear and min = linear and mip = linear */
  121374. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  121375. /** nearest is mag = nearest and min = nearest and mip = linear */
  121376. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  121377. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121378. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  121379. /** Trilinear is mag = linear and min = linear and mip = linear */
  121380. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  121381. /** mag = nearest and min = nearest and mip = nearest */
  121382. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  121383. /** mag = nearest and min = linear and mip = nearest */
  121384. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  121385. /** mag = nearest and min = linear and mip = linear */
  121386. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  121387. /** mag = nearest and min = linear and mip = none */
  121388. static readonly TEXTURE_NEAREST_LINEAR: number;
  121389. /** mag = nearest and min = nearest and mip = none */
  121390. static readonly TEXTURE_NEAREST_NEAREST: number;
  121391. /** mag = linear and min = nearest and mip = nearest */
  121392. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  121393. /** mag = linear and min = nearest and mip = linear */
  121394. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  121395. /** mag = linear and min = linear and mip = none */
  121396. static readonly TEXTURE_LINEAR_LINEAR: number;
  121397. /** mag = linear and min = nearest and mip = none */
  121398. static readonly TEXTURE_LINEAR_NEAREST: number;
  121399. /** Explicit coordinates mode */
  121400. static readonly TEXTURE_EXPLICIT_MODE: number;
  121401. /** Spherical coordinates mode */
  121402. static readonly TEXTURE_SPHERICAL_MODE: number;
  121403. /** Planar coordinates mode */
  121404. static readonly TEXTURE_PLANAR_MODE: number;
  121405. /** Cubic coordinates mode */
  121406. static readonly TEXTURE_CUBIC_MODE: number;
  121407. /** Projection coordinates mode */
  121408. static readonly TEXTURE_PROJECTION_MODE: number;
  121409. /** Skybox coordinates mode */
  121410. static readonly TEXTURE_SKYBOX_MODE: number;
  121411. /** Inverse Cubic coordinates mode */
  121412. static readonly TEXTURE_INVCUBIC_MODE: number;
  121413. /** Equirectangular coordinates mode */
  121414. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  121415. /** Equirectangular Fixed coordinates mode */
  121416. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  121417. /** Equirectangular Fixed Mirrored coordinates mode */
  121418. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  121419. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  121420. static readonly SCALEMODE_FLOOR: number;
  121421. /** Defines that texture rescaling will look for the nearest power of 2 size */
  121422. static readonly SCALEMODE_NEAREST: number;
  121423. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  121424. static readonly SCALEMODE_CEILING: number;
  121425. /**
  121426. * Returns the current npm package of the sdk
  121427. */
  121428. static get NpmPackage(): string;
  121429. /**
  121430. * Returns the current version of the framework
  121431. */
  121432. static get Version(): string;
  121433. /** Gets the list of created engines */
  121434. static get Instances(): Engine[];
  121435. /**
  121436. * Gets the latest created engine
  121437. */
  121438. static get LastCreatedEngine(): Nullable<Engine>;
  121439. /**
  121440. * Gets the latest created scene
  121441. */
  121442. static get LastCreatedScene(): Nullable<Scene>;
  121443. /**
  121444. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  121445. * @param flag defines which part of the materials must be marked as dirty
  121446. * @param predicate defines a predicate used to filter which materials should be affected
  121447. */
  121448. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121449. /**
  121450. * Method called to create the default loading screen.
  121451. * This can be overriden in your own app.
  121452. * @param canvas The rendering canvas element
  121453. * @returns The loading screen
  121454. */
  121455. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  121456. /**
  121457. * Method called to create the default rescale post process on each engine.
  121458. */
  121459. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  121460. /**
  121461. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  121462. **/
  121463. enableOfflineSupport: boolean;
  121464. /**
  121465. * 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)
  121466. **/
  121467. disableManifestCheck: boolean;
  121468. /**
  121469. * Gets the list of created scenes
  121470. */
  121471. scenes: Scene[];
  121472. /**
  121473. * Event raised when a new scene is created
  121474. */
  121475. onNewSceneAddedObservable: Observable<Scene>;
  121476. /**
  121477. * Gets the list of created postprocesses
  121478. */
  121479. postProcesses: PostProcess[];
  121480. /**
  121481. * Gets a boolean indicating if the pointer is currently locked
  121482. */
  121483. isPointerLock: boolean;
  121484. /**
  121485. * Observable event triggered each time the rendering canvas is resized
  121486. */
  121487. onResizeObservable: Observable<Engine>;
  121488. /**
  121489. * Observable event triggered each time the canvas loses focus
  121490. */
  121491. onCanvasBlurObservable: Observable<Engine>;
  121492. /**
  121493. * Observable event triggered each time the canvas gains focus
  121494. */
  121495. onCanvasFocusObservable: Observable<Engine>;
  121496. /**
  121497. * Observable event triggered each time the canvas receives pointerout event
  121498. */
  121499. onCanvasPointerOutObservable: Observable<PointerEvent>;
  121500. /**
  121501. * Observable raised when the engine begins a new frame
  121502. */
  121503. onBeginFrameObservable: Observable<Engine>;
  121504. /**
  121505. * If set, will be used to request the next animation frame for the render loop
  121506. */
  121507. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  121508. /**
  121509. * Observable raised when the engine ends the current frame
  121510. */
  121511. onEndFrameObservable: Observable<Engine>;
  121512. /**
  121513. * Observable raised when the engine is about to compile a shader
  121514. */
  121515. onBeforeShaderCompilationObservable: Observable<Engine>;
  121516. /**
  121517. * Observable raised when the engine has jsut compiled a shader
  121518. */
  121519. onAfterShaderCompilationObservable: Observable<Engine>;
  121520. /**
  121521. * Gets the audio engine
  121522. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121523. * @ignorenaming
  121524. */
  121525. static audioEngine: IAudioEngine;
  121526. /**
  121527. * Default AudioEngine factory responsible of creating the Audio Engine.
  121528. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  121529. */
  121530. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  121531. /**
  121532. * Default offline support factory responsible of creating a tool used to store data locally.
  121533. * By default, this will create a Database object if the workload has been embedded.
  121534. */
  121535. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  121536. private _loadingScreen;
  121537. private _pointerLockRequested;
  121538. private _rescalePostProcess;
  121539. private _deterministicLockstep;
  121540. private _lockstepMaxSteps;
  121541. private _timeStep;
  121542. protected get _supportsHardwareTextureRescaling(): boolean;
  121543. private _fps;
  121544. private _deltaTime;
  121545. /** @hidden */
  121546. _drawCalls: PerfCounter;
  121547. /** 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 */
  121548. canvasTabIndex: number;
  121549. /**
  121550. * Turn this value on if you want to pause FPS computation when in background
  121551. */
  121552. disablePerformanceMonitorInBackground: boolean;
  121553. private _performanceMonitor;
  121554. /**
  121555. * Gets the performance monitor attached to this engine
  121556. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  121557. */
  121558. get performanceMonitor(): PerformanceMonitor;
  121559. private _onFocus;
  121560. private _onBlur;
  121561. private _onCanvasPointerOut;
  121562. private _onCanvasBlur;
  121563. private _onCanvasFocus;
  121564. private _onFullscreenChange;
  121565. private _onPointerLockChange;
  121566. /**
  121567. * Gets the HTML element used to attach event listeners
  121568. * @returns a HTML element
  121569. */
  121570. getInputElement(): Nullable<HTMLElement>;
  121571. /**
  121572. * Creates a new engine
  121573. * @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
  121574. * @param antialias defines enable antialiasing (default: false)
  121575. * @param options defines further options to be sent to the getContext() function
  121576. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  121577. */
  121578. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  121579. /**
  121580. * Gets current aspect ratio
  121581. * @param viewportOwner defines the camera to use to get the aspect ratio
  121582. * @param useScreen defines if screen size must be used (or the current render target if any)
  121583. * @returns a number defining the aspect ratio
  121584. */
  121585. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  121586. /**
  121587. * Gets current screen aspect ratio
  121588. * @returns a number defining the aspect ratio
  121589. */
  121590. getScreenAspectRatio(): number;
  121591. /**
  121592. * Gets the client rect of the HTML canvas attached with the current webGL context
  121593. * @returns a client rectanglee
  121594. */
  121595. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  121596. /**
  121597. * Gets the client rect of the HTML element used for events
  121598. * @returns a client rectanglee
  121599. */
  121600. getInputElementClientRect(): Nullable<ClientRect>;
  121601. /**
  121602. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  121603. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121604. * @returns true if engine is in deterministic lock step mode
  121605. */
  121606. isDeterministicLockStep(): boolean;
  121607. /**
  121608. * Gets the max steps when engine is running in deterministic lock step
  121609. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121610. * @returns the max steps
  121611. */
  121612. getLockstepMaxSteps(): number;
  121613. /**
  121614. * Returns the time in ms between steps when using deterministic lock step.
  121615. * @returns time step in (ms)
  121616. */
  121617. getTimeStep(): number;
  121618. /**
  121619. * Force the mipmap generation for the given render target texture
  121620. * @param texture defines the render target texture to use
  121621. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  121622. */
  121623. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  121624. /** States */
  121625. /**
  121626. * Set various states to the webGL context
  121627. * @param culling defines backface culling state
  121628. * @param zOffset defines the value to apply to zOffset (0 by default)
  121629. * @param force defines if states must be applied even if cache is up to date
  121630. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  121631. */
  121632. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121633. /**
  121634. * Set the z offset to apply to current rendering
  121635. * @param value defines the offset to apply
  121636. */
  121637. setZOffset(value: number): void;
  121638. /**
  121639. * Gets the current value of the zOffset
  121640. * @returns the current zOffset state
  121641. */
  121642. getZOffset(): number;
  121643. /**
  121644. * Enable or disable depth buffering
  121645. * @param enable defines the state to set
  121646. */
  121647. setDepthBuffer(enable: boolean): void;
  121648. /**
  121649. * Gets a boolean indicating if depth writing is enabled
  121650. * @returns the current depth writing state
  121651. */
  121652. getDepthWrite(): boolean;
  121653. /**
  121654. * Enable or disable depth writing
  121655. * @param enable defines the state to set
  121656. */
  121657. setDepthWrite(enable: boolean): void;
  121658. /**
  121659. * Gets a boolean indicating if stencil buffer is enabled
  121660. * @returns the current stencil buffer state
  121661. */
  121662. getStencilBuffer(): boolean;
  121663. /**
  121664. * Enable or disable the stencil buffer
  121665. * @param enable defines if the stencil buffer must be enabled or disabled
  121666. */
  121667. setStencilBuffer(enable: boolean): void;
  121668. /**
  121669. * Gets the current stencil mask
  121670. * @returns a number defining the new stencil mask to use
  121671. */
  121672. getStencilMask(): number;
  121673. /**
  121674. * Sets the current stencil mask
  121675. * @param mask defines the new stencil mask to use
  121676. */
  121677. setStencilMask(mask: number): void;
  121678. /**
  121679. * Gets the current stencil function
  121680. * @returns a number defining the stencil function to use
  121681. */
  121682. getStencilFunction(): number;
  121683. /**
  121684. * Gets the current stencil reference value
  121685. * @returns a number defining the stencil reference value to use
  121686. */
  121687. getStencilFunctionReference(): number;
  121688. /**
  121689. * Gets the current stencil mask
  121690. * @returns a number defining the stencil mask to use
  121691. */
  121692. getStencilFunctionMask(): number;
  121693. /**
  121694. * Sets the current stencil function
  121695. * @param stencilFunc defines the new stencil function to use
  121696. */
  121697. setStencilFunction(stencilFunc: number): void;
  121698. /**
  121699. * Sets the current stencil reference
  121700. * @param reference defines the new stencil reference to use
  121701. */
  121702. setStencilFunctionReference(reference: number): void;
  121703. /**
  121704. * Sets the current stencil mask
  121705. * @param mask defines the new stencil mask to use
  121706. */
  121707. setStencilFunctionMask(mask: number): void;
  121708. /**
  121709. * Gets the current stencil operation when stencil fails
  121710. * @returns a number defining stencil operation to use when stencil fails
  121711. */
  121712. getStencilOperationFail(): number;
  121713. /**
  121714. * Gets the current stencil operation when depth fails
  121715. * @returns a number defining stencil operation to use when depth fails
  121716. */
  121717. getStencilOperationDepthFail(): number;
  121718. /**
  121719. * Gets the current stencil operation when stencil passes
  121720. * @returns a number defining stencil operation to use when stencil passes
  121721. */
  121722. getStencilOperationPass(): number;
  121723. /**
  121724. * Sets the stencil operation to use when stencil fails
  121725. * @param operation defines the stencil operation to use when stencil fails
  121726. */
  121727. setStencilOperationFail(operation: number): void;
  121728. /**
  121729. * Sets the stencil operation to use when depth fails
  121730. * @param operation defines the stencil operation to use when depth fails
  121731. */
  121732. setStencilOperationDepthFail(operation: number): void;
  121733. /**
  121734. * Sets the stencil operation to use when stencil passes
  121735. * @param operation defines the stencil operation to use when stencil passes
  121736. */
  121737. setStencilOperationPass(operation: number): void;
  121738. /**
  121739. * Sets a boolean indicating if the dithering state is enabled or disabled
  121740. * @param value defines the dithering state
  121741. */
  121742. setDitheringState(value: boolean): void;
  121743. /**
  121744. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  121745. * @param value defines the rasterizer state
  121746. */
  121747. setRasterizerState(value: boolean): void;
  121748. /**
  121749. * Gets the current depth function
  121750. * @returns a number defining the depth function
  121751. */
  121752. getDepthFunction(): Nullable<number>;
  121753. /**
  121754. * Sets the current depth function
  121755. * @param depthFunc defines the function to use
  121756. */
  121757. setDepthFunction(depthFunc: number): void;
  121758. /**
  121759. * Sets the current depth function to GREATER
  121760. */
  121761. setDepthFunctionToGreater(): void;
  121762. /**
  121763. * Sets the current depth function to GEQUAL
  121764. */
  121765. setDepthFunctionToGreaterOrEqual(): void;
  121766. /**
  121767. * Sets the current depth function to LESS
  121768. */
  121769. setDepthFunctionToLess(): void;
  121770. /**
  121771. * Sets the current depth function to LEQUAL
  121772. */
  121773. setDepthFunctionToLessOrEqual(): void;
  121774. private _cachedStencilBuffer;
  121775. private _cachedStencilFunction;
  121776. private _cachedStencilMask;
  121777. private _cachedStencilOperationPass;
  121778. private _cachedStencilOperationFail;
  121779. private _cachedStencilOperationDepthFail;
  121780. private _cachedStencilReference;
  121781. /**
  121782. * Caches the the state of the stencil buffer
  121783. */
  121784. cacheStencilState(): void;
  121785. /**
  121786. * Restores the state of the stencil buffer
  121787. */
  121788. restoreStencilState(): void;
  121789. /**
  121790. * Directly set the WebGL Viewport
  121791. * @param x defines the x coordinate of the viewport (in screen space)
  121792. * @param y defines the y coordinate of the viewport (in screen space)
  121793. * @param width defines the width of the viewport (in screen space)
  121794. * @param height defines the height of the viewport (in screen space)
  121795. * @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
  121796. */
  121797. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  121798. /**
  121799. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  121800. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  121801. * @param y defines the y-coordinate of the corner of the clear rectangle
  121802. * @param width defines the width of the clear rectangle
  121803. * @param height defines the height of the clear rectangle
  121804. * @param clearColor defines the clear color
  121805. */
  121806. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  121807. /**
  121808. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  121809. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  121810. * @param y defines the y-coordinate of the corner of the clear rectangle
  121811. * @param width defines the width of the clear rectangle
  121812. * @param height defines the height of the clear rectangle
  121813. */
  121814. enableScissor(x: number, y: number, width: number, height: number): void;
  121815. /**
  121816. * Disable previously set scissor test rectangle
  121817. */
  121818. disableScissor(): void;
  121819. protected _reportDrawCall(): void;
  121820. /**
  121821. * Initializes a webVR display and starts listening to display change events
  121822. * The onVRDisplayChangedObservable will be notified upon these changes
  121823. * @returns The onVRDisplayChangedObservable
  121824. */
  121825. initWebVR(): Observable<IDisplayChangedEventArgs>;
  121826. /** @hidden */
  121827. _prepareVRComponent(): void;
  121828. /** @hidden */
  121829. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  121830. /** @hidden */
  121831. _submitVRFrame(): void;
  121832. /**
  121833. * Call this function to leave webVR mode
  121834. * Will do nothing if webVR is not supported or if there is no webVR device
  121835. * @see https://doc.babylonjs.com/how_to/webvr_camera
  121836. */
  121837. disableVR(): void;
  121838. /**
  121839. * Gets a boolean indicating that the system is in VR mode and is presenting
  121840. * @returns true if VR mode is engaged
  121841. */
  121842. isVRPresenting(): boolean;
  121843. /** @hidden */
  121844. _requestVRFrame(): void;
  121845. /** @hidden */
  121846. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121847. /**
  121848. * Gets the source code of the vertex shader associated with a specific webGL program
  121849. * @param program defines the program to use
  121850. * @returns a string containing the source code of the vertex shader associated with the program
  121851. */
  121852. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  121853. /**
  121854. * Gets the source code of the fragment shader associated with a specific webGL program
  121855. * @param program defines the program to use
  121856. * @returns a string containing the source code of the fragment shader associated with the program
  121857. */
  121858. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  121859. /**
  121860. * Sets a depth stencil texture from a render target to the according uniform.
  121861. * @param channel The texture channel
  121862. * @param uniform The uniform to set
  121863. * @param texture The render target texture containing the depth stencil texture to apply
  121864. */
  121865. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  121866. /**
  121867. * Sets a texture to the webGL context from a postprocess
  121868. * @param channel defines the channel to use
  121869. * @param postProcess defines the source postprocess
  121870. */
  121871. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  121872. /**
  121873. * Binds the output of the passed in post process to the texture channel specified
  121874. * @param channel The channel the texture should be bound to
  121875. * @param postProcess The post process which's output should be bound
  121876. */
  121877. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  121878. protected _rebuildBuffers(): void;
  121879. /** @hidden */
  121880. _renderFrame(): void;
  121881. _renderLoop(): void;
  121882. /** @hidden */
  121883. _renderViews(): boolean;
  121884. /**
  121885. * Toggle full screen mode
  121886. * @param requestPointerLock defines if a pointer lock should be requested from the user
  121887. */
  121888. switchFullscreen(requestPointerLock: boolean): void;
  121889. /**
  121890. * Enters full screen mode
  121891. * @param requestPointerLock defines if a pointer lock should be requested from the user
  121892. */
  121893. enterFullscreen(requestPointerLock: boolean): void;
  121894. /**
  121895. * Exits full screen mode
  121896. */
  121897. exitFullscreen(): void;
  121898. /**
  121899. * Enters Pointerlock mode
  121900. */
  121901. enterPointerlock(): void;
  121902. /**
  121903. * Exits Pointerlock mode
  121904. */
  121905. exitPointerlock(): void;
  121906. /**
  121907. * Begin a new frame
  121908. */
  121909. beginFrame(): void;
  121910. /**
  121911. * Enf the current frame
  121912. */
  121913. endFrame(): void;
  121914. resize(): void;
  121915. /**
  121916. * Force a specific size of the canvas
  121917. * @param width defines the new canvas' width
  121918. * @param height defines the new canvas' height
  121919. * @returns true if the size was changed
  121920. */
  121921. setSize(width: number, height: number): boolean;
  121922. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  121923. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121924. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121925. _releaseTexture(texture: InternalTexture): void;
  121926. /**
  121927. * @hidden
  121928. * Rescales a texture
  121929. * @param source input texutre
  121930. * @param destination destination texture
  121931. * @param scene scene to use to render the resize
  121932. * @param internalFormat format to use when resizing
  121933. * @param onComplete callback to be called when resize has completed
  121934. */
  121935. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  121936. /**
  121937. * Gets the current framerate
  121938. * @returns a number representing the framerate
  121939. */
  121940. getFps(): number;
  121941. /**
  121942. * Gets the time spent between current and previous frame
  121943. * @returns a number representing the delta time in ms
  121944. */
  121945. getDeltaTime(): number;
  121946. private _measureFps;
  121947. /** @hidden */
  121948. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  121949. /**
  121950. * Updates the sample count of a render target texture
  121951. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  121952. * @param texture defines the texture to update
  121953. * @param samples defines the sample count to set
  121954. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  121955. */
  121956. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  121957. /**
  121958. * Updates a depth texture Comparison Mode and Function.
  121959. * If the comparison Function is equal to 0, the mode will be set to none.
  121960. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  121961. * @param texture The texture to set the comparison function for
  121962. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  121963. */
  121964. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  121965. /**
  121966. * Creates a webGL buffer to use with instanciation
  121967. * @param capacity defines the size of the buffer
  121968. * @returns the webGL buffer
  121969. */
  121970. createInstancesBuffer(capacity: number): DataBuffer;
  121971. /**
  121972. * Delete a webGL buffer used with instanciation
  121973. * @param buffer defines the webGL buffer to delete
  121974. */
  121975. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  121976. private _clientWaitAsync;
  121977. /** @hidden */
  121978. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  121979. dispose(): void;
  121980. private _disableTouchAction;
  121981. /**
  121982. * Display the loading screen
  121983. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121984. */
  121985. displayLoadingUI(): void;
  121986. /**
  121987. * Hide the loading screen
  121988. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121989. */
  121990. hideLoadingUI(): void;
  121991. /**
  121992. * Gets the current loading screen object
  121993. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121994. */
  121995. get loadingScreen(): ILoadingScreen;
  121996. /**
  121997. * Sets the current loading screen object
  121998. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121999. */
  122000. set loadingScreen(loadingScreen: ILoadingScreen);
  122001. /**
  122002. * Sets the current loading screen text
  122003. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122004. */
  122005. set loadingUIText(text: string);
  122006. /**
  122007. * Sets the current loading screen background color
  122008. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122009. */
  122010. set loadingUIBackgroundColor(color: string);
  122011. /** Pointerlock and fullscreen */
  122012. /**
  122013. * Ask the browser to promote the current element to pointerlock mode
  122014. * @param element defines the DOM element to promote
  122015. */
  122016. static _RequestPointerlock(element: HTMLElement): void;
  122017. /**
  122018. * Asks the browser to exit pointerlock mode
  122019. */
  122020. static _ExitPointerlock(): void;
  122021. /**
  122022. * Ask the browser to promote the current element to fullscreen rendering mode
  122023. * @param element defines the DOM element to promote
  122024. */
  122025. static _RequestFullscreen(element: HTMLElement): void;
  122026. /**
  122027. * Asks the browser to exit fullscreen mode
  122028. */
  122029. static _ExitFullscreen(): void;
  122030. }
  122031. }
  122032. declare module BABYLON {
  122033. /**
  122034. * The engine store class is responsible to hold all the instances of Engine and Scene created
  122035. * during the life time of the application.
  122036. */
  122037. export class EngineStore {
  122038. /** Gets the list of created engines */
  122039. static Instances: Engine[];
  122040. /** @hidden */
  122041. static _LastCreatedScene: Nullable<Scene>;
  122042. /**
  122043. * Gets the latest created engine
  122044. */
  122045. static get LastCreatedEngine(): Nullable<Engine>;
  122046. /**
  122047. * Gets the latest created scene
  122048. */
  122049. static get LastCreatedScene(): Nullable<Scene>;
  122050. /**
  122051. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  122052. * @ignorenaming
  122053. */
  122054. static UseFallbackTexture: boolean;
  122055. /**
  122056. * Texture content used if a texture cannot loaded
  122057. * @ignorenaming
  122058. */
  122059. static FallbackTexture: string;
  122060. }
  122061. }
  122062. declare module BABYLON {
  122063. /**
  122064. * Helper class that provides a small promise polyfill
  122065. */
  122066. export class PromisePolyfill {
  122067. /**
  122068. * Static function used to check if the polyfill is required
  122069. * If this is the case then the function will inject the polyfill to window.Promise
  122070. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  122071. */
  122072. static Apply(force?: boolean): void;
  122073. }
  122074. }
  122075. declare module BABYLON {
  122076. /**
  122077. * Interface for screenshot methods with describe argument called `size` as object with options
  122078. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  122079. */
  122080. export interface IScreenshotSize {
  122081. /**
  122082. * number in pixels for canvas height
  122083. */
  122084. height?: number;
  122085. /**
  122086. * multiplier allowing render at a higher or lower resolution
  122087. * If value is defined then height and width will be ignored and taken from camera
  122088. */
  122089. precision?: number;
  122090. /**
  122091. * number in pixels for canvas width
  122092. */
  122093. width?: number;
  122094. }
  122095. }
  122096. declare module BABYLON {
  122097. interface IColor4Like {
  122098. r: float;
  122099. g: float;
  122100. b: float;
  122101. a: float;
  122102. }
  122103. /**
  122104. * Class containing a set of static utilities functions
  122105. */
  122106. export class Tools {
  122107. /**
  122108. * Gets or sets the base URL to use to load assets
  122109. */
  122110. static get BaseUrl(): string;
  122111. static set BaseUrl(value: string);
  122112. /**
  122113. * Enable/Disable Custom HTTP Request Headers globally.
  122114. * default = false
  122115. * @see CustomRequestHeaders
  122116. */
  122117. static UseCustomRequestHeaders: boolean;
  122118. /**
  122119. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  122120. * i.e. when loading files, where the server/service expects an Authorization header
  122121. */
  122122. static CustomRequestHeaders: {
  122123. [key: string]: string;
  122124. };
  122125. /**
  122126. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  122127. */
  122128. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  122129. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  122130. /**
  122131. * Default behaviour for cors in the application.
  122132. * It can be a string if the expected behavior is identical in the entire app.
  122133. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  122134. */
  122135. static get CorsBehavior(): string | ((url: string | string[]) => string);
  122136. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  122137. /**
  122138. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  122139. * @ignorenaming
  122140. */
  122141. static get UseFallbackTexture(): boolean;
  122142. static set UseFallbackTexture(value: boolean);
  122143. /**
  122144. * Use this object to register external classes like custom textures or material
  122145. * to allow the laoders to instantiate them
  122146. */
  122147. static get RegisteredExternalClasses(): {
  122148. [key: string]: Object;
  122149. };
  122150. static set RegisteredExternalClasses(classes: {
  122151. [key: string]: Object;
  122152. });
  122153. /**
  122154. * Texture content used if a texture cannot loaded
  122155. * @ignorenaming
  122156. */
  122157. static get fallbackTexture(): string;
  122158. static set fallbackTexture(value: string);
  122159. /**
  122160. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  122161. * @param u defines the coordinate on X axis
  122162. * @param v defines the coordinate on Y axis
  122163. * @param width defines the width of the source data
  122164. * @param height defines the height of the source data
  122165. * @param pixels defines the source byte array
  122166. * @param color defines the output color
  122167. */
  122168. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  122169. /**
  122170. * Interpolates between a and b via alpha
  122171. * @param a The lower value (returned when alpha = 0)
  122172. * @param b The upper value (returned when alpha = 1)
  122173. * @param alpha The interpolation-factor
  122174. * @return The mixed value
  122175. */
  122176. static Mix(a: number, b: number, alpha: number): number;
  122177. /**
  122178. * Tries to instantiate a new object from a given class name
  122179. * @param className defines the class name to instantiate
  122180. * @returns the new object or null if the system was not able to do the instantiation
  122181. */
  122182. static Instantiate(className: string): any;
  122183. /**
  122184. * Provides a slice function that will work even on IE
  122185. * @param data defines the array to slice
  122186. * @param start defines the start of the data (optional)
  122187. * @param end defines the end of the data (optional)
  122188. * @returns the new sliced array
  122189. */
  122190. static Slice<T>(data: T, start?: number, end?: number): T;
  122191. /**
  122192. * Provides a slice function that will work even on IE
  122193. * The difference between this and Slice is that this will force-convert to array
  122194. * @param data defines the array to slice
  122195. * @param start defines the start of the data (optional)
  122196. * @param end defines the end of the data (optional)
  122197. * @returns the new sliced array
  122198. */
  122199. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  122200. /**
  122201. * Polyfill for setImmediate
  122202. * @param action defines the action to execute after the current execution block
  122203. */
  122204. static SetImmediate(action: () => void): void;
  122205. /**
  122206. * Function indicating if a number is an exponent of 2
  122207. * @param value defines the value to test
  122208. * @returns true if the value is an exponent of 2
  122209. */
  122210. static IsExponentOfTwo(value: number): boolean;
  122211. private static _tmpFloatArray;
  122212. /**
  122213. * Returns the nearest 32-bit single precision float representation of a Number
  122214. * @param value A Number. If the parameter is of a different type, it will get converted
  122215. * to a number or to NaN if it cannot be converted
  122216. * @returns number
  122217. */
  122218. static FloatRound(value: number): number;
  122219. /**
  122220. * Extracts the filename from a path
  122221. * @param path defines the path to use
  122222. * @returns the filename
  122223. */
  122224. static GetFilename(path: string): string;
  122225. /**
  122226. * Extracts the "folder" part of a path (everything before the filename).
  122227. * @param uri The URI to extract the info from
  122228. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  122229. * @returns The "folder" part of the path
  122230. */
  122231. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  122232. /**
  122233. * Extracts text content from a DOM element hierarchy
  122234. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  122235. */
  122236. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  122237. /**
  122238. * Convert an angle in radians to degrees
  122239. * @param angle defines the angle to convert
  122240. * @returns the angle in degrees
  122241. */
  122242. static ToDegrees(angle: number): number;
  122243. /**
  122244. * Convert an angle in degrees to radians
  122245. * @param angle defines the angle to convert
  122246. * @returns the angle in radians
  122247. */
  122248. static ToRadians(angle: number): number;
  122249. /**
  122250. * Returns an array if obj is not an array
  122251. * @param obj defines the object to evaluate as an array
  122252. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  122253. * @returns either obj directly if obj is an array or a new array containing obj
  122254. */
  122255. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  122256. /**
  122257. * Gets the pointer prefix to use
  122258. * @param engine defines the engine we are finding the prefix for
  122259. * @returns "pointer" if touch is enabled. Else returns "mouse"
  122260. */
  122261. static GetPointerPrefix(engine: Engine): string;
  122262. /**
  122263. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  122264. * @param url define the url we are trying
  122265. * @param element define the dom element where to configure the cors policy
  122266. */
  122267. static SetCorsBehavior(url: string | string[], element: {
  122268. crossOrigin: string | null;
  122269. }): void;
  122270. /**
  122271. * Removes unwanted characters from an url
  122272. * @param url defines the url to clean
  122273. * @returns the cleaned url
  122274. */
  122275. static CleanUrl(url: string): string;
  122276. /**
  122277. * Gets or sets a function used to pre-process url before using them to load assets
  122278. */
  122279. static get PreprocessUrl(): (url: string) => string;
  122280. static set PreprocessUrl(processor: (url: string) => string);
  122281. /**
  122282. * Loads an image as an HTMLImageElement.
  122283. * @param input url string, ArrayBuffer, or Blob to load
  122284. * @param onLoad callback called when the image successfully loads
  122285. * @param onError callback called when the image fails to load
  122286. * @param offlineProvider offline provider for caching
  122287. * @param mimeType optional mime type
  122288. * @returns the HTMLImageElement of the loaded image
  122289. */
  122290. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  122291. /**
  122292. * Loads a file from a url
  122293. * @param url url string, ArrayBuffer, or Blob to load
  122294. * @param onSuccess callback called when the file successfully loads
  122295. * @param onProgress callback called while file is loading (if the server supports this mode)
  122296. * @param offlineProvider defines the offline provider for caching
  122297. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  122298. * @param onError callback called when the file fails to load
  122299. * @returns a file request object
  122300. */
  122301. 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;
  122302. /**
  122303. * Loads a file from a url
  122304. * @param url the file url to load
  122305. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  122306. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  122307. */
  122308. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  122309. /**
  122310. * Load a script (identified by an url). When the url returns, the
  122311. * content of this file is added into a new script element, attached to the DOM (body element)
  122312. * @param scriptUrl defines the url of the script to laod
  122313. * @param onSuccess defines the callback called when the script is loaded
  122314. * @param onError defines the callback to call if an error occurs
  122315. * @param scriptId defines the id of the script element
  122316. */
  122317. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  122318. /**
  122319. * Load an asynchronous script (identified by an url). When the url returns, the
  122320. * content of this file is added into a new script element, attached to the DOM (body element)
  122321. * @param scriptUrl defines the url of the script to laod
  122322. * @param scriptId defines the id of the script element
  122323. * @returns a promise request object
  122324. */
  122325. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  122326. /**
  122327. * Loads a file from a blob
  122328. * @param fileToLoad defines the blob to use
  122329. * @param callback defines the callback to call when data is loaded
  122330. * @param progressCallback defines the callback to call during loading process
  122331. * @returns a file request object
  122332. */
  122333. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  122334. /**
  122335. * Reads a file from a File object
  122336. * @param file defines the file to load
  122337. * @param onSuccess defines the callback to call when data is loaded
  122338. * @param onProgress defines the callback to call during loading process
  122339. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  122340. * @param onError defines the callback to call when an error occurs
  122341. * @returns a file request object
  122342. */
  122343. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  122344. /**
  122345. * Creates a data url from a given string content
  122346. * @param content defines the content to convert
  122347. * @returns the new data url link
  122348. */
  122349. static FileAsURL(content: string): string;
  122350. /**
  122351. * Format the given number to a specific decimal format
  122352. * @param value defines the number to format
  122353. * @param decimals defines the number of decimals to use
  122354. * @returns the formatted string
  122355. */
  122356. static Format(value: number, decimals?: number): string;
  122357. /**
  122358. * Tries to copy an object by duplicating every property
  122359. * @param source defines the source object
  122360. * @param destination defines the target object
  122361. * @param doNotCopyList defines a list of properties to avoid
  122362. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  122363. */
  122364. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  122365. /**
  122366. * Gets a boolean indicating if the given object has no own property
  122367. * @param obj defines the object to test
  122368. * @returns true if object has no own property
  122369. */
  122370. static IsEmpty(obj: any): boolean;
  122371. /**
  122372. * Function used to register events at window level
  122373. * @param windowElement defines the Window object to use
  122374. * @param events defines the events to register
  122375. */
  122376. static RegisterTopRootEvents(windowElement: Window, events: {
  122377. name: string;
  122378. handler: Nullable<(e: FocusEvent) => any>;
  122379. }[]): void;
  122380. /**
  122381. * Function used to unregister events from window level
  122382. * @param windowElement defines the Window object to use
  122383. * @param events defines the events to unregister
  122384. */
  122385. static UnregisterTopRootEvents(windowElement: Window, events: {
  122386. name: string;
  122387. handler: Nullable<(e: FocusEvent) => any>;
  122388. }[]): void;
  122389. /**
  122390. * @ignore
  122391. */
  122392. static _ScreenshotCanvas: HTMLCanvasElement;
  122393. /**
  122394. * Dumps the current bound framebuffer
  122395. * @param width defines the rendering width
  122396. * @param height defines the rendering height
  122397. * @param engine defines the hosting engine
  122398. * @param successCallback defines the callback triggered once the data are available
  122399. * @param mimeType defines the mime type of the result
  122400. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  122401. */
  122402. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122403. /**
  122404. * Converts the canvas data to blob.
  122405. * This acts as a polyfill for browsers not supporting the to blob function.
  122406. * @param canvas Defines the canvas to extract the data from
  122407. * @param successCallback Defines the callback triggered once the data are available
  122408. * @param mimeType Defines the mime type of the result
  122409. */
  122410. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  122411. /**
  122412. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  122413. * @param successCallback defines the callback triggered once the data are available
  122414. * @param mimeType defines the mime type of the result
  122415. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  122416. */
  122417. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122418. /**
  122419. * Downloads a blob in the browser
  122420. * @param blob defines the blob to download
  122421. * @param fileName defines the name of the downloaded file
  122422. */
  122423. static Download(blob: Blob, fileName: string): void;
  122424. /**
  122425. * Captures a screenshot of the current rendering
  122426. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122427. * @param engine defines the rendering engine
  122428. * @param camera defines the source camera
  122429. * @param size This parameter can be set to a single number or to an object with the
  122430. * following (optional) properties: precision, width, height. If a single number is passed,
  122431. * it will be used for both width and height. If an object is passed, the screenshot size
  122432. * will be derived from the parameters. The precision property is a multiplier allowing
  122433. * rendering at a higher or lower resolution
  122434. * @param successCallback defines the callback receives a single parameter which contains the
  122435. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122436. * src parameter of an <img> to display it
  122437. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122438. * Check your browser for supported MIME types
  122439. */
  122440. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  122441. /**
  122442. * Captures a screenshot of the current rendering
  122443. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122444. * @param engine defines the rendering engine
  122445. * @param camera defines the source camera
  122446. * @param size This parameter can be set to a single number or to an object with the
  122447. * following (optional) properties: precision, width, height. If a single number is passed,
  122448. * it will be used for both width and height. If an object is passed, the screenshot size
  122449. * will be derived from the parameters. The precision property is a multiplier allowing
  122450. * rendering at a higher or lower resolution
  122451. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122452. * Check your browser for supported MIME types
  122453. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  122454. * to the src parameter of an <img> to display it
  122455. */
  122456. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  122457. /**
  122458. * Generates an image screenshot from the specified camera.
  122459. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122460. * @param engine The engine to use for rendering
  122461. * @param camera The camera to use for rendering
  122462. * @param size This parameter can be set to a single number or to an object with the
  122463. * following (optional) properties: precision, width, height. If a single number is passed,
  122464. * it will be used for both width and height. If an object is passed, the screenshot size
  122465. * will be derived from the parameters. The precision property is a multiplier allowing
  122466. * rendering at a higher or lower resolution
  122467. * @param successCallback The callback receives a single parameter which contains the
  122468. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122469. * src parameter of an <img> to display it
  122470. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122471. * Check your browser for supported MIME types
  122472. * @param samples Texture samples (default: 1)
  122473. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122474. * @param fileName A name for for the downloaded file.
  122475. */
  122476. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  122477. /**
  122478. * Generates an image screenshot from the specified camera.
  122479. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122480. * @param engine The engine to use for rendering
  122481. * @param camera The camera to use for rendering
  122482. * @param size This parameter can be set to a single number or to an object with the
  122483. * following (optional) properties: precision, width, height. If a single number is passed,
  122484. * it will be used for both width and height. If an object is passed, the screenshot size
  122485. * will be derived from the parameters. The precision property is a multiplier allowing
  122486. * rendering at a higher or lower resolution
  122487. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122488. * Check your browser for supported MIME types
  122489. * @param samples Texture samples (default: 1)
  122490. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122491. * @param fileName A name for for the downloaded file.
  122492. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  122493. * to the src parameter of an <img> to display it
  122494. */
  122495. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  122496. /**
  122497. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  122498. * Be aware Math.random() could cause collisions, but:
  122499. * "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"
  122500. * @returns a pseudo random id
  122501. */
  122502. static RandomId(): string;
  122503. /**
  122504. * Test if the given uri is a base64 string
  122505. * @param uri The uri to test
  122506. * @return True if the uri is a base64 string or false otherwise
  122507. */
  122508. static IsBase64(uri: string): boolean;
  122509. /**
  122510. * Decode the given base64 uri.
  122511. * @param uri The uri to decode
  122512. * @return The decoded base64 data.
  122513. */
  122514. static DecodeBase64(uri: string): ArrayBuffer;
  122515. /**
  122516. * Gets the absolute url.
  122517. * @param url the input url
  122518. * @return the absolute url
  122519. */
  122520. static GetAbsoluteUrl(url: string): string;
  122521. /**
  122522. * No log
  122523. */
  122524. static readonly NoneLogLevel: number;
  122525. /**
  122526. * Only message logs
  122527. */
  122528. static readonly MessageLogLevel: number;
  122529. /**
  122530. * Only warning logs
  122531. */
  122532. static readonly WarningLogLevel: number;
  122533. /**
  122534. * Only error logs
  122535. */
  122536. static readonly ErrorLogLevel: number;
  122537. /**
  122538. * All logs
  122539. */
  122540. static readonly AllLogLevel: number;
  122541. /**
  122542. * Gets a value indicating the number of loading errors
  122543. * @ignorenaming
  122544. */
  122545. static get errorsCount(): number;
  122546. /**
  122547. * Callback called when a new log is added
  122548. */
  122549. static OnNewCacheEntry: (entry: string) => void;
  122550. /**
  122551. * Log a message to the console
  122552. * @param message defines the message to log
  122553. */
  122554. static Log(message: string): void;
  122555. /**
  122556. * Write a warning message to the console
  122557. * @param message defines the message to log
  122558. */
  122559. static Warn(message: string): void;
  122560. /**
  122561. * Write an error message to the console
  122562. * @param message defines the message to log
  122563. */
  122564. static Error(message: string): void;
  122565. /**
  122566. * Gets current log cache (list of logs)
  122567. */
  122568. static get LogCache(): string;
  122569. /**
  122570. * Clears the log cache
  122571. */
  122572. static ClearLogCache(): void;
  122573. /**
  122574. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  122575. */
  122576. static set LogLevels(level: number);
  122577. /**
  122578. * Checks if the window object exists
  122579. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  122580. */
  122581. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  122582. /**
  122583. * No performance log
  122584. */
  122585. static readonly PerformanceNoneLogLevel: number;
  122586. /**
  122587. * Use user marks to log performance
  122588. */
  122589. static readonly PerformanceUserMarkLogLevel: number;
  122590. /**
  122591. * Log performance to the console
  122592. */
  122593. static readonly PerformanceConsoleLogLevel: number;
  122594. private static _performance;
  122595. /**
  122596. * Sets the current performance log level
  122597. */
  122598. static set PerformanceLogLevel(level: number);
  122599. private static _StartPerformanceCounterDisabled;
  122600. private static _EndPerformanceCounterDisabled;
  122601. private static _StartUserMark;
  122602. private static _EndUserMark;
  122603. private static _StartPerformanceConsole;
  122604. private static _EndPerformanceConsole;
  122605. /**
  122606. * Starts a performance counter
  122607. */
  122608. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  122609. /**
  122610. * Ends a specific performance coutner
  122611. */
  122612. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  122613. /**
  122614. * Gets either window.performance.now() if supported or Date.now() else
  122615. */
  122616. static get Now(): number;
  122617. /**
  122618. * This method will return the name of the class used to create the instance of the given object.
  122619. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  122620. * @param object the object to get the class name from
  122621. * @param isType defines if the object is actually a type
  122622. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  122623. */
  122624. static GetClassName(object: any, isType?: boolean): string;
  122625. /**
  122626. * Gets the first element of an array satisfying a given predicate
  122627. * @param array defines the array to browse
  122628. * @param predicate defines the predicate to use
  122629. * @returns null if not found or the element
  122630. */
  122631. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  122632. /**
  122633. * This method will return the name of the full name of the class, including its owning module (if any).
  122634. * 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).
  122635. * @param object the object to get the class name from
  122636. * @param isType defines if the object is actually a type
  122637. * @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.
  122638. * @ignorenaming
  122639. */
  122640. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  122641. /**
  122642. * Returns a promise that resolves after the given amount of time.
  122643. * @param delay Number of milliseconds to delay
  122644. * @returns Promise that resolves after the given amount of time
  122645. */
  122646. static DelayAsync(delay: number): Promise<void>;
  122647. /**
  122648. * Utility function to detect if the current user agent is Safari
  122649. * @returns whether or not the current user agent is safari
  122650. */
  122651. static IsSafari(): boolean;
  122652. }
  122653. /**
  122654. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  122655. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  122656. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  122657. * @param name The name of the class, case should be preserved
  122658. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  122659. */
  122660. export function className(name: string, module?: string): (target: Object) => void;
  122661. /**
  122662. * An implementation of a loop for asynchronous functions.
  122663. */
  122664. export class AsyncLoop {
  122665. /**
  122666. * Defines the number of iterations for the loop
  122667. */
  122668. iterations: number;
  122669. /**
  122670. * Defines the current index of the loop.
  122671. */
  122672. index: number;
  122673. private _done;
  122674. private _fn;
  122675. private _successCallback;
  122676. /**
  122677. * Constructor.
  122678. * @param iterations the number of iterations.
  122679. * @param func the function to run each iteration
  122680. * @param successCallback the callback that will be called upon succesful execution
  122681. * @param offset starting offset.
  122682. */
  122683. constructor(
  122684. /**
  122685. * Defines the number of iterations for the loop
  122686. */
  122687. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  122688. /**
  122689. * Execute the next iteration. Must be called after the last iteration was finished.
  122690. */
  122691. executeNext(): void;
  122692. /**
  122693. * Break the loop and run the success callback.
  122694. */
  122695. breakLoop(): void;
  122696. /**
  122697. * Create and run an async loop.
  122698. * @param iterations the number of iterations.
  122699. * @param fn the function to run each iteration
  122700. * @param successCallback the callback that will be called upon succesful execution
  122701. * @param offset starting offset.
  122702. * @returns the created async loop object
  122703. */
  122704. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  122705. /**
  122706. * A for-loop that will run a given number of iterations synchronous and the rest async.
  122707. * @param iterations total number of iterations
  122708. * @param syncedIterations number of synchronous iterations in each async iteration.
  122709. * @param fn the function to call each iteration.
  122710. * @param callback a success call back that will be called when iterating stops.
  122711. * @param breakFunction a break condition (optional)
  122712. * @param timeout timeout settings for the setTimeout function. default - 0.
  122713. * @returns the created async loop object
  122714. */
  122715. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  122716. }
  122717. }
  122718. declare module BABYLON {
  122719. /**
  122720. * This class implement a typical dictionary using a string as key and the generic type T as value.
  122721. * The underlying implementation relies on an associative array to ensure the best performances.
  122722. * The value can be anything including 'null' but except 'undefined'
  122723. */
  122724. export class StringDictionary<T> {
  122725. /**
  122726. * This will clear this dictionary and copy the content from the 'source' one.
  122727. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  122728. * @param source the dictionary to take the content from and copy to this dictionary
  122729. */
  122730. copyFrom(source: StringDictionary<T>): void;
  122731. /**
  122732. * Get a value based from its key
  122733. * @param key the given key to get the matching value from
  122734. * @return the value if found, otherwise undefined is returned
  122735. */
  122736. get(key: string): T | undefined;
  122737. /**
  122738. * Get a value from its key or add it if it doesn't exist.
  122739. * This method will ensure you that a given key/data will be present in the dictionary.
  122740. * @param key the given key to get the matching value from
  122741. * @param factory the factory that will create the value if the key is not present in the dictionary.
  122742. * The factory will only be invoked if there's no data for the given key.
  122743. * @return the value corresponding to the key.
  122744. */
  122745. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  122746. /**
  122747. * Get a value from its key if present in the dictionary otherwise add it
  122748. * @param key the key to get the value from
  122749. * @param val if there's no such key/value pair in the dictionary add it with this value
  122750. * @return the value corresponding to the key
  122751. */
  122752. getOrAdd(key: string, val: T): T;
  122753. /**
  122754. * Check if there's a given key in the dictionary
  122755. * @param key the key to check for
  122756. * @return true if the key is present, false otherwise
  122757. */
  122758. contains(key: string): boolean;
  122759. /**
  122760. * Add a new key and its corresponding value
  122761. * @param key the key to add
  122762. * @param value the value corresponding to the key
  122763. * @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
  122764. */
  122765. add(key: string, value: T): boolean;
  122766. /**
  122767. * Update a specific value associated to a key
  122768. * @param key defines the key to use
  122769. * @param value defines the value to store
  122770. * @returns true if the value was updated (or false if the key was not found)
  122771. */
  122772. set(key: string, value: T): boolean;
  122773. /**
  122774. * Get the element of the given key and remove it from the dictionary
  122775. * @param key defines the key to search
  122776. * @returns the value associated with the key or null if not found
  122777. */
  122778. getAndRemove(key: string): Nullable<T>;
  122779. /**
  122780. * Remove a key/value from the dictionary.
  122781. * @param key the key to remove
  122782. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  122783. */
  122784. remove(key: string): boolean;
  122785. /**
  122786. * Clear the whole content of the dictionary
  122787. */
  122788. clear(): void;
  122789. /**
  122790. * Gets the current count
  122791. */
  122792. get count(): number;
  122793. /**
  122794. * Execute a callback on each key/val of the dictionary.
  122795. * Note that you can remove any element in this dictionary in the callback implementation
  122796. * @param callback the callback to execute on a given key/value pair
  122797. */
  122798. forEach(callback: (key: string, val: T) => void): void;
  122799. /**
  122800. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  122801. * If the callback returns null or undefined the method will iterate to the next key/value pair
  122802. * Note that you can remove any element in this dictionary in the callback implementation
  122803. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  122804. * @returns the first item
  122805. */
  122806. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  122807. private _count;
  122808. private _data;
  122809. }
  122810. }
  122811. declare module BABYLON {
  122812. /** @hidden */
  122813. export interface ICollisionCoordinator {
  122814. createCollider(): Collider;
  122815. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  122816. init(scene: Scene): void;
  122817. }
  122818. /** @hidden */
  122819. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  122820. private _scene;
  122821. private _scaledPosition;
  122822. private _scaledVelocity;
  122823. private _finalPosition;
  122824. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  122825. createCollider(): Collider;
  122826. init(scene: Scene): void;
  122827. private _collideWithWorld;
  122828. }
  122829. }
  122830. declare module BABYLON {
  122831. /**
  122832. * Class used to manage all inputs for the scene.
  122833. */
  122834. export class InputManager {
  122835. /** The distance in pixel that you have to move to prevent some events */
  122836. static DragMovementThreshold: number;
  122837. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  122838. static LongPressDelay: number;
  122839. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  122840. static DoubleClickDelay: number;
  122841. /** If you need to check double click without raising a single click at first click, enable this flag */
  122842. static ExclusiveDoubleClickMode: boolean;
  122843. /** 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. */
  122844. private _alreadyAttached;
  122845. private _alreadyAttachedTo;
  122846. private _wheelEventName;
  122847. private _onPointerMove;
  122848. private _onPointerDown;
  122849. private _onPointerUp;
  122850. private _initClickEvent;
  122851. private _initActionManager;
  122852. private _delayedSimpleClick;
  122853. private _delayedSimpleClickTimeout;
  122854. private _previousDelayedSimpleClickTimeout;
  122855. private _meshPickProceed;
  122856. private _previousButtonPressed;
  122857. private _currentPickResult;
  122858. private _previousPickResult;
  122859. private _totalPointersPressed;
  122860. private _doubleClickOccured;
  122861. private _pointerOverMesh;
  122862. private _pickedDownMesh;
  122863. private _pickedUpMesh;
  122864. private _pointerX;
  122865. private _pointerY;
  122866. private _unTranslatedPointerX;
  122867. private _unTranslatedPointerY;
  122868. private _startingPointerPosition;
  122869. private _previousStartingPointerPosition;
  122870. private _startingPointerTime;
  122871. private _previousStartingPointerTime;
  122872. private _pointerCaptures;
  122873. private _meshUnderPointerId;
  122874. private _onKeyDown;
  122875. private _onKeyUp;
  122876. private _keyboardIsAttached;
  122877. private _onCanvasFocusObserver;
  122878. private _onCanvasBlurObserver;
  122879. private _scene;
  122880. /**
  122881. * Creates a new InputManager
  122882. * @param scene defines the hosting scene
  122883. */
  122884. constructor(scene: Scene);
  122885. /**
  122886. * Gets the mesh that is currently under the pointer
  122887. */
  122888. get meshUnderPointer(): Nullable<AbstractMesh>;
  122889. /**
  122890. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  122891. * @param pointerId the pointer id to use
  122892. * @returns The mesh under this pointer id or null if not found
  122893. */
  122894. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  122895. /**
  122896. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  122897. */
  122898. get unTranslatedPointer(): Vector2;
  122899. /**
  122900. * Gets or sets the current on-screen X position of the pointer
  122901. */
  122902. get pointerX(): number;
  122903. set pointerX(value: number);
  122904. /**
  122905. * Gets or sets the current on-screen Y position of the pointer
  122906. */
  122907. get pointerY(): number;
  122908. set pointerY(value: number);
  122909. private _updatePointerPosition;
  122910. private _processPointerMove;
  122911. private _setRayOnPointerInfo;
  122912. private _checkPrePointerObservable;
  122913. /**
  122914. * Use this method to simulate a pointer move on a mesh
  122915. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122916. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122917. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122918. */
  122919. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  122920. /**
  122921. * Use this method to simulate a pointer down on a mesh
  122922. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122923. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122924. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122925. */
  122926. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  122927. private _processPointerDown;
  122928. /** @hidden */
  122929. _isPointerSwiping(): boolean;
  122930. /**
  122931. * Use this method to simulate a pointer up on a mesh
  122932. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122933. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122934. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122935. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  122936. */
  122937. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  122938. private _processPointerUp;
  122939. /**
  122940. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  122941. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  122942. * @returns true if the pointer was captured
  122943. */
  122944. isPointerCaptured(pointerId?: number): boolean;
  122945. /**
  122946. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  122947. * @param attachUp defines if you want to attach events to pointerup
  122948. * @param attachDown defines if you want to attach events to pointerdown
  122949. * @param attachMove defines if you want to attach events to pointermove
  122950. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  122951. */
  122952. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  122953. /**
  122954. * Detaches all event handlers
  122955. */
  122956. detachControl(): void;
  122957. /**
  122958. * Force the value of meshUnderPointer
  122959. * @param mesh defines the mesh to use
  122960. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  122961. */
  122962. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  122963. /**
  122964. * Gets the mesh under the pointer
  122965. * @returns a Mesh or null if no mesh is under the pointer
  122966. */
  122967. getPointerOverMesh(): Nullable<AbstractMesh>;
  122968. }
  122969. }
  122970. declare module BABYLON {
  122971. /**
  122972. * This class defines the direct association between an animation and a target
  122973. */
  122974. export class TargetedAnimation {
  122975. /**
  122976. * Animation to perform
  122977. */
  122978. animation: Animation;
  122979. /**
  122980. * Target to animate
  122981. */
  122982. target: any;
  122983. /**
  122984. * Returns the string "TargetedAnimation"
  122985. * @returns "TargetedAnimation"
  122986. */
  122987. getClassName(): string;
  122988. /**
  122989. * Serialize the object
  122990. * @returns the JSON object representing the current entity
  122991. */
  122992. serialize(): any;
  122993. }
  122994. /**
  122995. * Use this class to create coordinated animations on multiple targets
  122996. */
  122997. export class AnimationGroup implements IDisposable {
  122998. /** The name of the animation group */
  122999. name: string;
  123000. private _scene;
  123001. private _targetedAnimations;
  123002. private _animatables;
  123003. private _from;
  123004. private _to;
  123005. private _isStarted;
  123006. private _isPaused;
  123007. private _speedRatio;
  123008. private _loopAnimation;
  123009. private _isAdditive;
  123010. /**
  123011. * Gets or sets the unique id of the node
  123012. */
  123013. uniqueId: number;
  123014. /**
  123015. * This observable will notify when one animation have ended
  123016. */
  123017. onAnimationEndObservable: Observable<TargetedAnimation>;
  123018. /**
  123019. * Observer raised when one animation loops
  123020. */
  123021. onAnimationLoopObservable: Observable<TargetedAnimation>;
  123022. /**
  123023. * Observer raised when all animations have looped
  123024. */
  123025. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  123026. /**
  123027. * This observable will notify when all animations have ended.
  123028. */
  123029. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  123030. /**
  123031. * This observable will notify when all animations have paused.
  123032. */
  123033. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  123034. /**
  123035. * This observable will notify when all animations are playing.
  123036. */
  123037. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  123038. /**
  123039. * Gets the first frame
  123040. */
  123041. get from(): number;
  123042. /**
  123043. * Gets the last frame
  123044. */
  123045. get to(): number;
  123046. /**
  123047. * Define if the animations are started
  123048. */
  123049. get isStarted(): boolean;
  123050. /**
  123051. * Gets a value indicating that the current group is playing
  123052. */
  123053. get isPlaying(): boolean;
  123054. /**
  123055. * Gets or sets the speed ratio to use for all animations
  123056. */
  123057. get speedRatio(): number;
  123058. /**
  123059. * Gets or sets the speed ratio to use for all animations
  123060. */
  123061. set speedRatio(value: number);
  123062. /**
  123063. * Gets or sets if all animations should loop or not
  123064. */
  123065. get loopAnimation(): boolean;
  123066. set loopAnimation(value: boolean);
  123067. /**
  123068. * Gets or sets if all animations should be evaluated additively
  123069. */
  123070. get isAdditive(): boolean;
  123071. set isAdditive(value: boolean);
  123072. /**
  123073. * Gets the targeted animations for this animation group
  123074. */
  123075. get targetedAnimations(): Array<TargetedAnimation>;
  123076. /**
  123077. * returning the list of animatables controlled by this animation group.
  123078. */
  123079. get animatables(): Array<Animatable>;
  123080. /**
  123081. * Gets the list of target animations
  123082. */
  123083. get children(): TargetedAnimation[];
  123084. /**
  123085. * Instantiates a new Animation Group.
  123086. * This helps managing several animations at once.
  123087. * @see https://doc.babylonjs.com/how_to/group
  123088. * @param name Defines the name of the group
  123089. * @param scene Defines the scene the group belongs to
  123090. */
  123091. constructor(
  123092. /** The name of the animation group */
  123093. name: string, scene?: Nullable<Scene>);
  123094. /**
  123095. * Add an animation (with its target) in the group
  123096. * @param animation defines the animation we want to add
  123097. * @param target defines the target of the animation
  123098. * @returns the TargetedAnimation object
  123099. */
  123100. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  123101. /**
  123102. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  123103. * It can add constant keys at begin or end
  123104. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  123105. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  123106. * @returns the animation group
  123107. */
  123108. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  123109. private _animationLoopCount;
  123110. private _animationLoopFlags;
  123111. private _processLoop;
  123112. /**
  123113. * Start all animations on given targets
  123114. * @param loop defines if animations must loop
  123115. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  123116. * @param from defines the from key (optional)
  123117. * @param to defines the to key (optional)
  123118. * @param isAdditive defines the additive state for the resulting animatables (optional)
  123119. * @returns the current animation group
  123120. */
  123121. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  123122. /**
  123123. * Pause all animations
  123124. * @returns the animation group
  123125. */
  123126. pause(): AnimationGroup;
  123127. /**
  123128. * Play all animations to initial state
  123129. * This function will start() the animations if they were not started or will restart() them if they were paused
  123130. * @param loop defines if animations must loop
  123131. * @returns the animation group
  123132. */
  123133. play(loop?: boolean): AnimationGroup;
  123134. /**
  123135. * Reset all animations to initial state
  123136. * @returns the animation group
  123137. */
  123138. reset(): AnimationGroup;
  123139. /**
  123140. * Restart animations from key 0
  123141. * @returns the animation group
  123142. */
  123143. restart(): AnimationGroup;
  123144. /**
  123145. * Stop all animations
  123146. * @returns the animation group
  123147. */
  123148. stop(): AnimationGroup;
  123149. /**
  123150. * Set animation weight for all animatables
  123151. * @param weight defines the weight to use
  123152. * @return the animationGroup
  123153. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  123154. */
  123155. setWeightForAllAnimatables(weight: number): AnimationGroup;
  123156. /**
  123157. * Synchronize and normalize all animatables with a source animatable
  123158. * @param root defines the root animatable to synchronize with
  123159. * @return the animationGroup
  123160. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  123161. */
  123162. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  123163. /**
  123164. * Goes to a specific frame in this animation group
  123165. * @param frame the frame number to go to
  123166. * @return the animationGroup
  123167. */
  123168. goToFrame(frame: number): AnimationGroup;
  123169. /**
  123170. * Dispose all associated resources
  123171. */
  123172. dispose(): void;
  123173. private _checkAnimationGroupEnded;
  123174. /**
  123175. * Clone the current animation group and returns a copy
  123176. * @param newName defines the name of the new group
  123177. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  123178. * @returns the new aniamtion group
  123179. */
  123180. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  123181. /**
  123182. * Serializes the animationGroup to an object
  123183. * @returns Serialized object
  123184. */
  123185. serialize(): any;
  123186. /**
  123187. * Returns a new AnimationGroup object parsed from the source provided.
  123188. * @param parsedAnimationGroup defines the source
  123189. * @param scene defines the scene that will receive the animationGroup
  123190. * @returns a new AnimationGroup
  123191. */
  123192. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  123193. /**
  123194. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  123195. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  123196. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  123197. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  123198. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  123199. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  123200. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  123201. */
  123202. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  123203. /**
  123204. * Returns the string "AnimationGroup"
  123205. * @returns "AnimationGroup"
  123206. */
  123207. getClassName(): string;
  123208. /**
  123209. * Creates a detailled string about the object
  123210. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  123211. * @returns a string representing the object
  123212. */
  123213. toString(fullDetails?: boolean): string;
  123214. }
  123215. }
  123216. declare module BABYLON {
  123217. /**
  123218. * Define an interface for all classes that will hold resources
  123219. */
  123220. export interface IDisposable {
  123221. /**
  123222. * Releases all held resources
  123223. */
  123224. dispose(): void;
  123225. }
  123226. /** Interface defining initialization parameters for Scene class */
  123227. export interface SceneOptions {
  123228. /**
  123229. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  123230. * It will improve performance when the number of geometries becomes important.
  123231. */
  123232. useGeometryUniqueIdsMap?: boolean;
  123233. /**
  123234. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  123235. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  123236. */
  123237. useMaterialMeshMap?: boolean;
  123238. /**
  123239. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  123240. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  123241. */
  123242. useClonedMeshMap?: boolean;
  123243. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  123244. virtual?: boolean;
  123245. }
  123246. /**
  123247. * Represents a scene to be rendered by the engine.
  123248. * @see https://doc.babylonjs.com/features/scene
  123249. */
  123250. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  123251. /** The fog is deactivated */
  123252. static readonly FOGMODE_NONE: number;
  123253. /** The fog density is following an exponential function */
  123254. static readonly FOGMODE_EXP: number;
  123255. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  123256. static readonly FOGMODE_EXP2: number;
  123257. /** The fog density is following a linear function. */
  123258. static readonly FOGMODE_LINEAR: number;
  123259. /**
  123260. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  123261. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123262. */
  123263. static MinDeltaTime: number;
  123264. /**
  123265. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  123266. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123267. */
  123268. static MaxDeltaTime: number;
  123269. /**
  123270. * Factory used to create the default material.
  123271. * @param name The name of the material to create
  123272. * @param scene The scene to create the material for
  123273. * @returns The default material
  123274. */
  123275. static DefaultMaterialFactory(scene: Scene): Material;
  123276. /**
  123277. * Factory used to create the a collision coordinator.
  123278. * @returns The collision coordinator
  123279. */
  123280. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  123281. /** @hidden */
  123282. _inputManager: InputManager;
  123283. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  123284. cameraToUseForPointers: Nullable<Camera>;
  123285. /** @hidden */
  123286. readonly _isScene: boolean;
  123287. /** @hidden */
  123288. _blockEntityCollection: boolean;
  123289. /**
  123290. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  123291. */
  123292. autoClear: boolean;
  123293. /**
  123294. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  123295. */
  123296. autoClearDepthAndStencil: boolean;
  123297. /**
  123298. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  123299. */
  123300. clearColor: Color4;
  123301. /**
  123302. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  123303. */
  123304. ambientColor: Color3;
  123305. /**
  123306. * This is use to store the default BRDF lookup for PBR materials in your scene.
  123307. * It should only be one of the following (if not the default embedded one):
  123308. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  123309. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  123310. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  123311. * The material properties need to be setup according to the type of texture in use.
  123312. */
  123313. environmentBRDFTexture: BaseTexture;
  123314. /**
  123315. * Texture used in all pbr material as the reflection texture.
  123316. * As in the majority of the scene they are the same (exception for multi room and so on),
  123317. * this is easier to reference from here than from all the materials.
  123318. */
  123319. get environmentTexture(): Nullable<BaseTexture>;
  123320. /**
  123321. * Texture used in all pbr material as the reflection texture.
  123322. * As in the majority of the scene they are the same (exception for multi room and so on),
  123323. * this is easier to set here than in all the materials.
  123324. */
  123325. set environmentTexture(value: Nullable<BaseTexture>);
  123326. /** @hidden */
  123327. protected _environmentIntensity: number;
  123328. /**
  123329. * Intensity of the environment in all pbr material.
  123330. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123331. * As in the majority of the scene they are the same (exception for multi room and so on),
  123332. * this is easier to reference from here than from all the materials.
  123333. */
  123334. get environmentIntensity(): number;
  123335. /**
  123336. * Intensity of the environment in all pbr material.
  123337. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123338. * As in the majority of the scene they are the same (exception for multi room and so on),
  123339. * this is easier to set here than in all the materials.
  123340. */
  123341. set environmentIntensity(value: number);
  123342. /** @hidden */
  123343. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123344. /**
  123345. * Default image processing configuration used either in the rendering
  123346. * Forward main pass or through the imageProcessingPostProcess if present.
  123347. * As in the majority of the scene they are the same (exception for multi camera),
  123348. * this is easier to reference from here than from all the materials and post process.
  123349. *
  123350. * No setter as we it is a shared configuration, you can set the values instead.
  123351. */
  123352. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123353. private _forceWireframe;
  123354. /**
  123355. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  123356. */
  123357. set forceWireframe(value: boolean);
  123358. get forceWireframe(): boolean;
  123359. private _skipFrustumClipping;
  123360. /**
  123361. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  123362. */
  123363. set skipFrustumClipping(value: boolean);
  123364. get skipFrustumClipping(): boolean;
  123365. private _forcePointsCloud;
  123366. /**
  123367. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  123368. */
  123369. set forcePointsCloud(value: boolean);
  123370. get forcePointsCloud(): boolean;
  123371. /**
  123372. * Gets or sets the active clipplane 1
  123373. */
  123374. clipPlane: Nullable<Plane>;
  123375. /**
  123376. * Gets or sets the active clipplane 2
  123377. */
  123378. clipPlane2: Nullable<Plane>;
  123379. /**
  123380. * Gets or sets the active clipplane 3
  123381. */
  123382. clipPlane3: Nullable<Plane>;
  123383. /**
  123384. * Gets or sets the active clipplane 4
  123385. */
  123386. clipPlane4: Nullable<Plane>;
  123387. /**
  123388. * Gets or sets the active clipplane 5
  123389. */
  123390. clipPlane5: Nullable<Plane>;
  123391. /**
  123392. * Gets or sets the active clipplane 6
  123393. */
  123394. clipPlane6: Nullable<Plane>;
  123395. /**
  123396. * Gets or sets a boolean indicating if animations are enabled
  123397. */
  123398. animationsEnabled: boolean;
  123399. private _animationPropertiesOverride;
  123400. /**
  123401. * Gets or sets the animation properties override
  123402. */
  123403. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  123404. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  123405. /**
  123406. * Gets or sets a boolean indicating if a constant deltatime has to be used
  123407. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  123408. */
  123409. useConstantAnimationDeltaTime: boolean;
  123410. /**
  123411. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  123412. * Please note that it requires to run a ray cast through the scene on every frame
  123413. */
  123414. constantlyUpdateMeshUnderPointer: boolean;
  123415. /**
  123416. * Defines the HTML cursor to use when hovering over interactive elements
  123417. */
  123418. hoverCursor: string;
  123419. /**
  123420. * Defines the HTML default cursor to use (empty by default)
  123421. */
  123422. defaultCursor: string;
  123423. /**
  123424. * Defines whether cursors are handled by the scene.
  123425. */
  123426. doNotHandleCursors: boolean;
  123427. /**
  123428. * This is used to call preventDefault() on pointer down
  123429. * in order to block unwanted artifacts like system double clicks
  123430. */
  123431. preventDefaultOnPointerDown: boolean;
  123432. /**
  123433. * This is used to call preventDefault() on pointer up
  123434. * in order to block unwanted artifacts like system double clicks
  123435. */
  123436. preventDefaultOnPointerUp: boolean;
  123437. /**
  123438. * Gets or sets user defined metadata
  123439. */
  123440. metadata: any;
  123441. /**
  123442. * For internal use only. Please do not use.
  123443. */
  123444. reservedDataStore: any;
  123445. /**
  123446. * Gets the name of the plugin used to load this scene (null by default)
  123447. */
  123448. loadingPluginName: string;
  123449. /**
  123450. * Use this array to add regular expressions used to disable offline support for specific urls
  123451. */
  123452. disableOfflineSupportExceptionRules: RegExp[];
  123453. /**
  123454. * An event triggered when the scene is disposed.
  123455. */
  123456. onDisposeObservable: Observable<Scene>;
  123457. private _onDisposeObserver;
  123458. /** Sets a function to be executed when this scene is disposed. */
  123459. set onDispose(callback: () => void);
  123460. /**
  123461. * An event triggered before rendering the scene (right after animations and physics)
  123462. */
  123463. onBeforeRenderObservable: Observable<Scene>;
  123464. private _onBeforeRenderObserver;
  123465. /** Sets a function to be executed before rendering this scene */
  123466. set beforeRender(callback: Nullable<() => void>);
  123467. /**
  123468. * An event triggered after rendering the scene
  123469. */
  123470. onAfterRenderObservable: Observable<Scene>;
  123471. /**
  123472. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  123473. */
  123474. onAfterRenderCameraObservable: Observable<Camera>;
  123475. private _onAfterRenderObserver;
  123476. /** Sets a function to be executed after rendering this scene */
  123477. set afterRender(callback: Nullable<() => void>);
  123478. /**
  123479. * An event triggered before animating the scene
  123480. */
  123481. onBeforeAnimationsObservable: Observable<Scene>;
  123482. /**
  123483. * An event triggered after animations processing
  123484. */
  123485. onAfterAnimationsObservable: Observable<Scene>;
  123486. /**
  123487. * An event triggered before draw calls are ready to be sent
  123488. */
  123489. onBeforeDrawPhaseObservable: Observable<Scene>;
  123490. /**
  123491. * An event triggered after draw calls have been sent
  123492. */
  123493. onAfterDrawPhaseObservable: Observable<Scene>;
  123494. /**
  123495. * An event triggered when the scene is ready
  123496. */
  123497. onReadyObservable: Observable<Scene>;
  123498. /**
  123499. * An event triggered before rendering a camera
  123500. */
  123501. onBeforeCameraRenderObservable: Observable<Camera>;
  123502. private _onBeforeCameraRenderObserver;
  123503. /** Sets a function to be executed before rendering a camera*/
  123504. set beforeCameraRender(callback: () => void);
  123505. /**
  123506. * An event triggered after rendering a camera
  123507. */
  123508. onAfterCameraRenderObservable: Observable<Camera>;
  123509. private _onAfterCameraRenderObserver;
  123510. /** Sets a function to be executed after rendering a camera*/
  123511. set afterCameraRender(callback: () => void);
  123512. /**
  123513. * An event triggered when active meshes evaluation is about to start
  123514. */
  123515. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  123516. /**
  123517. * An event triggered when active meshes evaluation is done
  123518. */
  123519. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  123520. /**
  123521. * An event triggered when particles rendering is about to start
  123522. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  123523. */
  123524. onBeforeParticlesRenderingObservable: Observable<Scene>;
  123525. /**
  123526. * An event triggered when particles rendering is done
  123527. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  123528. */
  123529. onAfterParticlesRenderingObservable: Observable<Scene>;
  123530. /**
  123531. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  123532. */
  123533. onDataLoadedObservable: Observable<Scene>;
  123534. /**
  123535. * An event triggered when a camera is created
  123536. */
  123537. onNewCameraAddedObservable: Observable<Camera>;
  123538. /**
  123539. * An event triggered when a camera is removed
  123540. */
  123541. onCameraRemovedObservable: Observable<Camera>;
  123542. /**
  123543. * An event triggered when a light is created
  123544. */
  123545. onNewLightAddedObservable: Observable<Light>;
  123546. /**
  123547. * An event triggered when a light is removed
  123548. */
  123549. onLightRemovedObservable: Observable<Light>;
  123550. /**
  123551. * An event triggered when a geometry is created
  123552. */
  123553. onNewGeometryAddedObservable: Observable<Geometry>;
  123554. /**
  123555. * An event triggered when a geometry is removed
  123556. */
  123557. onGeometryRemovedObservable: Observable<Geometry>;
  123558. /**
  123559. * An event triggered when a transform node is created
  123560. */
  123561. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  123562. /**
  123563. * An event triggered when a transform node is removed
  123564. */
  123565. onTransformNodeRemovedObservable: Observable<TransformNode>;
  123566. /**
  123567. * An event triggered when a mesh is created
  123568. */
  123569. onNewMeshAddedObservable: Observable<AbstractMesh>;
  123570. /**
  123571. * An event triggered when a mesh is removed
  123572. */
  123573. onMeshRemovedObservable: Observable<AbstractMesh>;
  123574. /**
  123575. * An event triggered when a skeleton is created
  123576. */
  123577. onNewSkeletonAddedObservable: Observable<Skeleton>;
  123578. /**
  123579. * An event triggered when a skeleton is removed
  123580. */
  123581. onSkeletonRemovedObservable: Observable<Skeleton>;
  123582. /**
  123583. * An event triggered when a material is created
  123584. */
  123585. onNewMaterialAddedObservable: Observable<Material>;
  123586. /**
  123587. * An event triggered when a material is removed
  123588. */
  123589. onMaterialRemovedObservable: Observable<Material>;
  123590. /**
  123591. * An event triggered when a texture is created
  123592. */
  123593. onNewTextureAddedObservable: Observable<BaseTexture>;
  123594. /**
  123595. * An event triggered when a texture is removed
  123596. */
  123597. onTextureRemovedObservable: Observable<BaseTexture>;
  123598. /**
  123599. * An event triggered when render targets are about to be rendered
  123600. * Can happen multiple times per frame.
  123601. */
  123602. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  123603. /**
  123604. * An event triggered when render targets were rendered.
  123605. * Can happen multiple times per frame.
  123606. */
  123607. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  123608. /**
  123609. * An event triggered before calculating deterministic simulation step
  123610. */
  123611. onBeforeStepObservable: Observable<Scene>;
  123612. /**
  123613. * An event triggered after calculating deterministic simulation step
  123614. */
  123615. onAfterStepObservable: Observable<Scene>;
  123616. /**
  123617. * An event triggered when the activeCamera property is updated
  123618. */
  123619. onActiveCameraChanged: Observable<Scene>;
  123620. /**
  123621. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  123622. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  123623. * 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)
  123624. */
  123625. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  123626. /**
  123627. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  123628. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  123629. * 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)
  123630. */
  123631. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  123632. /**
  123633. * This Observable will when a mesh has been imported into the scene.
  123634. */
  123635. onMeshImportedObservable: Observable<AbstractMesh>;
  123636. /**
  123637. * This Observable will when an animation file has been imported into the scene.
  123638. */
  123639. onAnimationFileImportedObservable: Observable<Scene>;
  123640. /**
  123641. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  123642. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  123643. */
  123644. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  123645. /** @hidden */
  123646. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  123647. /**
  123648. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  123649. */
  123650. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  123651. /**
  123652. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  123653. */
  123654. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  123655. /**
  123656. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  123657. */
  123658. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  123659. /** Callback called when a pointer move is detected */
  123660. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  123661. /** Callback called when a pointer down is detected */
  123662. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  123663. /** Callback called when a pointer up is detected */
  123664. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  123665. /** Callback called when a pointer pick is detected */
  123666. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  123667. /**
  123668. * 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).
  123669. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  123670. */
  123671. onPrePointerObservable: Observable<PointerInfoPre>;
  123672. /**
  123673. * Observable event triggered each time an input event is received from the rendering canvas
  123674. */
  123675. onPointerObservable: Observable<PointerInfo>;
  123676. /**
  123677. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  123678. */
  123679. get unTranslatedPointer(): Vector2;
  123680. /**
  123681. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  123682. */
  123683. static get DragMovementThreshold(): number;
  123684. static set DragMovementThreshold(value: number);
  123685. /**
  123686. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  123687. */
  123688. static get LongPressDelay(): number;
  123689. static set LongPressDelay(value: number);
  123690. /**
  123691. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  123692. */
  123693. static get DoubleClickDelay(): number;
  123694. static set DoubleClickDelay(value: number);
  123695. /** If you need to check double click without raising a single click at first click, enable this flag */
  123696. static get ExclusiveDoubleClickMode(): boolean;
  123697. static set ExclusiveDoubleClickMode(value: boolean);
  123698. /** @hidden */
  123699. _mirroredCameraPosition: Nullable<Vector3>;
  123700. /**
  123701. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  123702. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  123703. */
  123704. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  123705. /**
  123706. * Observable event triggered each time an keyboard event is received from the hosting window
  123707. */
  123708. onKeyboardObservable: Observable<KeyboardInfo>;
  123709. private _useRightHandedSystem;
  123710. /**
  123711. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  123712. */
  123713. set useRightHandedSystem(value: boolean);
  123714. get useRightHandedSystem(): boolean;
  123715. private _timeAccumulator;
  123716. private _currentStepId;
  123717. private _currentInternalStep;
  123718. /**
  123719. * Sets the step Id used by deterministic lock step
  123720. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123721. * @param newStepId defines the step Id
  123722. */
  123723. setStepId(newStepId: number): void;
  123724. /**
  123725. * Gets the step Id used by deterministic lock step
  123726. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123727. * @returns the step Id
  123728. */
  123729. getStepId(): number;
  123730. /**
  123731. * Gets the internal step used by deterministic lock step
  123732. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123733. * @returns the internal step
  123734. */
  123735. getInternalStep(): number;
  123736. private _fogEnabled;
  123737. /**
  123738. * Gets or sets a boolean indicating if fog is enabled on this scene
  123739. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123740. * (Default is true)
  123741. */
  123742. set fogEnabled(value: boolean);
  123743. get fogEnabled(): boolean;
  123744. private _fogMode;
  123745. /**
  123746. * Gets or sets the fog mode to use
  123747. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123748. * | mode | value |
  123749. * | --- | --- |
  123750. * | FOGMODE_NONE | 0 |
  123751. * | FOGMODE_EXP | 1 |
  123752. * | FOGMODE_EXP2 | 2 |
  123753. * | FOGMODE_LINEAR | 3 |
  123754. */
  123755. set fogMode(value: number);
  123756. get fogMode(): number;
  123757. /**
  123758. * Gets or sets the fog color to use
  123759. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123760. * (Default is Color3(0.2, 0.2, 0.3))
  123761. */
  123762. fogColor: Color3;
  123763. /**
  123764. * Gets or sets the fog density to use
  123765. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123766. * (Default is 0.1)
  123767. */
  123768. fogDensity: number;
  123769. /**
  123770. * Gets or sets the fog start distance to use
  123771. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123772. * (Default is 0)
  123773. */
  123774. fogStart: number;
  123775. /**
  123776. * Gets or sets the fog end distance to use
  123777. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123778. * (Default is 1000)
  123779. */
  123780. fogEnd: number;
  123781. /**
  123782. * Flag indicating that the frame buffer binding is handled by another component
  123783. */
  123784. prePass: boolean;
  123785. private _shadowsEnabled;
  123786. /**
  123787. * Gets or sets a boolean indicating if shadows are enabled on this scene
  123788. */
  123789. set shadowsEnabled(value: boolean);
  123790. get shadowsEnabled(): boolean;
  123791. private _lightsEnabled;
  123792. /**
  123793. * Gets or sets a boolean indicating if lights are enabled on this scene
  123794. */
  123795. set lightsEnabled(value: boolean);
  123796. get lightsEnabled(): boolean;
  123797. /** All of the active cameras added to this scene. */
  123798. activeCameras: Camera[];
  123799. /** @hidden */
  123800. _activeCamera: Nullable<Camera>;
  123801. /** Gets or sets the current active camera */
  123802. get activeCamera(): Nullable<Camera>;
  123803. set activeCamera(value: Nullable<Camera>);
  123804. private _defaultMaterial;
  123805. /** The default material used on meshes when no material is affected */
  123806. get defaultMaterial(): Material;
  123807. /** The default material used on meshes when no material is affected */
  123808. set defaultMaterial(value: Material);
  123809. private _texturesEnabled;
  123810. /**
  123811. * Gets or sets a boolean indicating if textures are enabled on this scene
  123812. */
  123813. set texturesEnabled(value: boolean);
  123814. get texturesEnabled(): boolean;
  123815. /**
  123816. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  123817. */
  123818. physicsEnabled: boolean;
  123819. /**
  123820. * Gets or sets a boolean indicating if particles are enabled on this scene
  123821. */
  123822. particlesEnabled: boolean;
  123823. /**
  123824. * Gets or sets a boolean indicating if sprites are enabled on this scene
  123825. */
  123826. spritesEnabled: boolean;
  123827. private _skeletonsEnabled;
  123828. /**
  123829. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  123830. */
  123831. set skeletonsEnabled(value: boolean);
  123832. get skeletonsEnabled(): boolean;
  123833. /**
  123834. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  123835. */
  123836. lensFlaresEnabled: boolean;
  123837. /**
  123838. * Gets or sets a boolean indicating if collisions are enabled on this scene
  123839. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  123840. */
  123841. collisionsEnabled: boolean;
  123842. private _collisionCoordinator;
  123843. /** @hidden */
  123844. get collisionCoordinator(): ICollisionCoordinator;
  123845. /**
  123846. * Defines the gravity applied to this scene (used only for collisions)
  123847. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  123848. */
  123849. gravity: Vector3;
  123850. /**
  123851. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  123852. */
  123853. postProcessesEnabled: boolean;
  123854. /**
  123855. * Gets the current postprocess manager
  123856. */
  123857. postProcessManager: PostProcessManager;
  123858. /**
  123859. * Gets or sets a boolean indicating if render targets are enabled on this scene
  123860. */
  123861. renderTargetsEnabled: boolean;
  123862. /**
  123863. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  123864. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  123865. */
  123866. dumpNextRenderTargets: boolean;
  123867. /**
  123868. * The list of user defined render targets added to the scene
  123869. */
  123870. customRenderTargets: RenderTargetTexture[];
  123871. /**
  123872. * Defines if texture loading must be delayed
  123873. * If true, textures will only be loaded when they need to be rendered
  123874. */
  123875. useDelayedTextureLoading: boolean;
  123876. /**
  123877. * Gets the list of meshes imported to the scene through SceneLoader
  123878. */
  123879. importedMeshesFiles: String[];
  123880. /**
  123881. * Gets or sets a boolean indicating if probes are enabled on this scene
  123882. */
  123883. probesEnabled: boolean;
  123884. /**
  123885. * Gets or sets the current offline provider to use to store scene data
  123886. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  123887. */
  123888. offlineProvider: IOfflineProvider;
  123889. /**
  123890. * Gets or sets the action manager associated with the scene
  123891. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  123892. */
  123893. actionManager: AbstractActionManager;
  123894. private _meshesForIntersections;
  123895. /**
  123896. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  123897. */
  123898. proceduralTexturesEnabled: boolean;
  123899. private _engine;
  123900. private _totalVertices;
  123901. /** @hidden */
  123902. _activeIndices: PerfCounter;
  123903. /** @hidden */
  123904. _activeParticles: PerfCounter;
  123905. /** @hidden */
  123906. _activeBones: PerfCounter;
  123907. private _animationRatio;
  123908. /** @hidden */
  123909. _animationTimeLast: number;
  123910. /** @hidden */
  123911. _animationTime: number;
  123912. /**
  123913. * Gets or sets a general scale for animation speed
  123914. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  123915. */
  123916. animationTimeScale: number;
  123917. /** @hidden */
  123918. _cachedMaterial: Nullable<Material>;
  123919. /** @hidden */
  123920. _cachedEffect: Nullable<Effect>;
  123921. /** @hidden */
  123922. _cachedVisibility: Nullable<number>;
  123923. private _renderId;
  123924. private _frameId;
  123925. private _executeWhenReadyTimeoutId;
  123926. private _intermediateRendering;
  123927. private _viewUpdateFlag;
  123928. private _projectionUpdateFlag;
  123929. /** @hidden */
  123930. _toBeDisposed: Nullable<IDisposable>[];
  123931. private _activeRequests;
  123932. /** @hidden */
  123933. _pendingData: any[];
  123934. private _isDisposed;
  123935. /**
  123936. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  123937. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  123938. */
  123939. dispatchAllSubMeshesOfActiveMeshes: boolean;
  123940. private _activeMeshes;
  123941. private _processedMaterials;
  123942. private _renderTargets;
  123943. /** @hidden */
  123944. _activeParticleSystems: SmartArray<IParticleSystem>;
  123945. private _activeSkeletons;
  123946. private _softwareSkinnedMeshes;
  123947. private _renderingManager;
  123948. /** @hidden */
  123949. _activeAnimatables: Animatable[];
  123950. private _transformMatrix;
  123951. private _sceneUbo;
  123952. /** @hidden */
  123953. _viewMatrix: Matrix;
  123954. private _projectionMatrix;
  123955. /** @hidden */
  123956. _forcedViewPosition: Nullable<Vector3>;
  123957. /** @hidden */
  123958. _frustumPlanes: Plane[];
  123959. /**
  123960. * Gets the list of frustum planes (built from the active camera)
  123961. */
  123962. get frustumPlanes(): Plane[];
  123963. /**
  123964. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  123965. * This is useful if there are more lights that the maximum simulteanous authorized
  123966. */
  123967. requireLightSorting: boolean;
  123968. /** @hidden */
  123969. readonly useMaterialMeshMap: boolean;
  123970. /** @hidden */
  123971. readonly useClonedMeshMap: boolean;
  123972. private _externalData;
  123973. private _uid;
  123974. /**
  123975. * @hidden
  123976. * Backing store of defined scene components.
  123977. */
  123978. _components: ISceneComponent[];
  123979. /**
  123980. * @hidden
  123981. * Backing store of defined scene components.
  123982. */
  123983. _serializableComponents: ISceneSerializableComponent[];
  123984. /**
  123985. * List of components to register on the next registration step.
  123986. */
  123987. private _transientComponents;
  123988. /**
  123989. * Registers the transient components if needed.
  123990. */
  123991. private _registerTransientComponents;
  123992. /**
  123993. * @hidden
  123994. * Add a component to the scene.
  123995. * Note that the ccomponent could be registered on th next frame if this is called after
  123996. * the register component stage.
  123997. * @param component Defines the component to add to the scene
  123998. */
  123999. _addComponent(component: ISceneComponent): void;
  124000. /**
  124001. * @hidden
  124002. * Gets a component from the scene.
  124003. * @param name defines the name of the component to retrieve
  124004. * @returns the component or null if not present
  124005. */
  124006. _getComponent(name: string): Nullable<ISceneComponent>;
  124007. /**
  124008. * @hidden
  124009. * Defines the actions happening before camera updates.
  124010. */
  124011. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  124012. /**
  124013. * @hidden
  124014. * Defines the actions happening before clear the canvas.
  124015. */
  124016. _beforeClearStage: Stage<SimpleStageAction>;
  124017. /**
  124018. * @hidden
  124019. * Defines the actions when collecting render targets for the frame.
  124020. */
  124021. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  124022. /**
  124023. * @hidden
  124024. * Defines the actions happening for one camera in the frame.
  124025. */
  124026. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  124027. /**
  124028. * @hidden
  124029. * Defines the actions happening during the per mesh ready checks.
  124030. */
  124031. _isReadyForMeshStage: Stage<MeshStageAction>;
  124032. /**
  124033. * @hidden
  124034. * Defines the actions happening before evaluate active mesh checks.
  124035. */
  124036. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  124037. /**
  124038. * @hidden
  124039. * Defines the actions happening during the evaluate sub mesh checks.
  124040. */
  124041. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  124042. /**
  124043. * @hidden
  124044. * Defines the actions happening during the active mesh stage.
  124045. */
  124046. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  124047. /**
  124048. * @hidden
  124049. * Defines the actions happening during the per camera render target step.
  124050. */
  124051. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  124052. /**
  124053. * @hidden
  124054. * Defines the actions happening just before the active camera is drawing.
  124055. */
  124056. _beforeCameraDrawStage: Stage<CameraStageAction>;
  124057. /**
  124058. * @hidden
  124059. * Defines the actions happening just before a render target is drawing.
  124060. */
  124061. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  124062. /**
  124063. * @hidden
  124064. * Defines the actions happening just before a rendering group is drawing.
  124065. */
  124066. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  124067. /**
  124068. * @hidden
  124069. * Defines the actions happening just before a mesh is drawing.
  124070. */
  124071. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  124072. /**
  124073. * @hidden
  124074. * Defines the actions happening just after a mesh has been drawn.
  124075. */
  124076. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  124077. /**
  124078. * @hidden
  124079. * Defines the actions happening just after a rendering group has been drawn.
  124080. */
  124081. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  124082. /**
  124083. * @hidden
  124084. * Defines the actions happening just after the active camera has been drawn.
  124085. */
  124086. _afterCameraDrawStage: Stage<CameraStageAction>;
  124087. /**
  124088. * @hidden
  124089. * Defines the actions happening just after a render target has been drawn.
  124090. */
  124091. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  124092. /**
  124093. * @hidden
  124094. * Defines the actions happening just after rendering all cameras and computing intersections.
  124095. */
  124096. _afterRenderStage: Stage<SimpleStageAction>;
  124097. /**
  124098. * @hidden
  124099. * Defines the actions happening when a pointer move event happens.
  124100. */
  124101. _pointerMoveStage: Stage<PointerMoveStageAction>;
  124102. /**
  124103. * @hidden
  124104. * Defines the actions happening when a pointer down event happens.
  124105. */
  124106. _pointerDownStage: Stage<PointerUpDownStageAction>;
  124107. /**
  124108. * @hidden
  124109. * Defines the actions happening when a pointer up event happens.
  124110. */
  124111. _pointerUpStage: Stage<PointerUpDownStageAction>;
  124112. /**
  124113. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  124114. */
  124115. private geometriesByUniqueId;
  124116. /**
  124117. * Creates a new Scene
  124118. * @param engine defines the engine to use to render this scene
  124119. * @param options defines the scene options
  124120. */
  124121. constructor(engine: Engine, options?: SceneOptions);
  124122. /**
  124123. * Gets a string identifying the name of the class
  124124. * @returns "Scene" string
  124125. */
  124126. getClassName(): string;
  124127. private _defaultMeshCandidates;
  124128. /**
  124129. * @hidden
  124130. */
  124131. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  124132. private _defaultSubMeshCandidates;
  124133. /**
  124134. * @hidden
  124135. */
  124136. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  124137. /**
  124138. * Sets the default candidate providers for the scene.
  124139. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  124140. * and getCollidingSubMeshCandidates to their default function
  124141. */
  124142. setDefaultCandidateProviders(): void;
  124143. /**
  124144. * Gets the mesh that is currently under the pointer
  124145. */
  124146. get meshUnderPointer(): Nullable<AbstractMesh>;
  124147. /**
  124148. * Gets or sets the current on-screen X position of the pointer
  124149. */
  124150. get pointerX(): number;
  124151. set pointerX(value: number);
  124152. /**
  124153. * Gets or sets the current on-screen Y position of the pointer
  124154. */
  124155. get pointerY(): number;
  124156. set pointerY(value: number);
  124157. /**
  124158. * Gets the cached material (ie. the latest rendered one)
  124159. * @returns the cached material
  124160. */
  124161. getCachedMaterial(): Nullable<Material>;
  124162. /**
  124163. * Gets the cached effect (ie. the latest rendered one)
  124164. * @returns the cached effect
  124165. */
  124166. getCachedEffect(): Nullable<Effect>;
  124167. /**
  124168. * Gets the cached visibility state (ie. the latest rendered one)
  124169. * @returns the cached visibility state
  124170. */
  124171. getCachedVisibility(): Nullable<number>;
  124172. /**
  124173. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  124174. * @param material defines the current material
  124175. * @param effect defines the current effect
  124176. * @param visibility defines the current visibility state
  124177. * @returns true if one parameter is not cached
  124178. */
  124179. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  124180. /**
  124181. * Gets the engine associated with the scene
  124182. * @returns an Engine
  124183. */
  124184. getEngine(): Engine;
  124185. /**
  124186. * Gets the total number of vertices rendered per frame
  124187. * @returns the total number of vertices rendered per frame
  124188. */
  124189. getTotalVertices(): number;
  124190. /**
  124191. * Gets the performance counter for total vertices
  124192. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124193. */
  124194. get totalVerticesPerfCounter(): PerfCounter;
  124195. /**
  124196. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  124197. * @returns the total number of active indices rendered per frame
  124198. */
  124199. getActiveIndices(): number;
  124200. /**
  124201. * Gets the performance counter for active indices
  124202. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124203. */
  124204. get totalActiveIndicesPerfCounter(): PerfCounter;
  124205. /**
  124206. * Gets the total number of active particles rendered per frame
  124207. * @returns the total number of active particles rendered per frame
  124208. */
  124209. getActiveParticles(): number;
  124210. /**
  124211. * Gets the performance counter for active particles
  124212. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124213. */
  124214. get activeParticlesPerfCounter(): PerfCounter;
  124215. /**
  124216. * Gets the total number of active bones rendered per frame
  124217. * @returns the total number of active bones rendered per frame
  124218. */
  124219. getActiveBones(): number;
  124220. /**
  124221. * Gets the performance counter for active bones
  124222. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124223. */
  124224. get activeBonesPerfCounter(): PerfCounter;
  124225. /**
  124226. * Gets the array of active meshes
  124227. * @returns an array of AbstractMesh
  124228. */
  124229. getActiveMeshes(): SmartArray<AbstractMesh>;
  124230. /**
  124231. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  124232. * @returns a number
  124233. */
  124234. getAnimationRatio(): number;
  124235. /**
  124236. * Gets an unique Id for the current render phase
  124237. * @returns a number
  124238. */
  124239. getRenderId(): number;
  124240. /**
  124241. * Gets an unique Id for the current frame
  124242. * @returns a number
  124243. */
  124244. getFrameId(): number;
  124245. /** Call this function if you want to manually increment the render Id*/
  124246. incrementRenderId(): void;
  124247. private _createUbo;
  124248. /**
  124249. * Use this method to simulate a pointer move on a mesh
  124250. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124251. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124252. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124253. * @returns the current scene
  124254. */
  124255. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  124256. /**
  124257. * Use this method to simulate a pointer down on a mesh
  124258. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124259. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124260. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124261. * @returns the current scene
  124262. */
  124263. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  124264. /**
  124265. * Use this method to simulate a pointer up on a mesh
  124266. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124267. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124268. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124269. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  124270. * @returns the current scene
  124271. */
  124272. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  124273. /**
  124274. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  124275. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  124276. * @returns true if the pointer was captured
  124277. */
  124278. isPointerCaptured(pointerId?: number): boolean;
  124279. /**
  124280. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  124281. * @param attachUp defines if you want to attach events to pointerup
  124282. * @param attachDown defines if you want to attach events to pointerdown
  124283. * @param attachMove defines if you want to attach events to pointermove
  124284. */
  124285. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  124286. /** Detaches all event handlers*/
  124287. detachControl(): void;
  124288. /**
  124289. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  124290. * Delay loaded resources are not taking in account
  124291. * @return true if all required resources are ready
  124292. */
  124293. isReady(): boolean;
  124294. /** Resets all cached information relative to material (including effect and visibility) */
  124295. resetCachedMaterial(): void;
  124296. /**
  124297. * Registers a function to be called before every frame render
  124298. * @param func defines the function to register
  124299. */
  124300. registerBeforeRender(func: () => void): void;
  124301. /**
  124302. * Unregisters a function called before every frame render
  124303. * @param func defines the function to unregister
  124304. */
  124305. unregisterBeforeRender(func: () => void): void;
  124306. /**
  124307. * Registers a function to be called after every frame render
  124308. * @param func defines the function to register
  124309. */
  124310. registerAfterRender(func: () => void): void;
  124311. /**
  124312. * Unregisters a function called after every frame render
  124313. * @param func defines the function to unregister
  124314. */
  124315. unregisterAfterRender(func: () => void): void;
  124316. private _executeOnceBeforeRender;
  124317. /**
  124318. * The provided function will run before render once and will be disposed afterwards.
  124319. * A timeout delay can be provided so that the function will be executed in N ms.
  124320. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  124321. * @param func The function to be executed.
  124322. * @param timeout optional delay in ms
  124323. */
  124324. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  124325. /** @hidden */
  124326. _addPendingData(data: any): void;
  124327. /** @hidden */
  124328. _removePendingData(data: any): void;
  124329. /**
  124330. * Returns the number of items waiting to be loaded
  124331. * @returns the number of items waiting to be loaded
  124332. */
  124333. getWaitingItemsCount(): number;
  124334. /**
  124335. * Returns a boolean indicating if the scene is still loading data
  124336. */
  124337. get isLoading(): boolean;
  124338. /**
  124339. * Registers a function to be executed when the scene is ready
  124340. * @param {Function} func - the function to be executed
  124341. */
  124342. executeWhenReady(func: () => void): void;
  124343. /**
  124344. * Returns a promise that resolves when the scene is ready
  124345. * @returns A promise that resolves when the scene is ready
  124346. */
  124347. whenReadyAsync(): Promise<void>;
  124348. /** @hidden */
  124349. _checkIsReady(): void;
  124350. /**
  124351. * Gets all animatable attached to the scene
  124352. */
  124353. get animatables(): Animatable[];
  124354. /**
  124355. * Resets the last animation time frame.
  124356. * Useful to override when animations start running when loading a scene for the first time.
  124357. */
  124358. resetLastAnimationTimeFrame(): void;
  124359. /**
  124360. * Gets the current view matrix
  124361. * @returns a Matrix
  124362. */
  124363. getViewMatrix(): Matrix;
  124364. /**
  124365. * Gets the current projection matrix
  124366. * @returns a Matrix
  124367. */
  124368. getProjectionMatrix(): Matrix;
  124369. /**
  124370. * Gets the current transform matrix
  124371. * @returns a Matrix made of View * Projection
  124372. */
  124373. getTransformMatrix(): Matrix;
  124374. /**
  124375. * Sets the current transform matrix
  124376. * @param viewL defines the View matrix to use
  124377. * @param projectionL defines the Projection matrix to use
  124378. * @param viewR defines the right View matrix to use (if provided)
  124379. * @param projectionR defines the right Projection matrix to use (if provided)
  124380. */
  124381. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  124382. /**
  124383. * Gets the uniform buffer used to store scene data
  124384. * @returns a UniformBuffer
  124385. */
  124386. getSceneUniformBuffer(): UniformBuffer;
  124387. /**
  124388. * Gets an unique (relatively to the current scene) Id
  124389. * @returns an unique number for the scene
  124390. */
  124391. getUniqueId(): number;
  124392. /**
  124393. * Add a mesh to the list of scene's meshes
  124394. * @param newMesh defines the mesh to add
  124395. * @param recursive if all child meshes should also be added to the scene
  124396. */
  124397. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  124398. /**
  124399. * Remove a mesh for the list of scene's meshes
  124400. * @param toRemove defines the mesh to remove
  124401. * @param recursive if all child meshes should also be removed from the scene
  124402. * @returns the index where the mesh was in the mesh list
  124403. */
  124404. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  124405. /**
  124406. * Add a transform node to the list of scene's transform nodes
  124407. * @param newTransformNode defines the transform node to add
  124408. */
  124409. addTransformNode(newTransformNode: TransformNode): void;
  124410. /**
  124411. * Remove a transform node for the list of scene's transform nodes
  124412. * @param toRemove defines the transform node to remove
  124413. * @returns the index where the transform node was in the transform node list
  124414. */
  124415. removeTransformNode(toRemove: TransformNode): number;
  124416. /**
  124417. * Remove a skeleton for the list of scene's skeletons
  124418. * @param toRemove defines the skeleton to remove
  124419. * @returns the index where the skeleton was in the skeleton list
  124420. */
  124421. removeSkeleton(toRemove: Skeleton): number;
  124422. /**
  124423. * Remove a morph target for the list of scene's morph targets
  124424. * @param toRemove defines the morph target to remove
  124425. * @returns the index where the morph target was in the morph target list
  124426. */
  124427. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  124428. /**
  124429. * Remove a light for the list of scene's lights
  124430. * @param toRemove defines the light to remove
  124431. * @returns the index where the light was in the light list
  124432. */
  124433. removeLight(toRemove: Light): number;
  124434. /**
  124435. * Remove a camera for the list of scene's cameras
  124436. * @param toRemove defines the camera to remove
  124437. * @returns the index where the camera was in the camera list
  124438. */
  124439. removeCamera(toRemove: Camera): number;
  124440. /**
  124441. * Remove a particle system for the list of scene's particle systems
  124442. * @param toRemove defines the particle system to remove
  124443. * @returns the index where the particle system was in the particle system list
  124444. */
  124445. removeParticleSystem(toRemove: IParticleSystem): number;
  124446. /**
  124447. * Remove a animation for the list of scene's animations
  124448. * @param toRemove defines the animation to remove
  124449. * @returns the index where the animation was in the animation list
  124450. */
  124451. removeAnimation(toRemove: Animation): number;
  124452. /**
  124453. * Will stop the animation of the given target
  124454. * @param target - the target
  124455. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  124456. * @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)
  124457. */
  124458. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  124459. /**
  124460. * Removes the given animation group from this scene.
  124461. * @param toRemove The animation group to remove
  124462. * @returns The index of the removed animation group
  124463. */
  124464. removeAnimationGroup(toRemove: AnimationGroup): number;
  124465. /**
  124466. * Removes the given multi-material from this scene.
  124467. * @param toRemove The multi-material to remove
  124468. * @returns The index of the removed multi-material
  124469. */
  124470. removeMultiMaterial(toRemove: MultiMaterial): number;
  124471. /**
  124472. * Removes the given material from this scene.
  124473. * @param toRemove The material to remove
  124474. * @returns The index of the removed material
  124475. */
  124476. removeMaterial(toRemove: Material): number;
  124477. /**
  124478. * Removes the given action manager from this scene.
  124479. * @param toRemove The action manager to remove
  124480. * @returns The index of the removed action manager
  124481. */
  124482. removeActionManager(toRemove: AbstractActionManager): number;
  124483. /**
  124484. * Removes the given texture from this scene.
  124485. * @param toRemove The texture to remove
  124486. * @returns The index of the removed texture
  124487. */
  124488. removeTexture(toRemove: BaseTexture): number;
  124489. /**
  124490. * Adds the given light to this scene
  124491. * @param newLight The light to add
  124492. */
  124493. addLight(newLight: Light): void;
  124494. /**
  124495. * Sorts the list list based on light priorities
  124496. */
  124497. sortLightsByPriority(): void;
  124498. /**
  124499. * Adds the given camera to this scene
  124500. * @param newCamera The camera to add
  124501. */
  124502. addCamera(newCamera: Camera): void;
  124503. /**
  124504. * Adds the given skeleton to this scene
  124505. * @param newSkeleton The skeleton to add
  124506. */
  124507. addSkeleton(newSkeleton: Skeleton): void;
  124508. /**
  124509. * Adds the given particle system to this scene
  124510. * @param newParticleSystem The particle system to add
  124511. */
  124512. addParticleSystem(newParticleSystem: IParticleSystem): void;
  124513. /**
  124514. * Adds the given animation to this scene
  124515. * @param newAnimation The animation to add
  124516. */
  124517. addAnimation(newAnimation: Animation): void;
  124518. /**
  124519. * Adds the given animation group to this scene.
  124520. * @param newAnimationGroup The animation group to add
  124521. */
  124522. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  124523. /**
  124524. * Adds the given multi-material to this scene
  124525. * @param newMultiMaterial The multi-material to add
  124526. */
  124527. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  124528. /**
  124529. * Adds the given material to this scene
  124530. * @param newMaterial The material to add
  124531. */
  124532. addMaterial(newMaterial: Material): void;
  124533. /**
  124534. * Adds the given morph target to this scene
  124535. * @param newMorphTargetManager The morph target to add
  124536. */
  124537. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  124538. /**
  124539. * Adds the given geometry to this scene
  124540. * @param newGeometry The geometry to add
  124541. */
  124542. addGeometry(newGeometry: Geometry): void;
  124543. /**
  124544. * Adds the given action manager to this scene
  124545. * @param newActionManager The action manager to add
  124546. */
  124547. addActionManager(newActionManager: AbstractActionManager): void;
  124548. /**
  124549. * Adds the given texture to this scene.
  124550. * @param newTexture The texture to add
  124551. */
  124552. addTexture(newTexture: BaseTexture): void;
  124553. /**
  124554. * Switch active camera
  124555. * @param newCamera defines the new active camera
  124556. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  124557. */
  124558. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  124559. /**
  124560. * sets the active camera of the scene using its ID
  124561. * @param id defines the camera's ID
  124562. * @return the new active camera or null if none found.
  124563. */
  124564. setActiveCameraByID(id: string): Nullable<Camera>;
  124565. /**
  124566. * sets the active camera of the scene using its name
  124567. * @param name defines the camera's name
  124568. * @returns the new active camera or null if none found.
  124569. */
  124570. setActiveCameraByName(name: string): Nullable<Camera>;
  124571. /**
  124572. * get an animation group using its name
  124573. * @param name defines the material's name
  124574. * @return the animation group or null if none found.
  124575. */
  124576. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  124577. /**
  124578. * Get a material using its unique id
  124579. * @param uniqueId defines the material's unique id
  124580. * @return the material or null if none found.
  124581. */
  124582. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  124583. /**
  124584. * get a material using its id
  124585. * @param id defines the material's ID
  124586. * @return the material or null if none found.
  124587. */
  124588. getMaterialByID(id: string): Nullable<Material>;
  124589. /**
  124590. * Gets a the last added material using a given id
  124591. * @param id defines the material's ID
  124592. * @return the last material with the given id or null if none found.
  124593. */
  124594. getLastMaterialByID(id: string): Nullable<Material>;
  124595. /**
  124596. * Gets a material using its name
  124597. * @param name defines the material's name
  124598. * @return the material or null if none found.
  124599. */
  124600. getMaterialByName(name: string): Nullable<Material>;
  124601. /**
  124602. * Get a texture using its unique id
  124603. * @param uniqueId defines the texture's unique id
  124604. * @return the texture or null if none found.
  124605. */
  124606. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  124607. /**
  124608. * Gets a camera using its id
  124609. * @param id defines the id to look for
  124610. * @returns the camera or null if not found
  124611. */
  124612. getCameraByID(id: string): Nullable<Camera>;
  124613. /**
  124614. * Gets a camera using its unique id
  124615. * @param uniqueId defines the unique id to look for
  124616. * @returns the camera or null if not found
  124617. */
  124618. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  124619. /**
  124620. * Gets a camera using its name
  124621. * @param name defines the camera's name
  124622. * @return the camera or null if none found.
  124623. */
  124624. getCameraByName(name: string): Nullable<Camera>;
  124625. /**
  124626. * Gets a bone using its id
  124627. * @param id defines the bone's id
  124628. * @return the bone or null if not found
  124629. */
  124630. getBoneByID(id: string): Nullable<Bone>;
  124631. /**
  124632. * Gets a bone using its id
  124633. * @param name defines the bone's name
  124634. * @return the bone or null if not found
  124635. */
  124636. getBoneByName(name: string): Nullable<Bone>;
  124637. /**
  124638. * Gets a light node using its name
  124639. * @param name defines the the light's name
  124640. * @return the light or null if none found.
  124641. */
  124642. getLightByName(name: string): Nullable<Light>;
  124643. /**
  124644. * Gets a light node using its id
  124645. * @param id defines the light's id
  124646. * @return the light or null if none found.
  124647. */
  124648. getLightByID(id: string): Nullable<Light>;
  124649. /**
  124650. * Gets a light node using its scene-generated unique ID
  124651. * @param uniqueId defines the light's unique id
  124652. * @return the light or null if none found.
  124653. */
  124654. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  124655. /**
  124656. * Gets a particle system by id
  124657. * @param id defines the particle system id
  124658. * @return the corresponding system or null if none found
  124659. */
  124660. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  124661. /**
  124662. * Gets a geometry using its ID
  124663. * @param id defines the geometry's id
  124664. * @return the geometry or null if none found.
  124665. */
  124666. getGeometryByID(id: string): Nullable<Geometry>;
  124667. private _getGeometryByUniqueID;
  124668. /**
  124669. * Add a new geometry to this scene
  124670. * @param geometry defines the geometry to be added to the scene.
  124671. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  124672. * @return a boolean defining if the geometry was added or not
  124673. */
  124674. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  124675. /**
  124676. * Removes an existing geometry
  124677. * @param geometry defines the geometry to be removed from the scene
  124678. * @return a boolean defining if the geometry was removed or not
  124679. */
  124680. removeGeometry(geometry: Geometry): boolean;
  124681. /**
  124682. * Gets the list of geometries attached to the scene
  124683. * @returns an array of Geometry
  124684. */
  124685. getGeometries(): Geometry[];
  124686. /**
  124687. * Gets the first added mesh found of a given ID
  124688. * @param id defines the id to search for
  124689. * @return the mesh found or null if not found at all
  124690. */
  124691. getMeshByID(id: string): Nullable<AbstractMesh>;
  124692. /**
  124693. * Gets a list of meshes using their id
  124694. * @param id defines the id to search for
  124695. * @returns a list of meshes
  124696. */
  124697. getMeshesByID(id: string): Array<AbstractMesh>;
  124698. /**
  124699. * Gets the first added transform node found of a given ID
  124700. * @param id defines the id to search for
  124701. * @return the found transform node or null if not found at all.
  124702. */
  124703. getTransformNodeByID(id: string): Nullable<TransformNode>;
  124704. /**
  124705. * Gets a transform node with its auto-generated unique id
  124706. * @param uniqueId efines the unique id to search for
  124707. * @return the found transform node or null if not found at all.
  124708. */
  124709. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  124710. /**
  124711. * Gets a list of transform nodes using their id
  124712. * @param id defines the id to search for
  124713. * @returns a list of transform nodes
  124714. */
  124715. getTransformNodesByID(id: string): Array<TransformNode>;
  124716. /**
  124717. * Gets a mesh with its auto-generated unique id
  124718. * @param uniqueId defines the unique id to search for
  124719. * @return the found mesh or null if not found at all.
  124720. */
  124721. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  124722. /**
  124723. * Gets a the last added mesh using a given id
  124724. * @param id defines the id to search for
  124725. * @return the found mesh or null if not found at all.
  124726. */
  124727. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  124728. /**
  124729. * Gets a the last added node (Mesh, Camera, Light) using a given id
  124730. * @param id defines the id to search for
  124731. * @return the found node or null if not found at all
  124732. */
  124733. getLastEntryByID(id: string): Nullable<Node>;
  124734. /**
  124735. * Gets a node (Mesh, Camera, Light) using a given id
  124736. * @param id defines the id to search for
  124737. * @return the found node or null if not found at all
  124738. */
  124739. getNodeByID(id: string): Nullable<Node>;
  124740. /**
  124741. * Gets a node (Mesh, Camera, Light) using a given name
  124742. * @param name defines the name to search for
  124743. * @return the found node or null if not found at all.
  124744. */
  124745. getNodeByName(name: string): Nullable<Node>;
  124746. /**
  124747. * Gets a mesh using a given name
  124748. * @param name defines the name to search for
  124749. * @return the found mesh or null if not found at all.
  124750. */
  124751. getMeshByName(name: string): Nullable<AbstractMesh>;
  124752. /**
  124753. * Gets a transform node using a given name
  124754. * @param name defines the name to search for
  124755. * @return the found transform node or null if not found at all.
  124756. */
  124757. getTransformNodeByName(name: string): Nullable<TransformNode>;
  124758. /**
  124759. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  124760. * @param id defines the id to search for
  124761. * @return the found skeleton or null if not found at all.
  124762. */
  124763. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  124764. /**
  124765. * Gets a skeleton using a given auto generated unique id
  124766. * @param uniqueId defines the unique id to search for
  124767. * @return the found skeleton or null if not found at all.
  124768. */
  124769. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  124770. /**
  124771. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  124772. * @param id defines the id to search for
  124773. * @return the found skeleton or null if not found at all.
  124774. */
  124775. getSkeletonById(id: string): Nullable<Skeleton>;
  124776. /**
  124777. * Gets a skeleton using a given name
  124778. * @param name defines the name to search for
  124779. * @return the found skeleton or null if not found at all.
  124780. */
  124781. getSkeletonByName(name: string): Nullable<Skeleton>;
  124782. /**
  124783. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  124784. * @param id defines the id to search for
  124785. * @return the found morph target manager or null if not found at all.
  124786. */
  124787. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  124788. /**
  124789. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  124790. * @param id defines the id to search for
  124791. * @return the found morph target or null if not found at all.
  124792. */
  124793. getMorphTargetById(id: string): Nullable<MorphTarget>;
  124794. /**
  124795. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  124796. * @param name defines the name to search for
  124797. * @return the found morph target or null if not found at all.
  124798. */
  124799. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  124800. /**
  124801. * Gets a post process using a given name (if many are found, this function will pick the first one)
  124802. * @param name defines the name to search for
  124803. * @return the found post process or null if not found at all.
  124804. */
  124805. getPostProcessByName(name: string): Nullable<PostProcess>;
  124806. /**
  124807. * Gets a boolean indicating if the given mesh is active
  124808. * @param mesh defines the mesh to look for
  124809. * @returns true if the mesh is in the active list
  124810. */
  124811. isActiveMesh(mesh: AbstractMesh): boolean;
  124812. /**
  124813. * Return a unique id as a string which can serve as an identifier for the scene
  124814. */
  124815. get uid(): string;
  124816. /**
  124817. * Add an externaly attached data from its key.
  124818. * This method call will fail and return false, if such key already exists.
  124819. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  124820. * @param key the unique key that identifies the data
  124821. * @param data the data object to associate to the key for this Engine instance
  124822. * @return true if no such key were already present and the data was added successfully, false otherwise
  124823. */
  124824. addExternalData<T>(key: string, data: T): boolean;
  124825. /**
  124826. * Get an externaly attached data from its key
  124827. * @param key the unique key that identifies the data
  124828. * @return the associated data, if present (can be null), or undefined if not present
  124829. */
  124830. getExternalData<T>(key: string): Nullable<T>;
  124831. /**
  124832. * Get an externaly attached data from its key, create it using a factory if it's not already present
  124833. * @param key the unique key that identifies the data
  124834. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  124835. * @return the associated data, can be null if the factory returned null.
  124836. */
  124837. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  124838. /**
  124839. * Remove an externaly attached data from the Engine instance
  124840. * @param key the unique key that identifies the data
  124841. * @return true if the data was successfully removed, false if it doesn't exist
  124842. */
  124843. removeExternalData(key: string): boolean;
  124844. private _evaluateSubMesh;
  124845. /**
  124846. * Clear the processed materials smart array preventing retention point in material dispose.
  124847. */
  124848. freeProcessedMaterials(): void;
  124849. private _preventFreeActiveMeshesAndRenderingGroups;
  124850. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  124851. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  124852. * when disposing several meshes in a row or a hierarchy of meshes.
  124853. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  124854. */
  124855. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  124856. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  124857. /**
  124858. * Clear the active meshes smart array preventing retention point in mesh dispose.
  124859. */
  124860. freeActiveMeshes(): void;
  124861. /**
  124862. * Clear the info related to rendering groups preventing retention points during dispose.
  124863. */
  124864. freeRenderingGroups(): void;
  124865. /** @hidden */
  124866. _isInIntermediateRendering(): boolean;
  124867. /**
  124868. * Lambda returning the list of potentially active meshes.
  124869. */
  124870. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  124871. /**
  124872. * Lambda returning the list of potentially active sub meshes.
  124873. */
  124874. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  124875. /**
  124876. * Lambda returning the list of potentially intersecting sub meshes.
  124877. */
  124878. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  124879. /**
  124880. * Lambda returning the list of potentially colliding sub meshes.
  124881. */
  124882. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  124883. private _activeMeshesFrozen;
  124884. private _skipEvaluateActiveMeshesCompletely;
  124885. /**
  124886. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  124887. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  124888. * @param onSuccess optional success callback
  124889. * @param onError optional error callback
  124890. * @returns the current scene
  124891. */
  124892. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  124893. /**
  124894. * Use this function to restart evaluating active meshes on every frame
  124895. * @returns the current scene
  124896. */
  124897. unfreezeActiveMeshes(): Scene;
  124898. private _evaluateActiveMeshes;
  124899. private _activeMesh;
  124900. /**
  124901. * Update the transform matrix to update from the current active camera
  124902. * @param force defines a boolean used to force the update even if cache is up to date
  124903. */
  124904. updateTransformMatrix(force?: boolean): void;
  124905. private _bindFrameBuffer;
  124906. /** @hidden */
  124907. _allowPostProcessClearColor: boolean;
  124908. /** @hidden */
  124909. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  124910. private _processSubCameras;
  124911. private _checkIntersections;
  124912. /** @hidden */
  124913. _advancePhysicsEngineStep(step: number): void;
  124914. /**
  124915. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  124916. */
  124917. getDeterministicFrameTime: () => number;
  124918. /** @hidden */
  124919. _animate(): void;
  124920. /** Execute all animations (for a frame) */
  124921. animate(): void;
  124922. /**
  124923. * Render the scene
  124924. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  124925. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  124926. */
  124927. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  124928. /**
  124929. * Freeze all materials
  124930. * A frozen material will not be updatable but should be faster to render
  124931. */
  124932. freezeMaterials(): void;
  124933. /**
  124934. * Unfreeze all materials
  124935. * A frozen material will not be updatable but should be faster to render
  124936. */
  124937. unfreezeMaterials(): void;
  124938. /**
  124939. * Releases all held ressources
  124940. */
  124941. dispose(): void;
  124942. /**
  124943. * Gets if the scene is already disposed
  124944. */
  124945. get isDisposed(): boolean;
  124946. /**
  124947. * Call this function to reduce memory footprint of the scene.
  124948. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  124949. */
  124950. clearCachedVertexData(): void;
  124951. /**
  124952. * This function will remove the local cached buffer data from texture.
  124953. * It will save memory but will prevent the texture from being rebuilt
  124954. */
  124955. cleanCachedTextureBuffer(): void;
  124956. /**
  124957. * Get the world extend vectors with an optional filter
  124958. *
  124959. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  124960. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  124961. */
  124962. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  124963. min: Vector3;
  124964. max: Vector3;
  124965. };
  124966. /**
  124967. * Creates a ray that can be used to pick in the scene
  124968. * @param x defines the x coordinate of the origin (on-screen)
  124969. * @param y defines the y coordinate of the origin (on-screen)
  124970. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  124971. * @param camera defines the camera to use for the picking
  124972. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  124973. * @returns a Ray
  124974. */
  124975. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  124976. /**
  124977. * Creates a ray that can be used to pick in the scene
  124978. * @param x defines the x coordinate of the origin (on-screen)
  124979. * @param y defines the y coordinate of the origin (on-screen)
  124980. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  124981. * @param result defines the ray where to store the picking ray
  124982. * @param camera defines the camera to use for the picking
  124983. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  124984. * @returns the current scene
  124985. */
  124986. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  124987. /**
  124988. * Creates a ray that can be used to pick in the scene
  124989. * @param x defines the x coordinate of the origin (on-screen)
  124990. * @param y defines the y coordinate of the origin (on-screen)
  124991. * @param camera defines the camera to use for the picking
  124992. * @returns a Ray
  124993. */
  124994. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  124995. /**
  124996. * Creates a ray that can be used to pick in the scene
  124997. * @param x defines the x coordinate of the origin (on-screen)
  124998. * @param y defines the y coordinate of the origin (on-screen)
  124999. * @param result defines the ray where to store the picking ray
  125000. * @param camera defines the camera to use for the picking
  125001. * @returns the current scene
  125002. */
  125003. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  125004. /** Launch a ray to try to pick a mesh in the scene
  125005. * @param x position on screen
  125006. * @param y position on screen
  125007. * @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
  125008. * @param fastCheck defines if the first intersection will be used (and not the closest)
  125009. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  125010. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  125011. * @returns a PickingInfo
  125012. */
  125013. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  125014. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  125015. * @param x position on screen
  125016. * @param y position on screen
  125017. * @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
  125018. * @param fastCheck defines if the first intersection will be used (and not the closest)
  125019. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  125020. * @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)
  125021. */
  125022. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  125023. /** Use the given ray to pick a mesh in the scene
  125024. * @param ray The ray to use to pick meshes
  125025. * @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
  125026. * @param fastCheck defines if the first intersection will be used (and not the closest)
  125027. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  125028. * @returns a PickingInfo
  125029. */
  125030. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  125031. /**
  125032. * Launch a ray to try to pick a mesh in the scene
  125033. * @param x X position on screen
  125034. * @param y Y position on screen
  125035. * @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
  125036. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  125037. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  125038. * @returns an array of PickingInfo
  125039. */
  125040. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  125041. /**
  125042. * Launch a ray to try to pick a mesh in the scene
  125043. * @param ray Ray to use
  125044. * @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
  125045. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  125046. * @returns an array of PickingInfo
  125047. */
  125048. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  125049. /**
  125050. * Force the value of meshUnderPointer
  125051. * @param mesh defines the mesh to use
  125052. * @param pointerId optional pointer id when using more than one pointer
  125053. */
  125054. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  125055. /**
  125056. * Gets the mesh under the pointer
  125057. * @returns a Mesh or null if no mesh is under the pointer
  125058. */
  125059. getPointerOverMesh(): Nullable<AbstractMesh>;
  125060. /** @hidden */
  125061. _rebuildGeometries(): void;
  125062. /** @hidden */
  125063. _rebuildTextures(): void;
  125064. private _getByTags;
  125065. /**
  125066. * Get a list of meshes by tags
  125067. * @param tagsQuery defines the tags query to use
  125068. * @param forEach defines a predicate used to filter results
  125069. * @returns an array of Mesh
  125070. */
  125071. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  125072. /**
  125073. * Get a list of cameras by tags
  125074. * @param tagsQuery defines the tags query to use
  125075. * @param forEach defines a predicate used to filter results
  125076. * @returns an array of Camera
  125077. */
  125078. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  125079. /**
  125080. * Get a list of lights by tags
  125081. * @param tagsQuery defines the tags query to use
  125082. * @param forEach defines a predicate used to filter results
  125083. * @returns an array of Light
  125084. */
  125085. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  125086. /**
  125087. * Get a list of materials by tags
  125088. * @param tagsQuery defines the tags query to use
  125089. * @param forEach defines a predicate used to filter results
  125090. * @returns an array of Material
  125091. */
  125092. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  125093. /**
  125094. * Get a list of transform nodes by tags
  125095. * @param tagsQuery defines the tags query to use
  125096. * @param forEach defines a predicate used to filter results
  125097. * @returns an array of TransformNode
  125098. */
  125099. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  125100. /**
  125101. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  125102. * This allowed control for front to back rendering or reversly depending of the special needs.
  125103. *
  125104. * @param renderingGroupId The rendering group id corresponding to its index
  125105. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  125106. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  125107. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  125108. */
  125109. 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;
  125110. /**
  125111. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  125112. *
  125113. * @param renderingGroupId The rendering group id corresponding to its index
  125114. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  125115. * @param depth Automatically clears depth between groups if true and autoClear is true.
  125116. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  125117. */
  125118. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  125119. /**
  125120. * Gets the current auto clear configuration for one rendering group of the rendering
  125121. * manager.
  125122. * @param index the rendering group index to get the information for
  125123. * @returns The auto clear setup for the requested rendering group
  125124. */
  125125. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  125126. private _blockMaterialDirtyMechanism;
  125127. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  125128. get blockMaterialDirtyMechanism(): boolean;
  125129. set blockMaterialDirtyMechanism(value: boolean);
  125130. /**
  125131. * Will flag all materials as dirty to trigger new shader compilation
  125132. * @param flag defines the flag used to specify which material part must be marked as dirty
  125133. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  125134. */
  125135. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  125136. /** @hidden */
  125137. _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;
  125138. /** @hidden */
  125139. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  125140. /** @hidden */
  125141. _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;
  125142. /** @hidden */
  125143. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  125144. /** @hidden */
  125145. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  125146. /** @hidden */
  125147. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  125148. }
  125149. }
  125150. declare module BABYLON {
  125151. /**
  125152. * Set of assets to keep when moving a scene into an asset container.
  125153. */
  125154. export class KeepAssets extends AbstractScene {
  125155. }
  125156. /**
  125157. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  125158. */
  125159. export class InstantiatedEntries {
  125160. /**
  125161. * List of new root nodes (eg. nodes with no parent)
  125162. */
  125163. rootNodes: TransformNode[];
  125164. /**
  125165. * List of new skeletons
  125166. */
  125167. skeletons: Skeleton[];
  125168. /**
  125169. * List of new animation groups
  125170. */
  125171. animationGroups: AnimationGroup[];
  125172. }
  125173. /**
  125174. * Container with a set of assets that can be added or removed from a scene.
  125175. */
  125176. export class AssetContainer extends AbstractScene {
  125177. private _wasAddedToScene;
  125178. /**
  125179. * The scene the AssetContainer belongs to.
  125180. */
  125181. scene: Scene;
  125182. /**
  125183. * Instantiates an AssetContainer.
  125184. * @param scene The scene the AssetContainer belongs to.
  125185. */
  125186. constructor(scene: Scene);
  125187. /**
  125188. * Instantiate or clone all meshes and add the new ones to the scene.
  125189. * Skeletons and animation groups will all be cloned
  125190. * @param nameFunction defines an optional function used to get new names for clones
  125191. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  125192. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  125193. */
  125194. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  125195. /**
  125196. * Adds all the assets from the container to the scene.
  125197. */
  125198. addAllToScene(): void;
  125199. /**
  125200. * Removes all the assets in the container from the scene
  125201. */
  125202. removeAllFromScene(): void;
  125203. /**
  125204. * Disposes all the assets in the container
  125205. */
  125206. dispose(): void;
  125207. private _moveAssets;
  125208. /**
  125209. * Removes all the assets contained in the scene and adds them to the container.
  125210. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  125211. */
  125212. moveAllFromScene(keepAssets?: KeepAssets): void;
  125213. /**
  125214. * 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.
  125215. * @returns the root mesh
  125216. */
  125217. createRootMesh(): Mesh;
  125218. /**
  125219. * Merge animations (direct and animation groups) from this asset container into a scene
  125220. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125221. * @param animatables set of animatables to retarget to a node from the scene
  125222. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  125223. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  125224. */
  125225. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  125226. }
  125227. }
  125228. declare module BABYLON {
  125229. /**
  125230. * Defines how the parser contract is defined.
  125231. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  125232. */
  125233. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  125234. /**
  125235. * Defines how the individual parser contract is defined.
  125236. * These parser can parse an individual asset
  125237. */
  125238. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  125239. /**
  125240. * Base class of the scene acting as a container for the different elements composing a scene.
  125241. * This class is dynamically extended by the different components of the scene increasing
  125242. * flexibility and reducing coupling
  125243. */
  125244. export abstract class AbstractScene {
  125245. /**
  125246. * Stores the list of available parsers in the application.
  125247. */
  125248. private static _BabylonFileParsers;
  125249. /**
  125250. * Stores the list of available individual parsers in the application.
  125251. */
  125252. private static _IndividualBabylonFileParsers;
  125253. /**
  125254. * Adds a parser in the list of available ones
  125255. * @param name Defines the name of the parser
  125256. * @param parser Defines the parser to add
  125257. */
  125258. static AddParser(name: string, parser: BabylonFileParser): void;
  125259. /**
  125260. * Gets a general parser from the list of avaialble ones
  125261. * @param name Defines the name of the parser
  125262. * @returns the requested parser or null
  125263. */
  125264. static GetParser(name: string): Nullable<BabylonFileParser>;
  125265. /**
  125266. * Adds n individual parser in the list of available ones
  125267. * @param name Defines the name of the parser
  125268. * @param parser Defines the parser to add
  125269. */
  125270. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  125271. /**
  125272. * Gets an individual parser from the list of avaialble ones
  125273. * @param name Defines the name of the parser
  125274. * @returns the requested parser or null
  125275. */
  125276. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  125277. /**
  125278. * Parser json data and populate both a scene and its associated container object
  125279. * @param jsonData Defines the data to parse
  125280. * @param scene Defines the scene to parse the data for
  125281. * @param container Defines the container attached to the parsing sequence
  125282. * @param rootUrl Defines the root url of the data
  125283. */
  125284. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  125285. /**
  125286. * Gets the list of root nodes (ie. nodes with no parent)
  125287. */
  125288. rootNodes: Node[];
  125289. /** All of the cameras added to this scene
  125290. * @see https://doc.babylonjs.com/babylon101/cameras
  125291. */
  125292. cameras: Camera[];
  125293. /**
  125294. * All of the lights added to this scene
  125295. * @see https://doc.babylonjs.com/babylon101/lights
  125296. */
  125297. lights: Light[];
  125298. /**
  125299. * All of the (abstract) meshes added to this scene
  125300. */
  125301. meshes: AbstractMesh[];
  125302. /**
  125303. * The list of skeletons added to the scene
  125304. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  125305. */
  125306. skeletons: Skeleton[];
  125307. /**
  125308. * All of the particle systems added to this scene
  125309. * @see https://doc.babylonjs.com/babylon101/particles
  125310. */
  125311. particleSystems: IParticleSystem[];
  125312. /**
  125313. * Gets a list of Animations associated with the scene
  125314. */
  125315. animations: Animation[];
  125316. /**
  125317. * All of the animation groups added to this scene
  125318. * @see https://doc.babylonjs.com/how_to/group
  125319. */
  125320. animationGroups: AnimationGroup[];
  125321. /**
  125322. * All of the multi-materials added to this scene
  125323. * @see https://doc.babylonjs.com/how_to/multi_materials
  125324. */
  125325. multiMaterials: MultiMaterial[];
  125326. /**
  125327. * All of the materials added to this scene
  125328. * In the context of a Scene, it is not supposed to be modified manually.
  125329. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  125330. * Note also that the order of the Material within the array is not significant and might change.
  125331. * @see https://doc.babylonjs.com/babylon101/materials
  125332. */
  125333. materials: Material[];
  125334. /**
  125335. * The list of morph target managers added to the scene
  125336. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  125337. */
  125338. morphTargetManagers: MorphTargetManager[];
  125339. /**
  125340. * The list of geometries used in the scene.
  125341. */
  125342. geometries: Geometry[];
  125343. /**
  125344. * All of the tranform nodes added to this scene
  125345. * In the context of a Scene, it is not supposed to be modified manually.
  125346. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  125347. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  125348. * @see https://doc.babylonjs.com/how_to/transformnode
  125349. */
  125350. transformNodes: TransformNode[];
  125351. /**
  125352. * ActionManagers available on the scene.
  125353. */
  125354. actionManagers: AbstractActionManager[];
  125355. /**
  125356. * Textures to keep.
  125357. */
  125358. textures: BaseTexture[];
  125359. /** @hidden */
  125360. protected _environmentTexture: Nullable<BaseTexture>;
  125361. /**
  125362. * Texture used in all pbr material as the reflection texture.
  125363. * As in the majority of the scene they are the same (exception for multi room and so on),
  125364. * this is easier to reference from here than from all the materials.
  125365. */
  125366. get environmentTexture(): Nullable<BaseTexture>;
  125367. set environmentTexture(value: Nullable<BaseTexture>);
  125368. /**
  125369. * The list of postprocesses added to the scene
  125370. */
  125371. postProcesses: PostProcess[];
  125372. /**
  125373. * @returns all meshes, lights, cameras, transformNodes and bones
  125374. */
  125375. getNodes(): Array<Node>;
  125376. }
  125377. }
  125378. declare module BABYLON {
  125379. /**
  125380. * Interface used to define options for Sound class
  125381. */
  125382. export interface ISoundOptions {
  125383. /**
  125384. * Does the sound autoplay once loaded.
  125385. */
  125386. autoplay?: boolean;
  125387. /**
  125388. * Does the sound loop after it finishes playing once.
  125389. */
  125390. loop?: boolean;
  125391. /**
  125392. * Sound's volume
  125393. */
  125394. volume?: number;
  125395. /**
  125396. * Is it a spatial sound?
  125397. */
  125398. spatialSound?: boolean;
  125399. /**
  125400. * Maximum distance to hear that sound
  125401. */
  125402. maxDistance?: number;
  125403. /**
  125404. * Uses user defined attenuation function
  125405. */
  125406. useCustomAttenuation?: boolean;
  125407. /**
  125408. * Define the roll off factor of spatial sounds.
  125409. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125410. */
  125411. rolloffFactor?: number;
  125412. /**
  125413. * Define the reference distance the sound should be heard perfectly.
  125414. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125415. */
  125416. refDistance?: number;
  125417. /**
  125418. * Define the distance attenuation model the sound will follow.
  125419. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125420. */
  125421. distanceModel?: string;
  125422. /**
  125423. * Defines the playback speed (1 by default)
  125424. */
  125425. playbackRate?: number;
  125426. /**
  125427. * Defines if the sound is from a streaming source
  125428. */
  125429. streaming?: boolean;
  125430. /**
  125431. * Defines an optional length (in seconds) inside the sound file
  125432. */
  125433. length?: number;
  125434. /**
  125435. * Defines an optional offset (in seconds) inside the sound file
  125436. */
  125437. offset?: number;
  125438. /**
  125439. * If true, URLs will not be required to state the audio file codec to use.
  125440. */
  125441. skipCodecCheck?: boolean;
  125442. }
  125443. /**
  125444. * Defines a sound that can be played in the application.
  125445. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  125446. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125447. */
  125448. export class Sound {
  125449. /**
  125450. * The name of the sound in the scene.
  125451. */
  125452. name: string;
  125453. /**
  125454. * Does the sound autoplay once loaded.
  125455. */
  125456. autoplay: boolean;
  125457. /**
  125458. * Does the sound loop after it finishes playing once.
  125459. */
  125460. loop: boolean;
  125461. /**
  125462. * Does the sound use a custom attenuation curve to simulate the falloff
  125463. * happening when the source gets further away from the camera.
  125464. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  125465. */
  125466. useCustomAttenuation: boolean;
  125467. /**
  125468. * The sound track id this sound belongs to.
  125469. */
  125470. soundTrackId: number;
  125471. /**
  125472. * Is this sound currently played.
  125473. */
  125474. isPlaying: boolean;
  125475. /**
  125476. * Is this sound currently paused.
  125477. */
  125478. isPaused: boolean;
  125479. /**
  125480. * Does this sound enables spatial sound.
  125481. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125482. */
  125483. spatialSound: boolean;
  125484. /**
  125485. * Define the reference distance the sound should be heard perfectly.
  125486. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125487. */
  125488. refDistance: number;
  125489. /**
  125490. * Define the roll off factor of spatial sounds.
  125491. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125492. */
  125493. rolloffFactor: number;
  125494. /**
  125495. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  125496. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125497. */
  125498. maxDistance: number;
  125499. /**
  125500. * Define the distance attenuation model the sound will follow.
  125501. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125502. */
  125503. distanceModel: string;
  125504. /**
  125505. * @hidden
  125506. * Back Compat
  125507. **/
  125508. onended: () => any;
  125509. /**
  125510. * Gets or sets an object used to store user defined information for the sound.
  125511. */
  125512. metadata: any;
  125513. /**
  125514. * Observable event when the current playing sound finishes.
  125515. */
  125516. onEndedObservable: Observable<Sound>;
  125517. private _panningModel;
  125518. private _playbackRate;
  125519. private _streaming;
  125520. private _startTime;
  125521. private _startOffset;
  125522. private _position;
  125523. /** @hidden */
  125524. _positionInEmitterSpace: boolean;
  125525. private _localDirection;
  125526. private _volume;
  125527. private _isReadyToPlay;
  125528. private _isDirectional;
  125529. private _readyToPlayCallback;
  125530. private _audioBuffer;
  125531. private _soundSource;
  125532. private _streamingSource;
  125533. private _soundPanner;
  125534. private _soundGain;
  125535. private _inputAudioNode;
  125536. private _outputAudioNode;
  125537. private _coneInnerAngle;
  125538. private _coneOuterAngle;
  125539. private _coneOuterGain;
  125540. private _scene;
  125541. private _connectedTransformNode;
  125542. private _customAttenuationFunction;
  125543. private _registerFunc;
  125544. private _isOutputConnected;
  125545. private _htmlAudioElement;
  125546. private _urlType;
  125547. private _length?;
  125548. private _offset?;
  125549. /** @hidden */
  125550. static _SceneComponentInitialization: (scene: Scene) => void;
  125551. /**
  125552. * Create a sound and attach it to a scene
  125553. * @param name Name of your sound
  125554. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  125555. * @param scene defines the scene the sound belongs to
  125556. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  125557. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  125558. */
  125559. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  125560. /**
  125561. * Release the sound and its associated resources
  125562. */
  125563. dispose(): void;
  125564. /**
  125565. * Gets if the sounds is ready to be played or not.
  125566. * @returns true if ready, otherwise false
  125567. */
  125568. isReady(): boolean;
  125569. private _soundLoaded;
  125570. /**
  125571. * Sets the data of the sound from an audiobuffer
  125572. * @param audioBuffer The audioBuffer containing the data
  125573. */
  125574. setAudioBuffer(audioBuffer: AudioBuffer): void;
  125575. /**
  125576. * Updates the current sounds options such as maxdistance, loop...
  125577. * @param options A JSON object containing values named as the object properties
  125578. */
  125579. updateOptions(options: ISoundOptions): void;
  125580. private _createSpatialParameters;
  125581. private _updateSpatialParameters;
  125582. /**
  125583. * Switch the panning model to HRTF:
  125584. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  125585. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125586. */
  125587. switchPanningModelToHRTF(): void;
  125588. /**
  125589. * Switch the panning model to Equal Power:
  125590. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  125591. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125592. */
  125593. switchPanningModelToEqualPower(): void;
  125594. private _switchPanningModel;
  125595. /**
  125596. * Connect this sound to a sound track audio node like gain...
  125597. * @param soundTrackAudioNode the sound track audio node to connect to
  125598. */
  125599. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  125600. /**
  125601. * Transform this sound into a directional source
  125602. * @param coneInnerAngle Size of the inner cone in degree
  125603. * @param coneOuterAngle Size of the outer cone in degree
  125604. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  125605. */
  125606. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  125607. /**
  125608. * Gets or sets the inner angle for the directional cone.
  125609. */
  125610. get directionalConeInnerAngle(): number;
  125611. /**
  125612. * Gets or sets the inner angle for the directional cone.
  125613. */
  125614. set directionalConeInnerAngle(value: number);
  125615. /**
  125616. * Gets or sets the outer angle for the directional cone.
  125617. */
  125618. get directionalConeOuterAngle(): number;
  125619. /**
  125620. * Gets or sets the outer angle for the directional cone.
  125621. */
  125622. set directionalConeOuterAngle(value: number);
  125623. /**
  125624. * Sets the position of the emitter if spatial sound is enabled
  125625. * @param newPosition Defines the new posisiton
  125626. */
  125627. setPosition(newPosition: Vector3): void;
  125628. /**
  125629. * Sets the local direction of the emitter if spatial sound is enabled
  125630. * @param newLocalDirection Defines the new local direction
  125631. */
  125632. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  125633. private _updateDirection;
  125634. /** @hidden */
  125635. updateDistanceFromListener(): void;
  125636. /**
  125637. * Sets a new custom attenuation function for the sound.
  125638. * @param callback Defines the function used for the attenuation
  125639. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  125640. */
  125641. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  125642. /**
  125643. * Play the sound
  125644. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  125645. * @param offset (optional) Start the sound at a specific time in seconds
  125646. * @param length (optional) Sound duration (in seconds)
  125647. */
  125648. play(time?: number, offset?: number, length?: number): void;
  125649. private _onended;
  125650. /**
  125651. * Stop the sound
  125652. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  125653. */
  125654. stop(time?: number): void;
  125655. /**
  125656. * Put the sound in pause
  125657. */
  125658. pause(): void;
  125659. /**
  125660. * Sets a dedicated volume for this sounds
  125661. * @param newVolume Define the new volume of the sound
  125662. * @param time Define time for gradual change to new volume
  125663. */
  125664. setVolume(newVolume: number, time?: number): void;
  125665. /**
  125666. * Set the sound play back rate
  125667. * @param newPlaybackRate Define the playback rate the sound should be played at
  125668. */
  125669. setPlaybackRate(newPlaybackRate: number): void;
  125670. /**
  125671. * Gets the volume of the sound.
  125672. * @returns the volume of the sound
  125673. */
  125674. getVolume(): number;
  125675. /**
  125676. * Attach the sound to a dedicated mesh
  125677. * @param transformNode The transform node to connect the sound with
  125678. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  125679. */
  125680. attachToMesh(transformNode: TransformNode): void;
  125681. /**
  125682. * Detach the sound from the previously attached mesh
  125683. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  125684. */
  125685. detachFromMesh(): void;
  125686. private _onRegisterAfterWorldMatrixUpdate;
  125687. /**
  125688. * Clone the current sound in the scene.
  125689. * @returns the new sound clone
  125690. */
  125691. clone(): Nullable<Sound>;
  125692. /**
  125693. * Gets the current underlying audio buffer containing the data
  125694. * @returns the audio buffer
  125695. */
  125696. getAudioBuffer(): Nullable<AudioBuffer>;
  125697. /**
  125698. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  125699. * @returns the source node
  125700. */
  125701. getSoundSource(): Nullable<AudioBufferSourceNode>;
  125702. /**
  125703. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  125704. * @returns the gain node
  125705. */
  125706. getSoundGain(): Nullable<GainNode>;
  125707. /**
  125708. * Serializes the Sound in a JSON representation
  125709. * @returns the JSON representation of the sound
  125710. */
  125711. serialize(): any;
  125712. /**
  125713. * Parse a JSON representation of a sound to innstantiate in a given scene
  125714. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  125715. * @param scene Define the scene the new parsed sound should be created in
  125716. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  125717. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  125718. * @returns the newly parsed sound
  125719. */
  125720. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  125721. }
  125722. }
  125723. declare module BABYLON {
  125724. /**
  125725. * This defines an action helpful to play a defined sound on a triggered action.
  125726. */
  125727. export class PlaySoundAction extends Action {
  125728. private _sound;
  125729. /**
  125730. * Instantiate the action
  125731. * @param triggerOptions defines the trigger options
  125732. * @param sound defines the sound to play
  125733. * @param condition defines the trigger related conditions
  125734. */
  125735. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  125736. /** @hidden */
  125737. _prepare(): void;
  125738. /**
  125739. * Execute the action and play the sound.
  125740. */
  125741. execute(): void;
  125742. /**
  125743. * Serializes the actions and its related information.
  125744. * @param parent defines the object to serialize in
  125745. * @returns the serialized object
  125746. */
  125747. serialize(parent: any): any;
  125748. }
  125749. /**
  125750. * This defines an action helpful to stop a defined sound on a triggered action.
  125751. */
  125752. export class StopSoundAction extends Action {
  125753. private _sound;
  125754. /**
  125755. * Instantiate the action
  125756. * @param triggerOptions defines the trigger options
  125757. * @param sound defines the sound to stop
  125758. * @param condition defines the trigger related conditions
  125759. */
  125760. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  125761. /** @hidden */
  125762. _prepare(): void;
  125763. /**
  125764. * Execute the action and stop the sound.
  125765. */
  125766. execute(): void;
  125767. /**
  125768. * Serializes the actions and its related information.
  125769. * @param parent defines the object to serialize in
  125770. * @returns the serialized object
  125771. */
  125772. serialize(parent: any): any;
  125773. }
  125774. }
  125775. declare module BABYLON {
  125776. /**
  125777. * This defines an action responsible to change the value of a property
  125778. * by interpolating between its current value and the newly set one once triggered.
  125779. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  125780. */
  125781. export class InterpolateValueAction extends Action {
  125782. /**
  125783. * Defines the path of the property where the value should be interpolated
  125784. */
  125785. propertyPath: string;
  125786. /**
  125787. * Defines the target value at the end of the interpolation.
  125788. */
  125789. value: any;
  125790. /**
  125791. * Defines the time it will take for the property to interpolate to the value.
  125792. */
  125793. duration: number;
  125794. /**
  125795. * Defines if the other scene animations should be stopped when the action has been triggered
  125796. */
  125797. stopOtherAnimations?: boolean;
  125798. /**
  125799. * Defines a callback raised once the interpolation animation has been done.
  125800. */
  125801. onInterpolationDone?: () => void;
  125802. /**
  125803. * Observable triggered once the interpolation animation has been done.
  125804. */
  125805. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  125806. private _target;
  125807. private _effectiveTarget;
  125808. private _property;
  125809. /**
  125810. * Instantiate the action
  125811. * @param triggerOptions defines the trigger options
  125812. * @param target defines the object containing the value to interpolate
  125813. * @param propertyPath defines the path to the property in the target object
  125814. * @param value defines the target value at the end of the interpolation
  125815. * @param duration deines the time it will take for the property to interpolate to the value.
  125816. * @param condition defines the trigger related conditions
  125817. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  125818. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  125819. */
  125820. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  125821. /** @hidden */
  125822. _prepare(): void;
  125823. /**
  125824. * Execute the action starts the value interpolation.
  125825. */
  125826. execute(): void;
  125827. /**
  125828. * Serializes the actions and its related information.
  125829. * @param parent defines the object to serialize in
  125830. * @returns the serialized object
  125831. */
  125832. serialize(parent: any): any;
  125833. }
  125834. }
  125835. declare module BABYLON {
  125836. /**
  125837. * Options allowed during the creation of a sound track.
  125838. */
  125839. export interface ISoundTrackOptions {
  125840. /**
  125841. * The volume the sound track should take during creation
  125842. */
  125843. volume?: number;
  125844. /**
  125845. * Define if the sound track is the main sound track of the scene
  125846. */
  125847. mainTrack?: boolean;
  125848. }
  125849. /**
  125850. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  125851. * It will be also used in a future release to apply effects on a specific track.
  125852. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  125853. */
  125854. export class SoundTrack {
  125855. /**
  125856. * The unique identifier of the sound track in the scene.
  125857. */
  125858. id: number;
  125859. /**
  125860. * The list of sounds included in the sound track.
  125861. */
  125862. soundCollection: Array<Sound>;
  125863. private _outputAudioNode;
  125864. private _scene;
  125865. private _connectedAnalyser;
  125866. private _options;
  125867. private _isInitialized;
  125868. /**
  125869. * Creates a new sound track.
  125870. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  125871. * @param scene Define the scene the sound track belongs to
  125872. * @param options
  125873. */
  125874. constructor(scene: Scene, options?: ISoundTrackOptions);
  125875. private _initializeSoundTrackAudioGraph;
  125876. /**
  125877. * Release the sound track and its associated resources
  125878. */
  125879. dispose(): void;
  125880. /**
  125881. * Adds a sound to this sound track
  125882. * @param sound define the cound to add
  125883. * @ignoreNaming
  125884. */
  125885. AddSound(sound: Sound): void;
  125886. /**
  125887. * Removes a sound to this sound track
  125888. * @param sound define the cound to remove
  125889. * @ignoreNaming
  125890. */
  125891. RemoveSound(sound: Sound): void;
  125892. /**
  125893. * Set a global volume for the full sound track.
  125894. * @param newVolume Define the new volume of the sound track
  125895. */
  125896. setVolume(newVolume: number): void;
  125897. /**
  125898. * Switch the panning model to HRTF:
  125899. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  125900. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125901. */
  125902. switchPanningModelToHRTF(): void;
  125903. /**
  125904. * Switch the panning model to Equal Power:
  125905. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  125906. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125907. */
  125908. switchPanningModelToEqualPower(): void;
  125909. /**
  125910. * Connect the sound track to an audio analyser allowing some amazing
  125911. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  125912. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  125913. * @param analyser The analyser to connect to the engine
  125914. */
  125915. connectToAnalyser(analyser: Analyser): void;
  125916. }
  125917. }
  125918. declare module BABYLON {
  125919. interface AbstractScene {
  125920. /**
  125921. * The list of sounds used in the scene.
  125922. */
  125923. sounds: Nullable<Array<Sound>>;
  125924. }
  125925. interface Scene {
  125926. /**
  125927. * @hidden
  125928. * Backing field
  125929. */
  125930. _mainSoundTrack: SoundTrack;
  125931. /**
  125932. * The main sound track played by the scene.
  125933. * It cotains your primary collection of sounds.
  125934. */
  125935. mainSoundTrack: SoundTrack;
  125936. /**
  125937. * The list of sound tracks added to the scene
  125938. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125939. */
  125940. soundTracks: Nullable<Array<SoundTrack>>;
  125941. /**
  125942. * Gets a sound using a given name
  125943. * @param name defines the name to search for
  125944. * @return the found sound or null if not found at all.
  125945. */
  125946. getSoundByName(name: string): Nullable<Sound>;
  125947. /**
  125948. * Gets or sets if audio support is enabled
  125949. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125950. */
  125951. audioEnabled: boolean;
  125952. /**
  125953. * Gets or sets if audio will be output to headphones
  125954. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125955. */
  125956. headphone: boolean;
  125957. /**
  125958. * Gets or sets custom audio listener position provider
  125959. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125960. */
  125961. audioListenerPositionProvider: Nullable<() => Vector3>;
  125962. /**
  125963. * Gets or sets a refresh rate when using 3D audio positioning
  125964. */
  125965. audioPositioningRefreshRate: number;
  125966. }
  125967. /**
  125968. * Defines the sound scene component responsible to manage any sounds
  125969. * in a given scene.
  125970. */
  125971. export class AudioSceneComponent implements ISceneSerializableComponent {
  125972. private static _CameraDirectionLH;
  125973. private static _CameraDirectionRH;
  125974. /**
  125975. * The component name helpfull to identify the component in the list of scene components.
  125976. */
  125977. readonly name: string;
  125978. /**
  125979. * The scene the component belongs to.
  125980. */
  125981. scene: Scene;
  125982. private _audioEnabled;
  125983. /**
  125984. * Gets whether audio is enabled or not.
  125985. * Please use related enable/disable method to switch state.
  125986. */
  125987. get audioEnabled(): boolean;
  125988. private _headphone;
  125989. /**
  125990. * Gets whether audio is outputing to headphone or not.
  125991. * Please use the according Switch methods to change output.
  125992. */
  125993. get headphone(): boolean;
  125994. /**
  125995. * Gets or sets a refresh rate when using 3D audio positioning
  125996. */
  125997. audioPositioningRefreshRate: number;
  125998. private _audioListenerPositionProvider;
  125999. /**
  126000. * Gets the current audio listener position provider
  126001. */
  126002. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  126003. /**
  126004. * Sets a custom listener position for all sounds in the scene
  126005. * By default, this is the position of the first active camera
  126006. */
  126007. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  126008. /**
  126009. * Creates a new instance of the component for the given scene
  126010. * @param scene Defines the scene to register the component in
  126011. */
  126012. constructor(scene: Scene);
  126013. /**
  126014. * Registers the component in a given scene
  126015. */
  126016. register(): void;
  126017. /**
  126018. * Rebuilds the elements related to this component in case of
  126019. * context lost for instance.
  126020. */
  126021. rebuild(): void;
  126022. /**
  126023. * Serializes the component data to the specified json object
  126024. * @param serializationObject The object to serialize to
  126025. */
  126026. serialize(serializationObject: any): void;
  126027. /**
  126028. * Adds all the elements from the container to the scene
  126029. * @param container the container holding the elements
  126030. */
  126031. addFromContainer(container: AbstractScene): void;
  126032. /**
  126033. * Removes all the elements in the container from the scene
  126034. * @param container contains the elements to remove
  126035. * @param dispose if the removed element should be disposed (default: false)
  126036. */
  126037. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126038. /**
  126039. * Disposes the component and the associated ressources.
  126040. */
  126041. dispose(): void;
  126042. /**
  126043. * Disables audio in the associated scene.
  126044. */
  126045. disableAudio(): void;
  126046. /**
  126047. * Enables audio in the associated scene.
  126048. */
  126049. enableAudio(): void;
  126050. /**
  126051. * Switch audio to headphone output.
  126052. */
  126053. switchAudioModeForHeadphones(): void;
  126054. /**
  126055. * Switch audio to normal speakers.
  126056. */
  126057. switchAudioModeForNormalSpeakers(): void;
  126058. private _cachedCameraDirection;
  126059. private _cachedCameraPosition;
  126060. private _lastCheck;
  126061. private _afterRender;
  126062. }
  126063. }
  126064. declare module BABYLON {
  126065. /**
  126066. * Wraps one or more Sound objects and selects one with random weight for playback.
  126067. */
  126068. export class WeightedSound {
  126069. /** When true a Sound will be selected and played when the current playing Sound completes. */
  126070. loop: boolean;
  126071. private _coneInnerAngle;
  126072. private _coneOuterAngle;
  126073. private _volume;
  126074. /** A Sound is currently playing. */
  126075. isPlaying: boolean;
  126076. /** A Sound is currently paused. */
  126077. isPaused: boolean;
  126078. private _sounds;
  126079. private _weights;
  126080. private _currentIndex?;
  126081. /**
  126082. * Creates a new WeightedSound from the list of sounds given.
  126083. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  126084. * @param sounds Array of Sounds that will be selected from.
  126085. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  126086. */
  126087. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  126088. /**
  126089. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  126090. */
  126091. get directionalConeInnerAngle(): number;
  126092. /**
  126093. * The size of cone in degress for a directional sound in which there will be no attenuation.
  126094. */
  126095. set directionalConeInnerAngle(value: number);
  126096. /**
  126097. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  126098. * Listener angles between innerAngle and outerAngle will falloff linearly.
  126099. */
  126100. get directionalConeOuterAngle(): number;
  126101. /**
  126102. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  126103. * Listener angles between innerAngle and outerAngle will falloff linearly.
  126104. */
  126105. set directionalConeOuterAngle(value: number);
  126106. /**
  126107. * Playback volume.
  126108. */
  126109. get volume(): number;
  126110. /**
  126111. * Playback volume.
  126112. */
  126113. set volume(value: number);
  126114. private _onended;
  126115. /**
  126116. * Suspend playback
  126117. */
  126118. pause(): void;
  126119. /**
  126120. * Stop playback
  126121. */
  126122. stop(): void;
  126123. /**
  126124. * Start playback.
  126125. * @param startOffset Position the clip head at a specific time in seconds.
  126126. */
  126127. play(startOffset?: number): void;
  126128. }
  126129. }
  126130. declare module BABYLON {
  126131. /**
  126132. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  126133. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126134. */
  126135. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  126136. /**
  126137. * Gets the name of the behavior.
  126138. */
  126139. get name(): string;
  126140. /**
  126141. * The easing function used by animations
  126142. */
  126143. static EasingFunction: BackEase;
  126144. /**
  126145. * The easing mode used by animations
  126146. */
  126147. static EasingMode: number;
  126148. /**
  126149. * The duration of the animation, in milliseconds
  126150. */
  126151. transitionDuration: number;
  126152. /**
  126153. * Length of the distance animated by the transition when lower radius is reached
  126154. */
  126155. lowerRadiusTransitionRange: number;
  126156. /**
  126157. * Length of the distance animated by the transition when upper radius is reached
  126158. */
  126159. upperRadiusTransitionRange: number;
  126160. private _autoTransitionRange;
  126161. /**
  126162. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  126163. */
  126164. get autoTransitionRange(): boolean;
  126165. /**
  126166. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  126167. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  126168. */
  126169. set autoTransitionRange(value: boolean);
  126170. private _attachedCamera;
  126171. private _onAfterCheckInputsObserver;
  126172. private _onMeshTargetChangedObserver;
  126173. /**
  126174. * Initializes the behavior.
  126175. */
  126176. init(): void;
  126177. /**
  126178. * Attaches the behavior to its arc rotate camera.
  126179. * @param camera Defines the camera to attach the behavior to
  126180. */
  126181. attach(camera: ArcRotateCamera): void;
  126182. /**
  126183. * Detaches the behavior from its current arc rotate camera.
  126184. */
  126185. detach(): void;
  126186. private _radiusIsAnimating;
  126187. private _radiusBounceTransition;
  126188. private _animatables;
  126189. private _cachedWheelPrecision;
  126190. /**
  126191. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  126192. * @param radiusLimit The limit to check against.
  126193. * @return Bool to indicate if at limit.
  126194. */
  126195. private _isRadiusAtLimit;
  126196. /**
  126197. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  126198. * @param radiusDelta The delta by which to animate to. Can be negative.
  126199. */
  126200. private _applyBoundRadiusAnimation;
  126201. /**
  126202. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  126203. */
  126204. protected _clearAnimationLocks(): void;
  126205. /**
  126206. * Stops and removes all animations that have been applied to the camera
  126207. */
  126208. stopAllAnimations(): void;
  126209. }
  126210. }
  126211. declare module BABYLON {
  126212. /**
  126213. * 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.
  126214. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126215. */
  126216. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  126217. /**
  126218. * Gets the name of the behavior.
  126219. */
  126220. get name(): string;
  126221. private _mode;
  126222. private _radiusScale;
  126223. private _positionScale;
  126224. private _defaultElevation;
  126225. private _elevationReturnTime;
  126226. private _elevationReturnWaitTime;
  126227. private _zoomStopsAnimation;
  126228. private _framingTime;
  126229. /**
  126230. * The easing function used by animations
  126231. */
  126232. static EasingFunction: ExponentialEase;
  126233. /**
  126234. * The easing mode used by animations
  126235. */
  126236. static EasingMode: number;
  126237. /**
  126238. * Sets the current mode used by the behavior
  126239. */
  126240. set mode(mode: number);
  126241. /**
  126242. * Gets current mode used by the behavior.
  126243. */
  126244. get mode(): number;
  126245. /**
  126246. * Sets the scale applied to the radius (1 by default)
  126247. */
  126248. set radiusScale(radius: number);
  126249. /**
  126250. * Gets the scale applied to the radius
  126251. */
  126252. get radiusScale(): number;
  126253. /**
  126254. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  126255. */
  126256. set positionScale(scale: number);
  126257. /**
  126258. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  126259. */
  126260. get positionScale(): number;
  126261. /**
  126262. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  126263. * behaviour is triggered, in radians.
  126264. */
  126265. set defaultElevation(elevation: number);
  126266. /**
  126267. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  126268. * behaviour is triggered, in radians.
  126269. */
  126270. get defaultElevation(): number;
  126271. /**
  126272. * Sets the time (in milliseconds) taken to return to the default beta position.
  126273. * Negative value indicates camera should not return to default.
  126274. */
  126275. set elevationReturnTime(speed: number);
  126276. /**
  126277. * Gets the time (in milliseconds) taken to return to the default beta position.
  126278. * Negative value indicates camera should not return to default.
  126279. */
  126280. get elevationReturnTime(): number;
  126281. /**
  126282. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  126283. */
  126284. set elevationReturnWaitTime(time: number);
  126285. /**
  126286. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  126287. */
  126288. get elevationReturnWaitTime(): number;
  126289. /**
  126290. * Sets the flag that indicates if user zooming should stop animation.
  126291. */
  126292. set zoomStopsAnimation(flag: boolean);
  126293. /**
  126294. * Gets the flag that indicates if user zooming should stop animation.
  126295. */
  126296. get zoomStopsAnimation(): boolean;
  126297. /**
  126298. * Sets the transition time when framing the mesh, in milliseconds
  126299. */
  126300. set framingTime(time: number);
  126301. /**
  126302. * Gets the transition time when framing the mesh, in milliseconds
  126303. */
  126304. get framingTime(): number;
  126305. /**
  126306. * Define if the behavior should automatically change the configured
  126307. * camera limits and sensibilities.
  126308. */
  126309. autoCorrectCameraLimitsAndSensibility: boolean;
  126310. private _onPrePointerObservableObserver;
  126311. private _onAfterCheckInputsObserver;
  126312. private _onMeshTargetChangedObserver;
  126313. private _attachedCamera;
  126314. private _isPointerDown;
  126315. private _lastInteractionTime;
  126316. /**
  126317. * Initializes the behavior.
  126318. */
  126319. init(): void;
  126320. /**
  126321. * Attaches the behavior to its arc rotate camera.
  126322. * @param camera Defines the camera to attach the behavior to
  126323. */
  126324. attach(camera: ArcRotateCamera): void;
  126325. /**
  126326. * Detaches the behavior from its current arc rotate camera.
  126327. */
  126328. detach(): void;
  126329. private _animatables;
  126330. private _betaIsAnimating;
  126331. private _betaTransition;
  126332. private _radiusTransition;
  126333. private _vectorTransition;
  126334. /**
  126335. * Targets the given mesh and updates zoom level accordingly.
  126336. * @param mesh The mesh to target.
  126337. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126338. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126339. */
  126340. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126341. /**
  126342. * Targets the given mesh with its children and updates zoom level accordingly.
  126343. * @param mesh The mesh to target.
  126344. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126345. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126346. */
  126347. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126348. /**
  126349. * Targets the given meshes with their children and updates zoom level accordingly.
  126350. * @param meshes The mesh to target.
  126351. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126352. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126353. */
  126354. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126355. /**
  126356. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  126357. * @param minimumWorld Determines the smaller position of the bounding box extend
  126358. * @param maximumWorld Determines the bigger position of the bounding box extend
  126359. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126360. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126361. */
  126362. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126363. /**
  126364. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  126365. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  126366. * frustum width.
  126367. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  126368. * to fully enclose the mesh in the viewing frustum.
  126369. */
  126370. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  126371. /**
  126372. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  126373. * is automatically returned to its default position (expected to be above ground plane).
  126374. */
  126375. private _maintainCameraAboveGround;
  126376. /**
  126377. * Returns the frustum slope based on the canvas ratio and camera FOV
  126378. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  126379. */
  126380. private _getFrustumSlope;
  126381. /**
  126382. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  126383. */
  126384. private _clearAnimationLocks;
  126385. /**
  126386. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  126387. */
  126388. private _applyUserInteraction;
  126389. /**
  126390. * Stops and removes all animations that have been applied to the camera
  126391. */
  126392. stopAllAnimations(): void;
  126393. /**
  126394. * Gets a value indicating if the user is moving the camera
  126395. */
  126396. get isUserIsMoving(): boolean;
  126397. /**
  126398. * The camera can move all the way towards the mesh.
  126399. */
  126400. static IgnoreBoundsSizeMode: number;
  126401. /**
  126402. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  126403. */
  126404. static FitFrustumSidesMode: number;
  126405. }
  126406. }
  126407. declare module BABYLON {
  126408. /**
  126409. * Base class for Camera Pointer Inputs.
  126410. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  126411. * for example usage.
  126412. */
  126413. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  126414. /**
  126415. * Defines the camera the input is attached to.
  126416. */
  126417. abstract camera: Camera;
  126418. /**
  126419. * Whether keyboard modifier keys are pressed at time of last mouse event.
  126420. */
  126421. protected _altKey: boolean;
  126422. protected _ctrlKey: boolean;
  126423. protected _metaKey: boolean;
  126424. protected _shiftKey: boolean;
  126425. /**
  126426. * Which mouse buttons were pressed at time of last mouse event.
  126427. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  126428. */
  126429. protected _buttonsPressed: number;
  126430. /**
  126431. * Defines the buttons associated with the input to handle camera move.
  126432. */
  126433. buttons: number[];
  126434. /**
  126435. * Attach the input controls to a specific dom element to get the input from.
  126436. * @param element Defines the element the controls should be listened from
  126437. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126438. */
  126439. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126440. /**
  126441. * Detach the current controls from the specified dom element.
  126442. * @param element Defines the element to stop listening the inputs from
  126443. */
  126444. detachControl(element: Nullable<HTMLElement>): void;
  126445. /**
  126446. * Gets the class name of the current input.
  126447. * @returns the class name
  126448. */
  126449. getClassName(): string;
  126450. /**
  126451. * Get the friendly name associated with the input class.
  126452. * @returns the input friendly name
  126453. */
  126454. getSimpleName(): string;
  126455. /**
  126456. * Called on pointer POINTERDOUBLETAP event.
  126457. * Override this method to provide functionality on POINTERDOUBLETAP event.
  126458. */
  126459. protected onDoubleTap(type: string): void;
  126460. /**
  126461. * Called on pointer POINTERMOVE event if only a single touch is active.
  126462. * Override this method to provide functionality.
  126463. */
  126464. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  126465. /**
  126466. * Called on pointer POINTERMOVE event if multiple touches are active.
  126467. * Override this method to provide functionality.
  126468. */
  126469. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  126470. /**
  126471. * Called on JS contextmenu event.
  126472. * Override this method to provide functionality.
  126473. */
  126474. protected onContextMenu(evt: PointerEvent): void;
  126475. /**
  126476. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  126477. * press.
  126478. * Override this method to provide functionality.
  126479. */
  126480. protected onButtonDown(evt: PointerEvent): void;
  126481. /**
  126482. * Called each time a new POINTERUP event occurs. Ie, for each button
  126483. * release.
  126484. * Override this method to provide functionality.
  126485. */
  126486. protected onButtonUp(evt: PointerEvent): void;
  126487. /**
  126488. * Called when window becomes inactive.
  126489. * Override this method to provide functionality.
  126490. */
  126491. protected onLostFocus(): void;
  126492. private _pointerInput;
  126493. private _observer;
  126494. private _onLostFocus;
  126495. private pointA;
  126496. private pointB;
  126497. }
  126498. }
  126499. declare module BABYLON {
  126500. /**
  126501. * Manage the pointers inputs to control an arc rotate camera.
  126502. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126503. */
  126504. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  126505. /**
  126506. * Defines the camera the input is attached to.
  126507. */
  126508. camera: ArcRotateCamera;
  126509. /**
  126510. * Gets the class name of the current input.
  126511. * @returns the class name
  126512. */
  126513. getClassName(): string;
  126514. /**
  126515. * Defines the buttons associated with the input to handle camera move.
  126516. */
  126517. buttons: number[];
  126518. /**
  126519. * Defines the pointer angular sensibility along the X axis or how fast is
  126520. * the camera rotating.
  126521. */
  126522. angularSensibilityX: number;
  126523. /**
  126524. * Defines the pointer angular sensibility along the Y axis or how fast is
  126525. * the camera rotating.
  126526. */
  126527. angularSensibilityY: number;
  126528. /**
  126529. * Defines the pointer pinch precision or how fast is the camera zooming.
  126530. */
  126531. pinchPrecision: number;
  126532. /**
  126533. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  126534. * from 0.
  126535. * It defines the percentage of current camera.radius to use as delta when
  126536. * pinch zoom is used.
  126537. */
  126538. pinchDeltaPercentage: number;
  126539. /**
  126540. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  126541. * that any object in the plane at the camera's target point will scale
  126542. * perfectly with finger motion.
  126543. * Overrides pinchDeltaPercentage and pinchPrecision.
  126544. */
  126545. useNaturalPinchZoom: boolean;
  126546. /**
  126547. * Defines the pointer panning sensibility or how fast is the camera moving.
  126548. */
  126549. panningSensibility: number;
  126550. /**
  126551. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  126552. */
  126553. multiTouchPanning: boolean;
  126554. /**
  126555. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  126556. * zoom (pinch) through multitouch.
  126557. */
  126558. multiTouchPanAndZoom: boolean;
  126559. /**
  126560. * Revers pinch action direction.
  126561. */
  126562. pinchInwards: boolean;
  126563. private _isPanClick;
  126564. private _twoFingerActivityCount;
  126565. private _isPinching;
  126566. /**
  126567. * Called on pointer POINTERMOVE event if only a single touch is active.
  126568. */
  126569. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  126570. /**
  126571. * Called on pointer POINTERDOUBLETAP event.
  126572. */
  126573. protected onDoubleTap(type: string): void;
  126574. /**
  126575. * Called on pointer POINTERMOVE event if multiple touches are active.
  126576. */
  126577. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  126578. /**
  126579. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  126580. * press.
  126581. */
  126582. protected onButtonDown(evt: PointerEvent): void;
  126583. /**
  126584. * Called each time a new POINTERUP event occurs. Ie, for each button
  126585. * release.
  126586. */
  126587. protected onButtonUp(evt: PointerEvent): void;
  126588. /**
  126589. * Called when window becomes inactive.
  126590. */
  126591. protected onLostFocus(): void;
  126592. }
  126593. }
  126594. declare module BABYLON {
  126595. /**
  126596. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  126597. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126598. */
  126599. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  126600. /**
  126601. * Defines the camera the input is attached to.
  126602. */
  126603. camera: ArcRotateCamera;
  126604. /**
  126605. * Defines the list of key codes associated with the up action (increase alpha)
  126606. */
  126607. keysUp: number[];
  126608. /**
  126609. * Defines the list of key codes associated with the down action (decrease alpha)
  126610. */
  126611. keysDown: number[];
  126612. /**
  126613. * Defines the list of key codes associated with the left action (increase beta)
  126614. */
  126615. keysLeft: number[];
  126616. /**
  126617. * Defines the list of key codes associated with the right action (decrease beta)
  126618. */
  126619. keysRight: number[];
  126620. /**
  126621. * Defines the list of key codes associated with the reset action.
  126622. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  126623. */
  126624. keysReset: number[];
  126625. /**
  126626. * Defines the panning sensibility of the inputs.
  126627. * (How fast is the camera panning)
  126628. */
  126629. panningSensibility: number;
  126630. /**
  126631. * Defines the zooming sensibility of the inputs.
  126632. * (How fast is the camera zooming)
  126633. */
  126634. zoomingSensibility: number;
  126635. /**
  126636. * Defines whether maintaining the alt key down switch the movement mode from
  126637. * orientation to zoom.
  126638. */
  126639. useAltToZoom: boolean;
  126640. /**
  126641. * Rotation speed of the camera
  126642. */
  126643. angularSpeed: number;
  126644. private _keys;
  126645. private _ctrlPressed;
  126646. private _altPressed;
  126647. private _onCanvasBlurObserver;
  126648. private _onKeyboardObserver;
  126649. private _engine;
  126650. private _scene;
  126651. /**
  126652. * Attach the input controls to a specific dom element to get the input from.
  126653. * @param element Defines the element the controls should be listened from
  126654. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126655. */
  126656. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126657. /**
  126658. * Detach the current controls from the specified dom element.
  126659. * @param element Defines the element to stop listening the inputs from
  126660. */
  126661. detachControl(element: Nullable<HTMLElement>): void;
  126662. /**
  126663. * Update the current camera state depending on the inputs that have been used this frame.
  126664. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  126665. */
  126666. checkInputs(): void;
  126667. /**
  126668. * Gets the class name of the current intput.
  126669. * @returns the class name
  126670. */
  126671. getClassName(): string;
  126672. /**
  126673. * Get the friendly name associated with the input class.
  126674. * @returns the input friendly name
  126675. */
  126676. getSimpleName(): string;
  126677. }
  126678. }
  126679. declare module BABYLON {
  126680. /**
  126681. * Manage the mouse wheel inputs to control an arc rotate camera.
  126682. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126683. */
  126684. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  126685. /**
  126686. * Defines the camera the input is attached to.
  126687. */
  126688. camera: ArcRotateCamera;
  126689. /**
  126690. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  126691. */
  126692. wheelPrecision: number;
  126693. /**
  126694. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  126695. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  126696. */
  126697. wheelDeltaPercentage: number;
  126698. private _wheel;
  126699. private _observer;
  126700. private computeDeltaFromMouseWheelLegacyEvent;
  126701. /**
  126702. * Attach the input controls to a specific dom element to get the input from.
  126703. * @param element Defines the element the controls should be listened from
  126704. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126705. */
  126706. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126707. /**
  126708. * Detach the current controls from the specified dom element.
  126709. * @param element Defines the element to stop listening the inputs from
  126710. */
  126711. detachControl(element: Nullable<HTMLElement>): void;
  126712. /**
  126713. * Gets the class name of the current intput.
  126714. * @returns the class name
  126715. */
  126716. getClassName(): string;
  126717. /**
  126718. * Get the friendly name associated with the input class.
  126719. * @returns the input friendly name
  126720. */
  126721. getSimpleName(): string;
  126722. }
  126723. }
  126724. declare module BABYLON {
  126725. /**
  126726. * Default Inputs manager for the ArcRotateCamera.
  126727. * It groups all the default supported inputs for ease of use.
  126728. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126729. */
  126730. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  126731. /**
  126732. * Instantiates a new ArcRotateCameraInputsManager.
  126733. * @param camera Defines the camera the inputs belong to
  126734. */
  126735. constructor(camera: ArcRotateCamera);
  126736. /**
  126737. * Add mouse wheel input support to the input manager.
  126738. * @returns the current input manager
  126739. */
  126740. addMouseWheel(): ArcRotateCameraInputsManager;
  126741. /**
  126742. * Add pointers input support to the input manager.
  126743. * @returns the current input manager
  126744. */
  126745. addPointers(): ArcRotateCameraInputsManager;
  126746. /**
  126747. * Add keyboard input support to the input manager.
  126748. * @returns the current input manager
  126749. */
  126750. addKeyboard(): ArcRotateCameraInputsManager;
  126751. }
  126752. }
  126753. declare module BABYLON {
  126754. /**
  126755. * This represents an orbital type of camera.
  126756. *
  126757. * 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.
  126758. * 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.
  126759. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  126760. */
  126761. export class ArcRotateCamera extends TargetCamera {
  126762. /**
  126763. * Defines the rotation angle of the camera along the longitudinal axis.
  126764. */
  126765. alpha: number;
  126766. /**
  126767. * Defines the rotation angle of the camera along the latitudinal axis.
  126768. */
  126769. beta: number;
  126770. /**
  126771. * Defines the radius of the camera from it s target point.
  126772. */
  126773. radius: number;
  126774. protected _target: Vector3;
  126775. protected _targetHost: Nullable<AbstractMesh>;
  126776. /**
  126777. * Defines the target point of the camera.
  126778. * The camera looks towards it form the radius distance.
  126779. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  126780. */
  126781. get target(): Vector3;
  126782. set target(value: Vector3);
  126783. /**
  126784. * Define the current local position of the camera in the scene
  126785. */
  126786. get position(): Vector3;
  126787. set position(newPosition: Vector3);
  126788. protected _upToYMatrix: Matrix;
  126789. protected _YToUpMatrix: Matrix;
  126790. /**
  126791. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  126792. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  126793. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  126794. */
  126795. set upVector(vec: Vector3);
  126796. get upVector(): Vector3;
  126797. /**
  126798. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  126799. */
  126800. setMatUp(): void;
  126801. /**
  126802. * Current inertia value on the longitudinal axis.
  126803. * The bigger this number the longer it will take for the camera to stop.
  126804. */
  126805. inertialAlphaOffset: number;
  126806. /**
  126807. * Current inertia value on the latitudinal axis.
  126808. * The bigger this number the longer it will take for the camera to stop.
  126809. */
  126810. inertialBetaOffset: number;
  126811. /**
  126812. * Current inertia value on the radius axis.
  126813. * The bigger this number the longer it will take for the camera to stop.
  126814. */
  126815. inertialRadiusOffset: number;
  126816. /**
  126817. * Minimum allowed angle on the longitudinal axis.
  126818. * This can help limiting how the Camera is able to move in the scene.
  126819. */
  126820. lowerAlphaLimit: Nullable<number>;
  126821. /**
  126822. * Maximum allowed angle on the longitudinal axis.
  126823. * This can help limiting how the Camera is able to move in the scene.
  126824. */
  126825. upperAlphaLimit: Nullable<number>;
  126826. /**
  126827. * Minimum allowed angle on the latitudinal axis.
  126828. * This can help limiting how the Camera is able to move in the scene.
  126829. */
  126830. lowerBetaLimit: number;
  126831. /**
  126832. * Maximum allowed angle on the latitudinal axis.
  126833. * This can help limiting how the Camera is able to move in the scene.
  126834. */
  126835. upperBetaLimit: number;
  126836. /**
  126837. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  126838. * This can help limiting how the Camera is able to move in the scene.
  126839. */
  126840. lowerRadiusLimit: Nullable<number>;
  126841. /**
  126842. * Maximum allowed distance of the camera to the target (The camera can not get further).
  126843. * This can help limiting how the Camera is able to move in the scene.
  126844. */
  126845. upperRadiusLimit: Nullable<number>;
  126846. /**
  126847. * Defines the current inertia value used during panning of the camera along the X axis.
  126848. */
  126849. inertialPanningX: number;
  126850. /**
  126851. * Defines the current inertia value used during panning of the camera along the Y axis.
  126852. */
  126853. inertialPanningY: number;
  126854. /**
  126855. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  126856. * Basically if your fingers moves away from more than this distance you will be considered
  126857. * in pinch mode.
  126858. */
  126859. pinchToPanMaxDistance: number;
  126860. /**
  126861. * Defines the maximum distance the camera can pan.
  126862. * This could help keeping the cammera always in your scene.
  126863. */
  126864. panningDistanceLimit: Nullable<number>;
  126865. /**
  126866. * Defines the target of the camera before paning.
  126867. */
  126868. panningOriginTarget: Vector3;
  126869. /**
  126870. * Defines the value of the inertia used during panning.
  126871. * 0 would mean stop inertia and one would mean no decelleration at all.
  126872. */
  126873. panningInertia: number;
  126874. /**
  126875. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  126876. */
  126877. get angularSensibilityX(): number;
  126878. set angularSensibilityX(value: number);
  126879. /**
  126880. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  126881. */
  126882. get angularSensibilityY(): number;
  126883. set angularSensibilityY(value: number);
  126884. /**
  126885. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  126886. */
  126887. get pinchPrecision(): number;
  126888. set pinchPrecision(value: number);
  126889. /**
  126890. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  126891. * It will be used instead of pinchDeltaPrecision if different from 0.
  126892. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  126893. */
  126894. get pinchDeltaPercentage(): number;
  126895. set pinchDeltaPercentage(value: number);
  126896. /**
  126897. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  126898. * and pinch delta percentage.
  126899. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  126900. * that any object in the plane at the camera's target point will scale
  126901. * perfectly with finger motion.
  126902. */
  126903. get useNaturalPinchZoom(): boolean;
  126904. set useNaturalPinchZoom(value: boolean);
  126905. /**
  126906. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  126907. */
  126908. get panningSensibility(): number;
  126909. set panningSensibility(value: number);
  126910. /**
  126911. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  126912. */
  126913. get keysUp(): number[];
  126914. set keysUp(value: number[]);
  126915. /**
  126916. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  126917. */
  126918. get keysDown(): number[];
  126919. set keysDown(value: number[]);
  126920. /**
  126921. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  126922. */
  126923. get keysLeft(): number[];
  126924. set keysLeft(value: number[]);
  126925. /**
  126926. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  126927. */
  126928. get keysRight(): number[];
  126929. set keysRight(value: number[]);
  126930. /**
  126931. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  126932. */
  126933. get wheelPrecision(): number;
  126934. set wheelPrecision(value: number);
  126935. /**
  126936. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  126937. * It will be used instead of pinchDeltaPrecision if different from 0.
  126938. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  126939. */
  126940. get wheelDeltaPercentage(): number;
  126941. set wheelDeltaPercentage(value: number);
  126942. /**
  126943. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  126944. */
  126945. zoomOnFactor: number;
  126946. /**
  126947. * Defines a screen offset for the camera position.
  126948. */
  126949. targetScreenOffset: Vector2;
  126950. /**
  126951. * Allows the camera to be completely reversed.
  126952. * If false the camera can not arrive upside down.
  126953. */
  126954. allowUpsideDown: boolean;
  126955. /**
  126956. * Define if double tap/click is used to restore the previously saved state of the camera.
  126957. */
  126958. useInputToRestoreState: boolean;
  126959. /** @hidden */
  126960. _viewMatrix: Matrix;
  126961. /** @hidden */
  126962. _useCtrlForPanning: boolean;
  126963. /** @hidden */
  126964. _panningMouseButton: number;
  126965. /**
  126966. * Defines the input associated to the camera.
  126967. */
  126968. inputs: ArcRotateCameraInputsManager;
  126969. /** @hidden */
  126970. _reset: () => void;
  126971. /**
  126972. * Defines the allowed panning axis.
  126973. */
  126974. panningAxis: Vector3;
  126975. protected _localDirection: Vector3;
  126976. protected _transformedDirection: Vector3;
  126977. private _bouncingBehavior;
  126978. /**
  126979. * Gets the bouncing behavior of the camera if it has been enabled.
  126980. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126981. */
  126982. get bouncingBehavior(): Nullable<BouncingBehavior>;
  126983. /**
  126984. * Defines if the bouncing behavior of the camera is enabled on the camera.
  126985. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126986. */
  126987. get useBouncingBehavior(): boolean;
  126988. set useBouncingBehavior(value: boolean);
  126989. private _framingBehavior;
  126990. /**
  126991. * Gets the framing behavior of the camera if it has been enabled.
  126992. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126993. */
  126994. get framingBehavior(): Nullable<FramingBehavior>;
  126995. /**
  126996. * Defines if the framing behavior of the camera is enabled on the camera.
  126997. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126998. */
  126999. get useFramingBehavior(): boolean;
  127000. set useFramingBehavior(value: boolean);
  127001. private _autoRotationBehavior;
  127002. /**
  127003. * Gets the auto rotation behavior of the camera if it has been enabled.
  127004. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  127005. */
  127006. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  127007. /**
  127008. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  127009. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  127010. */
  127011. get useAutoRotationBehavior(): boolean;
  127012. set useAutoRotationBehavior(value: boolean);
  127013. /**
  127014. * Observable triggered when the mesh target has been changed on the camera.
  127015. */
  127016. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  127017. /**
  127018. * Event raised when the camera is colliding with a mesh.
  127019. */
  127020. onCollide: (collidedMesh: AbstractMesh) => void;
  127021. /**
  127022. * Defines whether the camera should check collision with the objects oh the scene.
  127023. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  127024. */
  127025. checkCollisions: boolean;
  127026. /**
  127027. * Defines the collision radius of the camera.
  127028. * This simulates a sphere around the camera.
  127029. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  127030. */
  127031. collisionRadius: Vector3;
  127032. protected _collider: Collider;
  127033. protected _previousPosition: Vector3;
  127034. protected _collisionVelocity: Vector3;
  127035. protected _newPosition: Vector3;
  127036. protected _previousAlpha: number;
  127037. protected _previousBeta: number;
  127038. protected _previousRadius: number;
  127039. protected _collisionTriggered: boolean;
  127040. protected _targetBoundingCenter: Nullable<Vector3>;
  127041. private _computationVector;
  127042. /**
  127043. * Instantiates a new ArcRotateCamera in a given scene
  127044. * @param name Defines the name of the camera
  127045. * @param alpha Defines the camera rotation along the logitudinal axis
  127046. * @param beta Defines the camera rotation along the latitudinal axis
  127047. * @param radius Defines the camera distance from its target
  127048. * @param target Defines the camera target
  127049. * @param scene Defines the scene the camera belongs to
  127050. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  127051. */
  127052. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  127053. /** @hidden */
  127054. _initCache(): void;
  127055. /** @hidden */
  127056. _updateCache(ignoreParentClass?: boolean): void;
  127057. protected _getTargetPosition(): Vector3;
  127058. private _storedAlpha;
  127059. private _storedBeta;
  127060. private _storedRadius;
  127061. private _storedTarget;
  127062. private _storedTargetScreenOffset;
  127063. /**
  127064. * Stores the current state of the camera (alpha, beta, radius and target)
  127065. * @returns the camera itself
  127066. */
  127067. storeState(): Camera;
  127068. /**
  127069. * @hidden
  127070. * Restored camera state. You must call storeState() first
  127071. */
  127072. _restoreStateValues(): boolean;
  127073. /** @hidden */
  127074. _isSynchronizedViewMatrix(): boolean;
  127075. /**
  127076. * Attached controls to the current camera.
  127077. * @param element Defines the element the controls should be listened from
  127078. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127079. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  127080. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  127081. */
  127082. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  127083. /**
  127084. * Detach the current controls from the camera.
  127085. * The camera will stop reacting to inputs.
  127086. * @param element Defines the element to stop listening the inputs from
  127087. */
  127088. detachControl(element: HTMLElement): void;
  127089. /** @hidden */
  127090. _checkInputs(): void;
  127091. protected _checkLimits(): void;
  127092. /**
  127093. * Rebuilds angles (alpha, beta) and radius from the give position and target
  127094. */
  127095. rebuildAnglesAndRadius(): void;
  127096. /**
  127097. * Use a position to define the current camera related information like alpha, beta and radius
  127098. * @param position Defines the position to set the camera at
  127099. */
  127100. setPosition(position: Vector3): void;
  127101. /**
  127102. * Defines the target the camera should look at.
  127103. * This will automatically adapt alpha beta and radius to fit within the new target.
  127104. * @param target Defines the new target as a Vector or a mesh
  127105. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  127106. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  127107. */
  127108. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  127109. /** @hidden */
  127110. _getViewMatrix(): Matrix;
  127111. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  127112. /**
  127113. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  127114. * @param meshes Defines the mesh to zoom on
  127115. * @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)
  127116. */
  127117. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  127118. /**
  127119. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  127120. * The target will be changed but the radius
  127121. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  127122. * @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)
  127123. */
  127124. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  127125. min: Vector3;
  127126. max: Vector3;
  127127. distance: number;
  127128. }, doNotUpdateMaxZ?: boolean): void;
  127129. /**
  127130. * @override
  127131. * Override Camera.createRigCamera
  127132. */
  127133. createRigCamera(name: string, cameraIndex: number): Camera;
  127134. /**
  127135. * @hidden
  127136. * @override
  127137. * Override Camera._updateRigCameras
  127138. */
  127139. _updateRigCameras(): void;
  127140. /**
  127141. * Destroy the camera and release the current resources hold by it.
  127142. */
  127143. dispose(): void;
  127144. /**
  127145. * Gets the current object class name.
  127146. * @return the class name
  127147. */
  127148. getClassName(): string;
  127149. }
  127150. }
  127151. declare module BABYLON {
  127152. /**
  127153. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  127154. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  127155. */
  127156. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  127157. /**
  127158. * Gets the name of the behavior.
  127159. */
  127160. get name(): string;
  127161. private _zoomStopsAnimation;
  127162. private _idleRotationSpeed;
  127163. private _idleRotationWaitTime;
  127164. private _idleRotationSpinupTime;
  127165. /**
  127166. * Sets the flag that indicates if user zooming should stop animation.
  127167. */
  127168. set zoomStopsAnimation(flag: boolean);
  127169. /**
  127170. * Gets the flag that indicates if user zooming should stop animation.
  127171. */
  127172. get zoomStopsAnimation(): boolean;
  127173. /**
  127174. * Sets the default speed at which the camera rotates around the model.
  127175. */
  127176. set idleRotationSpeed(speed: number);
  127177. /**
  127178. * Gets the default speed at which the camera rotates around the model.
  127179. */
  127180. get idleRotationSpeed(): number;
  127181. /**
  127182. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  127183. */
  127184. set idleRotationWaitTime(time: number);
  127185. /**
  127186. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  127187. */
  127188. get idleRotationWaitTime(): number;
  127189. /**
  127190. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  127191. */
  127192. set idleRotationSpinupTime(time: number);
  127193. /**
  127194. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  127195. */
  127196. get idleRotationSpinupTime(): number;
  127197. /**
  127198. * Gets a value indicating if the camera is currently rotating because of this behavior
  127199. */
  127200. get rotationInProgress(): boolean;
  127201. private _onPrePointerObservableObserver;
  127202. private _onAfterCheckInputsObserver;
  127203. private _attachedCamera;
  127204. private _isPointerDown;
  127205. private _lastFrameTime;
  127206. private _lastInteractionTime;
  127207. private _cameraRotationSpeed;
  127208. /**
  127209. * Initializes the behavior.
  127210. */
  127211. init(): void;
  127212. /**
  127213. * Attaches the behavior to its arc rotate camera.
  127214. * @param camera Defines the camera to attach the behavior to
  127215. */
  127216. attach(camera: ArcRotateCamera): void;
  127217. /**
  127218. * Detaches the behavior from its current arc rotate camera.
  127219. */
  127220. detach(): void;
  127221. /**
  127222. * Returns true if user is scrolling.
  127223. * @return true if user is scrolling.
  127224. */
  127225. private _userIsZooming;
  127226. private _lastFrameRadius;
  127227. private _shouldAnimationStopForInteraction;
  127228. /**
  127229. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  127230. */
  127231. private _applyUserInteraction;
  127232. private _userIsMoving;
  127233. }
  127234. }
  127235. declare module BABYLON {
  127236. /**
  127237. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  127238. */
  127239. export class AttachToBoxBehavior implements Behavior<Mesh> {
  127240. private ui;
  127241. /**
  127242. * The name of the behavior
  127243. */
  127244. name: string;
  127245. /**
  127246. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  127247. */
  127248. distanceAwayFromFace: number;
  127249. /**
  127250. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  127251. */
  127252. distanceAwayFromBottomOfFace: number;
  127253. private _faceVectors;
  127254. private _target;
  127255. private _scene;
  127256. private _onRenderObserver;
  127257. private _tmpMatrix;
  127258. private _tmpVector;
  127259. /**
  127260. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  127261. * @param ui The transform node that should be attched to the mesh
  127262. */
  127263. constructor(ui: TransformNode);
  127264. /**
  127265. * Initializes the behavior
  127266. */
  127267. init(): void;
  127268. private _closestFace;
  127269. private _zeroVector;
  127270. private _lookAtTmpMatrix;
  127271. private _lookAtToRef;
  127272. /**
  127273. * Attaches the AttachToBoxBehavior to the passed in mesh
  127274. * @param target The mesh that the specified node will be attached to
  127275. */
  127276. attach(target: Mesh): void;
  127277. /**
  127278. * Detaches the behavior from the mesh
  127279. */
  127280. detach(): void;
  127281. }
  127282. }
  127283. declare module BABYLON {
  127284. /**
  127285. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  127286. */
  127287. export class FadeInOutBehavior implements Behavior<Mesh> {
  127288. /**
  127289. * Time in milliseconds to delay before fading in (Default: 0)
  127290. */
  127291. delay: number;
  127292. /**
  127293. * Time in milliseconds for the mesh to fade in (Default: 300)
  127294. */
  127295. fadeInTime: number;
  127296. private _millisecondsPerFrame;
  127297. private _hovered;
  127298. private _hoverValue;
  127299. private _ownerNode;
  127300. /**
  127301. * Instatiates the FadeInOutBehavior
  127302. */
  127303. constructor();
  127304. /**
  127305. * The name of the behavior
  127306. */
  127307. get name(): string;
  127308. /**
  127309. * Initializes the behavior
  127310. */
  127311. init(): void;
  127312. /**
  127313. * Attaches the fade behavior on the passed in mesh
  127314. * @param ownerNode The mesh that will be faded in/out once attached
  127315. */
  127316. attach(ownerNode: Mesh): void;
  127317. /**
  127318. * Detaches the behavior from the mesh
  127319. */
  127320. detach(): void;
  127321. /**
  127322. * Triggers the mesh to begin fading in or out
  127323. * @param value if the object should fade in or out (true to fade in)
  127324. */
  127325. fadeIn(value: boolean): void;
  127326. private _update;
  127327. private _setAllVisibility;
  127328. }
  127329. }
  127330. declare module BABYLON {
  127331. /**
  127332. * Class containing a set of static utilities functions for managing Pivots
  127333. * @hidden
  127334. */
  127335. export class PivotTools {
  127336. private static _PivotCached;
  127337. private static _OldPivotPoint;
  127338. private static _PivotTranslation;
  127339. private static _PivotTmpVector;
  127340. private static _PivotPostMultiplyPivotMatrix;
  127341. /** @hidden */
  127342. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  127343. /** @hidden */
  127344. static _RestorePivotPoint(mesh: AbstractMesh): void;
  127345. }
  127346. }
  127347. declare module BABYLON {
  127348. /**
  127349. * Class containing static functions to help procedurally build meshes
  127350. */
  127351. export class PlaneBuilder {
  127352. /**
  127353. * Creates a plane mesh
  127354. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  127355. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  127356. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  127357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127360. * @param name defines the name of the mesh
  127361. * @param options defines the options used to create the mesh
  127362. * @param scene defines the hosting scene
  127363. * @returns the plane mesh
  127364. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127365. */
  127366. static CreatePlane(name: string, options: {
  127367. size?: number;
  127368. width?: number;
  127369. height?: number;
  127370. sideOrientation?: number;
  127371. frontUVs?: Vector4;
  127372. backUVs?: Vector4;
  127373. updatable?: boolean;
  127374. sourcePlane?: Plane;
  127375. }, scene?: Nullable<Scene>): Mesh;
  127376. }
  127377. }
  127378. declare module BABYLON {
  127379. /**
  127380. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  127381. */
  127382. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  127383. private static _AnyMouseID;
  127384. /**
  127385. * Abstract mesh the behavior is set on
  127386. */
  127387. attachedNode: AbstractMesh;
  127388. private _dragPlane;
  127389. private _scene;
  127390. private _pointerObserver;
  127391. private _beforeRenderObserver;
  127392. private static _planeScene;
  127393. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  127394. /**
  127395. * 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)
  127396. */
  127397. maxDragAngle: number;
  127398. /**
  127399. * @hidden
  127400. */
  127401. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  127402. /**
  127403. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  127404. */
  127405. currentDraggingPointerID: number;
  127406. /**
  127407. * The last position where the pointer hit the drag plane in world space
  127408. */
  127409. lastDragPosition: Vector3;
  127410. /**
  127411. * If the behavior is currently in a dragging state
  127412. */
  127413. dragging: boolean;
  127414. /**
  127415. * 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)
  127416. */
  127417. dragDeltaRatio: number;
  127418. /**
  127419. * If the drag plane orientation should be updated during the dragging (Default: true)
  127420. */
  127421. updateDragPlane: boolean;
  127422. private _debugMode;
  127423. private _moving;
  127424. /**
  127425. * Fires each time the attached mesh is dragged with the pointer
  127426. * * delta between last drag position and current drag position in world space
  127427. * * dragDistance along the drag axis
  127428. * * dragPlaneNormal normal of the current drag plane used during the drag
  127429. * * dragPlanePoint in world space where the drag intersects the drag plane
  127430. */
  127431. onDragObservable: Observable<{
  127432. delta: Vector3;
  127433. dragPlanePoint: Vector3;
  127434. dragPlaneNormal: Vector3;
  127435. dragDistance: number;
  127436. pointerId: number;
  127437. }>;
  127438. /**
  127439. * Fires each time a drag begins (eg. mouse down on mesh)
  127440. */
  127441. onDragStartObservable: Observable<{
  127442. dragPlanePoint: Vector3;
  127443. pointerId: number;
  127444. }>;
  127445. /**
  127446. * Fires each time a drag ends (eg. mouse release after drag)
  127447. */
  127448. onDragEndObservable: Observable<{
  127449. dragPlanePoint: Vector3;
  127450. pointerId: number;
  127451. }>;
  127452. /**
  127453. * If the attached mesh should be moved when dragged
  127454. */
  127455. moveAttached: boolean;
  127456. /**
  127457. * If the drag behavior will react to drag events (Default: true)
  127458. */
  127459. enabled: boolean;
  127460. /**
  127461. * If pointer events should start and release the drag (Default: true)
  127462. */
  127463. startAndReleaseDragOnPointerEvents: boolean;
  127464. /**
  127465. * If camera controls should be detached during the drag
  127466. */
  127467. detachCameraControls: boolean;
  127468. /**
  127469. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  127470. */
  127471. useObjectOrientationForDragging: boolean;
  127472. private _options;
  127473. /**
  127474. * Gets the options used by the behavior
  127475. */
  127476. get options(): {
  127477. dragAxis?: Vector3;
  127478. dragPlaneNormal?: Vector3;
  127479. };
  127480. /**
  127481. * Sets the options used by the behavior
  127482. */
  127483. set options(options: {
  127484. dragAxis?: Vector3;
  127485. dragPlaneNormal?: Vector3;
  127486. });
  127487. /**
  127488. * Creates a pointer drag behavior that can be attached to a mesh
  127489. * @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)
  127490. */
  127491. constructor(options?: {
  127492. dragAxis?: Vector3;
  127493. dragPlaneNormal?: Vector3;
  127494. });
  127495. /**
  127496. * Predicate to determine if it is valid to move the object to a new position when it is moved
  127497. */
  127498. validateDrag: (targetPosition: Vector3) => boolean;
  127499. /**
  127500. * The name of the behavior
  127501. */
  127502. get name(): string;
  127503. /**
  127504. * Initializes the behavior
  127505. */
  127506. init(): void;
  127507. private _tmpVector;
  127508. private _alternatePickedPoint;
  127509. private _worldDragAxis;
  127510. private _targetPosition;
  127511. private _attachedElement;
  127512. /**
  127513. * Attaches the drag behavior the passed in mesh
  127514. * @param ownerNode The mesh that will be dragged around once attached
  127515. * @param predicate Predicate to use for pick filtering
  127516. */
  127517. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  127518. /**
  127519. * Force relase the drag action by code.
  127520. */
  127521. releaseDrag(): void;
  127522. private _startDragRay;
  127523. private _lastPointerRay;
  127524. /**
  127525. * Simulates the start of a pointer drag event on the behavior
  127526. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  127527. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  127528. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  127529. */
  127530. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  127531. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  127532. private _dragDelta;
  127533. protected _moveDrag(ray: Ray): void;
  127534. private _pickWithRayOnDragPlane;
  127535. private _pointA;
  127536. private _pointC;
  127537. private _localAxis;
  127538. private _lookAt;
  127539. private _updateDragPlanePosition;
  127540. /**
  127541. * Detaches the behavior from the mesh
  127542. */
  127543. detach(): void;
  127544. }
  127545. }
  127546. declare module BABYLON {
  127547. /**
  127548. * A behavior that when attached to a mesh will allow the mesh to be scaled
  127549. */
  127550. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  127551. private _dragBehaviorA;
  127552. private _dragBehaviorB;
  127553. private _startDistance;
  127554. private _initialScale;
  127555. private _targetScale;
  127556. private _ownerNode;
  127557. private _sceneRenderObserver;
  127558. /**
  127559. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  127560. */
  127561. constructor();
  127562. /**
  127563. * The name of the behavior
  127564. */
  127565. get name(): string;
  127566. /**
  127567. * Initializes the behavior
  127568. */
  127569. init(): void;
  127570. private _getCurrentDistance;
  127571. /**
  127572. * Attaches the scale behavior the passed in mesh
  127573. * @param ownerNode The mesh that will be scaled around once attached
  127574. */
  127575. attach(ownerNode: Mesh): void;
  127576. /**
  127577. * Detaches the behavior from the mesh
  127578. */
  127579. detach(): void;
  127580. }
  127581. }
  127582. declare module BABYLON {
  127583. /**
  127584. * 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
  127585. */
  127586. export class SixDofDragBehavior implements Behavior<Mesh> {
  127587. private static _virtualScene;
  127588. private _ownerNode;
  127589. private _sceneRenderObserver;
  127590. private _scene;
  127591. private _targetPosition;
  127592. private _virtualOriginMesh;
  127593. private _virtualDragMesh;
  127594. private _pointerObserver;
  127595. private _moving;
  127596. private _startingOrientation;
  127597. private _attachedElement;
  127598. /**
  127599. * 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)
  127600. */
  127601. private zDragFactor;
  127602. /**
  127603. * If the object should rotate to face the drag origin
  127604. */
  127605. rotateDraggedObject: boolean;
  127606. /**
  127607. * If the behavior is currently in a dragging state
  127608. */
  127609. dragging: boolean;
  127610. /**
  127611. * 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)
  127612. */
  127613. dragDeltaRatio: number;
  127614. /**
  127615. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  127616. */
  127617. currentDraggingPointerID: number;
  127618. /**
  127619. * If camera controls should be detached during the drag
  127620. */
  127621. detachCameraControls: boolean;
  127622. /**
  127623. * Fires each time a drag starts
  127624. */
  127625. onDragStartObservable: Observable<{}>;
  127626. /**
  127627. * Fires each time a drag ends (eg. mouse release after drag)
  127628. */
  127629. onDragEndObservable: Observable<{}>;
  127630. /**
  127631. * 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
  127632. */
  127633. constructor();
  127634. /**
  127635. * The name of the behavior
  127636. */
  127637. get name(): string;
  127638. /**
  127639. * Initializes the behavior
  127640. */
  127641. init(): void;
  127642. /**
  127643. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  127644. */
  127645. private get _pointerCamera();
  127646. /**
  127647. * Attaches the scale behavior the passed in mesh
  127648. * @param ownerNode The mesh that will be scaled around once attached
  127649. */
  127650. attach(ownerNode: Mesh): void;
  127651. /**
  127652. * Detaches the behavior from the mesh
  127653. */
  127654. detach(): void;
  127655. }
  127656. }
  127657. declare module BABYLON {
  127658. /**
  127659. * Class used to apply inverse kinematics to bones
  127660. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  127661. */
  127662. export class BoneIKController {
  127663. private static _tmpVecs;
  127664. private static _tmpQuat;
  127665. private static _tmpMats;
  127666. /**
  127667. * Gets or sets the target mesh
  127668. */
  127669. targetMesh: AbstractMesh;
  127670. /** Gets or sets the mesh used as pole */
  127671. poleTargetMesh: AbstractMesh;
  127672. /**
  127673. * Gets or sets the bone used as pole
  127674. */
  127675. poleTargetBone: Nullable<Bone>;
  127676. /**
  127677. * Gets or sets the target position
  127678. */
  127679. targetPosition: Vector3;
  127680. /**
  127681. * Gets or sets the pole target position
  127682. */
  127683. poleTargetPosition: Vector3;
  127684. /**
  127685. * Gets or sets the pole target local offset
  127686. */
  127687. poleTargetLocalOffset: Vector3;
  127688. /**
  127689. * Gets or sets the pole angle
  127690. */
  127691. poleAngle: number;
  127692. /**
  127693. * Gets or sets the mesh associated with the controller
  127694. */
  127695. mesh: AbstractMesh;
  127696. /**
  127697. * 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)
  127698. */
  127699. slerpAmount: number;
  127700. private _bone1Quat;
  127701. private _bone1Mat;
  127702. private _bone2Ang;
  127703. private _bone1;
  127704. private _bone2;
  127705. private _bone1Length;
  127706. private _bone2Length;
  127707. private _maxAngle;
  127708. private _maxReach;
  127709. private _rightHandedSystem;
  127710. private _bendAxis;
  127711. private _slerping;
  127712. private _adjustRoll;
  127713. /**
  127714. * Gets or sets maximum allowed angle
  127715. */
  127716. get maxAngle(): number;
  127717. set maxAngle(value: number);
  127718. /**
  127719. * Creates a new BoneIKController
  127720. * @param mesh defines the mesh to control
  127721. * @param bone defines the bone to control
  127722. * @param options defines options to set up the controller
  127723. */
  127724. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  127725. targetMesh?: AbstractMesh;
  127726. poleTargetMesh?: AbstractMesh;
  127727. poleTargetBone?: Bone;
  127728. poleTargetLocalOffset?: Vector3;
  127729. poleAngle?: number;
  127730. bendAxis?: Vector3;
  127731. maxAngle?: number;
  127732. slerpAmount?: number;
  127733. });
  127734. private _setMaxAngle;
  127735. /**
  127736. * Force the controller to update the bones
  127737. */
  127738. update(): void;
  127739. }
  127740. }
  127741. declare module BABYLON {
  127742. /**
  127743. * Class used to make a bone look toward a point in space
  127744. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  127745. */
  127746. export class BoneLookController {
  127747. private static _tmpVecs;
  127748. private static _tmpQuat;
  127749. private static _tmpMats;
  127750. /**
  127751. * The target Vector3 that the bone will look at
  127752. */
  127753. target: Vector3;
  127754. /**
  127755. * The mesh that the bone is attached to
  127756. */
  127757. mesh: AbstractMesh;
  127758. /**
  127759. * The bone that will be looking to the target
  127760. */
  127761. bone: Bone;
  127762. /**
  127763. * The up axis of the coordinate system that is used when the bone is rotated
  127764. */
  127765. upAxis: Vector3;
  127766. /**
  127767. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  127768. */
  127769. upAxisSpace: Space;
  127770. /**
  127771. * Used to make an adjustment to the yaw of the bone
  127772. */
  127773. adjustYaw: number;
  127774. /**
  127775. * Used to make an adjustment to the pitch of the bone
  127776. */
  127777. adjustPitch: number;
  127778. /**
  127779. * Used to make an adjustment to the roll of the bone
  127780. */
  127781. adjustRoll: number;
  127782. /**
  127783. * 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)
  127784. */
  127785. slerpAmount: number;
  127786. private _minYaw;
  127787. private _maxYaw;
  127788. private _minPitch;
  127789. private _maxPitch;
  127790. private _minYawSin;
  127791. private _minYawCos;
  127792. private _maxYawSin;
  127793. private _maxYawCos;
  127794. private _midYawConstraint;
  127795. private _minPitchTan;
  127796. private _maxPitchTan;
  127797. private _boneQuat;
  127798. private _slerping;
  127799. private _transformYawPitch;
  127800. private _transformYawPitchInv;
  127801. private _firstFrameSkipped;
  127802. private _yawRange;
  127803. private _fowardAxis;
  127804. /**
  127805. * Gets or sets the minimum yaw angle that the bone can look to
  127806. */
  127807. get minYaw(): number;
  127808. set minYaw(value: number);
  127809. /**
  127810. * Gets or sets the maximum yaw angle that the bone can look to
  127811. */
  127812. get maxYaw(): number;
  127813. set maxYaw(value: number);
  127814. /**
  127815. * Gets or sets the minimum pitch angle that the bone can look to
  127816. */
  127817. get minPitch(): number;
  127818. set minPitch(value: number);
  127819. /**
  127820. * Gets or sets the maximum pitch angle that the bone can look to
  127821. */
  127822. get maxPitch(): number;
  127823. set maxPitch(value: number);
  127824. /**
  127825. * Create a BoneLookController
  127826. * @param mesh the mesh that the bone belongs to
  127827. * @param bone the bone that will be looking to the target
  127828. * @param target the target Vector3 to look at
  127829. * @param options optional settings:
  127830. * * maxYaw: the maximum angle the bone will yaw to
  127831. * * minYaw: the minimum angle the bone will yaw to
  127832. * * maxPitch: the maximum angle the bone will pitch to
  127833. * * minPitch: the minimum angle the bone will yaw to
  127834. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  127835. * * upAxis: the up axis of the coordinate system
  127836. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  127837. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  127838. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  127839. * * adjustYaw: used to make an adjustment to the yaw of the bone
  127840. * * adjustPitch: used to make an adjustment to the pitch of the bone
  127841. * * adjustRoll: used to make an adjustment to the roll of the bone
  127842. **/
  127843. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  127844. maxYaw?: number;
  127845. minYaw?: number;
  127846. maxPitch?: number;
  127847. minPitch?: number;
  127848. slerpAmount?: number;
  127849. upAxis?: Vector3;
  127850. upAxisSpace?: Space;
  127851. yawAxis?: Vector3;
  127852. pitchAxis?: Vector3;
  127853. adjustYaw?: number;
  127854. adjustPitch?: number;
  127855. adjustRoll?: number;
  127856. });
  127857. /**
  127858. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  127859. */
  127860. update(): void;
  127861. private _getAngleDiff;
  127862. private _getAngleBetween;
  127863. private _isAngleBetween;
  127864. }
  127865. }
  127866. declare module BABYLON {
  127867. /**
  127868. * Manage the gamepad inputs to control an arc rotate camera.
  127869. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127870. */
  127871. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  127872. /**
  127873. * Defines the camera the input is attached to.
  127874. */
  127875. camera: ArcRotateCamera;
  127876. /**
  127877. * Defines the gamepad the input is gathering event from.
  127878. */
  127879. gamepad: Nullable<Gamepad>;
  127880. /**
  127881. * Defines the gamepad rotation sensiblity.
  127882. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  127883. */
  127884. gamepadRotationSensibility: number;
  127885. /**
  127886. * Defines the gamepad move sensiblity.
  127887. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  127888. */
  127889. gamepadMoveSensibility: number;
  127890. private _yAxisScale;
  127891. /**
  127892. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  127893. */
  127894. get invertYAxis(): boolean;
  127895. set invertYAxis(value: boolean);
  127896. private _onGamepadConnectedObserver;
  127897. private _onGamepadDisconnectedObserver;
  127898. /**
  127899. * Attach the input controls to a specific dom element to get the input from.
  127900. * @param element Defines the element the controls should be listened from
  127901. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127902. */
  127903. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127904. /**
  127905. * Detach the current controls from the specified dom element.
  127906. * @param element Defines the element to stop listening the inputs from
  127907. */
  127908. detachControl(element: Nullable<HTMLElement>): void;
  127909. /**
  127910. * Update the current camera state depending on the inputs that have been used this frame.
  127911. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127912. */
  127913. checkInputs(): void;
  127914. /**
  127915. * Gets the class name of the current intput.
  127916. * @returns the class name
  127917. */
  127918. getClassName(): string;
  127919. /**
  127920. * Get the friendly name associated with the input class.
  127921. * @returns the input friendly name
  127922. */
  127923. getSimpleName(): string;
  127924. }
  127925. }
  127926. declare module BABYLON {
  127927. interface ArcRotateCameraInputsManager {
  127928. /**
  127929. * Add orientation input support to the input manager.
  127930. * @returns the current input manager
  127931. */
  127932. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  127933. }
  127934. /**
  127935. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  127936. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127937. */
  127938. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  127939. /**
  127940. * Defines the camera the input is attached to.
  127941. */
  127942. camera: ArcRotateCamera;
  127943. /**
  127944. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  127945. */
  127946. alphaCorrection: number;
  127947. /**
  127948. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  127949. */
  127950. gammaCorrection: number;
  127951. private _alpha;
  127952. private _gamma;
  127953. private _dirty;
  127954. private _deviceOrientationHandler;
  127955. /**
  127956. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  127957. */
  127958. constructor();
  127959. /**
  127960. * Attach the input controls to a specific dom element to get the input from.
  127961. * @param element Defines the element the controls should be listened from
  127962. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127963. */
  127964. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127965. /** @hidden */
  127966. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  127967. /**
  127968. * Update the current camera state depending on the inputs that have been used this frame.
  127969. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127970. */
  127971. checkInputs(): void;
  127972. /**
  127973. * Detach the current controls from the specified dom element.
  127974. * @param element Defines the element to stop listening the inputs from
  127975. */
  127976. detachControl(element: Nullable<HTMLElement>): void;
  127977. /**
  127978. * Gets the class name of the current intput.
  127979. * @returns the class name
  127980. */
  127981. getClassName(): string;
  127982. /**
  127983. * Get the friendly name associated with the input class.
  127984. * @returns the input friendly name
  127985. */
  127986. getSimpleName(): string;
  127987. }
  127988. }
  127989. declare module BABYLON {
  127990. /**
  127991. * Listen to mouse events to control the camera.
  127992. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127993. */
  127994. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  127995. /**
  127996. * Defines the camera the input is attached to.
  127997. */
  127998. camera: FlyCamera;
  127999. /**
  128000. * Defines if touch is enabled. (Default is true.)
  128001. */
  128002. touchEnabled: boolean;
  128003. /**
  128004. * Defines the buttons associated with the input to handle camera rotation.
  128005. */
  128006. buttons: number[];
  128007. /**
  128008. * Assign buttons for Yaw control.
  128009. */
  128010. buttonsYaw: number[];
  128011. /**
  128012. * Assign buttons for Pitch control.
  128013. */
  128014. buttonsPitch: number[];
  128015. /**
  128016. * Assign buttons for Roll control.
  128017. */
  128018. buttonsRoll: number[];
  128019. /**
  128020. * Detect if any button is being pressed while mouse is moved.
  128021. * -1 = Mouse locked.
  128022. * 0 = Left button.
  128023. * 1 = Middle Button.
  128024. * 2 = Right Button.
  128025. */
  128026. activeButton: number;
  128027. /**
  128028. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  128029. * Higher values reduce its sensitivity.
  128030. */
  128031. angularSensibility: number;
  128032. private _observer;
  128033. private _rollObserver;
  128034. private previousPosition;
  128035. private noPreventDefault;
  128036. private element;
  128037. /**
  128038. * Listen to mouse events to control the camera.
  128039. * @param touchEnabled Define if touch is enabled. (Default is true.)
  128040. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128041. */
  128042. constructor(touchEnabled?: boolean);
  128043. /**
  128044. * Attach the mouse control to the HTML DOM element.
  128045. * @param element Defines the element that listens to the input events.
  128046. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  128047. */
  128048. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128049. /**
  128050. * Detach the current controls from the specified dom element.
  128051. * @param element Defines the element to stop listening the inputs from
  128052. */
  128053. detachControl(element: Nullable<HTMLElement>): void;
  128054. /**
  128055. * Gets the class name of the current input.
  128056. * @returns the class name.
  128057. */
  128058. getClassName(): string;
  128059. /**
  128060. * Get the friendly name associated with the input class.
  128061. * @returns the input's friendly name.
  128062. */
  128063. getSimpleName(): string;
  128064. private _pointerInput;
  128065. private _onMouseMove;
  128066. /**
  128067. * Rotate camera by mouse offset.
  128068. */
  128069. private rotateCamera;
  128070. }
  128071. }
  128072. declare module BABYLON {
  128073. /**
  128074. * Default Inputs manager for the FlyCamera.
  128075. * It groups all the default supported inputs for ease of use.
  128076. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128077. */
  128078. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  128079. /**
  128080. * Instantiates a new FlyCameraInputsManager.
  128081. * @param camera Defines the camera the inputs belong to.
  128082. */
  128083. constructor(camera: FlyCamera);
  128084. /**
  128085. * Add keyboard input support to the input manager.
  128086. * @returns the new FlyCameraKeyboardMoveInput().
  128087. */
  128088. addKeyboard(): FlyCameraInputsManager;
  128089. /**
  128090. * Add mouse input support to the input manager.
  128091. * @param touchEnabled Enable touch screen support.
  128092. * @returns the new FlyCameraMouseInput().
  128093. */
  128094. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  128095. }
  128096. }
  128097. declare module BABYLON {
  128098. /**
  128099. * This is a flying camera, designed for 3D movement and rotation in all directions,
  128100. * such as in a 3D Space Shooter or a Flight Simulator.
  128101. */
  128102. export class FlyCamera extends TargetCamera {
  128103. /**
  128104. * Define the collision ellipsoid of the camera.
  128105. * This is helpful for simulating a camera body, like a player's body.
  128106. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  128107. */
  128108. ellipsoid: Vector3;
  128109. /**
  128110. * Define an offset for the position of the ellipsoid around the camera.
  128111. * This can be helpful if the camera is attached away from the player's body center,
  128112. * such as at its head.
  128113. */
  128114. ellipsoidOffset: Vector3;
  128115. /**
  128116. * Enable or disable collisions of the camera with the rest of the scene objects.
  128117. */
  128118. checkCollisions: boolean;
  128119. /**
  128120. * Enable or disable gravity on the camera.
  128121. */
  128122. applyGravity: boolean;
  128123. /**
  128124. * Define the current direction the camera is moving to.
  128125. */
  128126. cameraDirection: Vector3;
  128127. /**
  128128. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  128129. * This overrides and empties cameraRotation.
  128130. */
  128131. rotationQuaternion: Quaternion;
  128132. /**
  128133. * Track Roll to maintain the wanted Rolling when looking around.
  128134. */
  128135. _trackRoll: number;
  128136. /**
  128137. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  128138. */
  128139. rollCorrect: number;
  128140. /**
  128141. * Mimic a banked turn, Rolling the camera when Yawing.
  128142. * It's recommended to use rollCorrect = 10 for faster banking correction.
  128143. */
  128144. bankedTurn: boolean;
  128145. /**
  128146. * Limit in radians for how much Roll banking will add. (Default: 90°)
  128147. */
  128148. bankedTurnLimit: number;
  128149. /**
  128150. * Value of 0 disables the banked Roll.
  128151. * Value of 1 is equal to the Yaw angle in radians.
  128152. */
  128153. bankedTurnMultiplier: number;
  128154. /**
  128155. * The inputs manager loads all the input sources, such as keyboard and mouse.
  128156. */
  128157. inputs: FlyCameraInputsManager;
  128158. /**
  128159. * Gets the input sensibility for mouse input.
  128160. * Higher values reduce sensitivity.
  128161. */
  128162. get angularSensibility(): number;
  128163. /**
  128164. * Sets the input sensibility for a mouse input.
  128165. * Higher values reduce sensitivity.
  128166. */
  128167. set angularSensibility(value: number);
  128168. /**
  128169. * Get the keys for camera movement forward.
  128170. */
  128171. get keysForward(): number[];
  128172. /**
  128173. * Set the keys for camera movement forward.
  128174. */
  128175. set keysForward(value: number[]);
  128176. /**
  128177. * Get the keys for camera movement backward.
  128178. */
  128179. get keysBackward(): number[];
  128180. set keysBackward(value: number[]);
  128181. /**
  128182. * Get the keys for camera movement up.
  128183. */
  128184. get keysUp(): number[];
  128185. /**
  128186. * Set the keys for camera movement up.
  128187. */
  128188. set keysUp(value: number[]);
  128189. /**
  128190. * Get the keys for camera movement down.
  128191. */
  128192. get keysDown(): number[];
  128193. /**
  128194. * Set the keys for camera movement down.
  128195. */
  128196. set keysDown(value: number[]);
  128197. /**
  128198. * Get the keys for camera movement left.
  128199. */
  128200. get keysLeft(): number[];
  128201. /**
  128202. * Set the keys for camera movement left.
  128203. */
  128204. set keysLeft(value: number[]);
  128205. /**
  128206. * Set the keys for camera movement right.
  128207. */
  128208. get keysRight(): number[];
  128209. /**
  128210. * Set the keys for camera movement right.
  128211. */
  128212. set keysRight(value: number[]);
  128213. /**
  128214. * Event raised when the camera collides with a mesh in the scene.
  128215. */
  128216. onCollide: (collidedMesh: AbstractMesh) => void;
  128217. private _collider;
  128218. private _needMoveForGravity;
  128219. private _oldPosition;
  128220. private _diffPosition;
  128221. private _newPosition;
  128222. /** @hidden */
  128223. _localDirection: Vector3;
  128224. /** @hidden */
  128225. _transformedDirection: Vector3;
  128226. /**
  128227. * Instantiates a FlyCamera.
  128228. * This is a flying camera, designed for 3D movement and rotation in all directions,
  128229. * such as in a 3D Space Shooter or a Flight Simulator.
  128230. * @param name Define the name of the camera in the scene.
  128231. * @param position Define the starting position of the camera in the scene.
  128232. * @param scene Define the scene the camera belongs to.
  128233. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  128234. */
  128235. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  128236. /**
  128237. * Attach a control to the HTML DOM element.
  128238. * @param element Defines the element that listens to the input events.
  128239. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  128240. */
  128241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128242. /**
  128243. * Detach a control from the HTML DOM element.
  128244. * The camera will stop reacting to that input.
  128245. * @param element Defines the element that listens to the input events.
  128246. */
  128247. detachControl(element: HTMLElement): void;
  128248. private _collisionMask;
  128249. /**
  128250. * Get the mask that the camera ignores in collision events.
  128251. */
  128252. get collisionMask(): number;
  128253. /**
  128254. * Set the mask that the camera ignores in collision events.
  128255. */
  128256. set collisionMask(mask: number);
  128257. /** @hidden */
  128258. _collideWithWorld(displacement: Vector3): void;
  128259. /** @hidden */
  128260. private _onCollisionPositionChange;
  128261. /** @hidden */
  128262. _checkInputs(): void;
  128263. /** @hidden */
  128264. _decideIfNeedsToMove(): boolean;
  128265. /** @hidden */
  128266. _updatePosition(): void;
  128267. /**
  128268. * Restore the Roll to its target value at the rate specified.
  128269. * @param rate - Higher means slower restoring.
  128270. * @hidden
  128271. */
  128272. restoreRoll(rate: number): void;
  128273. /**
  128274. * Destroy the camera and release the current resources held by it.
  128275. */
  128276. dispose(): void;
  128277. /**
  128278. * Get the current object class name.
  128279. * @returns the class name.
  128280. */
  128281. getClassName(): string;
  128282. }
  128283. }
  128284. declare module BABYLON {
  128285. /**
  128286. * Listen to keyboard events to control the camera.
  128287. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128288. */
  128289. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  128290. /**
  128291. * Defines the camera the input is attached to.
  128292. */
  128293. camera: FlyCamera;
  128294. /**
  128295. * The list of keyboard keys used to control the forward move of the camera.
  128296. */
  128297. keysForward: number[];
  128298. /**
  128299. * The list of keyboard keys used to control the backward move of the camera.
  128300. */
  128301. keysBackward: number[];
  128302. /**
  128303. * The list of keyboard keys used to control the forward move of the camera.
  128304. */
  128305. keysUp: number[];
  128306. /**
  128307. * The list of keyboard keys used to control the backward move of the camera.
  128308. */
  128309. keysDown: number[];
  128310. /**
  128311. * The list of keyboard keys used to control the right strafe move of the camera.
  128312. */
  128313. keysRight: number[];
  128314. /**
  128315. * The list of keyboard keys used to control the left strafe move of the camera.
  128316. */
  128317. keysLeft: number[];
  128318. private _keys;
  128319. private _onCanvasBlurObserver;
  128320. private _onKeyboardObserver;
  128321. private _engine;
  128322. private _scene;
  128323. /**
  128324. * Attach the input controls to a specific dom element to get the input from.
  128325. * @param element Defines the element the controls should be listened from
  128326. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128327. */
  128328. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128329. /**
  128330. * Detach the current controls from the specified dom element.
  128331. * @param element Defines the element to stop listening the inputs from
  128332. */
  128333. detachControl(element: Nullable<HTMLElement>): void;
  128334. /**
  128335. * Gets the class name of the current intput.
  128336. * @returns the class name
  128337. */
  128338. getClassName(): string;
  128339. /** @hidden */
  128340. _onLostFocus(e: FocusEvent): void;
  128341. /**
  128342. * Get the friendly name associated with the input class.
  128343. * @returns the input friendly name
  128344. */
  128345. getSimpleName(): string;
  128346. /**
  128347. * Update the current camera state depending on the inputs that have been used this frame.
  128348. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128349. */
  128350. checkInputs(): void;
  128351. }
  128352. }
  128353. declare module BABYLON {
  128354. /**
  128355. * Manage the mouse wheel inputs to control a follow camera.
  128356. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128357. */
  128358. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  128359. /**
  128360. * Defines the camera the input is attached to.
  128361. */
  128362. camera: FollowCamera;
  128363. /**
  128364. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  128365. */
  128366. axisControlRadius: boolean;
  128367. /**
  128368. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  128369. */
  128370. axisControlHeight: boolean;
  128371. /**
  128372. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  128373. */
  128374. axisControlRotation: boolean;
  128375. /**
  128376. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  128377. * relation to mouseWheel events.
  128378. */
  128379. wheelPrecision: number;
  128380. /**
  128381. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  128382. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  128383. */
  128384. wheelDeltaPercentage: number;
  128385. private _wheel;
  128386. private _observer;
  128387. /**
  128388. * Attach the input controls to a specific dom element to get the input from.
  128389. * @param element Defines the element the controls should be listened from
  128390. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128391. */
  128392. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128393. /**
  128394. * Detach the current controls from the specified dom element.
  128395. * @param element Defines the element to stop listening the inputs from
  128396. */
  128397. detachControl(element: Nullable<HTMLElement>): void;
  128398. /**
  128399. * Gets the class name of the current intput.
  128400. * @returns the class name
  128401. */
  128402. getClassName(): string;
  128403. /**
  128404. * Get the friendly name associated with the input class.
  128405. * @returns the input friendly name
  128406. */
  128407. getSimpleName(): string;
  128408. }
  128409. }
  128410. declare module BABYLON {
  128411. /**
  128412. * Manage the pointers inputs to control an follow camera.
  128413. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128414. */
  128415. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  128416. /**
  128417. * Defines the camera the input is attached to.
  128418. */
  128419. camera: FollowCamera;
  128420. /**
  128421. * Gets the class name of the current input.
  128422. * @returns the class name
  128423. */
  128424. getClassName(): string;
  128425. /**
  128426. * Defines the pointer angular sensibility along the X axis or how fast is
  128427. * the camera rotating.
  128428. * A negative number will reverse the axis direction.
  128429. */
  128430. angularSensibilityX: number;
  128431. /**
  128432. * Defines the pointer angular sensibility along the Y axis or how fast is
  128433. * the camera rotating.
  128434. * A negative number will reverse the axis direction.
  128435. */
  128436. angularSensibilityY: number;
  128437. /**
  128438. * Defines the pointer pinch precision or how fast is the camera zooming.
  128439. * A negative number will reverse the axis direction.
  128440. */
  128441. pinchPrecision: number;
  128442. /**
  128443. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  128444. * from 0.
  128445. * It defines the percentage of current camera.radius to use as delta when
  128446. * pinch zoom is used.
  128447. */
  128448. pinchDeltaPercentage: number;
  128449. /**
  128450. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  128451. */
  128452. axisXControlRadius: boolean;
  128453. /**
  128454. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  128455. */
  128456. axisXControlHeight: boolean;
  128457. /**
  128458. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  128459. */
  128460. axisXControlRotation: boolean;
  128461. /**
  128462. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  128463. */
  128464. axisYControlRadius: boolean;
  128465. /**
  128466. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  128467. */
  128468. axisYControlHeight: boolean;
  128469. /**
  128470. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  128471. */
  128472. axisYControlRotation: boolean;
  128473. /**
  128474. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  128475. */
  128476. axisPinchControlRadius: boolean;
  128477. /**
  128478. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  128479. */
  128480. axisPinchControlHeight: boolean;
  128481. /**
  128482. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  128483. */
  128484. axisPinchControlRotation: boolean;
  128485. /**
  128486. * Log error messages if basic misconfiguration has occurred.
  128487. */
  128488. warningEnable: boolean;
  128489. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  128490. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  128491. private _warningCounter;
  128492. private _warning;
  128493. }
  128494. }
  128495. declare module BABYLON {
  128496. /**
  128497. * Default Inputs manager for the FollowCamera.
  128498. * It groups all the default supported inputs for ease of use.
  128499. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128500. */
  128501. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  128502. /**
  128503. * Instantiates a new FollowCameraInputsManager.
  128504. * @param camera Defines the camera the inputs belong to
  128505. */
  128506. constructor(camera: FollowCamera);
  128507. /**
  128508. * Add keyboard input support to the input manager.
  128509. * @returns the current input manager
  128510. */
  128511. addKeyboard(): FollowCameraInputsManager;
  128512. /**
  128513. * Add mouse wheel input support to the input manager.
  128514. * @returns the current input manager
  128515. */
  128516. addMouseWheel(): FollowCameraInputsManager;
  128517. /**
  128518. * Add pointers input support to the input manager.
  128519. * @returns the current input manager
  128520. */
  128521. addPointers(): FollowCameraInputsManager;
  128522. /**
  128523. * Add orientation input support to the input manager.
  128524. * @returns the current input manager
  128525. */
  128526. addVRDeviceOrientation(): FollowCameraInputsManager;
  128527. }
  128528. }
  128529. declare module BABYLON {
  128530. /**
  128531. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  128532. * an arc rotate version arcFollowCamera are available.
  128533. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128534. */
  128535. export class FollowCamera extends TargetCamera {
  128536. /**
  128537. * Distance the follow camera should follow an object at
  128538. */
  128539. radius: number;
  128540. /**
  128541. * Minimum allowed distance of the camera to the axis of rotation
  128542. * (The camera can not get closer).
  128543. * This can help limiting how the Camera is able to move in the scene.
  128544. */
  128545. lowerRadiusLimit: Nullable<number>;
  128546. /**
  128547. * Maximum allowed distance of the camera to the axis of rotation
  128548. * (The camera can not get further).
  128549. * This can help limiting how the Camera is able to move in the scene.
  128550. */
  128551. upperRadiusLimit: Nullable<number>;
  128552. /**
  128553. * Define a rotation offset between the camera and the object it follows
  128554. */
  128555. rotationOffset: number;
  128556. /**
  128557. * Minimum allowed angle to camera position relative to target object.
  128558. * This can help limiting how the Camera is able to move in the scene.
  128559. */
  128560. lowerRotationOffsetLimit: Nullable<number>;
  128561. /**
  128562. * Maximum allowed angle to camera position relative to target object.
  128563. * This can help limiting how the Camera is able to move in the scene.
  128564. */
  128565. upperRotationOffsetLimit: Nullable<number>;
  128566. /**
  128567. * Define a height offset between the camera and the object it follows.
  128568. * It can help following an object from the top (like a car chaing a plane)
  128569. */
  128570. heightOffset: number;
  128571. /**
  128572. * Minimum allowed height of camera position relative to target object.
  128573. * This can help limiting how the Camera is able to move in the scene.
  128574. */
  128575. lowerHeightOffsetLimit: Nullable<number>;
  128576. /**
  128577. * Maximum allowed height of camera position relative to target object.
  128578. * This can help limiting how the Camera is able to move in the scene.
  128579. */
  128580. upperHeightOffsetLimit: Nullable<number>;
  128581. /**
  128582. * Define how fast the camera can accelerate to follow it s target.
  128583. */
  128584. cameraAcceleration: number;
  128585. /**
  128586. * Define the speed limit of the camera following an object.
  128587. */
  128588. maxCameraSpeed: number;
  128589. /**
  128590. * Define the target of the camera.
  128591. */
  128592. lockedTarget: Nullable<AbstractMesh>;
  128593. /**
  128594. * Defines the input associated with the camera.
  128595. */
  128596. inputs: FollowCameraInputsManager;
  128597. /**
  128598. * Instantiates the follow camera.
  128599. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128600. * @param name Define the name of the camera in the scene
  128601. * @param position Define the position of the camera
  128602. * @param scene Define the scene the camera belong to
  128603. * @param lockedTarget Define the target of the camera
  128604. */
  128605. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  128606. private _follow;
  128607. /**
  128608. * Attached controls to the current camera.
  128609. * @param element Defines the element the controls should be listened from
  128610. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128611. */
  128612. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128613. /**
  128614. * Detach the current controls from the camera.
  128615. * The camera will stop reacting to inputs.
  128616. * @param element Defines the element to stop listening the inputs from
  128617. */
  128618. detachControl(element: HTMLElement): void;
  128619. /** @hidden */
  128620. _checkInputs(): void;
  128621. private _checkLimits;
  128622. /**
  128623. * Gets the camera class name.
  128624. * @returns the class name
  128625. */
  128626. getClassName(): string;
  128627. }
  128628. /**
  128629. * Arc Rotate version of the follow camera.
  128630. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  128631. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128632. */
  128633. export class ArcFollowCamera extends TargetCamera {
  128634. /** The longitudinal angle of the camera */
  128635. alpha: number;
  128636. /** The latitudinal angle of the camera */
  128637. beta: number;
  128638. /** The radius of the camera from its target */
  128639. radius: number;
  128640. private _cartesianCoordinates;
  128641. /** Define the camera target (the mesh it should follow) */
  128642. private _meshTarget;
  128643. /**
  128644. * Instantiates a new ArcFollowCamera
  128645. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128646. * @param name Define the name of the camera
  128647. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  128648. * @param beta Define the rotation angle of the camera around the elevation axis
  128649. * @param radius Define the radius of the camera from its target point
  128650. * @param target Define the target of the camera
  128651. * @param scene Define the scene the camera belongs to
  128652. */
  128653. constructor(name: string,
  128654. /** The longitudinal angle of the camera */
  128655. alpha: number,
  128656. /** The latitudinal angle of the camera */
  128657. beta: number,
  128658. /** The radius of the camera from its target */
  128659. radius: number,
  128660. /** Define the camera target (the mesh it should follow) */
  128661. target: Nullable<AbstractMesh>, scene: Scene);
  128662. private _follow;
  128663. /** @hidden */
  128664. _checkInputs(): void;
  128665. /**
  128666. * Returns the class name of the object.
  128667. * It is mostly used internally for serialization purposes.
  128668. */
  128669. getClassName(): string;
  128670. }
  128671. }
  128672. declare module BABYLON {
  128673. /**
  128674. * Manage the keyboard inputs to control the movement of a follow camera.
  128675. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128676. */
  128677. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  128678. /**
  128679. * Defines the camera the input is attached to.
  128680. */
  128681. camera: FollowCamera;
  128682. /**
  128683. * Defines the list of key codes associated with the up action (increase heightOffset)
  128684. */
  128685. keysHeightOffsetIncr: number[];
  128686. /**
  128687. * Defines the list of key codes associated with the down action (decrease heightOffset)
  128688. */
  128689. keysHeightOffsetDecr: number[];
  128690. /**
  128691. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  128692. */
  128693. keysHeightOffsetModifierAlt: boolean;
  128694. /**
  128695. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  128696. */
  128697. keysHeightOffsetModifierCtrl: boolean;
  128698. /**
  128699. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  128700. */
  128701. keysHeightOffsetModifierShift: boolean;
  128702. /**
  128703. * Defines the list of key codes associated with the left action (increase rotationOffset)
  128704. */
  128705. keysRotationOffsetIncr: number[];
  128706. /**
  128707. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  128708. */
  128709. keysRotationOffsetDecr: number[];
  128710. /**
  128711. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  128712. */
  128713. keysRotationOffsetModifierAlt: boolean;
  128714. /**
  128715. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  128716. */
  128717. keysRotationOffsetModifierCtrl: boolean;
  128718. /**
  128719. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  128720. */
  128721. keysRotationOffsetModifierShift: boolean;
  128722. /**
  128723. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  128724. */
  128725. keysRadiusIncr: number[];
  128726. /**
  128727. * Defines the list of key codes associated with the zoom-out action (increase radius)
  128728. */
  128729. keysRadiusDecr: number[];
  128730. /**
  128731. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  128732. */
  128733. keysRadiusModifierAlt: boolean;
  128734. /**
  128735. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  128736. */
  128737. keysRadiusModifierCtrl: boolean;
  128738. /**
  128739. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  128740. */
  128741. keysRadiusModifierShift: boolean;
  128742. /**
  128743. * Defines the rate of change of heightOffset.
  128744. */
  128745. heightSensibility: number;
  128746. /**
  128747. * Defines the rate of change of rotationOffset.
  128748. */
  128749. rotationSensibility: number;
  128750. /**
  128751. * Defines the rate of change of radius.
  128752. */
  128753. radiusSensibility: number;
  128754. private _keys;
  128755. private _ctrlPressed;
  128756. private _altPressed;
  128757. private _shiftPressed;
  128758. private _onCanvasBlurObserver;
  128759. private _onKeyboardObserver;
  128760. private _engine;
  128761. private _scene;
  128762. /**
  128763. * Attach the input controls to a specific dom element to get the input from.
  128764. * @param element Defines the element the controls should be listened from
  128765. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128766. */
  128767. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128768. /**
  128769. * Detach the current controls from the specified dom element.
  128770. * @param element Defines the element to stop listening the inputs from
  128771. */
  128772. detachControl(element: Nullable<HTMLElement>): void;
  128773. /**
  128774. * Update the current camera state depending on the inputs that have been used this frame.
  128775. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128776. */
  128777. checkInputs(): void;
  128778. /**
  128779. * Gets the class name of the current input.
  128780. * @returns the class name
  128781. */
  128782. getClassName(): string;
  128783. /**
  128784. * Get the friendly name associated with the input class.
  128785. * @returns the input friendly name
  128786. */
  128787. getSimpleName(): string;
  128788. /**
  128789. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128790. * allow modification of the heightOffset value.
  128791. */
  128792. private _modifierHeightOffset;
  128793. /**
  128794. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128795. * allow modification of the rotationOffset value.
  128796. */
  128797. private _modifierRotationOffset;
  128798. /**
  128799. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128800. * allow modification of the radius value.
  128801. */
  128802. private _modifierRadius;
  128803. }
  128804. }
  128805. declare module BABYLON {
  128806. interface FreeCameraInputsManager {
  128807. /**
  128808. * @hidden
  128809. */
  128810. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  128811. /**
  128812. * Add orientation input support to the input manager.
  128813. * @returns the current input manager
  128814. */
  128815. addDeviceOrientation(): FreeCameraInputsManager;
  128816. }
  128817. /**
  128818. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  128819. * Screen rotation is taken into account.
  128820. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128821. */
  128822. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  128823. private _camera;
  128824. private _screenOrientationAngle;
  128825. private _constantTranform;
  128826. private _screenQuaternion;
  128827. private _alpha;
  128828. private _beta;
  128829. private _gamma;
  128830. /**
  128831. * Can be used to detect if a device orientation sensor is available on a device
  128832. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  128833. * @returns a promise that will resolve on orientation change
  128834. */
  128835. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  128836. /**
  128837. * @hidden
  128838. */
  128839. _onDeviceOrientationChangedObservable: Observable<void>;
  128840. /**
  128841. * Instantiates a new input
  128842. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128843. */
  128844. constructor();
  128845. /**
  128846. * Define the camera controlled by the input.
  128847. */
  128848. get camera(): FreeCamera;
  128849. set camera(camera: FreeCamera);
  128850. /**
  128851. * Attach the input controls to a specific dom element to get the input from.
  128852. * @param element Defines the element the controls should be listened from
  128853. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128854. */
  128855. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128856. private _orientationChanged;
  128857. private _deviceOrientation;
  128858. /**
  128859. * Detach the current controls from the specified dom element.
  128860. * @param element Defines the element to stop listening the inputs from
  128861. */
  128862. detachControl(element: Nullable<HTMLElement>): void;
  128863. /**
  128864. * Update the current camera state depending on the inputs that have been used this frame.
  128865. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128866. */
  128867. checkInputs(): void;
  128868. /**
  128869. * Gets the class name of the current intput.
  128870. * @returns the class name
  128871. */
  128872. getClassName(): string;
  128873. /**
  128874. * Get the friendly name associated with the input class.
  128875. * @returns the input friendly name
  128876. */
  128877. getSimpleName(): string;
  128878. }
  128879. }
  128880. declare module BABYLON {
  128881. /**
  128882. * Manage the gamepad inputs to control a free camera.
  128883. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128884. */
  128885. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  128886. /**
  128887. * Define the camera the input is attached to.
  128888. */
  128889. camera: FreeCamera;
  128890. /**
  128891. * Define the Gamepad controlling the input
  128892. */
  128893. gamepad: Nullable<Gamepad>;
  128894. /**
  128895. * Defines the gamepad rotation sensiblity.
  128896. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  128897. */
  128898. gamepadAngularSensibility: number;
  128899. /**
  128900. * Defines the gamepad move sensiblity.
  128901. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  128902. */
  128903. gamepadMoveSensibility: number;
  128904. private _yAxisScale;
  128905. /**
  128906. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  128907. */
  128908. get invertYAxis(): boolean;
  128909. set invertYAxis(value: boolean);
  128910. private _onGamepadConnectedObserver;
  128911. private _onGamepadDisconnectedObserver;
  128912. private _cameraTransform;
  128913. private _deltaTransform;
  128914. private _vector3;
  128915. private _vector2;
  128916. /**
  128917. * Attach the input controls to a specific dom element to get the input from.
  128918. * @param element Defines the element the controls should be listened from
  128919. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128920. */
  128921. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128922. /**
  128923. * Detach the current controls from the specified dom element.
  128924. * @param element Defines the element to stop listening the inputs from
  128925. */
  128926. detachControl(element: Nullable<HTMLElement>): void;
  128927. /**
  128928. * Update the current camera state depending on the inputs that have been used this frame.
  128929. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128930. */
  128931. checkInputs(): void;
  128932. /**
  128933. * Gets the class name of the current intput.
  128934. * @returns the class name
  128935. */
  128936. getClassName(): string;
  128937. /**
  128938. * Get the friendly name associated with the input class.
  128939. * @returns the input friendly name
  128940. */
  128941. getSimpleName(): string;
  128942. }
  128943. }
  128944. declare module BABYLON {
  128945. /**
  128946. * Defines the potential axis of a Joystick
  128947. */
  128948. export enum JoystickAxis {
  128949. /** X axis */
  128950. X = 0,
  128951. /** Y axis */
  128952. Y = 1,
  128953. /** Z axis */
  128954. Z = 2
  128955. }
  128956. /**
  128957. * Represents the different customization options available
  128958. * for VirtualJoystick
  128959. */
  128960. interface VirtualJoystickCustomizations {
  128961. /**
  128962. * Size of the joystick's puck
  128963. */
  128964. puckSize: number;
  128965. /**
  128966. * Size of the joystick's container
  128967. */
  128968. containerSize: number;
  128969. /**
  128970. * Color of the joystick && puck
  128971. */
  128972. color: string;
  128973. /**
  128974. * Image URL for the joystick's puck
  128975. */
  128976. puckImage?: string;
  128977. /**
  128978. * Image URL for the joystick's container
  128979. */
  128980. containerImage?: string;
  128981. /**
  128982. * Defines the unmoving position of the joystick container
  128983. */
  128984. position?: {
  128985. x: number;
  128986. y: number;
  128987. };
  128988. /**
  128989. * Defines whether or not the joystick container is always visible
  128990. */
  128991. alwaysVisible: boolean;
  128992. /**
  128993. * Defines whether or not to limit the movement of the puck to the joystick's container
  128994. */
  128995. limitToContainer: boolean;
  128996. }
  128997. /**
  128998. * Class used to define virtual joystick (used in touch mode)
  128999. */
  129000. export class VirtualJoystick {
  129001. /**
  129002. * Gets or sets a boolean indicating that left and right values must be inverted
  129003. */
  129004. reverseLeftRight: boolean;
  129005. /**
  129006. * Gets or sets a boolean indicating that up and down values must be inverted
  129007. */
  129008. reverseUpDown: boolean;
  129009. /**
  129010. * Gets the offset value for the position (ie. the change of the position value)
  129011. */
  129012. deltaPosition: Vector3;
  129013. /**
  129014. * Gets a boolean indicating if the virtual joystick was pressed
  129015. */
  129016. pressed: boolean;
  129017. /**
  129018. * Canvas the virtual joystick will render onto, default z-index of this is 5
  129019. */
  129020. static Canvas: Nullable<HTMLCanvasElement>;
  129021. /**
  129022. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  129023. */
  129024. limitToContainer: boolean;
  129025. private static _globalJoystickIndex;
  129026. private static _alwaysVisibleSticks;
  129027. private static vjCanvasContext;
  129028. private static vjCanvasWidth;
  129029. private static vjCanvasHeight;
  129030. private static halfWidth;
  129031. private static _GetDefaultOptions;
  129032. private _action;
  129033. private _axisTargetedByLeftAndRight;
  129034. private _axisTargetedByUpAndDown;
  129035. private _joystickSensibility;
  129036. private _inversedSensibility;
  129037. private _joystickPointerID;
  129038. private _joystickColor;
  129039. private _joystickPointerPos;
  129040. private _joystickPreviousPointerPos;
  129041. private _joystickPointerStartPos;
  129042. private _deltaJoystickVector;
  129043. private _leftJoystick;
  129044. private _touches;
  129045. private _joystickPosition;
  129046. private _alwaysVisible;
  129047. private _puckImage;
  129048. private _containerImage;
  129049. private _joystickPuckSize;
  129050. private _joystickContainerSize;
  129051. private _clearPuckSize;
  129052. private _clearContainerSize;
  129053. private _clearPuckSizeOffset;
  129054. private _clearContainerSizeOffset;
  129055. private _onPointerDownHandlerRef;
  129056. private _onPointerMoveHandlerRef;
  129057. private _onPointerUpHandlerRef;
  129058. private _onResize;
  129059. /**
  129060. * Creates a new virtual joystick
  129061. * @param leftJoystick defines that the joystick is for left hand (false by default)
  129062. * @param customizations Defines the options we want to customize the VirtualJoystick
  129063. */
  129064. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  129065. /**
  129066. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  129067. * @param newJoystickSensibility defines the new sensibility
  129068. */
  129069. setJoystickSensibility(newJoystickSensibility: number): void;
  129070. private _onPointerDown;
  129071. private _onPointerMove;
  129072. private _onPointerUp;
  129073. /**
  129074. * Change the color of the virtual joystick
  129075. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  129076. */
  129077. setJoystickColor(newColor: string): void;
  129078. /**
  129079. * Size of the joystick's container
  129080. */
  129081. set containerSize(newSize: number);
  129082. get containerSize(): number;
  129083. /**
  129084. * Size of the joystick's puck
  129085. */
  129086. set puckSize(newSize: number);
  129087. get puckSize(): number;
  129088. /**
  129089. * Clears the set position of the joystick
  129090. */
  129091. clearPosition(): void;
  129092. /**
  129093. * Defines whether or not the joystick container is always visible
  129094. */
  129095. set alwaysVisible(value: boolean);
  129096. get alwaysVisible(): boolean;
  129097. /**
  129098. * Sets the constant position of the Joystick container
  129099. * @param x X axis coordinate
  129100. * @param y Y axis coordinate
  129101. */
  129102. setPosition(x: number, y: number): void;
  129103. /**
  129104. * Defines a callback to call when the joystick is touched
  129105. * @param action defines the callback
  129106. */
  129107. setActionOnTouch(action: () => any): void;
  129108. /**
  129109. * Defines which axis you'd like to control for left & right
  129110. * @param axis defines the axis to use
  129111. */
  129112. setAxisForLeftRight(axis: JoystickAxis): void;
  129113. /**
  129114. * Defines which axis you'd like to control for up & down
  129115. * @param axis defines the axis to use
  129116. */
  129117. setAxisForUpDown(axis: JoystickAxis): void;
  129118. /**
  129119. * Clears the canvas from the previous puck / container draw
  129120. */
  129121. private _clearPreviousDraw;
  129122. /**
  129123. * Loads `urlPath` to be used for the container's image
  129124. * @param urlPath defines the urlPath of an image to use
  129125. */
  129126. setContainerImage(urlPath: string): void;
  129127. /**
  129128. * Loads `urlPath` to be used for the puck's image
  129129. * @param urlPath defines the urlPath of an image to use
  129130. */
  129131. setPuckImage(urlPath: string): void;
  129132. /**
  129133. * Draws the Virtual Joystick's container
  129134. */
  129135. private _drawContainer;
  129136. /**
  129137. * Draws the Virtual Joystick's puck
  129138. */
  129139. private _drawPuck;
  129140. private _drawVirtualJoystick;
  129141. /**
  129142. * Release internal HTML canvas
  129143. */
  129144. releaseCanvas(): void;
  129145. }
  129146. }
  129147. declare module BABYLON {
  129148. interface FreeCameraInputsManager {
  129149. /**
  129150. * Add virtual joystick input support to the input manager.
  129151. * @returns the current input manager
  129152. */
  129153. addVirtualJoystick(): FreeCameraInputsManager;
  129154. }
  129155. /**
  129156. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  129157. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129158. */
  129159. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  129160. /**
  129161. * Defines the camera the input is attached to.
  129162. */
  129163. camera: FreeCamera;
  129164. private _leftjoystick;
  129165. private _rightjoystick;
  129166. /**
  129167. * Gets the left stick of the virtual joystick.
  129168. * @returns The virtual Joystick
  129169. */
  129170. getLeftJoystick(): VirtualJoystick;
  129171. /**
  129172. * Gets the right stick of the virtual joystick.
  129173. * @returns The virtual Joystick
  129174. */
  129175. getRightJoystick(): VirtualJoystick;
  129176. /**
  129177. * Update the current camera state depending on the inputs that have been used this frame.
  129178. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129179. */
  129180. checkInputs(): void;
  129181. /**
  129182. * Attach the input controls to a specific dom element to get the input from.
  129183. * @param element Defines the element the controls should be listened from
  129184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129185. */
  129186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  129187. /**
  129188. * Detach the current controls from the specified dom element.
  129189. * @param element Defines the element to stop listening the inputs from
  129190. */
  129191. detachControl(element: Nullable<HTMLElement>): void;
  129192. /**
  129193. * Gets the class name of the current intput.
  129194. * @returns the class name
  129195. */
  129196. getClassName(): string;
  129197. /**
  129198. * Get the friendly name associated with the input class.
  129199. * @returns the input friendly name
  129200. */
  129201. getSimpleName(): string;
  129202. }
  129203. }
  129204. declare module BABYLON {
  129205. /**
  129206. * This represents a FPS type of camera controlled by touch.
  129207. * This is like a universal camera minus the Gamepad controls.
  129208. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129209. */
  129210. export class TouchCamera extends FreeCamera {
  129211. /**
  129212. * Defines the touch sensibility for rotation.
  129213. * The higher the faster.
  129214. */
  129215. get touchAngularSensibility(): number;
  129216. set touchAngularSensibility(value: number);
  129217. /**
  129218. * Defines the touch sensibility for move.
  129219. * The higher the faster.
  129220. */
  129221. get touchMoveSensibility(): number;
  129222. set touchMoveSensibility(value: number);
  129223. /**
  129224. * Instantiates a new touch camera.
  129225. * This represents a FPS type of camera controlled by touch.
  129226. * This is like a universal camera minus the Gamepad controls.
  129227. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129228. * @param name Define the name of the camera in the scene
  129229. * @param position Define the start position of the camera in the scene
  129230. * @param scene Define the scene the camera belongs to
  129231. */
  129232. constructor(name: string, position: Vector3, scene: Scene);
  129233. /**
  129234. * Gets the current object class name.
  129235. * @return the class name
  129236. */
  129237. getClassName(): string;
  129238. /** @hidden */
  129239. _setupInputs(): void;
  129240. }
  129241. }
  129242. declare module BABYLON {
  129243. /**
  129244. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  129245. * being tilted forward or back and left or right.
  129246. */
  129247. export class DeviceOrientationCamera extends FreeCamera {
  129248. private _initialQuaternion;
  129249. private _quaternionCache;
  129250. private _tmpDragQuaternion;
  129251. private _disablePointerInputWhenUsingDeviceOrientation;
  129252. /**
  129253. * Creates a new device orientation camera
  129254. * @param name The name of the camera
  129255. * @param position The start position camera
  129256. * @param scene The scene the camera belongs to
  129257. */
  129258. constructor(name: string, position: Vector3, scene: Scene);
  129259. /**
  129260. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  129261. */
  129262. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  129263. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  129264. private _dragFactor;
  129265. /**
  129266. * Enabled turning on the y axis when the orientation sensor is active
  129267. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  129268. */
  129269. enableHorizontalDragging(dragFactor?: number): void;
  129270. /**
  129271. * Gets the current instance class name ("DeviceOrientationCamera").
  129272. * This helps avoiding instanceof at run time.
  129273. * @returns the class name
  129274. */
  129275. getClassName(): string;
  129276. /**
  129277. * @hidden
  129278. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  129279. */
  129280. _checkInputs(): void;
  129281. /**
  129282. * Reset the camera to its default orientation on the specified axis only.
  129283. * @param axis The axis to reset
  129284. */
  129285. resetToCurrentRotation(axis?: Axis): void;
  129286. }
  129287. }
  129288. declare module BABYLON {
  129289. /**
  129290. * Defines supported buttons for XBox360 compatible gamepads
  129291. */
  129292. export enum Xbox360Button {
  129293. /** A */
  129294. A = 0,
  129295. /** B */
  129296. B = 1,
  129297. /** X */
  129298. X = 2,
  129299. /** Y */
  129300. Y = 3,
  129301. /** Left button */
  129302. LB = 4,
  129303. /** Right button */
  129304. RB = 5,
  129305. /** Back */
  129306. Back = 8,
  129307. /** Start */
  129308. Start = 9,
  129309. /** Left stick */
  129310. LeftStick = 10,
  129311. /** Right stick */
  129312. RightStick = 11
  129313. }
  129314. /** Defines values for XBox360 DPad */
  129315. export enum Xbox360Dpad {
  129316. /** Up */
  129317. Up = 12,
  129318. /** Down */
  129319. Down = 13,
  129320. /** Left */
  129321. Left = 14,
  129322. /** Right */
  129323. Right = 15
  129324. }
  129325. /**
  129326. * Defines a XBox360 gamepad
  129327. */
  129328. export class Xbox360Pad extends Gamepad {
  129329. private _leftTrigger;
  129330. private _rightTrigger;
  129331. private _onlefttriggerchanged;
  129332. private _onrighttriggerchanged;
  129333. private _onbuttondown;
  129334. private _onbuttonup;
  129335. private _ondpaddown;
  129336. private _ondpadup;
  129337. /** Observable raised when a button is pressed */
  129338. onButtonDownObservable: Observable<Xbox360Button>;
  129339. /** Observable raised when a button is released */
  129340. onButtonUpObservable: Observable<Xbox360Button>;
  129341. /** Observable raised when a pad is pressed */
  129342. onPadDownObservable: Observable<Xbox360Dpad>;
  129343. /** Observable raised when a pad is released */
  129344. onPadUpObservable: Observable<Xbox360Dpad>;
  129345. private _buttonA;
  129346. private _buttonB;
  129347. private _buttonX;
  129348. private _buttonY;
  129349. private _buttonBack;
  129350. private _buttonStart;
  129351. private _buttonLB;
  129352. private _buttonRB;
  129353. private _buttonLeftStick;
  129354. private _buttonRightStick;
  129355. private _dPadUp;
  129356. private _dPadDown;
  129357. private _dPadLeft;
  129358. private _dPadRight;
  129359. private _isXboxOnePad;
  129360. /**
  129361. * Creates a new XBox360 gamepad object
  129362. * @param id defines the id of this gamepad
  129363. * @param index defines its index
  129364. * @param gamepad defines the internal HTML gamepad object
  129365. * @param xboxOne defines if it is a XBox One gamepad
  129366. */
  129367. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  129368. /**
  129369. * Defines the callback to call when left trigger is pressed
  129370. * @param callback defines the callback to use
  129371. */
  129372. onlefttriggerchanged(callback: (value: number) => void): void;
  129373. /**
  129374. * Defines the callback to call when right trigger is pressed
  129375. * @param callback defines the callback to use
  129376. */
  129377. onrighttriggerchanged(callback: (value: number) => void): void;
  129378. /**
  129379. * Gets the left trigger value
  129380. */
  129381. get leftTrigger(): number;
  129382. /**
  129383. * Sets the left trigger value
  129384. */
  129385. set leftTrigger(newValue: number);
  129386. /**
  129387. * Gets the right trigger value
  129388. */
  129389. get rightTrigger(): number;
  129390. /**
  129391. * Sets the right trigger value
  129392. */
  129393. set rightTrigger(newValue: number);
  129394. /**
  129395. * Defines the callback to call when a button is pressed
  129396. * @param callback defines the callback to use
  129397. */
  129398. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  129399. /**
  129400. * Defines the callback to call when a button is released
  129401. * @param callback defines the callback to use
  129402. */
  129403. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  129404. /**
  129405. * Defines the callback to call when a pad is pressed
  129406. * @param callback defines the callback to use
  129407. */
  129408. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  129409. /**
  129410. * Defines the callback to call when a pad is released
  129411. * @param callback defines the callback to use
  129412. */
  129413. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  129414. private _setButtonValue;
  129415. private _setDPadValue;
  129416. /**
  129417. * Gets the value of the `A` button
  129418. */
  129419. get buttonA(): number;
  129420. /**
  129421. * Sets the value of the `A` button
  129422. */
  129423. set buttonA(value: number);
  129424. /**
  129425. * Gets the value of the `B` button
  129426. */
  129427. get buttonB(): number;
  129428. /**
  129429. * Sets the value of the `B` button
  129430. */
  129431. set buttonB(value: number);
  129432. /**
  129433. * Gets the value of the `X` button
  129434. */
  129435. get buttonX(): number;
  129436. /**
  129437. * Sets the value of the `X` button
  129438. */
  129439. set buttonX(value: number);
  129440. /**
  129441. * Gets the value of the `Y` button
  129442. */
  129443. get buttonY(): number;
  129444. /**
  129445. * Sets the value of the `Y` button
  129446. */
  129447. set buttonY(value: number);
  129448. /**
  129449. * Gets the value of the `Start` button
  129450. */
  129451. get buttonStart(): number;
  129452. /**
  129453. * Sets the value of the `Start` button
  129454. */
  129455. set buttonStart(value: number);
  129456. /**
  129457. * Gets the value of the `Back` button
  129458. */
  129459. get buttonBack(): number;
  129460. /**
  129461. * Sets the value of the `Back` button
  129462. */
  129463. set buttonBack(value: number);
  129464. /**
  129465. * Gets the value of the `Left` button
  129466. */
  129467. get buttonLB(): number;
  129468. /**
  129469. * Sets the value of the `Left` button
  129470. */
  129471. set buttonLB(value: number);
  129472. /**
  129473. * Gets the value of the `Right` button
  129474. */
  129475. get buttonRB(): number;
  129476. /**
  129477. * Sets the value of the `Right` button
  129478. */
  129479. set buttonRB(value: number);
  129480. /**
  129481. * Gets the value of the Left joystick
  129482. */
  129483. get buttonLeftStick(): number;
  129484. /**
  129485. * Sets the value of the Left joystick
  129486. */
  129487. set buttonLeftStick(value: number);
  129488. /**
  129489. * Gets the value of the Right joystick
  129490. */
  129491. get buttonRightStick(): number;
  129492. /**
  129493. * Sets the value of the Right joystick
  129494. */
  129495. set buttonRightStick(value: number);
  129496. /**
  129497. * Gets the value of D-pad up
  129498. */
  129499. get dPadUp(): number;
  129500. /**
  129501. * Sets the value of D-pad up
  129502. */
  129503. set dPadUp(value: number);
  129504. /**
  129505. * Gets the value of D-pad down
  129506. */
  129507. get dPadDown(): number;
  129508. /**
  129509. * Sets the value of D-pad down
  129510. */
  129511. set dPadDown(value: number);
  129512. /**
  129513. * Gets the value of D-pad left
  129514. */
  129515. get dPadLeft(): number;
  129516. /**
  129517. * Sets the value of D-pad left
  129518. */
  129519. set dPadLeft(value: number);
  129520. /**
  129521. * Gets the value of D-pad right
  129522. */
  129523. get dPadRight(): number;
  129524. /**
  129525. * Sets the value of D-pad right
  129526. */
  129527. set dPadRight(value: number);
  129528. /**
  129529. * Force the gamepad to synchronize with device values
  129530. */
  129531. update(): void;
  129532. /**
  129533. * Disposes the gamepad
  129534. */
  129535. dispose(): void;
  129536. }
  129537. }
  129538. declare module BABYLON {
  129539. /**
  129540. * Defines supported buttons for DualShock compatible gamepads
  129541. */
  129542. export enum DualShockButton {
  129543. /** Cross */
  129544. Cross = 0,
  129545. /** Circle */
  129546. Circle = 1,
  129547. /** Square */
  129548. Square = 2,
  129549. /** Triangle */
  129550. Triangle = 3,
  129551. /** L1 */
  129552. L1 = 4,
  129553. /** R1 */
  129554. R1 = 5,
  129555. /** Share */
  129556. Share = 8,
  129557. /** Options */
  129558. Options = 9,
  129559. /** Left stick */
  129560. LeftStick = 10,
  129561. /** Right stick */
  129562. RightStick = 11
  129563. }
  129564. /** Defines values for DualShock DPad */
  129565. export enum DualShockDpad {
  129566. /** Up */
  129567. Up = 12,
  129568. /** Down */
  129569. Down = 13,
  129570. /** Left */
  129571. Left = 14,
  129572. /** Right */
  129573. Right = 15
  129574. }
  129575. /**
  129576. * Defines a DualShock gamepad
  129577. */
  129578. export class DualShockPad extends Gamepad {
  129579. private _leftTrigger;
  129580. private _rightTrigger;
  129581. private _onlefttriggerchanged;
  129582. private _onrighttriggerchanged;
  129583. private _onbuttondown;
  129584. private _onbuttonup;
  129585. private _ondpaddown;
  129586. private _ondpadup;
  129587. /** Observable raised when a button is pressed */
  129588. onButtonDownObservable: Observable<DualShockButton>;
  129589. /** Observable raised when a button is released */
  129590. onButtonUpObservable: Observable<DualShockButton>;
  129591. /** Observable raised when a pad is pressed */
  129592. onPadDownObservable: Observable<DualShockDpad>;
  129593. /** Observable raised when a pad is released */
  129594. onPadUpObservable: Observable<DualShockDpad>;
  129595. private _buttonCross;
  129596. private _buttonCircle;
  129597. private _buttonSquare;
  129598. private _buttonTriangle;
  129599. private _buttonShare;
  129600. private _buttonOptions;
  129601. private _buttonL1;
  129602. private _buttonR1;
  129603. private _buttonLeftStick;
  129604. private _buttonRightStick;
  129605. private _dPadUp;
  129606. private _dPadDown;
  129607. private _dPadLeft;
  129608. private _dPadRight;
  129609. /**
  129610. * Creates a new DualShock gamepad object
  129611. * @param id defines the id of this gamepad
  129612. * @param index defines its index
  129613. * @param gamepad defines the internal HTML gamepad object
  129614. */
  129615. constructor(id: string, index: number, gamepad: any);
  129616. /**
  129617. * Defines the callback to call when left trigger is pressed
  129618. * @param callback defines the callback to use
  129619. */
  129620. onlefttriggerchanged(callback: (value: number) => void): void;
  129621. /**
  129622. * Defines the callback to call when right trigger is pressed
  129623. * @param callback defines the callback to use
  129624. */
  129625. onrighttriggerchanged(callback: (value: number) => void): void;
  129626. /**
  129627. * Gets the left trigger value
  129628. */
  129629. get leftTrigger(): number;
  129630. /**
  129631. * Sets the left trigger value
  129632. */
  129633. set leftTrigger(newValue: number);
  129634. /**
  129635. * Gets the right trigger value
  129636. */
  129637. get rightTrigger(): number;
  129638. /**
  129639. * Sets the right trigger value
  129640. */
  129641. set rightTrigger(newValue: number);
  129642. /**
  129643. * Defines the callback to call when a button is pressed
  129644. * @param callback defines the callback to use
  129645. */
  129646. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  129647. /**
  129648. * Defines the callback to call when a button is released
  129649. * @param callback defines the callback to use
  129650. */
  129651. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  129652. /**
  129653. * Defines the callback to call when a pad is pressed
  129654. * @param callback defines the callback to use
  129655. */
  129656. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  129657. /**
  129658. * Defines the callback to call when a pad is released
  129659. * @param callback defines the callback to use
  129660. */
  129661. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  129662. private _setButtonValue;
  129663. private _setDPadValue;
  129664. /**
  129665. * Gets the value of the `Cross` button
  129666. */
  129667. get buttonCross(): number;
  129668. /**
  129669. * Sets the value of the `Cross` button
  129670. */
  129671. set buttonCross(value: number);
  129672. /**
  129673. * Gets the value of the `Circle` button
  129674. */
  129675. get buttonCircle(): number;
  129676. /**
  129677. * Sets the value of the `Circle` button
  129678. */
  129679. set buttonCircle(value: number);
  129680. /**
  129681. * Gets the value of the `Square` button
  129682. */
  129683. get buttonSquare(): number;
  129684. /**
  129685. * Sets the value of the `Square` button
  129686. */
  129687. set buttonSquare(value: number);
  129688. /**
  129689. * Gets the value of the `Triangle` button
  129690. */
  129691. get buttonTriangle(): number;
  129692. /**
  129693. * Sets the value of the `Triangle` button
  129694. */
  129695. set buttonTriangle(value: number);
  129696. /**
  129697. * Gets the value of the `Options` button
  129698. */
  129699. get buttonOptions(): number;
  129700. /**
  129701. * Sets the value of the `Options` button
  129702. */
  129703. set buttonOptions(value: number);
  129704. /**
  129705. * Gets the value of the `Share` button
  129706. */
  129707. get buttonShare(): number;
  129708. /**
  129709. * Sets the value of the `Share` button
  129710. */
  129711. set buttonShare(value: number);
  129712. /**
  129713. * Gets the value of the `L1` button
  129714. */
  129715. get buttonL1(): number;
  129716. /**
  129717. * Sets the value of the `L1` button
  129718. */
  129719. set buttonL1(value: number);
  129720. /**
  129721. * Gets the value of the `R1` button
  129722. */
  129723. get buttonR1(): number;
  129724. /**
  129725. * Sets the value of the `R1` button
  129726. */
  129727. set buttonR1(value: number);
  129728. /**
  129729. * Gets the value of the Left joystick
  129730. */
  129731. get buttonLeftStick(): number;
  129732. /**
  129733. * Sets the value of the Left joystick
  129734. */
  129735. set buttonLeftStick(value: number);
  129736. /**
  129737. * Gets the value of the Right joystick
  129738. */
  129739. get buttonRightStick(): number;
  129740. /**
  129741. * Sets the value of the Right joystick
  129742. */
  129743. set buttonRightStick(value: number);
  129744. /**
  129745. * Gets the value of D-pad up
  129746. */
  129747. get dPadUp(): number;
  129748. /**
  129749. * Sets the value of D-pad up
  129750. */
  129751. set dPadUp(value: number);
  129752. /**
  129753. * Gets the value of D-pad down
  129754. */
  129755. get dPadDown(): number;
  129756. /**
  129757. * Sets the value of D-pad down
  129758. */
  129759. set dPadDown(value: number);
  129760. /**
  129761. * Gets the value of D-pad left
  129762. */
  129763. get dPadLeft(): number;
  129764. /**
  129765. * Sets the value of D-pad left
  129766. */
  129767. set dPadLeft(value: number);
  129768. /**
  129769. * Gets the value of D-pad right
  129770. */
  129771. get dPadRight(): number;
  129772. /**
  129773. * Sets the value of D-pad right
  129774. */
  129775. set dPadRight(value: number);
  129776. /**
  129777. * Force the gamepad to synchronize with device values
  129778. */
  129779. update(): void;
  129780. /**
  129781. * Disposes the gamepad
  129782. */
  129783. dispose(): void;
  129784. }
  129785. }
  129786. declare module BABYLON {
  129787. /**
  129788. * Manager for handling gamepads
  129789. */
  129790. export class GamepadManager {
  129791. private _scene?;
  129792. private _babylonGamepads;
  129793. private _oneGamepadConnected;
  129794. /** @hidden */
  129795. _isMonitoring: boolean;
  129796. private _gamepadEventSupported;
  129797. private _gamepadSupport?;
  129798. /**
  129799. * observable to be triggered when the gamepad controller has been connected
  129800. */
  129801. onGamepadConnectedObservable: Observable<Gamepad>;
  129802. /**
  129803. * observable to be triggered when the gamepad controller has been disconnected
  129804. */
  129805. onGamepadDisconnectedObservable: Observable<Gamepad>;
  129806. private _onGamepadConnectedEvent;
  129807. private _onGamepadDisconnectedEvent;
  129808. /**
  129809. * Initializes the gamepad manager
  129810. * @param _scene BabylonJS scene
  129811. */
  129812. constructor(_scene?: Scene | undefined);
  129813. /**
  129814. * The gamepads in the game pad manager
  129815. */
  129816. get gamepads(): Gamepad[];
  129817. /**
  129818. * Get the gamepad controllers based on type
  129819. * @param type The type of gamepad controller
  129820. * @returns Nullable gamepad
  129821. */
  129822. getGamepadByType(type?: number): Nullable<Gamepad>;
  129823. /**
  129824. * Disposes the gamepad manager
  129825. */
  129826. dispose(): void;
  129827. private _addNewGamepad;
  129828. private _startMonitoringGamepads;
  129829. private _stopMonitoringGamepads;
  129830. /** @hidden */
  129831. _checkGamepadsStatus(): void;
  129832. private _updateGamepadObjects;
  129833. }
  129834. }
  129835. declare module BABYLON {
  129836. interface Scene {
  129837. /** @hidden */
  129838. _gamepadManager: Nullable<GamepadManager>;
  129839. /**
  129840. * Gets the gamepad manager associated with the scene
  129841. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  129842. */
  129843. gamepadManager: GamepadManager;
  129844. }
  129845. /**
  129846. * Interface representing a free camera inputs manager
  129847. */
  129848. interface FreeCameraInputsManager {
  129849. /**
  129850. * Adds gamepad input support to the FreeCameraInputsManager.
  129851. * @returns the FreeCameraInputsManager
  129852. */
  129853. addGamepad(): FreeCameraInputsManager;
  129854. }
  129855. /**
  129856. * Interface representing an arc rotate camera inputs manager
  129857. */
  129858. interface ArcRotateCameraInputsManager {
  129859. /**
  129860. * Adds gamepad input support to the ArcRotateCamera InputManager.
  129861. * @returns the camera inputs manager
  129862. */
  129863. addGamepad(): ArcRotateCameraInputsManager;
  129864. }
  129865. /**
  129866. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  129867. */
  129868. export class GamepadSystemSceneComponent implements ISceneComponent {
  129869. /**
  129870. * The component name helpfull to identify the component in the list of scene components.
  129871. */
  129872. readonly name: string;
  129873. /**
  129874. * The scene the component belongs to.
  129875. */
  129876. scene: Scene;
  129877. /**
  129878. * Creates a new instance of the component for the given scene
  129879. * @param scene Defines the scene to register the component in
  129880. */
  129881. constructor(scene: Scene);
  129882. /**
  129883. * Registers the component in a given scene
  129884. */
  129885. register(): void;
  129886. /**
  129887. * Rebuilds the elements related to this component in case of
  129888. * context lost for instance.
  129889. */
  129890. rebuild(): void;
  129891. /**
  129892. * Disposes the component and the associated ressources
  129893. */
  129894. dispose(): void;
  129895. private _beforeCameraUpdate;
  129896. }
  129897. }
  129898. declare module BABYLON {
  129899. /**
  129900. * 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,
  129901. * which still works and will still be found in many Playgrounds.
  129902. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129903. */
  129904. export class UniversalCamera extends TouchCamera {
  129905. /**
  129906. * Defines the gamepad rotation sensiblity.
  129907. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  129908. */
  129909. get gamepadAngularSensibility(): number;
  129910. set gamepadAngularSensibility(value: number);
  129911. /**
  129912. * Defines the gamepad move sensiblity.
  129913. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  129914. */
  129915. get gamepadMoveSensibility(): number;
  129916. set gamepadMoveSensibility(value: number);
  129917. /**
  129918. * 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,
  129919. * which still works and will still be found in many Playgrounds.
  129920. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129921. * @param name Define the name of the camera in the scene
  129922. * @param position Define the start position of the camera in the scene
  129923. * @param scene Define the scene the camera belongs to
  129924. */
  129925. constructor(name: string, position: Vector3, scene: Scene);
  129926. /**
  129927. * Gets the current object class name.
  129928. * @return the class name
  129929. */
  129930. getClassName(): string;
  129931. }
  129932. }
  129933. declare module BABYLON {
  129934. /**
  129935. * This represents a FPS type of camera. This is only here for back compat purpose.
  129936. * Please use the UniversalCamera instead as both are identical.
  129937. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129938. */
  129939. export class GamepadCamera extends UniversalCamera {
  129940. /**
  129941. * Instantiates a new Gamepad Camera
  129942. * This represents a FPS type of camera. This is only here for back compat purpose.
  129943. * Please use the UniversalCamera instead as both are identical.
  129944. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129945. * @param name Define the name of the camera in the scene
  129946. * @param position Define the start position of the camera in the scene
  129947. * @param scene Define the scene the camera belongs to
  129948. */
  129949. constructor(name: string, position: Vector3, scene: Scene);
  129950. /**
  129951. * Gets the current object class name.
  129952. * @return the class name
  129953. */
  129954. getClassName(): string;
  129955. }
  129956. }
  129957. declare module BABYLON {
  129958. /** @hidden */
  129959. export var passPixelShader: {
  129960. name: string;
  129961. shader: string;
  129962. };
  129963. }
  129964. declare module BABYLON {
  129965. /** @hidden */
  129966. export var passCubePixelShader: {
  129967. name: string;
  129968. shader: string;
  129969. };
  129970. }
  129971. declare module BABYLON {
  129972. /**
  129973. * PassPostProcess which produces an output the same as it's input
  129974. */
  129975. export class PassPostProcess extends PostProcess {
  129976. /**
  129977. * Gets a string identifying the name of the class
  129978. * @returns "PassPostProcess" string
  129979. */
  129980. getClassName(): string;
  129981. /**
  129982. * Creates the PassPostProcess
  129983. * @param name The name of the effect.
  129984. * @param options The required width/height ratio to downsize to before computing the render pass.
  129985. * @param camera The camera to apply the render pass to.
  129986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129987. * @param engine The engine which the post process will be applied. (default: current engine)
  129988. * @param reusable If the post process can be reused on the same frame. (default: false)
  129989. * @param textureType The type of texture to be used when performing the post processing.
  129990. * @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)
  129991. */
  129992. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129993. /** @hidden */
  129994. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  129995. }
  129996. /**
  129997. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  129998. */
  129999. export class PassCubePostProcess extends PostProcess {
  130000. private _face;
  130001. /**
  130002. * Gets or sets the cube face to display.
  130003. * * 0 is +X
  130004. * * 1 is -X
  130005. * * 2 is +Y
  130006. * * 3 is -Y
  130007. * * 4 is +Z
  130008. * * 5 is -Z
  130009. */
  130010. get face(): number;
  130011. set face(value: number);
  130012. /**
  130013. * Gets a string identifying the name of the class
  130014. * @returns "PassCubePostProcess" string
  130015. */
  130016. getClassName(): string;
  130017. /**
  130018. * Creates the PassCubePostProcess
  130019. * @param name The name of the effect.
  130020. * @param options The required width/height ratio to downsize to before computing the render pass.
  130021. * @param camera The camera to apply the render pass to.
  130022. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130023. * @param engine The engine which the post process will be applied. (default: current engine)
  130024. * @param reusable If the post process can be reused on the same frame. (default: false)
  130025. * @param textureType The type of texture to be used when performing the post processing.
  130026. * @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)
  130027. */
  130028. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130029. /** @hidden */
  130030. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  130031. }
  130032. }
  130033. declare module BABYLON {
  130034. /** @hidden */
  130035. export var anaglyphPixelShader: {
  130036. name: string;
  130037. shader: string;
  130038. };
  130039. }
  130040. declare module BABYLON {
  130041. /**
  130042. * Postprocess used to generate anaglyphic rendering
  130043. */
  130044. export class AnaglyphPostProcess extends PostProcess {
  130045. private _passedProcess;
  130046. /**
  130047. * Gets a string identifying the name of the class
  130048. * @returns "AnaglyphPostProcess" string
  130049. */
  130050. getClassName(): string;
  130051. /**
  130052. * Creates a new AnaglyphPostProcess
  130053. * @param name defines postprocess name
  130054. * @param options defines creation options or target ratio scale
  130055. * @param rigCameras defines cameras using this postprocess
  130056. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  130057. * @param engine defines hosting engine
  130058. * @param reusable defines if the postprocess will be reused multiple times per frame
  130059. */
  130060. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  130061. }
  130062. }
  130063. declare module BABYLON {
  130064. /**
  130065. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  130066. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130067. */
  130068. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  130069. /**
  130070. * Creates a new AnaglyphArcRotateCamera
  130071. * @param name defines camera name
  130072. * @param alpha defines alpha angle (in radians)
  130073. * @param beta defines beta angle (in radians)
  130074. * @param radius defines radius
  130075. * @param target defines camera target
  130076. * @param interaxialDistance defines distance between each color axis
  130077. * @param scene defines the hosting scene
  130078. */
  130079. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  130080. /**
  130081. * Gets camera class name
  130082. * @returns AnaglyphArcRotateCamera
  130083. */
  130084. getClassName(): string;
  130085. }
  130086. }
  130087. declare module BABYLON {
  130088. /**
  130089. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  130090. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130091. */
  130092. export class AnaglyphFreeCamera extends FreeCamera {
  130093. /**
  130094. * Creates a new AnaglyphFreeCamera
  130095. * @param name defines camera name
  130096. * @param position defines initial position
  130097. * @param interaxialDistance defines distance between each color axis
  130098. * @param scene defines the hosting scene
  130099. */
  130100. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130101. /**
  130102. * Gets camera class name
  130103. * @returns AnaglyphFreeCamera
  130104. */
  130105. getClassName(): string;
  130106. }
  130107. }
  130108. declare module BABYLON {
  130109. /**
  130110. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  130111. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130112. */
  130113. export class AnaglyphGamepadCamera extends GamepadCamera {
  130114. /**
  130115. * Creates a new AnaglyphGamepadCamera
  130116. * @param name defines camera name
  130117. * @param position defines initial position
  130118. * @param interaxialDistance defines distance between each color axis
  130119. * @param scene defines the hosting scene
  130120. */
  130121. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130122. /**
  130123. * Gets camera class name
  130124. * @returns AnaglyphGamepadCamera
  130125. */
  130126. getClassName(): string;
  130127. }
  130128. }
  130129. declare module BABYLON {
  130130. /**
  130131. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  130132. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130133. */
  130134. export class AnaglyphUniversalCamera extends UniversalCamera {
  130135. /**
  130136. * Creates a new AnaglyphUniversalCamera
  130137. * @param name defines camera name
  130138. * @param position defines initial position
  130139. * @param interaxialDistance defines distance between each color axis
  130140. * @param scene defines the hosting scene
  130141. */
  130142. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130143. /**
  130144. * Gets camera class name
  130145. * @returns AnaglyphUniversalCamera
  130146. */
  130147. getClassName(): string;
  130148. }
  130149. }
  130150. declare module BABYLON {
  130151. /**
  130152. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  130153. * @see https://doc.babylonjs.com/features/cameras
  130154. */
  130155. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  130156. /**
  130157. * Creates a new StereoscopicArcRotateCamera
  130158. * @param name defines camera name
  130159. * @param alpha defines alpha angle (in radians)
  130160. * @param beta defines beta angle (in radians)
  130161. * @param radius defines radius
  130162. * @param target defines camera target
  130163. * @param interaxialDistance defines distance between each color axis
  130164. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130165. * @param scene defines the hosting scene
  130166. */
  130167. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130168. /**
  130169. * Gets camera class name
  130170. * @returns StereoscopicArcRotateCamera
  130171. */
  130172. getClassName(): string;
  130173. }
  130174. }
  130175. declare module BABYLON {
  130176. /**
  130177. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  130178. * @see https://doc.babylonjs.com/features/cameras
  130179. */
  130180. export class StereoscopicFreeCamera extends FreeCamera {
  130181. /**
  130182. * Creates a new StereoscopicFreeCamera
  130183. * @param name defines camera name
  130184. * @param position defines initial position
  130185. * @param interaxialDistance defines distance between each color axis
  130186. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130187. * @param scene defines the hosting scene
  130188. */
  130189. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130190. /**
  130191. * Gets camera class name
  130192. * @returns StereoscopicFreeCamera
  130193. */
  130194. getClassName(): string;
  130195. }
  130196. }
  130197. declare module BABYLON {
  130198. /**
  130199. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  130200. * @see https://doc.babylonjs.com/features/cameras
  130201. */
  130202. export class StereoscopicGamepadCamera extends GamepadCamera {
  130203. /**
  130204. * Creates a new StereoscopicGamepadCamera
  130205. * @param name defines camera name
  130206. * @param position defines initial position
  130207. * @param interaxialDistance defines distance between each color axis
  130208. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130209. * @param scene defines the hosting scene
  130210. */
  130211. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130212. /**
  130213. * Gets camera class name
  130214. * @returns StereoscopicGamepadCamera
  130215. */
  130216. getClassName(): string;
  130217. }
  130218. }
  130219. declare module BABYLON {
  130220. /**
  130221. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  130222. * @see https://doc.babylonjs.com/features/cameras
  130223. */
  130224. export class StereoscopicUniversalCamera extends UniversalCamera {
  130225. /**
  130226. * Creates a new StereoscopicUniversalCamera
  130227. * @param name defines camera name
  130228. * @param position defines initial position
  130229. * @param interaxialDistance defines distance between each color axis
  130230. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130231. * @param scene defines the hosting scene
  130232. */
  130233. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130234. /**
  130235. * Gets camera class name
  130236. * @returns StereoscopicUniversalCamera
  130237. */
  130238. getClassName(): string;
  130239. }
  130240. }
  130241. declare module BABYLON {
  130242. /**
  130243. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  130244. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  130245. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  130246. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  130247. */
  130248. export class VirtualJoysticksCamera extends FreeCamera {
  130249. /**
  130250. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  130251. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  130252. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  130253. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  130254. * @param name Define the name of the camera in the scene
  130255. * @param position Define the start position of the camera in the scene
  130256. * @param scene Define the scene the camera belongs to
  130257. */
  130258. constructor(name: string, position: Vector3, scene: Scene);
  130259. /**
  130260. * Gets the current object class name.
  130261. * @return the class name
  130262. */
  130263. getClassName(): string;
  130264. }
  130265. }
  130266. declare module BABYLON {
  130267. /**
  130268. * This represents all the required metrics to create a VR camera.
  130269. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  130270. */
  130271. export class VRCameraMetrics {
  130272. /**
  130273. * Define the horizontal resolution off the screen.
  130274. */
  130275. hResolution: number;
  130276. /**
  130277. * Define the vertical resolution off the screen.
  130278. */
  130279. vResolution: number;
  130280. /**
  130281. * Define the horizontal screen size.
  130282. */
  130283. hScreenSize: number;
  130284. /**
  130285. * Define the vertical screen size.
  130286. */
  130287. vScreenSize: number;
  130288. /**
  130289. * Define the vertical screen center position.
  130290. */
  130291. vScreenCenter: number;
  130292. /**
  130293. * Define the distance of the eyes to the screen.
  130294. */
  130295. eyeToScreenDistance: number;
  130296. /**
  130297. * Define the distance between both lenses
  130298. */
  130299. lensSeparationDistance: number;
  130300. /**
  130301. * Define the distance between both viewer's eyes.
  130302. */
  130303. interpupillaryDistance: number;
  130304. /**
  130305. * Define the distortion factor of the VR postprocess.
  130306. * Please, touch with care.
  130307. */
  130308. distortionK: number[];
  130309. /**
  130310. * Define the chromatic aberration correction factors for the VR post process.
  130311. */
  130312. chromaAbCorrection: number[];
  130313. /**
  130314. * Define the scale factor of the post process.
  130315. * The smaller the better but the slower.
  130316. */
  130317. postProcessScaleFactor: number;
  130318. /**
  130319. * Define an offset for the lens center.
  130320. */
  130321. lensCenterOffset: number;
  130322. /**
  130323. * Define if the current vr camera should compensate the distortion of the lense or not.
  130324. */
  130325. compensateDistortion: boolean;
  130326. /**
  130327. * Defines if multiview should be enabled when rendering (Default: false)
  130328. */
  130329. multiviewEnabled: boolean;
  130330. /**
  130331. * Gets the rendering aspect ratio based on the provided resolutions.
  130332. */
  130333. get aspectRatio(): number;
  130334. /**
  130335. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  130336. */
  130337. get aspectRatioFov(): number;
  130338. /**
  130339. * @hidden
  130340. */
  130341. get leftHMatrix(): Matrix;
  130342. /**
  130343. * @hidden
  130344. */
  130345. get rightHMatrix(): Matrix;
  130346. /**
  130347. * @hidden
  130348. */
  130349. get leftPreViewMatrix(): Matrix;
  130350. /**
  130351. * @hidden
  130352. */
  130353. get rightPreViewMatrix(): Matrix;
  130354. /**
  130355. * Get the default VRMetrics based on the most generic setup.
  130356. * @returns the default vr metrics
  130357. */
  130358. static GetDefault(): VRCameraMetrics;
  130359. }
  130360. }
  130361. declare module BABYLON {
  130362. /** @hidden */
  130363. export var vrDistortionCorrectionPixelShader: {
  130364. name: string;
  130365. shader: string;
  130366. };
  130367. }
  130368. declare module BABYLON {
  130369. /**
  130370. * VRDistortionCorrectionPostProcess used for mobile VR
  130371. */
  130372. export class VRDistortionCorrectionPostProcess extends PostProcess {
  130373. private _isRightEye;
  130374. private _distortionFactors;
  130375. private _postProcessScaleFactor;
  130376. private _lensCenterOffset;
  130377. private _scaleIn;
  130378. private _scaleFactor;
  130379. private _lensCenter;
  130380. /**
  130381. * Gets a string identifying the name of the class
  130382. * @returns "VRDistortionCorrectionPostProcess" string
  130383. */
  130384. getClassName(): string;
  130385. /**
  130386. * Initializes the VRDistortionCorrectionPostProcess
  130387. * @param name The name of the effect.
  130388. * @param camera The camera to apply the render pass to.
  130389. * @param isRightEye If this is for the right eye distortion
  130390. * @param vrMetrics All the required metrics for the VR camera
  130391. */
  130392. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  130393. }
  130394. }
  130395. declare module BABYLON {
  130396. /**
  130397. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  130398. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130399. */
  130400. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  130401. /**
  130402. * Creates a new VRDeviceOrientationArcRotateCamera
  130403. * @param name defines camera name
  130404. * @param alpha defines the camera rotation along the logitudinal axis
  130405. * @param beta defines the camera rotation along the latitudinal axis
  130406. * @param radius defines the camera distance from its target
  130407. * @param target defines the camera target
  130408. * @param scene defines the scene the camera belongs to
  130409. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130410. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130411. */
  130412. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130413. /**
  130414. * Gets camera class name
  130415. * @returns VRDeviceOrientationArcRotateCamera
  130416. */
  130417. getClassName(): string;
  130418. }
  130419. }
  130420. declare module BABYLON {
  130421. /**
  130422. * Camera used to simulate VR rendering (based on FreeCamera)
  130423. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130424. */
  130425. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  130426. /**
  130427. * Creates a new VRDeviceOrientationFreeCamera
  130428. * @param name defines camera name
  130429. * @param position defines the start position of the camera
  130430. * @param scene defines the scene the camera belongs to
  130431. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130432. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130433. */
  130434. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130435. /**
  130436. * Gets camera class name
  130437. * @returns VRDeviceOrientationFreeCamera
  130438. */
  130439. getClassName(): string;
  130440. }
  130441. }
  130442. declare module BABYLON {
  130443. /**
  130444. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  130445. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130446. */
  130447. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  130448. /**
  130449. * Creates a new VRDeviceOrientationGamepadCamera
  130450. * @param name defines camera name
  130451. * @param position defines the start position of the camera
  130452. * @param scene defines the scene the camera belongs to
  130453. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130454. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130455. */
  130456. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130457. /**
  130458. * Gets camera class name
  130459. * @returns VRDeviceOrientationGamepadCamera
  130460. */
  130461. getClassName(): string;
  130462. }
  130463. }
  130464. declare module BABYLON {
  130465. /**
  130466. * A class extending Texture allowing drawing on a texture
  130467. * @see https://doc.babylonjs.com/how_to/dynamictexture
  130468. */
  130469. export class DynamicTexture extends Texture {
  130470. private _generateMipMaps;
  130471. private _canvas;
  130472. private _context;
  130473. /**
  130474. * Creates a DynamicTexture
  130475. * @param name defines the name of the texture
  130476. * @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
  130477. * @param scene defines the scene where you want the texture
  130478. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  130479. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130480. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  130481. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  130482. */
  130483. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  130484. /**
  130485. * Get the current class name of the texture useful for serialization or dynamic coding.
  130486. * @returns "DynamicTexture"
  130487. */
  130488. getClassName(): string;
  130489. /**
  130490. * Gets the current state of canRescale
  130491. */
  130492. get canRescale(): boolean;
  130493. private _recreate;
  130494. /**
  130495. * Scales the texture
  130496. * @param ratio the scale factor to apply to both width and height
  130497. */
  130498. scale(ratio: number): void;
  130499. /**
  130500. * Resizes the texture
  130501. * @param width the new width
  130502. * @param height the new height
  130503. */
  130504. scaleTo(width: number, height: number): void;
  130505. /**
  130506. * Gets the context of the canvas used by the texture
  130507. * @returns the canvas context of the dynamic texture
  130508. */
  130509. getContext(): CanvasRenderingContext2D;
  130510. /**
  130511. * Clears the texture
  130512. */
  130513. clear(): void;
  130514. /**
  130515. * Updates the texture
  130516. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  130517. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  130518. */
  130519. update(invertY?: boolean, premulAlpha?: boolean): void;
  130520. /**
  130521. * Draws text onto the texture
  130522. * @param text defines the text to be drawn
  130523. * @param x defines the placement of the text from the left
  130524. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  130525. * @param font defines the font to be used with font-style, font-size, font-name
  130526. * @param color defines the color used for the text
  130527. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  130528. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  130529. * @param update defines whether texture is immediately update (default is true)
  130530. */
  130531. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  130532. /**
  130533. * Clones the texture
  130534. * @returns the clone of the texture.
  130535. */
  130536. clone(): DynamicTexture;
  130537. /**
  130538. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  130539. * @returns a serialized dynamic texture object
  130540. */
  130541. serialize(): any;
  130542. private _IsCanvasElement;
  130543. /** @hidden */
  130544. _rebuild(): void;
  130545. }
  130546. }
  130547. declare module BABYLON {
  130548. /**
  130549. * Class containing static functions to help procedurally build meshes
  130550. */
  130551. export class GroundBuilder {
  130552. /**
  130553. * Creates a ground mesh
  130554. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  130555. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  130556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130557. * @param name defines the name of the mesh
  130558. * @param options defines the options used to create the mesh
  130559. * @param scene defines the hosting scene
  130560. * @returns the ground mesh
  130561. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  130562. */
  130563. static CreateGround(name: string, options: {
  130564. width?: number;
  130565. height?: number;
  130566. subdivisions?: number;
  130567. subdivisionsX?: number;
  130568. subdivisionsY?: number;
  130569. updatable?: boolean;
  130570. }, scene: any): Mesh;
  130571. /**
  130572. * Creates a tiled ground mesh
  130573. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  130574. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  130575. * * 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
  130576. * * 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
  130577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130578. * @param name defines the name of the mesh
  130579. * @param options defines the options used to create the mesh
  130580. * @param scene defines the hosting scene
  130581. * @returns the tiled ground mesh
  130582. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  130583. */
  130584. static CreateTiledGround(name: string, options: {
  130585. xmin: number;
  130586. zmin: number;
  130587. xmax: number;
  130588. zmax: number;
  130589. subdivisions?: {
  130590. w: number;
  130591. h: number;
  130592. };
  130593. precision?: {
  130594. w: number;
  130595. h: number;
  130596. };
  130597. updatable?: boolean;
  130598. }, scene?: Nullable<Scene>): Mesh;
  130599. /**
  130600. * Creates a ground mesh from a height map
  130601. * * The parameter `url` sets the URL of the height map image resource.
  130602. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  130603. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  130604. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  130605. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  130606. * * 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.
  130607. * * 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).
  130608. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  130609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130610. * @param name defines the name of the mesh
  130611. * @param url defines the url to the height map
  130612. * @param options defines the options used to create the mesh
  130613. * @param scene defines the hosting scene
  130614. * @returns the ground mesh
  130615. * @see https://doc.babylonjs.com/babylon101/height_map
  130616. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  130617. */
  130618. static CreateGroundFromHeightMap(name: string, url: string, options: {
  130619. width?: number;
  130620. height?: number;
  130621. subdivisions?: number;
  130622. minHeight?: number;
  130623. maxHeight?: number;
  130624. colorFilter?: Color3;
  130625. alphaFilter?: number;
  130626. updatable?: boolean;
  130627. onReady?: (mesh: GroundMesh) => void;
  130628. }, scene?: Nullable<Scene>): GroundMesh;
  130629. }
  130630. }
  130631. declare module BABYLON {
  130632. /**
  130633. * Class containing static functions to help procedurally build meshes
  130634. */
  130635. export class TorusBuilder {
  130636. /**
  130637. * Creates a torus mesh
  130638. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  130639. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  130640. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  130641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130642. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130644. * @param name defines the name of the mesh
  130645. * @param options defines the options used to create the mesh
  130646. * @param scene defines the hosting scene
  130647. * @returns the torus mesh
  130648. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  130649. */
  130650. static CreateTorus(name: string, options: {
  130651. diameter?: number;
  130652. thickness?: number;
  130653. tessellation?: number;
  130654. updatable?: boolean;
  130655. sideOrientation?: number;
  130656. frontUVs?: Vector4;
  130657. backUVs?: Vector4;
  130658. }, scene: any): Mesh;
  130659. }
  130660. }
  130661. declare module BABYLON {
  130662. /**
  130663. * Class containing static functions to help procedurally build meshes
  130664. */
  130665. export class CylinderBuilder {
  130666. /**
  130667. * Creates a cylinder or a cone mesh
  130668. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  130669. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  130670. * * 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.
  130671. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  130672. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  130673. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  130674. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  130675. * * 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).
  130676. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  130677. * * 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).
  130678. * * 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
  130679. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  130680. * * 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
  130681. * * 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.
  130682. * * If `enclose` is false, a ring surface is one element.
  130683. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  130684. * * 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
  130685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130686. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130688. * @param name defines the name of the mesh
  130689. * @param options defines the options used to create the mesh
  130690. * @param scene defines the hosting scene
  130691. * @returns the cylinder mesh
  130692. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  130693. */
  130694. static CreateCylinder(name: string, options: {
  130695. height?: number;
  130696. diameterTop?: number;
  130697. diameterBottom?: number;
  130698. diameter?: number;
  130699. tessellation?: number;
  130700. subdivisions?: number;
  130701. arc?: number;
  130702. faceColors?: Color4[];
  130703. faceUV?: Vector4[];
  130704. updatable?: boolean;
  130705. hasRings?: boolean;
  130706. enclose?: boolean;
  130707. cap?: number;
  130708. sideOrientation?: number;
  130709. frontUVs?: Vector4;
  130710. backUVs?: Vector4;
  130711. }, scene: any): Mesh;
  130712. }
  130713. }
  130714. declare module BABYLON {
  130715. /**
  130716. * States of the webXR experience
  130717. */
  130718. export enum WebXRState {
  130719. /**
  130720. * Transitioning to being in XR mode
  130721. */
  130722. ENTERING_XR = 0,
  130723. /**
  130724. * Transitioning to non XR mode
  130725. */
  130726. EXITING_XR = 1,
  130727. /**
  130728. * In XR mode and presenting
  130729. */
  130730. IN_XR = 2,
  130731. /**
  130732. * Not entered XR mode
  130733. */
  130734. NOT_IN_XR = 3
  130735. }
  130736. /**
  130737. * The state of the XR camera's tracking
  130738. */
  130739. export enum WebXRTrackingState {
  130740. /**
  130741. * No transformation received, device is not being tracked
  130742. */
  130743. NOT_TRACKING = 0,
  130744. /**
  130745. * Tracking lost - using emulated position
  130746. */
  130747. TRACKING_LOST = 1,
  130748. /**
  130749. * Transformation tracking works normally
  130750. */
  130751. TRACKING = 2
  130752. }
  130753. /**
  130754. * Abstraction of the XR render target
  130755. */
  130756. export interface WebXRRenderTarget extends IDisposable {
  130757. /**
  130758. * xrpresent context of the canvas which can be used to display/mirror xr content
  130759. */
  130760. canvasContext: WebGLRenderingContext;
  130761. /**
  130762. * xr layer for the canvas
  130763. */
  130764. xrLayer: Nullable<XRWebGLLayer>;
  130765. /**
  130766. * Initializes the xr layer for the session
  130767. * @param xrSession xr session
  130768. * @returns a promise that will resolve once the XR Layer has been created
  130769. */
  130770. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  130771. }
  130772. }
  130773. declare module BABYLON {
  130774. /**
  130775. * COnfiguration object for WebXR output canvas
  130776. */
  130777. export class WebXRManagedOutputCanvasOptions {
  130778. /**
  130779. * An optional canvas in case you wish to create it yourself and provide it here.
  130780. * If not provided, a new canvas will be created
  130781. */
  130782. canvasElement?: HTMLCanvasElement;
  130783. /**
  130784. * Options for this XR Layer output
  130785. */
  130786. canvasOptions?: XRWebGLLayerOptions;
  130787. /**
  130788. * CSS styling for a newly created canvas (if not provided)
  130789. */
  130790. newCanvasCssStyle?: string;
  130791. /**
  130792. * Get the default values of the configuration object
  130793. * @param engine defines the engine to use (can be null)
  130794. * @returns default values of this configuration object
  130795. */
  130796. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  130797. }
  130798. /**
  130799. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  130800. */
  130801. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  130802. private _options;
  130803. private _canvas;
  130804. private _engine;
  130805. private _originalCanvasSize;
  130806. /**
  130807. * Rendering context of the canvas which can be used to display/mirror xr content
  130808. */
  130809. canvasContext: WebGLRenderingContext;
  130810. /**
  130811. * xr layer for the canvas
  130812. */
  130813. xrLayer: Nullable<XRWebGLLayer>;
  130814. /**
  130815. * Obseervers registered here will be triggered when the xr layer was initialized
  130816. */
  130817. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  130818. /**
  130819. * Initializes the canvas to be added/removed upon entering/exiting xr
  130820. * @param _xrSessionManager The XR Session manager
  130821. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  130822. */
  130823. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  130824. /**
  130825. * Disposes of the object
  130826. */
  130827. dispose(): void;
  130828. /**
  130829. * Initializes the xr layer for the session
  130830. * @param xrSession xr session
  130831. * @returns a promise that will resolve once the XR Layer has been created
  130832. */
  130833. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  130834. private _addCanvas;
  130835. private _removeCanvas;
  130836. private _setCanvasSize;
  130837. private _setManagedOutputCanvas;
  130838. }
  130839. }
  130840. declare module BABYLON {
  130841. /**
  130842. * Manages an XRSession to work with Babylon's engine
  130843. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  130844. */
  130845. export class WebXRSessionManager implements IDisposable {
  130846. /** The scene which the session should be created for */
  130847. scene: Scene;
  130848. private _referenceSpace;
  130849. private _rttProvider;
  130850. private _sessionEnded;
  130851. private _xrNavigator;
  130852. private baseLayer;
  130853. /**
  130854. * The base reference space from which the session started. good if you want to reset your
  130855. * reference space
  130856. */
  130857. baseReferenceSpace: XRReferenceSpace;
  130858. /**
  130859. * Current XR frame
  130860. */
  130861. currentFrame: Nullable<XRFrame>;
  130862. /** WebXR timestamp updated every frame */
  130863. currentTimestamp: number;
  130864. /**
  130865. * Used just in case of a failure to initialize an immersive session.
  130866. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  130867. */
  130868. defaultHeightCompensation: number;
  130869. /**
  130870. * Fires every time a new xrFrame arrives which can be used to update the camera
  130871. */
  130872. onXRFrameObservable: Observable<XRFrame>;
  130873. /**
  130874. * Fires when the reference space changed
  130875. */
  130876. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  130877. /**
  130878. * Fires when the xr session is ended either by the device or manually done
  130879. */
  130880. onXRSessionEnded: Observable<any>;
  130881. /**
  130882. * Fires when the xr session is ended either by the device or manually done
  130883. */
  130884. onXRSessionInit: Observable<XRSession>;
  130885. /**
  130886. * Underlying xr session
  130887. */
  130888. session: XRSession;
  130889. /**
  130890. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  130891. * or get the offset the player is currently at.
  130892. */
  130893. viewerReferenceSpace: XRReferenceSpace;
  130894. /**
  130895. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  130896. * @param scene The scene which the session should be created for
  130897. */
  130898. constructor(
  130899. /** The scene which the session should be created for */
  130900. scene: Scene);
  130901. /**
  130902. * The current reference space used in this session. This reference space can constantly change!
  130903. * It is mainly used to offset the camera's position.
  130904. */
  130905. get referenceSpace(): XRReferenceSpace;
  130906. /**
  130907. * Set a new reference space and triggers the observable
  130908. */
  130909. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  130910. /**
  130911. * Disposes of the session manager
  130912. */
  130913. dispose(): void;
  130914. /**
  130915. * Stops the xrSession and restores the render loop
  130916. * @returns Promise which resolves after it exits XR
  130917. */
  130918. exitXRAsync(): Promise<void>;
  130919. /**
  130920. * Gets the correct render target texture to be rendered this frame for this eye
  130921. * @param eye the eye for which to get the render target
  130922. * @returns the render target for the specified eye
  130923. */
  130924. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  130925. /**
  130926. * Creates a WebXRRenderTarget object for the XR session
  130927. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  130928. * @param options optional options to provide when creating a new render target
  130929. * @returns a WebXR render target to which the session can render
  130930. */
  130931. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  130932. /**
  130933. * Initializes the manager
  130934. * After initialization enterXR can be called to start an XR session
  130935. * @returns Promise which resolves after it is initialized
  130936. */
  130937. initializeAsync(): Promise<void>;
  130938. /**
  130939. * Initializes an xr session
  130940. * @param xrSessionMode mode to initialize
  130941. * @param xrSessionInit defines optional and required values to pass to the session builder
  130942. * @returns a promise which will resolve once the session has been initialized
  130943. */
  130944. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  130945. /**
  130946. * Checks if a session would be supported for the creation options specified
  130947. * @param sessionMode session mode to check if supported eg. immersive-vr
  130948. * @returns A Promise that resolves to true if supported and false if not
  130949. */
  130950. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  130951. /**
  130952. * Resets the reference space to the one started the session
  130953. */
  130954. resetReferenceSpace(): void;
  130955. /**
  130956. * Starts rendering to the xr layer
  130957. */
  130958. runXRRenderLoop(): void;
  130959. /**
  130960. * Sets the reference space on the xr session
  130961. * @param referenceSpaceType space to set
  130962. * @returns a promise that will resolve once the reference space has been set
  130963. */
  130964. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130965. /**
  130966. * Updates the render state of the session
  130967. * @param state state to set
  130968. * @returns a promise that resolves once the render state has been updated
  130969. */
  130970. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  130971. /**
  130972. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  130973. * @param sessionMode defines the session to test
  130974. * @returns a promise with boolean as final value
  130975. */
  130976. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  130977. private _createRenderTargetTexture;
  130978. }
  130979. }
  130980. declare module BABYLON {
  130981. /**
  130982. * WebXR Camera which holds the views for the xrSession
  130983. * @see https://doc.babylonjs.com/how_to/webxr_camera
  130984. */
  130985. export class WebXRCamera extends FreeCamera {
  130986. private _xrSessionManager;
  130987. private _firstFrame;
  130988. private _referenceQuaternion;
  130989. private _referencedPosition;
  130990. private _xrInvPositionCache;
  130991. private _xrInvQuaternionCache;
  130992. private _trackingState;
  130993. /**
  130994. * Observable raised before camera teleportation
  130995. */
  130996. onBeforeCameraTeleport: Observable<Vector3>;
  130997. /**
  130998. * Observable raised after camera teleportation
  130999. */
  131000. onAfterCameraTeleport: Observable<Vector3>;
  131001. /**
  131002. * Notifies when the camera's tracking state has changed.
  131003. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  131004. */
  131005. onTrackingStateChanged: Observable<WebXRTrackingState>;
  131006. /**
  131007. * Should position compensation execute on first frame.
  131008. * This is used when copying the position from a native (non XR) camera
  131009. */
  131010. compensateOnFirstFrame: boolean;
  131011. /**
  131012. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  131013. * @param name the name of the camera
  131014. * @param scene the scene to add the camera to
  131015. * @param _xrSessionManager a constructed xr session manager
  131016. */
  131017. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  131018. /**
  131019. * Get the current XR tracking state of the camera
  131020. */
  131021. get trackingState(): WebXRTrackingState;
  131022. private _setTrackingState;
  131023. /**
  131024. * Return the user's height, unrelated to the current ground.
  131025. * This will be the y position of this camera, when ground level is 0.
  131026. */
  131027. get realWorldHeight(): number;
  131028. /** @hidden */
  131029. _updateForDualEyeDebugging(): void;
  131030. /**
  131031. * Sets this camera's transformation based on a non-vr camera
  131032. * @param otherCamera the non-vr camera to copy the transformation from
  131033. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  131034. */
  131035. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  131036. /**
  131037. * Gets the current instance class name ("WebXRCamera").
  131038. * @returns the class name
  131039. */
  131040. getClassName(): string;
  131041. private _rotate180;
  131042. private _updateFromXRSession;
  131043. private _updateNumberOfRigCameras;
  131044. private _updateReferenceSpace;
  131045. private _updateReferenceSpaceOffset;
  131046. }
  131047. }
  131048. declare module BABYLON {
  131049. /**
  131050. * Defining the interface required for a (webxr) feature
  131051. */
  131052. export interface IWebXRFeature extends IDisposable {
  131053. /**
  131054. * Is this feature attached
  131055. */
  131056. attached: boolean;
  131057. /**
  131058. * Should auto-attach be disabled?
  131059. */
  131060. disableAutoAttach: boolean;
  131061. /**
  131062. * Attach the feature to the session
  131063. * Will usually be called by the features manager
  131064. *
  131065. * @param force should attachment be forced (even when already attached)
  131066. * @returns true if successful.
  131067. */
  131068. attach(force?: boolean): boolean;
  131069. /**
  131070. * Detach the feature from the session
  131071. * Will usually be called by the features manager
  131072. *
  131073. * @returns true if successful.
  131074. */
  131075. detach(): boolean;
  131076. /**
  131077. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  131078. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  131079. *
  131080. * @returns whether or not the feature is compatible in this environment
  131081. */
  131082. isCompatible(): boolean;
  131083. /**
  131084. * Was this feature disposed;
  131085. */
  131086. isDisposed: boolean;
  131087. /**
  131088. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  131089. */
  131090. xrNativeFeatureName?: string;
  131091. /**
  131092. * A list of (Babylon WebXR) features this feature depends on
  131093. */
  131094. dependsOn?: string[];
  131095. }
  131096. /**
  131097. * A list of the currently available features without referencing them
  131098. */
  131099. export class WebXRFeatureName {
  131100. /**
  131101. * The name of the anchor system feature
  131102. */
  131103. static readonly ANCHOR_SYSTEM: string;
  131104. /**
  131105. * The name of the background remover feature
  131106. */
  131107. static readonly BACKGROUND_REMOVER: string;
  131108. /**
  131109. * The name of the hit test feature
  131110. */
  131111. static readonly HIT_TEST: string;
  131112. /**
  131113. * physics impostors for xr controllers feature
  131114. */
  131115. static readonly PHYSICS_CONTROLLERS: string;
  131116. /**
  131117. * The name of the plane detection feature
  131118. */
  131119. static readonly PLANE_DETECTION: string;
  131120. /**
  131121. * The name of the pointer selection feature
  131122. */
  131123. static readonly POINTER_SELECTION: string;
  131124. /**
  131125. * The name of the teleportation feature
  131126. */
  131127. static readonly TELEPORTATION: string;
  131128. /**
  131129. * The name of the feature points feature.
  131130. */
  131131. static readonly FEATURE_POINTS: string;
  131132. /**
  131133. * The name of the hand tracking feature.
  131134. */
  131135. static readonly HAND_TRACKING: string;
  131136. }
  131137. /**
  131138. * Defining the constructor of a feature. Used to register the modules.
  131139. */
  131140. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  131141. /**
  131142. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  131143. * It is mainly used in AR sessions.
  131144. *
  131145. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  131146. */
  131147. export class WebXRFeaturesManager implements IDisposable {
  131148. private _xrSessionManager;
  131149. private static readonly _AvailableFeatures;
  131150. private _features;
  131151. /**
  131152. * constructs a new features manages.
  131153. *
  131154. * @param _xrSessionManager an instance of WebXRSessionManager
  131155. */
  131156. constructor(_xrSessionManager: WebXRSessionManager);
  131157. /**
  131158. * Used to register a module. After calling this function a developer can use this feature in the scene.
  131159. * Mainly used internally.
  131160. *
  131161. * @param featureName the name of the feature to register
  131162. * @param constructorFunction the function used to construct the module
  131163. * @param version the (babylon) version of the module
  131164. * @param stable is that a stable version of this module
  131165. */
  131166. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  131167. /**
  131168. * Returns a constructor of a specific feature.
  131169. *
  131170. * @param featureName the name of the feature to construct
  131171. * @param version the version of the feature to load
  131172. * @param xrSessionManager the xrSessionManager. Used to construct the module
  131173. * @param options optional options provided to the module.
  131174. * @returns a function that, when called, will return a new instance of this feature
  131175. */
  131176. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  131177. /**
  131178. * Can be used to return the list of features currently registered
  131179. *
  131180. * @returns an Array of available features
  131181. */
  131182. static GetAvailableFeatures(): string[];
  131183. /**
  131184. * Gets the versions available for a specific feature
  131185. * @param featureName the name of the feature
  131186. * @returns an array with the available versions
  131187. */
  131188. static GetAvailableVersions(featureName: string): string[];
  131189. /**
  131190. * Return the latest unstable version of this feature
  131191. * @param featureName the name of the feature to search
  131192. * @returns the version number. if not found will return -1
  131193. */
  131194. static GetLatestVersionOfFeature(featureName: string): number;
  131195. /**
  131196. * Return the latest stable version of this feature
  131197. * @param featureName the name of the feature to search
  131198. * @returns the version number. if not found will return -1
  131199. */
  131200. static GetStableVersionOfFeature(featureName: string): number;
  131201. /**
  131202. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  131203. * Can be used during a session to start a feature
  131204. * @param featureName the name of feature to attach
  131205. */
  131206. attachFeature(featureName: string): void;
  131207. /**
  131208. * Can be used inside a session or when the session ends to detach a specific feature
  131209. * @param featureName the name of the feature to detach
  131210. */
  131211. detachFeature(featureName: string): void;
  131212. /**
  131213. * Used to disable an already-enabled feature
  131214. * The feature will be disposed and will be recreated once enabled.
  131215. * @param featureName the feature to disable
  131216. * @returns true if disable was successful
  131217. */
  131218. disableFeature(featureName: string | {
  131219. Name: string;
  131220. }): boolean;
  131221. /**
  131222. * dispose this features manager
  131223. */
  131224. dispose(): void;
  131225. /**
  131226. * 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.
  131227. * 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.
  131228. *
  131229. * @param featureName the name of the feature to load or the class of the feature
  131230. * @param version optional version to load. if not provided the latest version will be enabled
  131231. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  131232. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  131233. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  131234. * @returns a new constructed feature or throws an error if feature not found.
  131235. */
  131236. enableFeature(featureName: string | {
  131237. Name: string;
  131238. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  131239. /**
  131240. * get the implementation of an enabled feature.
  131241. * @param featureName the name of the feature to load
  131242. * @returns the feature class, if found
  131243. */
  131244. getEnabledFeature(featureName: string): IWebXRFeature;
  131245. /**
  131246. * Get the list of enabled features
  131247. * @returns an array of enabled features
  131248. */
  131249. getEnabledFeatures(): string[];
  131250. /**
  131251. * This function will exten the session creation configuration object with enabled features.
  131252. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  131253. * according to the defined "required" variable, provided during enableFeature call
  131254. * @param xrSessionInit the xr Session init object to extend
  131255. *
  131256. * @returns an extended XRSessionInit object
  131257. */
  131258. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  131259. }
  131260. }
  131261. declare module BABYLON {
  131262. /**
  131263. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  131264. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  131265. */
  131266. export class WebXRExperienceHelper implements IDisposable {
  131267. private scene;
  131268. private _nonVRCamera;
  131269. private _originalSceneAutoClear;
  131270. private _supported;
  131271. /**
  131272. * Camera used to render xr content
  131273. */
  131274. camera: WebXRCamera;
  131275. /** A features manager for this xr session */
  131276. featuresManager: WebXRFeaturesManager;
  131277. /**
  131278. * Observers registered here will be triggered after the camera's initial transformation is set
  131279. * This can be used to set a different ground level or an extra rotation.
  131280. *
  131281. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  131282. * to the position set after this observable is done executing.
  131283. */
  131284. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  131285. /**
  131286. * Fires when the state of the experience helper has changed
  131287. */
  131288. onStateChangedObservable: Observable<WebXRState>;
  131289. /** Session manager used to keep track of xr session */
  131290. sessionManager: WebXRSessionManager;
  131291. /**
  131292. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  131293. */
  131294. state: WebXRState;
  131295. /**
  131296. * Creates a WebXRExperienceHelper
  131297. * @param scene The scene the helper should be created in
  131298. */
  131299. private constructor();
  131300. /**
  131301. * Creates the experience helper
  131302. * @param scene the scene to attach the experience helper to
  131303. * @returns a promise for the experience helper
  131304. */
  131305. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  131306. /**
  131307. * Disposes of the experience helper
  131308. */
  131309. dispose(): void;
  131310. /**
  131311. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  131312. * @param sessionMode options for the XR session
  131313. * @param referenceSpaceType frame of reference of the XR session
  131314. * @param renderTarget the output canvas that will be used to enter XR mode
  131315. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  131316. * @returns promise that resolves after xr mode has entered
  131317. */
  131318. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  131319. /**
  131320. * Exits XR mode and returns the scene to its original state
  131321. * @returns promise that resolves after xr mode has exited
  131322. */
  131323. exitXRAsync(): Promise<void>;
  131324. private _nonXRToXRCamera;
  131325. private _setState;
  131326. }
  131327. }
  131328. declare module BABYLON {
  131329. /**
  131330. * X-Y values for axes in WebXR
  131331. */
  131332. export interface IWebXRMotionControllerAxesValue {
  131333. /**
  131334. * The value of the x axis
  131335. */
  131336. x: number;
  131337. /**
  131338. * The value of the y-axis
  131339. */
  131340. y: number;
  131341. }
  131342. /**
  131343. * changed / previous values for the values of this component
  131344. */
  131345. export interface IWebXRMotionControllerComponentChangesValues<T> {
  131346. /**
  131347. * current (this frame) value
  131348. */
  131349. current: T;
  131350. /**
  131351. * previous (last change) value
  131352. */
  131353. previous: T;
  131354. }
  131355. /**
  131356. * Represents changes in the component between current frame and last values recorded
  131357. */
  131358. export interface IWebXRMotionControllerComponentChanges {
  131359. /**
  131360. * will be populated with previous and current values if axes changed
  131361. */
  131362. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  131363. /**
  131364. * will be populated with previous and current values if pressed changed
  131365. */
  131366. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131367. /**
  131368. * will be populated with previous and current values if touched changed
  131369. */
  131370. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131371. /**
  131372. * will be populated with previous and current values if value changed
  131373. */
  131374. value?: IWebXRMotionControllerComponentChangesValues<number>;
  131375. }
  131376. /**
  131377. * This class represents a single component (for example button or thumbstick) of a motion controller
  131378. */
  131379. export class WebXRControllerComponent implements IDisposable {
  131380. /**
  131381. * the id of this component
  131382. */
  131383. id: string;
  131384. /**
  131385. * the type of the component
  131386. */
  131387. type: MotionControllerComponentType;
  131388. private _buttonIndex;
  131389. private _axesIndices;
  131390. private _axes;
  131391. private _changes;
  131392. private _currentValue;
  131393. private _hasChanges;
  131394. private _pressed;
  131395. private _touched;
  131396. /**
  131397. * button component type
  131398. */
  131399. static BUTTON_TYPE: MotionControllerComponentType;
  131400. /**
  131401. * squeeze component type
  131402. */
  131403. static SQUEEZE_TYPE: MotionControllerComponentType;
  131404. /**
  131405. * Thumbstick component type
  131406. */
  131407. static THUMBSTICK_TYPE: MotionControllerComponentType;
  131408. /**
  131409. * Touchpad component type
  131410. */
  131411. static TOUCHPAD_TYPE: MotionControllerComponentType;
  131412. /**
  131413. * trigger component type
  131414. */
  131415. static TRIGGER_TYPE: MotionControllerComponentType;
  131416. /**
  131417. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  131418. * the axes data changes
  131419. */
  131420. onAxisValueChangedObservable: Observable<{
  131421. x: number;
  131422. y: number;
  131423. }>;
  131424. /**
  131425. * Observers registered here will be triggered when the state of a button changes
  131426. * State change is either pressed / touched / value
  131427. */
  131428. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  131429. /**
  131430. * Creates a new component for a motion controller.
  131431. * It is created by the motion controller itself
  131432. *
  131433. * @param id the id of this component
  131434. * @param type the type of the component
  131435. * @param _buttonIndex index in the buttons array of the gamepad
  131436. * @param _axesIndices indices of the values in the axes array of the gamepad
  131437. */
  131438. constructor(
  131439. /**
  131440. * the id of this component
  131441. */
  131442. id: string,
  131443. /**
  131444. * the type of the component
  131445. */
  131446. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  131447. /**
  131448. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  131449. */
  131450. get axes(): IWebXRMotionControllerAxesValue;
  131451. /**
  131452. * Get the changes. Elements will be populated only if they changed with their previous and current value
  131453. */
  131454. get changes(): IWebXRMotionControllerComponentChanges;
  131455. /**
  131456. * Return whether or not the component changed the last frame
  131457. */
  131458. get hasChanges(): boolean;
  131459. /**
  131460. * is the button currently pressed
  131461. */
  131462. get pressed(): boolean;
  131463. /**
  131464. * is the button currently touched
  131465. */
  131466. get touched(): boolean;
  131467. /**
  131468. * Get the current value of this component
  131469. */
  131470. get value(): number;
  131471. /**
  131472. * Dispose this component
  131473. */
  131474. dispose(): void;
  131475. /**
  131476. * Are there axes correlating to this component
  131477. * @return true is axes data is available
  131478. */
  131479. isAxes(): boolean;
  131480. /**
  131481. * Is this component a button (hence - pressable)
  131482. * @returns true if can be pressed
  131483. */
  131484. isButton(): boolean;
  131485. /**
  131486. * update this component using the gamepad object it is in. Called on every frame
  131487. * @param nativeController the native gamepad controller object
  131488. */
  131489. update(nativeController: IMinimalMotionControllerObject): void;
  131490. }
  131491. }
  131492. declare module BABYLON {
  131493. /**
  131494. * Interface used to represent data loading progression
  131495. */
  131496. export interface ISceneLoaderProgressEvent {
  131497. /**
  131498. * Defines if data length to load can be evaluated
  131499. */
  131500. readonly lengthComputable: boolean;
  131501. /**
  131502. * Defines the loaded data length
  131503. */
  131504. readonly loaded: number;
  131505. /**
  131506. * Defines the data length to load
  131507. */
  131508. readonly total: number;
  131509. }
  131510. /**
  131511. * Interface used by SceneLoader plugins to define supported file extensions
  131512. */
  131513. export interface ISceneLoaderPluginExtensions {
  131514. /**
  131515. * Defines the list of supported extensions
  131516. */
  131517. [extension: string]: {
  131518. isBinary: boolean;
  131519. };
  131520. }
  131521. /**
  131522. * Interface used by SceneLoader plugin factory
  131523. */
  131524. export interface ISceneLoaderPluginFactory {
  131525. /**
  131526. * Defines the name of the factory
  131527. */
  131528. name: string;
  131529. /**
  131530. * Function called to create a new plugin
  131531. * @return the new plugin
  131532. */
  131533. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  131534. /**
  131535. * The callback that returns true if the data can be directly loaded.
  131536. * @param data string containing the file data
  131537. * @returns if the data can be loaded directly
  131538. */
  131539. canDirectLoad?(data: string): boolean;
  131540. }
  131541. /**
  131542. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  131543. */
  131544. export interface ISceneLoaderPluginBase {
  131545. /**
  131546. * The friendly name of this plugin.
  131547. */
  131548. name: string;
  131549. /**
  131550. * The file extensions supported by this plugin.
  131551. */
  131552. extensions: string | ISceneLoaderPluginExtensions;
  131553. /**
  131554. * The callback called when loading from a url.
  131555. * @param scene scene loading this url
  131556. * @param url url to load
  131557. * @param onSuccess callback called when the file successfully loads
  131558. * @param onProgress callback called while file is loading (if the server supports this mode)
  131559. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  131560. * @param onError callback called when the file fails to load
  131561. * @returns a file request object
  131562. */
  131563. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  131564. /**
  131565. * The callback called when loading from a file object.
  131566. * @param scene scene loading this file
  131567. * @param file defines the file to load
  131568. * @param onSuccess defines the callback to call when data is loaded
  131569. * @param onProgress defines the callback to call during loading process
  131570. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  131571. * @param onError defines the callback to call when an error occurs
  131572. * @returns a file request object
  131573. */
  131574. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  131575. /**
  131576. * The callback that returns true if the data can be directly loaded.
  131577. * @param data string containing the file data
  131578. * @returns if the data can be loaded directly
  131579. */
  131580. canDirectLoad?(data: string): boolean;
  131581. /**
  131582. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  131583. * @param scene scene loading this data
  131584. * @param data string containing the data
  131585. * @returns data to pass to the plugin
  131586. */
  131587. directLoad?(scene: Scene, data: string): any;
  131588. /**
  131589. * The callback that allows custom handling of the root url based on the response url.
  131590. * @param rootUrl the original root url
  131591. * @param responseURL the response url if available
  131592. * @returns the new root url
  131593. */
  131594. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  131595. }
  131596. /**
  131597. * Interface used to define a SceneLoader plugin
  131598. */
  131599. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  131600. /**
  131601. * Import meshes into a scene.
  131602. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131603. * @param scene The scene to import into
  131604. * @param data The data to import
  131605. * @param rootUrl The root url for scene and resources
  131606. * @param meshes The meshes array to import into
  131607. * @param particleSystems The particle systems array to import into
  131608. * @param skeletons The skeletons array to import into
  131609. * @param onError The callback when import fails
  131610. * @returns True if successful or false otherwise
  131611. */
  131612. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  131613. /**
  131614. * Load into a scene.
  131615. * @param scene The scene to load into
  131616. * @param data The data to import
  131617. * @param rootUrl The root url for scene and resources
  131618. * @param onError The callback when import fails
  131619. * @returns True if successful or false otherwise
  131620. */
  131621. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  131622. /**
  131623. * Load into an asset container.
  131624. * @param scene The scene to load into
  131625. * @param data The data to import
  131626. * @param rootUrl The root url for scene and resources
  131627. * @param onError The callback when import fails
  131628. * @returns The loaded asset container
  131629. */
  131630. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  131631. }
  131632. /**
  131633. * Interface used to define an async SceneLoader plugin
  131634. */
  131635. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  131636. /**
  131637. * Import meshes into a scene.
  131638. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131639. * @param scene The scene to import into
  131640. * @param data The data to import
  131641. * @param rootUrl The root url for scene and resources
  131642. * @param onProgress The callback when the load progresses
  131643. * @param fileName Defines the name of the file to load
  131644. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  131645. */
  131646. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  131647. meshes: AbstractMesh[];
  131648. particleSystems: IParticleSystem[];
  131649. skeletons: Skeleton[];
  131650. animationGroups: AnimationGroup[];
  131651. }>;
  131652. /**
  131653. * Load into a scene.
  131654. * @param scene The scene to load into
  131655. * @param data The data to import
  131656. * @param rootUrl The root url for scene and resources
  131657. * @param onProgress The callback when the load progresses
  131658. * @param fileName Defines the name of the file to load
  131659. * @returns Nothing
  131660. */
  131661. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  131662. /**
  131663. * Load into an asset container.
  131664. * @param scene The scene to load into
  131665. * @param data The data to import
  131666. * @param rootUrl The root url for scene and resources
  131667. * @param onProgress The callback when the load progresses
  131668. * @param fileName Defines the name of the file to load
  131669. * @returns The loaded asset container
  131670. */
  131671. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  131672. }
  131673. /**
  131674. * Mode that determines how to handle old animation groups before loading new ones.
  131675. */
  131676. export enum SceneLoaderAnimationGroupLoadingMode {
  131677. /**
  131678. * Reset all old animations to initial state then dispose them.
  131679. */
  131680. Clean = 0,
  131681. /**
  131682. * Stop all old animations.
  131683. */
  131684. Stop = 1,
  131685. /**
  131686. * Restart old animations from first frame.
  131687. */
  131688. Sync = 2,
  131689. /**
  131690. * Old animations remains untouched.
  131691. */
  131692. NoSync = 3
  131693. }
  131694. /**
  131695. * Defines a plugin registered by the SceneLoader
  131696. */
  131697. interface IRegisteredPlugin {
  131698. /**
  131699. * Defines the plugin to use
  131700. */
  131701. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  131702. /**
  131703. * Defines if the plugin supports binary data
  131704. */
  131705. isBinary: boolean;
  131706. }
  131707. /**
  131708. * Class used to load scene from various file formats using registered plugins
  131709. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  131710. */
  131711. export class SceneLoader {
  131712. /**
  131713. * No logging while loading
  131714. */
  131715. static readonly NO_LOGGING: number;
  131716. /**
  131717. * Minimal logging while loading
  131718. */
  131719. static readonly MINIMAL_LOGGING: number;
  131720. /**
  131721. * Summary logging while loading
  131722. */
  131723. static readonly SUMMARY_LOGGING: number;
  131724. /**
  131725. * Detailled logging while loading
  131726. */
  131727. static readonly DETAILED_LOGGING: number;
  131728. /**
  131729. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  131730. */
  131731. static get ForceFullSceneLoadingForIncremental(): boolean;
  131732. static set ForceFullSceneLoadingForIncremental(value: boolean);
  131733. /**
  131734. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  131735. */
  131736. static get ShowLoadingScreen(): boolean;
  131737. static set ShowLoadingScreen(value: boolean);
  131738. /**
  131739. * Defines the current logging level (while loading the scene)
  131740. * @ignorenaming
  131741. */
  131742. static get loggingLevel(): number;
  131743. static set loggingLevel(value: number);
  131744. /**
  131745. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  131746. */
  131747. static get CleanBoneMatrixWeights(): boolean;
  131748. static set CleanBoneMatrixWeights(value: boolean);
  131749. /**
  131750. * Event raised when a plugin is used to load a scene
  131751. */
  131752. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  131753. private static _registeredPlugins;
  131754. private static _showingLoadingScreen;
  131755. /**
  131756. * Gets the default plugin (used to load Babylon files)
  131757. * @returns the .babylon plugin
  131758. */
  131759. static GetDefaultPlugin(): IRegisteredPlugin;
  131760. private static _GetPluginForExtension;
  131761. private static _GetPluginForDirectLoad;
  131762. private static _GetPluginForFilename;
  131763. private static _GetDirectLoad;
  131764. private static _LoadData;
  131765. private static _GetFileInfo;
  131766. /**
  131767. * Gets a plugin that can load the given extension
  131768. * @param extension defines the extension to load
  131769. * @returns a plugin or null if none works
  131770. */
  131771. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  131772. /**
  131773. * Gets a boolean indicating that the given extension can be loaded
  131774. * @param extension defines the extension to load
  131775. * @returns true if the extension is supported
  131776. */
  131777. static IsPluginForExtensionAvailable(extension: string): boolean;
  131778. /**
  131779. * Adds a new plugin to the list of registered plugins
  131780. * @param plugin defines the plugin to add
  131781. */
  131782. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  131783. /**
  131784. * Import meshes into a scene
  131785. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131786. * @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)
  131787. * @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)
  131788. * @param scene the instance of BABYLON.Scene to append to
  131789. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  131790. * @param onProgress a callback with a progress event for each file being loaded
  131791. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131792. * @param pluginExtension the extension used to determine the plugin
  131793. * @returns The loaded plugin
  131794. */
  131795. 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>;
  131796. /**
  131797. * Import meshes into a scene
  131798. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131799. * @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)
  131800. * @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)
  131801. * @param scene the instance of BABYLON.Scene to append to
  131802. * @param onProgress a callback with a progress event for each file being loaded
  131803. * @param pluginExtension the extension used to determine the plugin
  131804. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  131805. */
  131806. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  131807. meshes: AbstractMesh[];
  131808. particleSystems: IParticleSystem[];
  131809. skeletons: Skeleton[];
  131810. animationGroups: AnimationGroup[];
  131811. }>;
  131812. /**
  131813. * Load a scene
  131814. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  131815. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  131816. * @param engine is the instance of BABYLON.Engine to use to create the scene
  131817. * @param onSuccess a callback with the scene when import succeeds
  131818. * @param onProgress a callback with a progress event for each file being loaded
  131819. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131820. * @param pluginExtension the extension used to determine the plugin
  131821. * @returns The loaded plugin
  131822. */
  131823. static 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>;
  131824. /**
  131825. * Load a scene
  131826. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  131827. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  131828. * @param engine is the instance of BABYLON.Engine to use to create the scene
  131829. * @param onProgress a callback with a progress event for each file being loaded
  131830. * @param pluginExtension the extension used to determine the plugin
  131831. * @returns The loaded scene
  131832. */
  131833. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  131834. /**
  131835. * Append a scene
  131836. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  131837. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  131838. * @param scene is the instance of BABYLON.Scene to append to
  131839. * @param onSuccess a callback with the scene when import succeeds
  131840. * @param onProgress a callback with a progress event for each file being loaded
  131841. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131842. * @param pluginExtension the extension used to determine the plugin
  131843. * @returns The loaded plugin
  131844. */
  131845. 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>;
  131846. /**
  131847. * Append a scene
  131848. * @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)
  131849. * @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)
  131850. * @param scene is the instance of BABYLON.Scene to append to
  131851. * @param onProgress a callback with a progress event for each file being loaded
  131852. * @param pluginExtension the extension used to determine the plugin
  131853. * @returns The given scene
  131854. */
  131855. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  131856. /**
  131857. * Load a scene into an asset container
  131858. * @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)
  131859. * @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)
  131860. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131861. * @param onSuccess a callback with the scene when import succeeds
  131862. * @param onProgress a callback with a progress event for each file being loaded
  131863. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131864. * @param pluginExtension the extension used to determine the plugin
  131865. * @returns The loaded plugin
  131866. */
  131867. 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>;
  131868. /**
  131869. * Load a scene into an asset container
  131870. * @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)
  131871. * @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)
  131872. * @param scene is the instance of Scene to append to
  131873. * @param onProgress a callback with a progress event for each file being loaded
  131874. * @param pluginExtension the extension used to determine the plugin
  131875. * @returns The loaded asset container
  131876. */
  131877. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  131878. /**
  131879. * Import animations from a file into a scene
  131880. * @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)
  131881. * @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)
  131882. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131883. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  131884. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  131885. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  131886. * @param onSuccess a callback with the scene when import succeeds
  131887. * @param onProgress a callback with a progress event for each file being loaded
  131888. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131889. * @param pluginExtension the extension used to determine the plugin
  131890. */
  131891. 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;
  131892. /**
  131893. * Import animations from a file into a scene
  131894. * @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)
  131895. * @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)
  131896. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131897. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  131898. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  131899. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  131900. * @param onSuccess a callback with the scene when import succeeds
  131901. * @param onProgress a callback with a progress event for each file being loaded
  131902. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131903. * @param pluginExtension the extension used to determine the plugin
  131904. * @returns the updated scene with imported animations
  131905. */
  131906. 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>;
  131907. }
  131908. }
  131909. declare module BABYLON {
  131910. /**
  131911. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  131912. */
  131913. export type MotionControllerHandedness = "none" | "left" | "right";
  131914. /**
  131915. * The type of components available in motion controllers.
  131916. * This is not the name of the component.
  131917. */
  131918. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  131919. /**
  131920. * The state of a controller component
  131921. */
  131922. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  131923. /**
  131924. * The schema of motion controller layout.
  131925. * No object will be initialized using this interface
  131926. * This is used just to define the profile.
  131927. */
  131928. export interface IMotionControllerLayout {
  131929. /**
  131930. * Path to load the assets. Usually relative to the base path
  131931. */
  131932. assetPath: string;
  131933. /**
  131934. * Available components (unsorted)
  131935. */
  131936. components: {
  131937. /**
  131938. * A map of component Ids
  131939. */
  131940. [componentId: string]: {
  131941. /**
  131942. * The type of input the component outputs
  131943. */
  131944. type: MotionControllerComponentType;
  131945. /**
  131946. * The indices of this component in the gamepad object
  131947. */
  131948. gamepadIndices: {
  131949. /**
  131950. * Index of button
  131951. */
  131952. button?: number;
  131953. /**
  131954. * If available, index of x-axis
  131955. */
  131956. xAxis?: number;
  131957. /**
  131958. * If available, index of y-axis
  131959. */
  131960. yAxis?: number;
  131961. };
  131962. /**
  131963. * The mesh's root node name
  131964. */
  131965. rootNodeName: string;
  131966. /**
  131967. * Animation definitions for this model
  131968. */
  131969. visualResponses: {
  131970. [stateKey: string]: {
  131971. /**
  131972. * What property will be animated
  131973. */
  131974. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  131975. /**
  131976. * What states influence this visual response
  131977. */
  131978. states: MotionControllerComponentStateType[];
  131979. /**
  131980. * Type of animation - movement or visibility
  131981. */
  131982. valueNodeProperty: "transform" | "visibility";
  131983. /**
  131984. * Base node name to move. Its position will be calculated according to the min and max nodes
  131985. */
  131986. valueNodeName?: string;
  131987. /**
  131988. * Minimum movement node
  131989. */
  131990. minNodeName?: string;
  131991. /**
  131992. * Max movement node
  131993. */
  131994. maxNodeName?: string;
  131995. };
  131996. };
  131997. /**
  131998. * If touch enabled, what is the name of node to display user feedback
  131999. */
  132000. touchPointNodeName?: string;
  132001. };
  132002. };
  132003. /**
  132004. * Is it xr standard mapping or not
  132005. */
  132006. gamepadMapping: "" | "xr-standard";
  132007. /**
  132008. * Base root node of this entire model
  132009. */
  132010. rootNodeName: string;
  132011. /**
  132012. * Defines the main button component id
  132013. */
  132014. selectComponentId: string;
  132015. }
  132016. /**
  132017. * A definition for the layout map in the input profile
  132018. */
  132019. export interface IMotionControllerLayoutMap {
  132020. /**
  132021. * Layouts with handedness type as a key
  132022. */
  132023. [handedness: string]: IMotionControllerLayout;
  132024. }
  132025. /**
  132026. * The XR Input profile schema
  132027. * Profiles can be found here:
  132028. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  132029. */
  132030. export interface IMotionControllerProfile {
  132031. /**
  132032. * fallback profiles for this profileId
  132033. */
  132034. fallbackProfileIds: string[];
  132035. /**
  132036. * The layout map, with handedness as key
  132037. */
  132038. layouts: IMotionControllerLayoutMap;
  132039. /**
  132040. * The id of this profile
  132041. * correlates to the profile(s) in the xrInput.profiles array
  132042. */
  132043. profileId: string;
  132044. }
  132045. /**
  132046. * A helper-interface for the 3 meshes needed for controller button animation
  132047. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  132048. */
  132049. export interface IMotionControllerButtonMeshMap {
  132050. /**
  132051. * the mesh that defines the pressed value mesh position.
  132052. * This is used to find the max-position of this button
  132053. */
  132054. pressedMesh: AbstractMesh;
  132055. /**
  132056. * the mesh that defines the unpressed value mesh position.
  132057. * This is used to find the min (or initial) position of this button
  132058. */
  132059. unpressedMesh: AbstractMesh;
  132060. /**
  132061. * The mesh that will be changed when value changes
  132062. */
  132063. valueMesh: AbstractMesh;
  132064. }
  132065. /**
  132066. * A helper-interface for the 3 meshes needed for controller axis animation.
  132067. * This will be expanded when touchpad animations are fully supported
  132068. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  132069. */
  132070. export interface IMotionControllerMeshMap {
  132071. /**
  132072. * the mesh that defines the maximum value mesh position.
  132073. */
  132074. maxMesh?: AbstractMesh;
  132075. /**
  132076. * the mesh that defines the minimum value mesh position.
  132077. */
  132078. minMesh?: AbstractMesh;
  132079. /**
  132080. * The mesh that will be changed when axis value changes
  132081. */
  132082. valueMesh?: AbstractMesh;
  132083. }
  132084. /**
  132085. * The elements needed for change-detection of the gamepad objects in motion controllers
  132086. */
  132087. export interface IMinimalMotionControllerObject {
  132088. /**
  132089. * Available axes of this controller
  132090. */
  132091. axes: number[];
  132092. /**
  132093. * An array of available buttons
  132094. */
  132095. buttons: Array<{
  132096. /**
  132097. * Value of the button/trigger
  132098. */
  132099. value: number;
  132100. /**
  132101. * If the button/trigger is currently touched
  132102. */
  132103. touched: boolean;
  132104. /**
  132105. * If the button/trigger is currently pressed
  132106. */
  132107. pressed: boolean;
  132108. }>;
  132109. /**
  132110. * EXPERIMENTAL haptic support.
  132111. */
  132112. hapticActuators?: Array<{
  132113. pulse: (value: number, duration: number) => Promise<boolean>;
  132114. }>;
  132115. }
  132116. /**
  132117. * An Abstract Motion controller
  132118. * This class receives an xrInput and a profile layout and uses those to initialize the components
  132119. * Each component has an observable to check for changes in value and state
  132120. */
  132121. export abstract class WebXRAbstractMotionController implements IDisposable {
  132122. protected scene: Scene;
  132123. protected layout: IMotionControllerLayout;
  132124. /**
  132125. * The gamepad object correlating to this controller
  132126. */
  132127. gamepadObject: IMinimalMotionControllerObject;
  132128. /**
  132129. * handedness (left/right/none) of this controller
  132130. */
  132131. handedness: MotionControllerHandedness;
  132132. private _initComponent;
  132133. private _modelReady;
  132134. /**
  132135. * A map of components (WebXRControllerComponent) in this motion controller
  132136. * Components have a ComponentType and can also have both button and axis definitions
  132137. */
  132138. readonly components: {
  132139. [id: string]: WebXRControllerComponent;
  132140. };
  132141. /**
  132142. * Disable the model's animation. Can be set at any time.
  132143. */
  132144. disableAnimation: boolean;
  132145. /**
  132146. * Observers registered here will be triggered when the model of this controller is done loading
  132147. */
  132148. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  132149. /**
  132150. * The profile id of this motion controller
  132151. */
  132152. abstract profileId: string;
  132153. /**
  132154. * The root mesh of the model. It is null if the model was not yet initialized
  132155. */
  132156. rootMesh: Nullable<AbstractMesh>;
  132157. /**
  132158. * constructs a new abstract motion controller
  132159. * @param scene the scene to which the model of the controller will be added
  132160. * @param layout The profile layout to load
  132161. * @param gamepadObject The gamepad object correlating to this controller
  132162. * @param handedness handedness (left/right/none) of this controller
  132163. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  132164. */
  132165. constructor(scene: Scene, layout: IMotionControllerLayout,
  132166. /**
  132167. * The gamepad object correlating to this controller
  132168. */
  132169. gamepadObject: IMinimalMotionControllerObject,
  132170. /**
  132171. * handedness (left/right/none) of this controller
  132172. */
  132173. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  132174. /**
  132175. * Dispose this controller, the model mesh and all its components
  132176. */
  132177. dispose(): void;
  132178. /**
  132179. * Returns all components of specific type
  132180. * @param type the type to search for
  132181. * @return an array of components with this type
  132182. */
  132183. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  132184. /**
  132185. * get a component based an its component id as defined in layout.components
  132186. * @param id the id of the component
  132187. * @returns the component correlates to the id or undefined if not found
  132188. */
  132189. getComponent(id: string): WebXRControllerComponent;
  132190. /**
  132191. * Get the list of components available in this motion controller
  132192. * @returns an array of strings correlating to available components
  132193. */
  132194. getComponentIds(): string[];
  132195. /**
  132196. * Get the first component of specific type
  132197. * @param type type of component to find
  132198. * @return a controller component or null if not found
  132199. */
  132200. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  132201. /**
  132202. * Get the main (Select) component of this controller as defined in the layout
  132203. * @returns the main component of this controller
  132204. */
  132205. getMainComponent(): WebXRControllerComponent;
  132206. /**
  132207. * Loads the model correlating to this controller
  132208. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  132209. * @returns A promise fulfilled with the result of the model loading
  132210. */
  132211. loadModel(): Promise<boolean>;
  132212. /**
  132213. * Update this model using the current XRFrame
  132214. * @param xrFrame the current xr frame to use and update the model
  132215. */
  132216. updateFromXRFrame(xrFrame: XRFrame): void;
  132217. /**
  132218. * Backwards compatibility due to a deeply-integrated typo
  132219. */
  132220. get handness(): XREye;
  132221. /**
  132222. * Pulse (vibrate) this controller
  132223. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  132224. * Consecutive calls to this function will cancel the last pulse call
  132225. *
  132226. * @param value the strength of the pulse in 0.0...1.0 range
  132227. * @param duration Duration of the pulse in milliseconds
  132228. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  132229. * @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
  132230. */
  132231. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  132232. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  132233. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  132234. /**
  132235. * Moves the axis on the controller mesh based on its current state
  132236. * @param axis the index of the axis
  132237. * @param axisValue the value of the axis which determines the meshes new position
  132238. * @hidden
  132239. */
  132240. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  132241. /**
  132242. * Update the model itself with the current frame data
  132243. * @param xrFrame the frame to use for updating the model mesh
  132244. */
  132245. protected updateModel(xrFrame: XRFrame): void;
  132246. /**
  132247. * Get the filename and path for this controller's model
  132248. * @returns a map of filename and path
  132249. */
  132250. protected abstract _getFilenameAndPath(): {
  132251. filename: string;
  132252. path: string;
  132253. };
  132254. /**
  132255. * This function is called before the mesh is loaded. It checks for loading constraints.
  132256. * For example, this function can check if the GLB loader is available
  132257. * If this function returns false, the generic controller will be loaded instead
  132258. * @returns Is the client ready to load the mesh
  132259. */
  132260. protected abstract _getModelLoadingConstraints(): boolean;
  132261. /**
  132262. * This function will be called after the model was successfully loaded and can be used
  132263. * for mesh transformations before it is available for the user
  132264. * @param meshes the loaded meshes
  132265. */
  132266. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  132267. /**
  132268. * Set the root mesh for this controller. Important for the WebXR controller class
  132269. * @param meshes the loaded meshes
  132270. */
  132271. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  132272. /**
  132273. * A function executed each frame that updates the mesh (if needed)
  132274. * @param xrFrame the current xrFrame
  132275. */
  132276. protected abstract _updateModel(xrFrame: XRFrame): void;
  132277. private _getGenericFilenameAndPath;
  132278. private _getGenericParentMesh;
  132279. }
  132280. }
  132281. declare module BABYLON {
  132282. /**
  132283. * A generic trigger-only motion controller for WebXR
  132284. */
  132285. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  132286. /**
  132287. * Static version of the profile id of this controller
  132288. */
  132289. static ProfileId: string;
  132290. profileId: string;
  132291. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  132292. protected _getFilenameAndPath(): {
  132293. filename: string;
  132294. path: string;
  132295. };
  132296. protected _getModelLoadingConstraints(): boolean;
  132297. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  132298. protected _setRootMesh(meshes: AbstractMesh[]): void;
  132299. protected _updateModel(): void;
  132300. }
  132301. }
  132302. declare module BABYLON {
  132303. /**
  132304. * Class containing static functions to help procedurally build meshes
  132305. */
  132306. export class SphereBuilder {
  132307. /**
  132308. * Creates a sphere mesh
  132309. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  132310. * * 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`)
  132311. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  132312. * * 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
  132313. * * 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)
  132314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132317. * @param name defines the name of the mesh
  132318. * @param options defines the options used to create the mesh
  132319. * @param scene defines the hosting scene
  132320. * @returns the sphere mesh
  132321. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  132322. */
  132323. static CreateSphere(name: string, options: {
  132324. segments?: number;
  132325. diameter?: number;
  132326. diameterX?: number;
  132327. diameterY?: number;
  132328. diameterZ?: number;
  132329. arc?: number;
  132330. slice?: number;
  132331. sideOrientation?: number;
  132332. frontUVs?: Vector4;
  132333. backUVs?: Vector4;
  132334. updatable?: boolean;
  132335. }, scene?: Nullable<Scene>): Mesh;
  132336. }
  132337. }
  132338. declare module BABYLON {
  132339. /**
  132340. * A profiled motion controller has its profile loaded from an online repository.
  132341. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  132342. */
  132343. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  132344. private _repositoryUrl;
  132345. private _buttonMeshMapping;
  132346. private _touchDots;
  132347. /**
  132348. * The profile ID of this controller. Will be populated when the controller initializes.
  132349. */
  132350. profileId: string;
  132351. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  132352. dispose(): void;
  132353. protected _getFilenameAndPath(): {
  132354. filename: string;
  132355. path: string;
  132356. };
  132357. protected _getModelLoadingConstraints(): boolean;
  132358. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  132359. protected _setRootMesh(meshes: AbstractMesh[]): void;
  132360. protected _updateModel(_xrFrame: XRFrame): void;
  132361. }
  132362. }
  132363. declare module BABYLON {
  132364. /**
  132365. * A construction function type to create a new controller based on an xrInput object
  132366. */
  132367. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  132368. /**
  132369. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  132370. *
  132371. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  132372. * it should be replaced with auto-loaded controllers.
  132373. *
  132374. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  132375. */
  132376. export class WebXRMotionControllerManager {
  132377. private static _AvailableControllers;
  132378. private static _Fallbacks;
  132379. private static _ProfileLoadingPromises;
  132380. private static _ProfilesList;
  132381. /**
  132382. * The base URL of the online controller repository. Can be changed at any time.
  132383. */
  132384. static BaseRepositoryUrl: string;
  132385. /**
  132386. * Which repository gets priority - local or online
  132387. */
  132388. static PrioritizeOnlineRepository: boolean;
  132389. /**
  132390. * Use the online repository, or use only locally-defined controllers
  132391. */
  132392. static UseOnlineRepository: boolean;
  132393. /**
  132394. * Clear the cache used for profile loading and reload when requested again
  132395. */
  132396. static ClearProfilesCache(): void;
  132397. /**
  132398. * Register the default fallbacks.
  132399. * This function is called automatically when this file is imported.
  132400. */
  132401. static DefaultFallbacks(): void;
  132402. /**
  132403. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  132404. * @param profileId the profile to which a fallback needs to be found
  132405. * @return an array with corresponding fallback profiles
  132406. */
  132407. static FindFallbackWithProfileId(profileId: string): string[];
  132408. /**
  132409. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  132410. * The order of search:
  132411. *
  132412. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  132413. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  132414. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  132415. * 4) return the generic trigger controller if none were found
  132416. *
  132417. * @param xrInput the xrInput to which a new controller is initialized
  132418. * @param scene the scene to which the model will be added
  132419. * @param forceProfile force a certain profile for this controller
  132420. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  132421. */
  132422. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  132423. /**
  132424. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  132425. *
  132426. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  132427. *
  132428. * @param type the profile type to register
  132429. * @param constructFunction the function to be called when loading this profile
  132430. */
  132431. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  132432. /**
  132433. * Register a fallback to a specific profile.
  132434. * @param profileId the profileId that will receive the fallbacks
  132435. * @param fallbacks A list of fallback profiles
  132436. */
  132437. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  132438. /**
  132439. * Will update the list of profiles available in the repository
  132440. * @return a promise that resolves to a map of profiles available online
  132441. */
  132442. static UpdateProfilesList(): Promise<{
  132443. [profile: string]: string;
  132444. }>;
  132445. private static _LoadProfileFromRepository;
  132446. private static _LoadProfilesFromAvailableControllers;
  132447. }
  132448. }
  132449. declare module BABYLON {
  132450. /**
  132451. * Configuration options for the WebXR controller creation
  132452. */
  132453. export interface IWebXRControllerOptions {
  132454. /**
  132455. * Should the controller mesh be animated when a user interacts with it
  132456. * The pressed buttons / thumbstick and touchpad animations will be disabled
  132457. */
  132458. disableMotionControllerAnimation?: boolean;
  132459. /**
  132460. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  132461. */
  132462. doNotLoadControllerMesh?: boolean;
  132463. /**
  132464. * Force a specific controller type for this controller.
  132465. * This can be used when creating your own profile or when testing different controllers
  132466. */
  132467. forceControllerProfile?: string;
  132468. /**
  132469. * Defines a rendering group ID for meshes that will be loaded.
  132470. * This is for the default controllers only.
  132471. */
  132472. renderingGroupId?: number;
  132473. }
  132474. /**
  132475. * Represents an XR controller
  132476. */
  132477. export class WebXRInputSource {
  132478. private _scene;
  132479. /** The underlying input source for the controller */
  132480. inputSource: XRInputSource;
  132481. private _options;
  132482. private _tmpVector;
  132483. private _uniqueId;
  132484. private _disposed;
  132485. /**
  132486. * 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
  132487. */
  132488. grip?: AbstractMesh;
  132489. /**
  132490. * If available, this is the gamepad object related to this controller.
  132491. * Using this object it is possible to get click events and trackpad changes of the
  132492. * webxr controller that is currently being used.
  132493. */
  132494. motionController?: WebXRAbstractMotionController;
  132495. /**
  132496. * Event that fires when the controller is removed/disposed.
  132497. * The object provided as event data is this controller, after associated assets were disposed.
  132498. * uniqueId is still available.
  132499. */
  132500. onDisposeObservable: Observable<WebXRInputSource>;
  132501. /**
  132502. * Will be triggered when the mesh associated with the motion controller is done loading.
  132503. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  132504. * A shortened version of controller -> motion controller -> on mesh loaded.
  132505. */
  132506. onMeshLoadedObservable: Observable<AbstractMesh>;
  132507. /**
  132508. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  132509. */
  132510. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  132511. /**
  132512. * Pointer which can be used to select objects or attach a visible laser to
  132513. */
  132514. pointer: AbstractMesh;
  132515. /**
  132516. * Creates the input source object
  132517. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  132518. * @param _scene the scene which the controller should be associated to
  132519. * @param inputSource the underlying input source for the controller
  132520. * @param _options options for this controller creation
  132521. */
  132522. constructor(_scene: Scene,
  132523. /** The underlying input source for the controller */
  132524. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  132525. /**
  132526. * Get this controllers unique id
  132527. */
  132528. get uniqueId(): string;
  132529. /**
  132530. * Disposes of the object
  132531. */
  132532. dispose(): void;
  132533. /**
  132534. * Gets a world space ray coming from the pointer or grip
  132535. * @param result the resulting ray
  132536. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  132537. */
  132538. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  132539. /**
  132540. * Updates the controller pose based on the given XRFrame
  132541. * @param xrFrame xr frame to update the pose with
  132542. * @param referenceSpace reference space to use
  132543. */
  132544. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  132545. }
  132546. }
  132547. declare module BABYLON {
  132548. /**
  132549. * The schema for initialization options of the XR Input class
  132550. */
  132551. export interface IWebXRInputOptions {
  132552. /**
  132553. * If set to true no model will be automatically loaded
  132554. */
  132555. doNotLoadControllerMeshes?: boolean;
  132556. /**
  132557. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  132558. * If not found, the xr input profile data will be used.
  132559. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  132560. */
  132561. forceInputProfile?: string;
  132562. /**
  132563. * Do not send a request to the controller repository to load the profile.
  132564. *
  132565. * Instead, use the controllers available in babylon itself.
  132566. */
  132567. disableOnlineControllerRepository?: boolean;
  132568. /**
  132569. * A custom URL for the controllers repository
  132570. */
  132571. customControllersRepositoryURL?: string;
  132572. /**
  132573. * Should the controller model's components not move according to the user input
  132574. */
  132575. disableControllerAnimation?: boolean;
  132576. /**
  132577. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  132578. */
  132579. controllerOptions?: IWebXRControllerOptions;
  132580. }
  132581. /**
  132582. * XR input used to track XR inputs such as controllers/rays
  132583. */
  132584. export class WebXRInput implements IDisposable {
  132585. /**
  132586. * the xr session manager for this session
  132587. */
  132588. xrSessionManager: WebXRSessionManager;
  132589. /**
  132590. * the WebXR camera for this session. Mainly used for teleportation
  132591. */
  132592. xrCamera: WebXRCamera;
  132593. private readonly options;
  132594. /**
  132595. * XR controllers being tracked
  132596. */
  132597. controllers: Array<WebXRInputSource>;
  132598. private _frameObserver;
  132599. private _sessionEndedObserver;
  132600. private _sessionInitObserver;
  132601. /**
  132602. * Event when a controller has been connected/added
  132603. */
  132604. onControllerAddedObservable: Observable<WebXRInputSource>;
  132605. /**
  132606. * Event when a controller has been removed/disconnected
  132607. */
  132608. onControllerRemovedObservable: Observable<WebXRInputSource>;
  132609. /**
  132610. * Initializes the WebXRInput
  132611. * @param xrSessionManager the xr session manager for this session
  132612. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  132613. * @param options = initialization options for this xr input
  132614. */
  132615. constructor(
  132616. /**
  132617. * the xr session manager for this session
  132618. */
  132619. xrSessionManager: WebXRSessionManager,
  132620. /**
  132621. * the WebXR camera for this session. Mainly used for teleportation
  132622. */
  132623. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  132624. private _onInputSourcesChange;
  132625. private _addAndRemoveControllers;
  132626. /**
  132627. * Disposes of the object
  132628. */
  132629. dispose(): void;
  132630. }
  132631. }
  132632. declare module BABYLON {
  132633. /**
  132634. * This is the base class for all WebXR features.
  132635. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  132636. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  132637. */
  132638. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  132639. protected _xrSessionManager: WebXRSessionManager;
  132640. private _attached;
  132641. private _removeOnDetach;
  132642. /**
  132643. * Is this feature disposed?
  132644. */
  132645. isDisposed: boolean;
  132646. /**
  132647. * Should auto-attach be disabled?
  132648. */
  132649. disableAutoAttach: boolean;
  132650. /**
  132651. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  132652. */
  132653. xrNativeFeatureName: string;
  132654. /**
  132655. * Construct a new (abstract) WebXR feature
  132656. * @param _xrSessionManager the xr session manager for this feature
  132657. */
  132658. constructor(_xrSessionManager: WebXRSessionManager);
  132659. /**
  132660. * Is this feature attached
  132661. */
  132662. get attached(): boolean;
  132663. /**
  132664. * attach this feature
  132665. *
  132666. * @param force should attachment be forced (even when already attached)
  132667. * @returns true if successful, false is failed or already attached
  132668. */
  132669. attach(force?: boolean): boolean;
  132670. /**
  132671. * detach this feature.
  132672. *
  132673. * @returns true if successful, false if failed or already detached
  132674. */
  132675. detach(): boolean;
  132676. /**
  132677. * Dispose this feature and all of the resources attached
  132678. */
  132679. dispose(): void;
  132680. /**
  132681. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  132682. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  132683. *
  132684. * @returns whether or not the feature is compatible in this environment
  132685. */
  132686. isCompatible(): boolean;
  132687. /**
  132688. * This is used to register callbacks that will automatically be removed when detach is called.
  132689. * @param observable the observable to which the observer will be attached
  132690. * @param callback the callback to register
  132691. */
  132692. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  132693. /**
  132694. * Code in this function will be executed on each xrFrame received from the browser.
  132695. * This function will not execute after the feature is detached.
  132696. * @param _xrFrame the current frame
  132697. */
  132698. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  132699. }
  132700. }
  132701. declare module BABYLON {
  132702. /**
  132703. * Renders a layer on top of an existing scene
  132704. */
  132705. export class UtilityLayerRenderer implements IDisposable {
  132706. /** the original scene that will be rendered on top of */
  132707. originalScene: Scene;
  132708. private _pointerCaptures;
  132709. private _lastPointerEvents;
  132710. private static _DefaultUtilityLayer;
  132711. private static _DefaultKeepDepthUtilityLayer;
  132712. private _sharedGizmoLight;
  132713. private _renderCamera;
  132714. /**
  132715. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  132716. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  132717. * @returns the camera that is used when rendering the utility layer
  132718. */
  132719. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  132720. /**
  132721. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  132722. * @param cam the camera that should be used when rendering the utility layer
  132723. */
  132724. setRenderCamera(cam: Nullable<Camera>): void;
  132725. /**
  132726. * @hidden
  132727. * Light which used by gizmos to get light shading
  132728. */
  132729. _getSharedGizmoLight(): HemisphericLight;
  132730. /**
  132731. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  132732. */
  132733. pickUtilitySceneFirst: boolean;
  132734. /**
  132735. * 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)
  132736. */
  132737. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  132738. /**
  132739. * 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)
  132740. */
  132741. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  132742. /**
  132743. * The scene that is rendered on top of the original scene
  132744. */
  132745. utilityLayerScene: Scene;
  132746. /**
  132747. * If the utility layer should automatically be rendered on top of existing scene
  132748. */
  132749. shouldRender: boolean;
  132750. /**
  132751. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  132752. */
  132753. onlyCheckPointerDownEvents: boolean;
  132754. /**
  132755. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  132756. */
  132757. processAllEvents: boolean;
  132758. /**
  132759. * Observable raised when the pointer move from the utility layer scene to the main scene
  132760. */
  132761. onPointerOutObservable: Observable<number>;
  132762. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  132763. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  132764. private _afterRenderObserver;
  132765. private _sceneDisposeObserver;
  132766. private _originalPointerObserver;
  132767. /**
  132768. * Instantiates a UtilityLayerRenderer
  132769. * @param originalScene the original scene that will be rendered on top of
  132770. * @param handleEvents boolean indicating if the utility layer should handle events
  132771. */
  132772. constructor(
  132773. /** the original scene that will be rendered on top of */
  132774. originalScene: Scene, handleEvents?: boolean);
  132775. private _notifyObservers;
  132776. /**
  132777. * Renders the utility layers scene on top of the original scene
  132778. */
  132779. render(): void;
  132780. /**
  132781. * Disposes of the renderer
  132782. */
  132783. dispose(): void;
  132784. private _updateCamera;
  132785. }
  132786. }
  132787. declare module BABYLON {
  132788. /**
  132789. * Options interface for the pointer selection module
  132790. */
  132791. export interface IWebXRControllerPointerSelectionOptions {
  132792. /**
  132793. * if provided, this scene will be used to render meshes.
  132794. */
  132795. customUtilityLayerScene?: Scene;
  132796. /**
  132797. * 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)
  132798. * If not disabled, the last picked point will be used to execute a pointer up event
  132799. * If disabled, pointer up event will be triggered right after the pointer down event.
  132800. * Used in screen and gaze target ray mode only
  132801. */
  132802. disablePointerUpOnTouchOut: boolean;
  132803. /**
  132804. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  132805. */
  132806. forceGazeMode: boolean;
  132807. /**
  132808. * 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
  132809. * to start a new countdown to the pointer down event.
  132810. * Defaults to 1.
  132811. */
  132812. gazeModePointerMovedFactor?: number;
  132813. /**
  132814. * Different button type to use instead of the main component
  132815. */
  132816. overrideButtonId?: string;
  132817. /**
  132818. * use this rendering group id for the meshes (optional)
  132819. */
  132820. renderingGroupId?: number;
  132821. /**
  132822. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  132823. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  132824. * 3000 means 3 seconds between pointing at something and selecting it
  132825. */
  132826. timeToSelect?: number;
  132827. /**
  132828. * Should meshes created here be added to a utility layer or the main scene
  132829. */
  132830. useUtilityLayer?: boolean;
  132831. /**
  132832. * Optional WebXR camera to be used for gaze selection
  132833. */
  132834. gazeCamera?: WebXRCamera;
  132835. /**
  132836. * the xr input to use with this pointer selection
  132837. */
  132838. xrInput: WebXRInput;
  132839. /**
  132840. * Should the scene pointerX and pointerY update be disabled
  132841. * This is required for fullscreen AR GUI, but might slow down other experiences.
  132842. * Disable in VR, if not needed.
  132843. * The first rig camera (left eye) will be used to calculate the projection
  132844. */
  132845. disableScenePointerVectorUpdate: boolean;
  132846. /**
  132847. * Enable pointer selection on all controllers instead of switching between them
  132848. */
  132849. enablePointerSelectionOnAllControllers?: boolean;
  132850. /**
  132851. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  132852. * If switch is enabled, it will still allow the user to switch between the different controllers
  132853. */
  132854. preferredHandedness?: XRHandedness;
  132855. /**
  132856. * Disable switching the pointer selection from one controller to the other.
  132857. * If the preferred hand is set it will be fixed on this hand, and if not it will be fixed on the first controller added to the scene
  132858. */
  132859. disableSwitchOnClick?: boolean;
  132860. /**
  132861. * The maximum distance of the pointer selection feature. Defaults to 100.
  132862. */
  132863. maxPointerDistance?: number;
  132864. }
  132865. /**
  132866. * A module that will enable pointer selection for motion controllers of XR Input Sources
  132867. */
  132868. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  132869. private readonly _options;
  132870. private static _idCounter;
  132871. private _attachController;
  132872. private _controllers;
  132873. private _scene;
  132874. private _tmpVectorForPickCompare;
  132875. private _attachedController;
  132876. /**
  132877. * The module's name
  132878. */
  132879. static readonly Name: string;
  132880. /**
  132881. * The (Babylon) version of this module.
  132882. * This is an integer representing the implementation version.
  132883. * This number does not correspond to the WebXR specs version
  132884. */
  132885. static readonly Version: number;
  132886. /**
  132887. * Disable lighting on the laser pointer (so it will always be visible)
  132888. */
  132889. disablePointerLighting: boolean;
  132890. /**
  132891. * Disable lighting on the selection mesh (so it will always be visible)
  132892. */
  132893. disableSelectionMeshLighting: boolean;
  132894. /**
  132895. * Should the laser pointer be displayed
  132896. */
  132897. displayLaserPointer: boolean;
  132898. /**
  132899. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  132900. */
  132901. displaySelectionMesh: boolean;
  132902. /**
  132903. * This color will be set to the laser pointer when selection is triggered
  132904. */
  132905. laserPointerPickedColor: Color3;
  132906. /**
  132907. * Default color of the laser pointer
  132908. */
  132909. laserPointerDefaultColor: Color3;
  132910. /**
  132911. * default color of the selection ring
  132912. */
  132913. selectionMeshDefaultColor: Color3;
  132914. /**
  132915. * This color will be applied to the selection ring when selection is triggered
  132916. */
  132917. selectionMeshPickedColor: Color3;
  132918. /**
  132919. * Optional filter to be used for ray selection. This predicate shares behavior with
  132920. * scene.pointerMovePredicate which takes priority if it is also assigned.
  132921. */
  132922. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  132923. /**
  132924. * constructs a new background remover module
  132925. * @param _xrSessionManager the session manager for this module
  132926. * @param _options read-only options to be used in this module
  132927. */
  132928. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  132929. /**
  132930. * attach this feature
  132931. * Will usually be called by the features manager
  132932. *
  132933. * @returns true if successful.
  132934. */
  132935. attach(): boolean;
  132936. /**
  132937. * detach this feature.
  132938. * Will usually be called by the features manager
  132939. *
  132940. * @returns true if successful.
  132941. */
  132942. detach(): boolean;
  132943. /**
  132944. * Will get the mesh under a specific pointer.
  132945. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  132946. * @param controllerId the controllerId to check
  132947. * @returns The mesh under pointer or null if no mesh is under the pointer
  132948. */
  132949. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  132950. /**
  132951. * Get the xr controller that correlates to the pointer id in the pointer event
  132952. *
  132953. * @param id the pointer id to search for
  132954. * @returns the controller that correlates to this id or null if not found
  132955. */
  132956. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  132957. private _identityMatrix;
  132958. private _screenCoordinatesRef;
  132959. private _viewportRef;
  132960. protected _onXRFrame(_xrFrame: XRFrame): void;
  132961. private _attachGazeMode;
  132962. private _attachScreenRayMode;
  132963. private _attachTrackedPointerRayMode;
  132964. private _convertNormalToDirectionOfRay;
  132965. private _detachController;
  132966. private _generateNewMeshPair;
  132967. private _pickingMoved;
  132968. private _updatePointerDistance;
  132969. /** @hidden */
  132970. get lasterPointerDefaultColor(): Color3;
  132971. }
  132972. }
  132973. declare module BABYLON {
  132974. /**
  132975. * Button which can be used to enter a different mode of XR
  132976. */
  132977. export class WebXREnterExitUIButton {
  132978. /** button element */
  132979. element: HTMLElement;
  132980. /** XR initialization options for the button */
  132981. sessionMode: XRSessionMode;
  132982. /** Reference space type */
  132983. referenceSpaceType: XRReferenceSpaceType;
  132984. /**
  132985. * Creates a WebXREnterExitUIButton
  132986. * @param element button element
  132987. * @param sessionMode XR initialization session mode
  132988. * @param referenceSpaceType the type of reference space to be used
  132989. */
  132990. constructor(
  132991. /** button element */
  132992. element: HTMLElement,
  132993. /** XR initialization options for the button */
  132994. sessionMode: XRSessionMode,
  132995. /** Reference space type */
  132996. referenceSpaceType: XRReferenceSpaceType);
  132997. /**
  132998. * Extendable function which can be used to update the button's visuals when the state changes
  132999. * @param activeButton the current active button in the UI
  133000. */
  133001. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  133002. }
  133003. /**
  133004. * Options to create the webXR UI
  133005. */
  133006. export class WebXREnterExitUIOptions {
  133007. /**
  133008. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  133009. */
  133010. customButtons?: Array<WebXREnterExitUIButton>;
  133011. /**
  133012. * A reference space type to use when creating the default button.
  133013. * Default is local-floor
  133014. */
  133015. referenceSpaceType?: XRReferenceSpaceType;
  133016. /**
  133017. * Context to enter xr with
  133018. */
  133019. renderTarget?: Nullable<WebXRRenderTarget>;
  133020. /**
  133021. * A session mode to use when creating the default button.
  133022. * Default is immersive-vr
  133023. */
  133024. sessionMode?: XRSessionMode;
  133025. /**
  133026. * A list of optional features to init the session with
  133027. */
  133028. optionalFeatures?: string[];
  133029. /**
  133030. * A list of optional features to init the session with
  133031. */
  133032. requiredFeatures?: string[];
  133033. }
  133034. /**
  133035. * UI to allow the user to enter/exit XR mode
  133036. */
  133037. export class WebXREnterExitUI implements IDisposable {
  133038. private scene;
  133039. /** version of the options passed to this UI */
  133040. options: WebXREnterExitUIOptions;
  133041. private _activeButton;
  133042. private _buttons;
  133043. /**
  133044. * The HTML Div Element to which buttons are added.
  133045. */
  133046. readonly overlay: HTMLDivElement;
  133047. /**
  133048. * Fired every time the active button is changed.
  133049. *
  133050. * When xr is entered via a button that launches xr that button will be the callback parameter
  133051. *
  133052. * When exiting xr the callback parameter will be null)
  133053. */
  133054. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  133055. /**
  133056. *
  133057. * @param scene babylon scene object to use
  133058. * @param options (read-only) version of the options passed to this UI
  133059. */
  133060. private constructor();
  133061. /**
  133062. * Creates UI to allow the user to enter/exit XR mode
  133063. * @param scene the scene to add the ui to
  133064. * @param helper the xr experience helper to enter/exit xr with
  133065. * @param options options to configure the UI
  133066. * @returns the created ui
  133067. */
  133068. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  133069. /**
  133070. * Disposes of the XR UI component
  133071. */
  133072. dispose(): void;
  133073. private _updateButtons;
  133074. }
  133075. }
  133076. declare module BABYLON {
  133077. /**
  133078. * Class containing static functions to help procedurally build meshes
  133079. */
  133080. export class LinesBuilder {
  133081. /**
  133082. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  133083. * * 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
  133084. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  133085. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  133086. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  133087. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  133088. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  133089. * * 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
  133090. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  133091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133092. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  133093. * @param name defines the name of the new line system
  133094. * @param options defines the options used to create the line system
  133095. * @param scene defines the hosting scene
  133096. * @returns a new line system mesh
  133097. */
  133098. static CreateLineSystem(name: string, options: {
  133099. lines: Vector3[][];
  133100. updatable?: boolean;
  133101. instance?: Nullable<LinesMesh>;
  133102. colors?: Nullable<Color4[][]>;
  133103. useVertexAlpha?: boolean;
  133104. }, scene: Nullable<Scene>): LinesMesh;
  133105. /**
  133106. * Creates a line mesh
  133107. * 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
  133108. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133109. * * The parameter `points` is an array successive Vector3
  133110. * * 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
  133111. * * The optional parameter `colors` is an array of successive Color4, one per line point
  133112. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  133113. * * When updating an instance, remember that only point positions can change, not the number of points
  133114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133115. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  133116. * @param name defines the name of the new line system
  133117. * @param options defines the options used to create the line system
  133118. * @param scene defines the hosting scene
  133119. * @returns a new line mesh
  133120. */
  133121. static CreateLines(name: string, options: {
  133122. points: Vector3[];
  133123. updatable?: boolean;
  133124. instance?: Nullable<LinesMesh>;
  133125. colors?: Color4[];
  133126. useVertexAlpha?: boolean;
  133127. }, scene?: Nullable<Scene>): LinesMesh;
  133128. /**
  133129. * Creates a dashed line mesh
  133130. * * 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
  133131. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133132. * * The parameter `points` is an array successive Vector3
  133133. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  133134. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  133135. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  133136. * * 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
  133137. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  133138. * * When updating an instance, remember that only point positions can change, not the number of points
  133139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133140. * @param name defines the name of the mesh
  133141. * @param options defines the options used to create the mesh
  133142. * @param scene defines the hosting scene
  133143. * @returns the dashed line mesh
  133144. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  133145. */
  133146. static CreateDashedLines(name: string, options: {
  133147. points: Vector3[];
  133148. dashSize?: number;
  133149. gapSize?: number;
  133150. dashNb?: number;
  133151. updatable?: boolean;
  133152. instance?: LinesMesh;
  133153. useVertexAlpha?: boolean;
  133154. }, scene?: Nullable<Scene>): LinesMesh;
  133155. }
  133156. }
  133157. declare module BABYLON {
  133158. /**
  133159. * Construction options for a timer
  133160. */
  133161. export interface ITimerOptions<T> {
  133162. /**
  133163. * Time-to-end
  133164. */
  133165. timeout: number;
  133166. /**
  133167. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  133168. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  133169. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  133170. */
  133171. contextObservable: Observable<T>;
  133172. /**
  133173. * Optional parameters when adding an observer to the observable
  133174. */
  133175. observableParameters?: {
  133176. mask?: number;
  133177. insertFirst?: boolean;
  133178. scope?: any;
  133179. };
  133180. /**
  133181. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  133182. */
  133183. breakCondition?: (data?: ITimerData<T>) => boolean;
  133184. /**
  133185. * Will be triggered when the time condition has met
  133186. */
  133187. onEnded?: (data: ITimerData<any>) => void;
  133188. /**
  133189. * Will be triggered when the break condition has met (prematurely ended)
  133190. */
  133191. onAborted?: (data: ITimerData<any>) => void;
  133192. /**
  133193. * Optional function to execute on each tick (or count)
  133194. */
  133195. onTick?: (data: ITimerData<any>) => void;
  133196. }
  133197. /**
  133198. * An interface defining the data sent by the timer
  133199. */
  133200. export interface ITimerData<T> {
  133201. /**
  133202. * When did it start
  133203. */
  133204. startTime: number;
  133205. /**
  133206. * Time now
  133207. */
  133208. currentTime: number;
  133209. /**
  133210. * Time passed since started
  133211. */
  133212. deltaTime: number;
  133213. /**
  133214. * How much is completed, in [0.0...1.0].
  133215. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  133216. */
  133217. completeRate: number;
  133218. /**
  133219. * What the registered observable sent in the last count
  133220. */
  133221. payload: T;
  133222. }
  133223. /**
  133224. * The current state of the timer
  133225. */
  133226. export enum TimerState {
  133227. /**
  133228. * Timer initialized, not yet started
  133229. */
  133230. INIT = 0,
  133231. /**
  133232. * Timer started and counting
  133233. */
  133234. STARTED = 1,
  133235. /**
  133236. * Timer ended (whether aborted or time reached)
  133237. */
  133238. ENDED = 2
  133239. }
  133240. /**
  133241. * A simple version of the timer. Will take options and start the timer immediately after calling it
  133242. *
  133243. * @param options options with which to initialize this timer
  133244. */
  133245. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  133246. /**
  133247. * An advanced implementation of a timer class
  133248. */
  133249. export class AdvancedTimer<T = any> implements IDisposable {
  133250. /**
  133251. * Will notify each time the timer calculates the remaining time
  133252. */
  133253. onEachCountObservable: Observable<ITimerData<T>>;
  133254. /**
  133255. * Will trigger when the timer was aborted due to the break condition
  133256. */
  133257. onTimerAbortedObservable: Observable<ITimerData<T>>;
  133258. /**
  133259. * Will trigger when the timer ended successfully
  133260. */
  133261. onTimerEndedObservable: Observable<ITimerData<T>>;
  133262. /**
  133263. * Will trigger when the timer state has changed
  133264. */
  133265. onStateChangedObservable: Observable<TimerState>;
  133266. private _observer;
  133267. private _contextObservable;
  133268. private _observableParameters;
  133269. private _startTime;
  133270. private _timer;
  133271. private _state;
  133272. private _breakCondition;
  133273. private _timeToEnd;
  133274. private _breakOnNextTick;
  133275. /**
  133276. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  133277. * @param options construction options for this advanced timer
  133278. */
  133279. constructor(options: ITimerOptions<T>);
  133280. /**
  133281. * set a breaking condition for this timer. Default is to never break during count
  133282. * @param predicate the new break condition. Returns true to break, false otherwise
  133283. */
  133284. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  133285. /**
  133286. * Reset ALL associated observables in this advanced timer
  133287. */
  133288. clearObservables(): void;
  133289. /**
  133290. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  133291. *
  133292. * @param timeToEnd how much time to measure until timer ended
  133293. */
  133294. start(timeToEnd?: number): void;
  133295. /**
  133296. * Will force a stop on the next tick.
  133297. */
  133298. stop(): void;
  133299. /**
  133300. * Dispose this timer, clearing all resources
  133301. */
  133302. dispose(): void;
  133303. private _setState;
  133304. private _tick;
  133305. private _stop;
  133306. }
  133307. }
  133308. declare module BABYLON {
  133309. /**
  133310. * The options container for the teleportation module
  133311. */
  133312. export interface IWebXRTeleportationOptions {
  133313. /**
  133314. * if provided, this scene will be used to render meshes.
  133315. */
  133316. customUtilityLayerScene?: Scene;
  133317. /**
  133318. * Values to configure the default target mesh
  133319. */
  133320. defaultTargetMeshOptions?: {
  133321. /**
  133322. * Fill color of the teleportation area
  133323. */
  133324. teleportationFillColor?: string;
  133325. /**
  133326. * Border color for the teleportation area
  133327. */
  133328. teleportationBorderColor?: string;
  133329. /**
  133330. * Disable the mesh's animation sequence
  133331. */
  133332. disableAnimation?: boolean;
  133333. /**
  133334. * Disable lighting on the material or the ring and arrow
  133335. */
  133336. disableLighting?: boolean;
  133337. /**
  133338. * Override the default material of the torus and arrow
  133339. */
  133340. torusArrowMaterial?: Material;
  133341. };
  133342. /**
  133343. * A list of meshes to use as floor meshes.
  133344. * Meshes can be added and removed after initializing the feature using the
  133345. * addFloorMesh and removeFloorMesh functions
  133346. * If empty, rotation will still work
  133347. */
  133348. floorMeshes?: AbstractMesh[];
  133349. /**
  133350. * use this rendering group id for the meshes (optional)
  133351. */
  133352. renderingGroupId?: number;
  133353. /**
  133354. * Should teleportation move only to snap points
  133355. */
  133356. snapPointsOnly?: boolean;
  133357. /**
  133358. * An array of points to which the teleportation will snap to.
  133359. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  133360. */
  133361. snapPositions?: Vector3[];
  133362. /**
  133363. * How close should the teleportation ray be in order to snap to position.
  133364. * Default to 0.8 units (meters)
  133365. */
  133366. snapToPositionRadius?: number;
  133367. /**
  133368. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  133369. * If you want to support rotation, make sure your mesh has a direction indicator.
  133370. *
  133371. * When left untouched, the default mesh will be initialized.
  133372. */
  133373. teleportationTargetMesh?: AbstractMesh;
  133374. /**
  133375. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  133376. */
  133377. timeToTeleport?: number;
  133378. /**
  133379. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  133380. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  133381. */
  133382. useMainComponentOnly?: boolean;
  133383. /**
  133384. * Should meshes created here be added to a utility layer or the main scene
  133385. */
  133386. useUtilityLayer?: boolean;
  133387. /**
  133388. * Babylon XR Input class for controller
  133389. */
  133390. xrInput: WebXRInput;
  133391. /**
  133392. * Meshes that the teleportation ray cannot go through
  133393. */
  133394. pickBlockerMeshes?: AbstractMesh[];
  133395. }
  133396. /**
  133397. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  133398. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  133399. * the input of the attached controllers.
  133400. */
  133401. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  133402. private _options;
  133403. private _controllers;
  133404. private _currentTeleportationControllerId;
  133405. private _floorMeshes;
  133406. private _quadraticBezierCurve;
  133407. private _selectionFeature;
  133408. private _snapToPositions;
  133409. private _snappedToPoint;
  133410. private _teleportationRingMaterial?;
  133411. private _tmpRay;
  133412. private _tmpVector;
  133413. private _tmpQuaternion;
  133414. /**
  133415. * The module's name
  133416. */
  133417. static readonly Name: string;
  133418. /**
  133419. * The (Babylon) version of this module.
  133420. * This is an integer representing the implementation version.
  133421. * This number does not correspond to the webxr specs version
  133422. */
  133423. static readonly Version: number;
  133424. /**
  133425. * Is movement backwards enabled
  133426. */
  133427. backwardsMovementEnabled: boolean;
  133428. /**
  133429. * Distance to travel when moving backwards
  133430. */
  133431. backwardsTeleportationDistance: number;
  133432. /**
  133433. * The distance from the user to the inspection point in the direction of the controller
  133434. * A higher number will allow the user to move further
  133435. * defaults to 5 (meters, in xr units)
  133436. */
  133437. parabolicCheckRadius: number;
  133438. /**
  133439. * Should the module support parabolic ray on top of direct ray
  133440. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  133441. * Very helpful when moving between floors / different heights
  133442. */
  133443. parabolicRayEnabled: boolean;
  133444. /**
  133445. * How much rotation should be applied when rotating right and left
  133446. */
  133447. rotationAngle: number;
  133448. /**
  133449. * Is rotation enabled when moving forward?
  133450. * Disabling this feature will prevent the user from deciding the direction when teleporting
  133451. */
  133452. rotationEnabled: boolean;
  133453. /**
  133454. * constructs a new anchor system
  133455. * @param _xrSessionManager an instance of WebXRSessionManager
  133456. * @param _options configuration object for this feature
  133457. */
  133458. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  133459. /**
  133460. * Get the snapPointsOnly flag
  133461. */
  133462. get snapPointsOnly(): boolean;
  133463. /**
  133464. * Sets the snapPointsOnly flag
  133465. * @param snapToPoints should teleportation be exclusively to snap points
  133466. */
  133467. set snapPointsOnly(snapToPoints: boolean);
  133468. /**
  133469. * Add a new mesh to the floor meshes array
  133470. * @param mesh the mesh to use as floor mesh
  133471. */
  133472. addFloorMesh(mesh: AbstractMesh): void;
  133473. /**
  133474. * Add a new snap-to point to fix teleportation to this position
  133475. * @param newSnapPoint The new Snap-To point
  133476. */
  133477. addSnapPoint(newSnapPoint: Vector3): void;
  133478. attach(): boolean;
  133479. detach(): boolean;
  133480. dispose(): void;
  133481. /**
  133482. * Remove a mesh from the floor meshes array
  133483. * @param mesh the mesh to remove
  133484. */
  133485. removeFloorMesh(mesh: AbstractMesh): void;
  133486. /**
  133487. * Remove a mesh from the floor meshes array using its name
  133488. * @param name the mesh name to remove
  133489. */
  133490. removeFloorMeshByName(name: string): void;
  133491. /**
  133492. * 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
  133493. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  133494. * @returns was the point found and removed or not
  133495. */
  133496. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  133497. /**
  133498. * This function sets a selection feature that will be disabled when
  133499. * the forward ray is shown and will be reattached when hidden.
  133500. * This is used to remove the selection rays when moving.
  133501. * @param selectionFeature the feature to disable when forward movement is enabled
  133502. */
  133503. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  133504. protected _onXRFrame(_xrFrame: XRFrame): void;
  133505. private _attachController;
  133506. private _createDefaultTargetMesh;
  133507. private _detachController;
  133508. private _findClosestSnapPointWithRadius;
  133509. private _setTargetMeshPosition;
  133510. private _setTargetMeshVisibility;
  133511. private _showParabolicPath;
  133512. private _teleportForward;
  133513. }
  133514. }
  133515. declare module BABYLON {
  133516. /**
  133517. * Options for the default xr helper
  133518. */
  133519. export class WebXRDefaultExperienceOptions {
  133520. /**
  133521. * Enable or disable default UI to enter XR
  133522. */
  133523. disableDefaultUI?: boolean;
  133524. /**
  133525. * Should teleportation not initialize. defaults to false.
  133526. */
  133527. disableTeleportation?: boolean;
  133528. /**
  133529. * Floor meshes that will be used for teleport
  133530. */
  133531. floorMeshes?: Array<AbstractMesh>;
  133532. /**
  133533. * If set to true, the first frame will not be used to reset position
  133534. * The first frame is mainly used when copying transformation from the old camera
  133535. * Mainly used in AR
  133536. */
  133537. ignoreNativeCameraTransformation?: boolean;
  133538. /**
  133539. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  133540. */
  133541. inputOptions?: IWebXRInputOptions;
  133542. /**
  133543. * optional configuration for the output canvas
  133544. */
  133545. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  133546. /**
  133547. * optional UI options. This can be used among other to change session mode and reference space type
  133548. */
  133549. uiOptions?: WebXREnterExitUIOptions;
  133550. /**
  133551. * When loading teleportation and pointer select, use stable versions instead of latest.
  133552. */
  133553. useStablePlugins?: boolean;
  133554. /**
  133555. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  133556. */
  133557. renderingGroupId?: number;
  133558. /**
  133559. * A list of optional features to init the session with
  133560. * If set to true, all features we support will be added
  133561. */
  133562. optionalFeatures?: boolean | string[];
  133563. }
  133564. /**
  133565. * Default experience which provides a similar setup to the previous webVRExperience
  133566. */
  133567. export class WebXRDefaultExperience {
  133568. /**
  133569. * Base experience
  133570. */
  133571. baseExperience: WebXRExperienceHelper;
  133572. /**
  133573. * Enables ui for entering/exiting xr
  133574. */
  133575. enterExitUI: WebXREnterExitUI;
  133576. /**
  133577. * Input experience extension
  133578. */
  133579. input: WebXRInput;
  133580. /**
  133581. * Enables laser pointer and selection
  133582. */
  133583. pointerSelection: WebXRControllerPointerSelection;
  133584. /**
  133585. * Default target xr should render to
  133586. */
  133587. renderTarget: WebXRRenderTarget;
  133588. /**
  133589. * Enables teleportation
  133590. */
  133591. teleportation: WebXRMotionControllerTeleportation;
  133592. private constructor();
  133593. /**
  133594. * Creates the default xr experience
  133595. * @param scene scene
  133596. * @param options options for basic configuration
  133597. * @returns resulting WebXRDefaultExperience
  133598. */
  133599. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  133600. /**
  133601. * DIsposes of the experience helper
  133602. */
  133603. dispose(): void;
  133604. }
  133605. }
  133606. declare module BABYLON {
  133607. /**
  133608. * Options to modify the vr teleportation behavior.
  133609. */
  133610. export interface VRTeleportationOptions {
  133611. /**
  133612. * The name of the mesh which should be used as the teleportation floor. (default: null)
  133613. */
  133614. floorMeshName?: string;
  133615. /**
  133616. * A list of meshes to be used as the teleportation floor. (default: empty)
  133617. */
  133618. floorMeshes?: Mesh[];
  133619. /**
  133620. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  133621. */
  133622. teleportationMode?: number;
  133623. /**
  133624. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  133625. */
  133626. teleportationTime?: number;
  133627. /**
  133628. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  133629. */
  133630. teleportationSpeed?: number;
  133631. /**
  133632. * The easing function used in the animation or null for Linear. (default CircleEase)
  133633. */
  133634. easingFunction?: EasingFunction;
  133635. }
  133636. /**
  133637. * Options to modify the vr experience helper's behavior.
  133638. */
  133639. export interface VRExperienceHelperOptions extends WebVROptions {
  133640. /**
  133641. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  133642. */
  133643. createDeviceOrientationCamera?: boolean;
  133644. /**
  133645. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  133646. */
  133647. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  133648. /**
  133649. * Uses the main button on the controller to toggle the laser casted. (default: true)
  133650. */
  133651. laserToggle?: boolean;
  133652. /**
  133653. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  133654. */
  133655. floorMeshes?: Mesh[];
  133656. /**
  133657. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  133658. */
  133659. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  133660. /**
  133661. * Defines if WebXR should be used instead of WebVR (if available)
  133662. */
  133663. useXR?: boolean;
  133664. }
  133665. /**
  133666. * Event containing information after VR has been entered
  133667. */
  133668. export class OnAfterEnteringVRObservableEvent {
  133669. /**
  133670. * If entering vr was successful
  133671. */
  133672. success: boolean;
  133673. }
  133674. /**
  133675. * Helps to quickly add VR support to an existing scene.
  133676. * See https://doc.babylonjs.com/how_to/webvr_helper
  133677. */
  133678. export class VRExperienceHelper {
  133679. /** Options to modify the vr experience helper's behavior. */
  133680. webVROptions: VRExperienceHelperOptions;
  133681. private _scene;
  133682. private _position;
  133683. private _btnVR;
  133684. private _btnVRDisplayed;
  133685. private _webVRsupported;
  133686. private _webVRready;
  133687. private _webVRrequesting;
  133688. private _webVRpresenting;
  133689. private _hasEnteredVR;
  133690. private _fullscreenVRpresenting;
  133691. private _inputElement;
  133692. private _webVRCamera;
  133693. private _vrDeviceOrientationCamera;
  133694. private _deviceOrientationCamera;
  133695. private _existingCamera;
  133696. private _onKeyDown;
  133697. private _onVrDisplayPresentChange;
  133698. private _onVRDisplayChanged;
  133699. private _onVRRequestPresentStart;
  133700. private _onVRRequestPresentComplete;
  133701. /**
  133702. * 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)
  133703. */
  133704. enableGazeEvenWhenNoPointerLock: boolean;
  133705. /**
  133706. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  133707. */
  133708. exitVROnDoubleTap: boolean;
  133709. /**
  133710. * Observable raised right before entering VR.
  133711. */
  133712. onEnteringVRObservable: Observable<VRExperienceHelper>;
  133713. /**
  133714. * Observable raised when entering VR has completed.
  133715. */
  133716. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  133717. /**
  133718. * Observable raised when exiting VR.
  133719. */
  133720. onExitingVRObservable: Observable<VRExperienceHelper>;
  133721. /**
  133722. * Observable raised when controller mesh is loaded.
  133723. */
  133724. onControllerMeshLoadedObservable: Observable<WebVRController>;
  133725. /** Return this.onEnteringVRObservable
  133726. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  133727. */
  133728. get onEnteringVR(): Observable<VRExperienceHelper>;
  133729. /** Return this.onExitingVRObservable
  133730. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  133731. */
  133732. get onExitingVR(): Observable<VRExperienceHelper>;
  133733. /** Return this.onControllerMeshLoadedObservable
  133734. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  133735. */
  133736. get onControllerMeshLoaded(): Observable<WebVRController>;
  133737. private _rayLength;
  133738. private _useCustomVRButton;
  133739. private _teleportationRequested;
  133740. private _teleportActive;
  133741. private _floorMeshName;
  133742. private _floorMeshesCollection;
  133743. private _teleportationMode;
  133744. private _teleportationTime;
  133745. private _teleportationSpeed;
  133746. private _teleportationEasing;
  133747. private _rotationAllowed;
  133748. private _teleportBackwardsVector;
  133749. private _teleportationTarget;
  133750. private _isDefaultTeleportationTarget;
  133751. private _postProcessMove;
  133752. private _teleportationFillColor;
  133753. private _teleportationBorderColor;
  133754. private _rotationAngle;
  133755. private _haloCenter;
  133756. private _cameraGazer;
  133757. private _padSensibilityUp;
  133758. private _padSensibilityDown;
  133759. private _leftController;
  133760. private _rightController;
  133761. private _gazeColor;
  133762. private _laserColor;
  133763. private _pickedLaserColor;
  133764. private _pickedGazeColor;
  133765. /**
  133766. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  133767. */
  133768. onNewMeshSelected: Observable<AbstractMesh>;
  133769. /**
  133770. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  133771. * This observable will provide the mesh and the controller used to select the mesh
  133772. */
  133773. onMeshSelectedWithController: Observable<{
  133774. mesh: AbstractMesh;
  133775. controller: WebVRController;
  133776. }>;
  133777. /**
  133778. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  133779. */
  133780. onNewMeshPicked: Observable<PickingInfo>;
  133781. private _circleEase;
  133782. /**
  133783. * Observable raised before camera teleportation
  133784. */
  133785. onBeforeCameraTeleport: Observable<Vector3>;
  133786. /**
  133787. * Observable raised after camera teleportation
  133788. */
  133789. onAfterCameraTeleport: Observable<Vector3>;
  133790. /**
  133791. * Observable raised when current selected mesh gets unselected
  133792. */
  133793. onSelectedMeshUnselected: Observable<AbstractMesh>;
  133794. private _raySelectionPredicate;
  133795. /**
  133796. * To be optionaly changed by user to define custom ray selection
  133797. */
  133798. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  133799. /**
  133800. * To be optionaly changed by user to define custom selection logic (after ray selection)
  133801. */
  133802. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  133803. /**
  133804. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  133805. */
  133806. teleportationEnabled: boolean;
  133807. private _defaultHeight;
  133808. private _teleportationInitialized;
  133809. private _interactionsEnabled;
  133810. private _interactionsRequested;
  133811. private _displayGaze;
  133812. private _displayLaserPointer;
  133813. /**
  133814. * The mesh used to display where the user is going to teleport.
  133815. */
  133816. get teleportationTarget(): Mesh;
  133817. /**
  133818. * Sets the mesh to be used to display where the user is going to teleport.
  133819. */
  133820. set teleportationTarget(value: Mesh);
  133821. /**
  133822. * 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
  133823. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  133824. * See https://doc.babylonjs.com/resources/baking_transformations
  133825. */
  133826. get gazeTrackerMesh(): Mesh;
  133827. set gazeTrackerMesh(value: Mesh);
  133828. /**
  133829. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  133830. */
  133831. updateGazeTrackerScale: boolean;
  133832. /**
  133833. * If the gaze trackers color should be updated when selecting meshes
  133834. */
  133835. updateGazeTrackerColor: boolean;
  133836. /**
  133837. * If the controller laser color should be updated when selecting meshes
  133838. */
  133839. updateControllerLaserColor: boolean;
  133840. /**
  133841. * The gaze tracking mesh corresponding to the left controller
  133842. */
  133843. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  133844. /**
  133845. * The gaze tracking mesh corresponding to the right controller
  133846. */
  133847. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  133848. /**
  133849. * If the ray of the gaze should be displayed.
  133850. */
  133851. get displayGaze(): boolean;
  133852. /**
  133853. * Sets if the ray of the gaze should be displayed.
  133854. */
  133855. set displayGaze(value: boolean);
  133856. /**
  133857. * If the ray of the LaserPointer should be displayed.
  133858. */
  133859. get displayLaserPointer(): boolean;
  133860. /**
  133861. * Sets if the ray of the LaserPointer should be displayed.
  133862. */
  133863. set displayLaserPointer(value: boolean);
  133864. /**
  133865. * The deviceOrientationCamera used as the camera when not in VR.
  133866. */
  133867. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  133868. /**
  133869. * Based on the current WebVR support, returns the current VR camera used.
  133870. */
  133871. get currentVRCamera(): Nullable<Camera>;
  133872. /**
  133873. * The webVRCamera which is used when in VR.
  133874. */
  133875. get webVRCamera(): WebVRFreeCamera;
  133876. /**
  133877. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  133878. */
  133879. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  133880. /**
  133881. * The html button that is used to trigger entering into VR.
  133882. */
  133883. get vrButton(): Nullable<HTMLButtonElement>;
  133884. private get _teleportationRequestInitiated();
  133885. /**
  133886. * Defines whether or not Pointer lock should be requested when switching to
  133887. * full screen.
  133888. */
  133889. requestPointerLockOnFullScreen: boolean;
  133890. /**
  133891. * If asking to force XR, this will be populated with the default xr experience
  133892. */
  133893. xr: WebXRDefaultExperience;
  133894. /**
  133895. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  133896. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  133897. */
  133898. xrTestDone: boolean;
  133899. /**
  133900. * Instantiates a VRExperienceHelper.
  133901. * Helps to quickly add VR support to an existing scene.
  133902. * @param scene The scene the VRExperienceHelper belongs to.
  133903. * @param webVROptions Options to modify the vr experience helper's behavior.
  133904. */
  133905. constructor(scene: Scene,
  133906. /** Options to modify the vr experience helper's behavior. */
  133907. webVROptions?: VRExperienceHelperOptions);
  133908. private completeVRInit;
  133909. private _onDefaultMeshLoaded;
  133910. private _onResize;
  133911. private _onFullscreenChange;
  133912. /**
  133913. * Gets a value indicating if we are currently in VR mode.
  133914. */
  133915. get isInVRMode(): boolean;
  133916. private onVrDisplayPresentChange;
  133917. private onVRDisplayChanged;
  133918. private moveButtonToBottomRight;
  133919. private displayVRButton;
  133920. private updateButtonVisibility;
  133921. private _cachedAngularSensibility;
  133922. /**
  133923. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  133924. * Otherwise, will use the fullscreen API.
  133925. */
  133926. enterVR(): void;
  133927. /**
  133928. * Attempt to exit VR, or fullscreen.
  133929. */
  133930. exitVR(): void;
  133931. /**
  133932. * The position of the vr experience helper.
  133933. */
  133934. get position(): Vector3;
  133935. /**
  133936. * Sets the position of the vr experience helper.
  133937. */
  133938. set position(value: Vector3);
  133939. /**
  133940. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  133941. */
  133942. enableInteractions(): void;
  133943. private get _noControllerIsActive();
  133944. private beforeRender;
  133945. private _isTeleportationFloor;
  133946. /**
  133947. * Adds a floor mesh to be used for teleportation.
  133948. * @param floorMesh the mesh to be used for teleportation.
  133949. */
  133950. addFloorMesh(floorMesh: Mesh): void;
  133951. /**
  133952. * Removes a floor mesh from being used for teleportation.
  133953. * @param floorMesh the mesh to be removed.
  133954. */
  133955. removeFloorMesh(floorMesh: Mesh): void;
  133956. /**
  133957. * Enables interactions and teleportation using the VR controllers and gaze.
  133958. * @param vrTeleportationOptions options to modify teleportation behavior.
  133959. */
  133960. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  133961. private _onNewGamepadConnected;
  133962. private _tryEnableInteractionOnController;
  133963. private _onNewGamepadDisconnected;
  133964. private _enableInteractionOnController;
  133965. private _checkTeleportWithRay;
  133966. private _checkRotate;
  133967. private _checkTeleportBackwards;
  133968. private _enableTeleportationOnController;
  133969. private _createTeleportationCircles;
  133970. private _displayTeleportationTarget;
  133971. private _hideTeleportationTarget;
  133972. private _rotateCamera;
  133973. private _moveTeleportationSelectorTo;
  133974. private _workingVector;
  133975. private _workingQuaternion;
  133976. private _workingMatrix;
  133977. /**
  133978. * Time Constant Teleportation Mode
  133979. */
  133980. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  133981. /**
  133982. * Speed Constant Teleportation Mode
  133983. */
  133984. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  133985. /**
  133986. * Teleports the users feet to the desired location
  133987. * @param location The location where the user's feet should be placed
  133988. */
  133989. teleportCamera(location: Vector3): void;
  133990. private _convertNormalToDirectionOfRay;
  133991. private _castRayAndSelectObject;
  133992. private _notifySelectedMeshUnselected;
  133993. /**
  133994. * Permanently set new colors for the laser pointer
  133995. * @param color the new laser color
  133996. * @param pickedColor the new laser color when picked mesh detected
  133997. */
  133998. setLaserColor(color: Color3, pickedColor?: Color3): void;
  133999. /**
  134000. * Set lighting enabled / disabled on the laser pointer of both controllers
  134001. * @param enabled should the lighting be enabled on the laser pointer
  134002. */
  134003. setLaserLightingState(enabled?: boolean): void;
  134004. /**
  134005. * Permanently set new colors for the gaze pointer
  134006. * @param color the new gaze color
  134007. * @param pickedColor the new gaze color when picked mesh detected
  134008. */
  134009. setGazeColor(color: Color3, pickedColor?: Color3): void;
  134010. /**
  134011. * Sets the color of the laser ray from the vr controllers.
  134012. * @param color new color for the ray.
  134013. */
  134014. changeLaserColor(color: Color3): void;
  134015. /**
  134016. * Sets the color of the ray from the vr headsets gaze.
  134017. * @param color new color for the ray.
  134018. */
  134019. changeGazeColor(color: Color3): void;
  134020. /**
  134021. * Exits VR and disposes of the vr experience helper
  134022. */
  134023. dispose(): void;
  134024. /**
  134025. * Gets the name of the VRExperienceHelper class
  134026. * @returns "VRExperienceHelper"
  134027. */
  134028. getClassName(): string;
  134029. }
  134030. }
  134031. declare module BABYLON {
  134032. /**
  134033. * Contains an array of blocks representing the octree
  134034. */
  134035. export interface IOctreeContainer<T> {
  134036. /**
  134037. * Blocks within the octree
  134038. */
  134039. blocks: Array<OctreeBlock<T>>;
  134040. }
  134041. /**
  134042. * Class used to store a cell in an octree
  134043. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134044. */
  134045. export class OctreeBlock<T> {
  134046. /**
  134047. * Gets the content of the current block
  134048. */
  134049. entries: T[];
  134050. /**
  134051. * Gets the list of block children
  134052. */
  134053. blocks: Array<OctreeBlock<T>>;
  134054. private _depth;
  134055. private _maxDepth;
  134056. private _capacity;
  134057. private _minPoint;
  134058. private _maxPoint;
  134059. private _boundingVectors;
  134060. private _creationFunc;
  134061. /**
  134062. * Creates a new block
  134063. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  134064. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  134065. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  134066. * @param depth defines the current depth of this block in the octree
  134067. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  134068. * @param creationFunc defines a callback to call when an element is added to the block
  134069. */
  134070. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  134071. /**
  134072. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  134073. */
  134074. get capacity(): number;
  134075. /**
  134076. * Gets the minimum vector (in world space) of the block's bounding box
  134077. */
  134078. get minPoint(): Vector3;
  134079. /**
  134080. * Gets the maximum vector (in world space) of the block's bounding box
  134081. */
  134082. get maxPoint(): Vector3;
  134083. /**
  134084. * Add a new element to this block
  134085. * @param entry defines the element to add
  134086. */
  134087. addEntry(entry: T): void;
  134088. /**
  134089. * Remove an element from this block
  134090. * @param entry defines the element to remove
  134091. */
  134092. removeEntry(entry: T): void;
  134093. /**
  134094. * Add an array of elements to this block
  134095. * @param entries defines the array of elements to add
  134096. */
  134097. addEntries(entries: T[]): void;
  134098. /**
  134099. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  134100. * @param frustumPlanes defines the frustum planes to test
  134101. * @param selection defines the array to store current content if selection is positive
  134102. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134103. */
  134104. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  134105. /**
  134106. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  134107. * @param sphereCenter defines the bounding sphere center
  134108. * @param sphereRadius defines the bounding sphere radius
  134109. * @param selection defines the array to store current content if selection is positive
  134110. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134111. */
  134112. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  134113. /**
  134114. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  134115. * @param ray defines the ray to test with
  134116. * @param selection defines the array to store current content if selection is positive
  134117. */
  134118. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  134119. /**
  134120. * Subdivide the content into child blocks (this block will then be empty)
  134121. */
  134122. createInnerBlocks(): void;
  134123. /**
  134124. * @hidden
  134125. */
  134126. 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;
  134127. }
  134128. }
  134129. declare module BABYLON {
  134130. /**
  134131. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  134132. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134133. */
  134134. export class Octree<T> {
  134135. /** 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.) */
  134136. maxDepth: number;
  134137. /**
  134138. * Blocks within the octree containing objects
  134139. */
  134140. blocks: Array<OctreeBlock<T>>;
  134141. /**
  134142. * Content stored in the octree
  134143. */
  134144. dynamicContent: T[];
  134145. private _maxBlockCapacity;
  134146. private _selectionContent;
  134147. private _creationFunc;
  134148. /**
  134149. * Creates a octree
  134150. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134151. * @param creationFunc function to be used to instatiate the octree
  134152. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  134153. * @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.)
  134154. */
  134155. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  134156. /** 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.) */
  134157. maxDepth?: number);
  134158. /**
  134159. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  134160. * @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);
  134161. * @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);
  134162. * @param entries meshes to be added to the octree blocks
  134163. */
  134164. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  134165. /**
  134166. * Adds a mesh to the octree
  134167. * @param entry Mesh to add to the octree
  134168. */
  134169. addMesh(entry: T): void;
  134170. /**
  134171. * Remove an element from the octree
  134172. * @param entry defines the element to remove
  134173. */
  134174. removeMesh(entry: T): void;
  134175. /**
  134176. * Selects an array of meshes within the frustum
  134177. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  134178. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  134179. * @returns array of meshes within the frustum
  134180. */
  134181. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  134182. /**
  134183. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  134184. * @param sphereCenter defines the bounding sphere center
  134185. * @param sphereRadius defines the bounding sphere radius
  134186. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134187. * @returns an array of objects that intersect the sphere
  134188. */
  134189. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  134190. /**
  134191. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  134192. * @param ray defines the ray to test with
  134193. * @returns array of intersected objects
  134194. */
  134195. intersectsRay(ray: Ray): SmartArray<T>;
  134196. /**
  134197. * Adds a mesh into the octree block if it intersects the block
  134198. */
  134199. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  134200. /**
  134201. * Adds a submesh into the octree block if it intersects the block
  134202. */
  134203. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  134204. }
  134205. }
  134206. declare module BABYLON {
  134207. interface Scene {
  134208. /**
  134209. * @hidden
  134210. * Backing Filed
  134211. */
  134212. _selectionOctree: Octree<AbstractMesh>;
  134213. /**
  134214. * Gets the octree used to boost mesh selection (picking)
  134215. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134216. */
  134217. selectionOctree: Octree<AbstractMesh>;
  134218. /**
  134219. * Creates or updates the octree used to boost selection (picking)
  134220. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134221. * @param maxCapacity defines the maximum capacity per leaf
  134222. * @param maxDepth defines the maximum depth of the octree
  134223. * @returns an octree of AbstractMesh
  134224. */
  134225. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  134226. }
  134227. interface AbstractMesh {
  134228. /**
  134229. * @hidden
  134230. * Backing Field
  134231. */
  134232. _submeshesOctree: Octree<SubMesh>;
  134233. /**
  134234. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  134235. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  134236. * @param maxCapacity defines the maximum size of each block (64 by default)
  134237. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  134238. * @returns the new octree
  134239. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  134240. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134241. */
  134242. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  134243. }
  134244. /**
  134245. * Defines the octree scene component responsible to manage any octrees
  134246. * in a given scene.
  134247. */
  134248. export class OctreeSceneComponent {
  134249. /**
  134250. * The component name help to identify the component in the list of scene components.
  134251. */
  134252. readonly name: string;
  134253. /**
  134254. * The scene the component belongs to.
  134255. */
  134256. scene: Scene;
  134257. /**
  134258. * Indicates if the meshes have been checked to make sure they are isEnabled()
  134259. */
  134260. readonly checksIsEnabled: boolean;
  134261. /**
  134262. * Creates a new instance of the component for the given scene
  134263. * @param scene Defines the scene to register the component in
  134264. */
  134265. constructor(scene: Scene);
  134266. /**
  134267. * Registers the component in a given scene
  134268. */
  134269. register(): void;
  134270. /**
  134271. * Return the list of active meshes
  134272. * @returns the list of active meshes
  134273. */
  134274. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  134275. /**
  134276. * Return the list of active sub meshes
  134277. * @param mesh The mesh to get the candidates sub meshes from
  134278. * @returns the list of active sub meshes
  134279. */
  134280. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  134281. private _tempRay;
  134282. /**
  134283. * Return the list of sub meshes intersecting with a given local ray
  134284. * @param mesh defines the mesh to find the submesh for
  134285. * @param localRay defines the ray in local space
  134286. * @returns the list of intersecting sub meshes
  134287. */
  134288. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  134289. /**
  134290. * Return the list of sub meshes colliding with a collider
  134291. * @param mesh defines the mesh to find the submesh for
  134292. * @param collider defines the collider to evaluate the collision against
  134293. * @returns the list of colliding sub meshes
  134294. */
  134295. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  134296. /**
  134297. * Rebuilds the elements related to this component in case of
  134298. * context lost for instance.
  134299. */
  134300. rebuild(): void;
  134301. /**
  134302. * Disposes the component and the associated ressources.
  134303. */
  134304. dispose(): void;
  134305. }
  134306. }
  134307. declare module BABYLON {
  134308. /**
  134309. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  134310. */
  134311. export class Gizmo implements IDisposable {
  134312. /** The utility layer the gizmo will be added to */
  134313. gizmoLayer: UtilityLayerRenderer;
  134314. /**
  134315. * The root mesh of the gizmo
  134316. */
  134317. _rootMesh: Mesh;
  134318. private _attachedMesh;
  134319. private _attachedNode;
  134320. /**
  134321. * Ratio for the scale of the gizmo (Default: 1)
  134322. */
  134323. protected _scaleRatio: number;
  134324. /**
  134325. * boolean updated by pointermove when a gizmo mesh is hovered
  134326. */
  134327. protected _isHovered: boolean;
  134328. /**
  134329. * Ratio for the scale of the gizmo (Default: 1)
  134330. */
  134331. set scaleRatio(value: number);
  134332. get scaleRatio(): number;
  134333. /**
  134334. * True when the mouse pointer is hovered a gizmo mesh
  134335. */
  134336. get isHovered(): boolean;
  134337. /**
  134338. * If a custom mesh has been set (Default: false)
  134339. */
  134340. protected _customMeshSet: boolean;
  134341. /**
  134342. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  134343. * * When set, interactions will be enabled
  134344. */
  134345. get attachedMesh(): Nullable<AbstractMesh>;
  134346. set attachedMesh(value: Nullable<AbstractMesh>);
  134347. /**
  134348. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  134349. * * When set, interactions will be enabled
  134350. */
  134351. get attachedNode(): Nullable<Node>;
  134352. set attachedNode(value: Nullable<Node>);
  134353. /**
  134354. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  134355. * @param mesh The mesh to replace the default mesh of the gizmo
  134356. */
  134357. setCustomMesh(mesh: Mesh): void;
  134358. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  134359. /**
  134360. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  134361. */
  134362. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134363. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134364. /**
  134365. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  134366. */
  134367. updateGizmoPositionToMatchAttachedMesh: boolean;
  134368. /**
  134369. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  134370. */
  134371. updateScale: boolean;
  134372. protected _interactionsEnabled: boolean;
  134373. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134374. private _beforeRenderObserver;
  134375. private _tempQuaternion;
  134376. private _tempVector;
  134377. private _tempVector2;
  134378. private _tempMatrix1;
  134379. private _tempMatrix2;
  134380. private _rightHandtoLeftHandMatrix;
  134381. /**
  134382. * Creates a gizmo
  134383. * @param gizmoLayer The utility layer the gizmo will be added to
  134384. */
  134385. constructor(
  134386. /** The utility layer the gizmo will be added to */
  134387. gizmoLayer?: UtilityLayerRenderer);
  134388. /**
  134389. * Updates the gizmo to match the attached mesh's position/rotation
  134390. */
  134391. protected _update(): void;
  134392. /**
  134393. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  134394. * @param value Node, TransformNode or mesh
  134395. */
  134396. protected _matrixChanged(): void;
  134397. /**
  134398. * Disposes of the gizmo
  134399. */
  134400. dispose(): void;
  134401. }
  134402. }
  134403. declare module BABYLON {
  134404. /**
  134405. * Single plane drag gizmo
  134406. */
  134407. export class PlaneDragGizmo extends Gizmo {
  134408. /**
  134409. * Drag behavior responsible for the gizmos dragging interactions
  134410. */
  134411. dragBehavior: PointerDragBehavior;
  134412. private _pointerObserver;
  134413. /**
  134414. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134415. */
  134416. snapDistance: number;
  134417. /**
  134418. * Event that fires each time the gizmo snaps to a new location.
  134419. * * snapDistance is the the change in distance
  134420. */
  134421. onSnapObservable: Observable<{
  134422. snapDistance: number;
  134423. }>;
  134424. private _plane;
  134425. private _coloredMaterial;
  134426. private _hoverMaterial;
  134427. private _isEnabled;
  134428. private _parent;
  134429. /** @hidden */
  134430. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  134431. /** @hidden */
  134432. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  134433. /**
  134434. * Creates a PlaneDragGizmo
  134435. * @param gizmoLayer The utility layer the gizmo will be added to
  134436. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  134437. * @param color The color of the gizmo
  134438. */
  134439. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  134440. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134441. /**
  134442. * If the gizmo is enabled
  134443. */
  134444. set isEnabled(value: boolean);
  134445. get isEnabled(): boolean;
  134446. /**
  134447. * Disposes of the gizmo
  134448. */
  134449. dispose(): void;
  134450. }
  134451. }
  134452. declare module BABYLON {
  134453. /**
  134454. * Gizmo that enables dragging a mesh along 3 axis
  134455. */
  134456. export class PositionGizmo extends Gizmo {
  134457. /**
  134458. * Internal gizmo used for interactions on the x axis
  134459. */
  134460. xGizmo: AxisDragGizmo;
  134461. /**
  134462. * Internal gizmo used for interactions on the y axis
  134463. */
  134464. yGizmo: AxisDragGizmo;
  134465. /**
  134466. * Internal gizmo used for interactions on the z axis
  134467. */
  134468. zGizmo: AxisDragGizmo;
  134469. /**
  134470. * Internal gizmo used for interactions on the yz plane
  134471. */
  134472. xPlaneGizmo: PlaneDragGizmo;
  134473. /**
  134474. * Internal gizmo used for interactions on the xz plane
  134475. */
  134476. yPlaneGizmo: PlaneDragGizmo;
  134477. /**
  134478. * Internal gizmo used for interactions on the xy plane
  134479. */
  134480. zPlaneGizmo: PlaneDragGizmo;
  134481. /**
  134482. * private variables
  134483. */
  134484. private _meshAttached;
  134485. private _nodeAttached;
  134486. private _snapDistance;
  134487. /** Fires an event when any of it's sub gizmos are dragged */
  134488. onDragStartObservable: Observable<unknown>;
  134489. /** Fires an event when any of it's sub gizmos are released from dragging */
  134490. onDragEndObservable: Observable<unknown>;
  134491. /**
  134492. * If set to true, planar drag is enabled
  134493. */
  134494. private _planarGizmoEnabled;
  134495. get attachedMesh(): Nullable<AbstractMesh>;
  134496. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134497. get attachedNode(): Nullable<Node>;
  134498. set attachedNode(node: Nullable<Node>);
  134499. /**
  134500. * True when the mouse pointer is hovering a gizmo mesh
  134501. */
  134502. get isHovered(): boolean;
  134503. /**
  134504. * Creates a PositionGizmo
  134505. * @param gizmoLayer The utility layer the gizmo will be added to
  134506. @param thickness display gizmo axis thickness
  134507. */
  134508. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  134509. /**
  134510. * If the planar drag gizmo is enabled
  134511. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  134512. */
  134513. set planarGizmoEnabled(value: boolean);
  134514. get planarGizmoEnabled(): boolean;
  134515. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134516. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134517. /**
  134518. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134519. */
  134520. set snapDistance(value: number);
  134521. get snapDistance(): number;
  134522. /**
  134523. * Ratio for the scale of the gizmo (Default: 1)
  134524. */
  134525. set scaleRatio(value: number);
  134526. get scaleRatio(): number;
  134527. /**
  134528. * Disposes of the gizmo
  134529. */
  134530. dispose(): void;
  134531. /**
  134532. * CustomMeshes are not supported by this gizmo
  134533. * @param mesh The mesh to replace the default mesh of the gizmo
  134534. */
  134535. setCustomMesh(mesh: Mesh): void;
  134536. }
  134537. }
  134538. declare module BABYLON {
  134539. /**
  134540. * Single axis drag gizmo
  134541. */
  134542. export class AxisDragGizmo extends Gizmo {
  134543. /**
  134544. * Drag behavior responsible for the gizmos dragging interactions
  134545. */
  134546. dragBehavior: PointerDragBehavior;
  134547. private _pointerObserver;
  134548. /**
  134549. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134550. */
  134551. snapDistance: number;
  134552. /**
  134553. * Event that fires each time the gizmo snaps to a new location.
  134554. * * snapDistance is the the change in distance
  134555. */
  134556. onSnapObservable: Observable<{
  134557. snapDistance: number;
  134558. }>;
  134559. private _isEnabled;
  134560. private _parent;
  134561. private _arrow;
  134562. private _coloredMaterial;
  134563. private _hoverMaterial;
  134564. /** @hidden */
  134565. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  134566. /** @hidden */
  134567. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  134568. /**
  134569. * Creates an AxisDragGizmo
  134570. * @param gizmoLayer The utility layer the gizmo will be added to
  134571. * @param dragAxis The axis which the gizmo will be able to drag on
  134572. * @param color The color of the gizmo
  134573. * @param thickness display gizmo axis thickness
  134574. */
  134575. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  134576. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134577. /**
  134578. * If the gizmo is enabled
  134579. */
  134580. set isEnabled(value: boolean);
  134581. get isEnabled(): boolean;
  134582. /**
  134583. * Disposes of the gizmo
  134584. */
  134585. dispose(): void;
  134586. }
  134587. }
  134588. declare module BABYLON.Debug {
  134589. /**
  134590. * The Axes viewer will show 3 axes in a specific point in space
  134591. */
  134592. export class AxesViewer {
  134593. private _xAxis;
  134594. private _yAxis;
  134595. private _zAxis;
  134596. private _scaleLinesFactor;
  134597. private _instanced;
  134598. /**
  134599. * Gets the hosting scene
  134600. */
  134601. scene: Nullable<Scene>;
  134602. /**
  134603. * Gets or sets a number used to scale line length
  134604. */
  134605. scaleLines: number;
  134606. /** Gets the node hierarchy used to render x-axis */
  134607. get xAxis(): TransformNode;
  134608. /** Gets the node hierarchy used to render y-axis */
  134609. get yAxis(): TransformNode;
  134610. /** Gets the node hierarchy used to render z-axis */
  134611. get zAxis(): TransformNode;
  134612. /**
  134613. * Creates a new AxesViewer
  134614. * @param scene defines the hosting scene
  134615. * @param scaleLines defines a number used to scale line length (1 by default)
  134616. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  134617. * @param xAxis defines the node hierarchy used to render the x-axis
  134618. * @param yAxis defines the node hierarchy used to render the y-axis
  134619. * @param zAxis defines the node hierarchy used to render the z-axis
  134620. */
  134621. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  134622. /**
  134623. * Force the viewer to update
  134624. * @param position defines the position of the viewer
  134625. * @param xaxis defines the x axis of the viewer
  134626. * @param yaxis defines the y axis of the viewer
  134627. * @param zaxis defines the z axis of the viewer
  134628. */
  134629. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  134630. /**
  134631. * Creates an instance of this axes viewer.
  134632. * @returns a new axes viewer with instanced meshes
  134633. */
  134634. createInstance(): AxesViewer;
  134635. /** Releases resources */
  134636. dispose(): void;
  134637. private static _SetRenderingGroupId;
  134638. }
  134639. }
  134640. declare module BABYLON.Debug {
  134641. /**
  134642. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  134643. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  134644. */
  134645. export class BoneAxesViewer extends AxesViewer {
  134646. /**
  134647. * Gets or sets the target mesh where to display the axes viewer
  134648. */
  134649. mesh: Nullable<Mesh>;
  134650. /**
  134651. * Gets or sets the target bone where to display the axes viewer
  134652. */
  134653. bone: Nullable<Bone>;
  134654. /** Gets current position */
  134655. pos: Vector3;
  134656. /** Gets direction of X axis */
  134657. xaxis: Vector3;
  134658. /** Gets direction of Y axis */
  134659. yaxis: Vector3;
  134660. /** Gets direction of Z axis */
  134661. zaxis: Vector3;
  134662. /**
  134663. * Creates a new BoneAxesViewer
  134664. * @param scene defines the hosting scene
  134665. * @param bone defines the target bone
  134666. * @param mesh defines the target mesh
  134667. * @param scaleLines defines a scaling factor for line length (1 by default)
  134668. */
  134669. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  134670. /**
  134671. * Force the viewer to update
  134672. */
  134673. update(): void;
  134674. /** Releases resources */
  134675. dispose(): void;
  134676. }
  134677. }
  134678. declare module BABYLON {
  134679. /**
  134680. * Interface used to define scene explorer extensibility option
  134681. */
  134682. export interface IExplorerExtensibilityOption {
  134683. /**
  134684. * Define the option label
  134685. */
  134686. label: string;
  134687. /**
  134688. * Defines the action to execute on click
  134689. */
  134690. action: (entity: any) => void;
  134691. }
  134692. /**
  134693. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  134694. */
  134695. export interface IExplorerExtensibilityGroup {
  134696. /**
  134697. * Defines a predicate to test if a given type mut be extended
  134698. */
  134699. predicate: (entity: any) => boolean;
  134700. /**
  134701. * Gets the list of options added to a type
  134702. */
  134703. entries: IExplorerExtensibilityOption[];
  134704. }
  134705. /**
  134706. * Interface used to define the options to use to create the Inspector
  134707. */
  134708. export interface IInspectorOptions {
  134709. /**
  134710. * Display in overlay mode (default: false)
  134711. */
  134712. overlay?: boolean;
  134713. /**
  134714. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  134715. */
  134716. globalRoot?: HTMLElement;
  134717. /**
  134718. * Display the Scene explorer
  134719. */
  134720. showExplorer?: boolean;
  134721. /**
  134722. * Display the property inspector
  134723. */
  134724. showInspector?: boolean;
  134725. /**
  134726. * Display in embed mode (both panes on the right)
  134727. */
  134728. embedMode?: boolean;
  134729. /**
  134730. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  134731. */
  134732. handleResize?: boolean;
  134733. /**
  134734. * Allow the panes to popup (default: true)
  134735. */
  134736. enablePopup?: boolean;
  134737. /**
  134738. * Allow the panes to be closed by users (default: true)
  134739. */
  134740. enableClose?: boolean;
  134741. /**
  134742. * Optional list of extensibility entries
  134743. */
  134744. explorerExtensibility?: IExplorerExtensibilityGroup[];
  134745. /**
  134746. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  134747. */
  134748. inspectorURL?: string;
  134749. /**
  134750. * Optional initial tab (default to DebugLayerTab.Properties)
  134751. */
  134752. initialTab?: DebugLayerTab;
  134753. }
  134754. interface Scene {
  134755. /**
  134756. * @hidden
  134757. * Backing field
  134758. */
  134759. _debugLayer: DebugLayer;
  134760. /**
  134761. * Gets the debug layer (aka Inspector) associated with the scene
  134762. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134763. */
  134764. debugLayer: DebugLayer;
  134765. }
  134766. /**
  134767. * Enum of inspector action tab
  134768. */
  134769. export enum DebugLayerTab {
  134770. /**
  134771. * Properties tag (default)
  134772. */
  134773. Properties = 0,
  134774. /**
  134775. * Debug tab
  134776. */
  134777. Debug = 1,
  134778. /**
  134779. * Statistics tab
  134780. */
  134781. Statistics = 2,
  134782. /**
  134783. * Tools tab
  134784. */
  134785. Tools = 3,
  134786. /**
  134787. * Settings tab
  134788. */
  134789. Settings = 4
  134790. }
  134791. /**
  134792. * The debug layer (aka Inspector) is the go to tool in order to better understand
  134793. * what is happening in your scene
  134794. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134795. */
  134796. export class DebugLayer {
  134797. /**
  134798. * Define the url to get the inspector script from.
  134799. * By default it uses the babylonjs CDN.
  134800. * @ignoreNaming
  134801. */
  134802. static InspectorURL: string;
  134803. private _scene;
  134804. private BJSINSPECTOR;
  134805. private _onPropertyChangedObservable?;
  134806. /**
  134807. * Observable triggered when a property is changed through the inspector.
  134808. */
  134809. get onPropertyChangedObservable(): any;
  134810. /**
  134811. * Instantiates a new debug layer.
  134812. * The debug layer (aka Inspector) is the go to tool in order to better understand
  134813. * what is happening in your scene
  134814. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134815. * @param scene Defines the scene to inspect
  134816. */
  134817. constructor(scene: Scene);
  134818. /** Creates the inspector window. */
  134819. private _createInspector;
  134820. /**
  134821. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  134822. * @param entity defines the entity to select
  134823. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  134824. */
  134825. select(entity: any, lineContainerTitles?: string | string[]): void;
  134826. /** Get the inspector from bundle or global */
  134827. private _getGlobalInspector;
  134828. /**
  134829. * Get if the inspector is visible or not.
  134830. * @returns true if visible otherwise, false
  134831. */
  134832. isVisible(): boolean;
  134833. /**
  134834. * Hide the inspector and close its window.
  134835. */
  134836. hide(): void;
  134837. /**
  134838. * Update the scene in the inspector
  134839. */
  134840. setAsActiveScene(): void;
  134841. /**
  134842. * Launch the debugLayer.
  134843. * @param config Define the configuration of the inspector
  134844. * @return a promise fulfilled when the debug layer is visible
  134845. */
  134846. show(config?: IInspectorOptions): Promise<DebugLayer>;
  134847. }
  134848. }
  134849. declare module BABYLON {
  134850. /**
  134851. * Class containing static functions to help procedurally build meshes
  134852. */
  134853. export class BoxBuilder {
  134854. /**
  134855. * Creates a box mesh
  134856. * * The parameter `size` sets the size (float) of each box side (default 1)
  134857. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134858. * * 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)
  134859. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134863. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134864. * @param name defines the name of the mesh
  134865. * @param options defines the options used to create the mesh
  134866. * @param scene defines the hosting scene
  134867. * @returns the box mesh
  134868. */
  134869. static CreateBox(name: string, options: {
  134870. size?: number;
  134871. width?: number;
  134872. height?: number;
  134873. depth?: number;
  134874. faceUV?: Vector4[];
  134875. faceColors?: Color4[];
  134876. sideOrientation?: number;
  134877. frontUVs?: Vector4;
  134878. backUVs?: Vector4;
  134879. wrap?: boolean;
  134880. topBaseAt?: number;
  134881. bottomBaseAt?: number;
  134882. updatable?: boolean;
  134883. }, scene?: Nullable<Scene>): Mesh;
  134884. }
  134885. }
  134886. declare module BABYLON.Debug {
  134887. /**
  134888. * Used to show the physics impostor around the specific mesh
  134889. */
  134890. export class PhysicsViewer {
  134891. /** @hidden */
  134892. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  134893. /** @hidden */
  134894. protected _meshes: Array<Nullable<AbstractMesh>>;
  134895. /** @hidden */
  134896. protected _scene: Nullable<Scene>;
  134897. /** @hidden */
  134898. protected _numMeshes: number;
  134899. /** @hidden */
  134900. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  134901. private _renderFunction;
  134902. private _utilityLayer;
  134903. private _debugBoxMesh;
  134904. private _debugSphereMesh;
  134905. private _debugCylinderMesh;
  134906. private _debugMaterial;
  134907. private _debugMeshMeshes;
  134908. /**
  134909. * Creates a new PhysicsViewer
  134910. * @param scene defines the hosting scene
  134911. */
  134912. constructor(scene: Scene);
  134913. /** @hidden */
  134914. protected _updateDebugMeshes(): void;
  134915. /**
  134916. * Renders a specified physic impostor
  134917. * @param impostor defines the impostor to render
  134918. * @param targetMesh defines the mesh represented by the impostor
  134919. * @returns the new debug mesh used to render the impostor
  134920. */
  134921. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  134922. /**
  134923. * Hides a specified physic impostor
  134924. * @param impostor defines the impostor to hide
  134925. */
  134926. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  134927. private _getDebugMaterial;
  134928. private _getDebugBoxMesh;
  134929. private _getDebugSphereMesh;
  134930. private _getDebugCylinderMesh;
  134931. private _getDebugMeshMesh;
  134932. private _getDebugMesh;
  134933. /** Releases all resources */
  134934. dispose(): void;
  134935. }
  134936. }
  134937. declare module BABYLON {
  134938. /**
  134939. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  134940. * in order to better appreciate the issue one might have.
  134941. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  134942. */
  134943. export class RayHelper {
  134944. /**
  134945. * Defines the ray we are currently tryin to visualize.
  134946. */
  134947. ray: Nullable<Ray>;
  134948. private _renderPoints;
  134949. private _renderLine;
  134950. private _renderFunction;
  134951. private _scene;
  134952. private _onAfterRenderObserver;
  134953. private _onAfterStepObserver;
  134954. private _attachedToMesh;
  134955. private _meshSpaceDirection;
  134956. private _meshSpaceOrigin;
  134957. /**
  134958. * Helper function to create a colored helper in a scene in one line.
  134959. * @param ray Defines the ray we are currently tryin to visualize
  134960. * @param scene Defines the scene the ray is used in
  134961. * @param color Defines the color we want to see the ray in
  134962. * @returns The newly created ray helper.
  134963. */
  134964. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  134965. /**
  134966. * Instantiate a new ray helper.
  134967. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  134968. * in order to better appreciate the issue one might have.
  134969. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  134970. * @param ray Defines the ray we are currently tryin to visualize
  134971. */
  134972. constructor(ray: Ray);
  134973. /**
  134974. * Shows the ray we are willing to debug.
  134975. * @param scene Defines the scene the ray needs to be rendered in
  134976. * @param color Defines the color the ray needs to be rendered in
  134977. */
  134978. show(scene: Scene, color?: Color3): void;
  134979. /**
  134980. * Hides the ray we are debugging.
  134981. */
  134982. hide(): void;
  134983. private _render;
  134984. /**
  134985. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  134986. * @param mesh Defines the mesh we want the helper attached to
  134987. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  134988. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  134989. * @param length Defines the length of the ray
  134990. */
  134991. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  134992. /**
  134993. * Detach the ray helper from the mesh it has previously been attached to.
  134994. */
  134995. detachFromMesh(): void;
  134996. private _updateToMesh;
  134997. /**
  134998. * Dispose the helper and release its associated resources.
  134999. */
  135000. dispose(): void;
  135001. }
  135002. }
  135003. declare module BABYLON {
  135004. /**
  135005. * Defines the options associated with the creation of a SkeletonViewer.
  135006. */
  135007. export interface ISkeletonViewerOptions {
  135008. /** Should the system pause animations before building the Viewer? */
  135009. pauseAnimations: boolean;
  135010. /** Should the system return the skeleton to rest before building? */
  135011. returnToRest: boolean;
  135012. /** public Display Mode of the Viewer */
  135013. displayMode: number;
  135014. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  135015. displayOptions: ISkeletonViewerDisplayOptions;
  135016. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  135017. computeBonesUsingShaders: boolean;
  135018. /** Flag ignore non weighted bones */
  135019. useAllBones: boolean;
  135020. }
  135021. /**
  135022. * Defines how to display the various bone meshes for the viewer.
  135023. */
  135024. export interface ISkeletonViewerDisplayOptions {
  135025. /** How far down to start tapering the bone spurs */
  135026. midStep?: number;
  135027. /** How big is the midStep? */
  135028. midStepFactor?: number;
  135029. /** Base for the Sphere Size */
  135030. sphereBaseSize?: number;
  135031. /** The ratio of the sphere to the longest bone in units */
  135032. sphereScaleUnit?: number;
  135033. /** Ratio for the Sphere Size */
  135034. sphereFactor?: number;
  135035. /** Whether a spur should attach its far end to the child bone position */
  135036. spurFollowsChild?: boolean;
  135037. /** Whether to show local axes or not */
  135038. showLocalAxes?: boolean;
  135039. /** Length of each local axis */
  135040. localAxesSize?: number;
  135041. }
  135042. /**
  135043. * Defines the constructor options for the BoneWeight Shader.
  135044. */
  135045. export interface IBoneWeightShaderOptions {
  135046. /** Skeleton to Map */
  135047. skeleton: Skeleton;
  135048. /** Colors for Uninfluenced bones */
  135049. colorBase?: Color3;
  135050. /** Colors for 0.0-0.25 Weight bones */
  135051. colorZero?: Color3;
  135052. /** Color for 0.25-0.5 Weight Influence */
  135053. colorQuarter?: Color3;
  135054. /** Color for 0.5-0.75 Weight Influence */
  135055. colorHalf?: Color3;
  135056. /** Color for 0.75-1 Weight Influence */
  135057. colorFull?: Color3;
  135058. /** Color for Zero Weight Influence */
  135059. targetBoneIndex?: number;
  135060. }
  135061. /**
  135062. * Simple structure of the gradient steps for the Color Map.
  135063. */
  135064. export interface ISkeletonMapShaderColorMapKnot {
  135065. /** Color of the Knot */
  135066. color: Color3;
  135067. /** Location of the Knot */
  135068. location: number;
  135069. }
  135070. /**
  135071. * Defines the constructor options for the SkeletonMap Shader.
  135072. */
  135073. export interface ISkeletonMapShaderOptions {
  135074. /** Skeleton to Map */
  135075. skeleton: Skeleton;
  135076. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  135077. colorMap?: ISkeletonMapShaderColorMapKnot[];
  135078. }
  135079. }
  135080. declare module BABYLON {
  135081. /**
  135082. * Class containing static functions to help procedurally build meshes
  135083. */
  135084. export class RibbonBuilder {
  135085. /**
  135086. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135087. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  135088. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  135089. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  135090. * * 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
  135091. * * 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
  135092. * * 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
  135093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135094. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135095. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135096. * * 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
  135097. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  135098. * * 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
  135099. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  135100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135101. * @param name defines the name of the mesh
  135102. * @param options defines the options used to create the mesh
  135103. * @param scene defines the hosting scene
  135104. * @returns the ribbon mesh
  135105. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  135106. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135107. */
  135108. static CreateRibbon(name: string, options: {
  135109. pathArray: Vector3[][];
  135110. closeArray?: boolean;
  135111. closePath?: boolean;
  135112. offset?: number;
  135113. updatable?: boolean;
  135114. sideOrientation?: number;
  135115. frontUVs?: Vector4;
  135116. backUVs?: Vector4;
  135117. instance?: Mesh;
  135118. invertUV?: boolean;
  135119. uvs?: Vector2[];
  135120. colors?: Color4[];
  135121. }, scene?: Nullable<Scene>): Mesh;
  135122. }
  135123. }
  135124. declare module BABYLON {
  135125. /**
  135126. * Class containing static functions to help procedurally build meshes
  135127. */
  135128. export class ShapeBuilder {
  135129. /**
  135130. * 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.
  135131. * * 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.
  135132. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135133. * * 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.
  135134. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  135135. * * 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
  135136. * * 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
  135137. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  135138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135139. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135140. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  135141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135142. * @param name defines the name of the mesh
  135143. * @param options defines the options used to create the mesh
  135144. * @param scene defines the hosting scene
  135145. * @returns the extruded shape mesh
  135146. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135147. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135148. */
  135149. static ExtrudeShape(name: string, options: {
  135150. shape: Vector3[];
  135151. path: Vector3[];
  135152. scale?: number;
  135153. rotation?: number;
  135154. cap?: number;
  135155. updatable?: boolean;
  135156. sideOrientation?: number;
  135157. frontUVs?: Vector4;
  135158. backUVs?: Vector4;
  135159. instance?: Mesh;
  135160. invertUV?: boolean;
  135161. }, scene?: Nullable<Scene>): Mesh;
  135162. /**
  135163. * Creates an custom extruded shape mesh.
  135164. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  135165. * * 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.
  135166. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135167. * * 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
  135168. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  135169. * * 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
  135170. * * It must returns a float value that will be the scale value applied to the shape on each path point
  135171. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  135172. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  135173. * * 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
  135174. * * 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
  135175. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  135176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135177. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135178. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135180. * @param name defines the name of the mesh
  135181. * @param options defines the options used to create the mesh
  135182. * @param scene defines the hosting scene
  135183. * @returns the custom extruded shape mesh
  135184. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  135185. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135186. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135187. */
  135188. static ExtrudeShapeCustom(name: string, options: {
  135189. shape: Vector3[];
  135190. path: Vector3[];
  135191. scaleFunction?: any;
  135192. rotationFunction?: any;
  135193. ribbonCloseArray?: boolean;
  135194. ribbonClosePath?: boolean;
  135195. cap?: number;
  135196. updatable?: boolean;
  135197. sideOrientation?: number;
  135198. frontUVs?: Vector4;
  135199. backUVs?: Vector4;
  135200. instance?: Mesh;
  135201. invertUV?: boolean;
  135202. }, scene?: Nullable<Scene>): Mesh;
  135203. private static _ExtrudeShapeGeneric;
  135204. }
  135205. }
  135206. declare module BABYLON.Debug {
  135207. /**
  135208. * Class used to render a debug view of a given skeleton
  135209. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  135210. */
  135211. export class SkeletonViewer {
  135212. /** defines the skeleton to render */
  135213. skeleton: Skeleton;
  135214. /** defines the mesh attached to the skeleton */
  135215. mesh: AbstractMesh;
  135216. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  135217. autoUpdateBonesMatrices: boolean;
  135218. /** defines the rendering group id to use with the viewer */
  135219. renderingGroupId: number;
  135220. /** is the options for the viewer */
  135221. options: Partial<ISkeletonViewerOptions>;
  135222. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  135223. static readonly DISPLAY_LINES: number;
  135224. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  135225. static readonly DISPLAY_SPHERES: number;
  135226. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  135227. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  135228. /** public static method to create a BoneWeight Shader
  135229. * @param options The constructor options
  135230. * @param scene The scene that the shader is scoped to
  135231. * @returns The created ShaderMaterial
  135232. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  135233. */
  135234. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  135235. /** public static method to create a BoneWeight Shader
  135236. * @param options The constructor options
  135237. * @param scene The scene that the shader is scoped to
  135238. * @returns The created ShaderMaterial
  135239. */
  135240. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  135241. /** private static method to create a BoneWeight Shader
  135242. * @param size The size of the buffer to create (usually the bone count)
  135243. * @param colorMap The gradient data to generate
  135244. * @param scene The scene that the shader is scoped to
  135245. * @returns an Array of floats from the color gradient values
  135246. */
  135247. private static _CreateBoneMapColorBuffer;
  135248. /** If SkeletonViewer scene scope. */
  135249. private _scene;
  135250. /** Gets or sets the color used to render the skeleton */
  135251. color: Color3;
  135252. /** Array of the points of the skeleton fo the line view. */
  135253. private _debugLines;
  135254. /** The SkeletonViewers Mesh. */
  135255. private _debugMesh;
  135256. /** The local axes Meshes. */
  135257. private _localAxes;
  135258. /** If SkeletonViewer is enabled. */
  135259. private _isEnabled;
  135260. /** If SkeletonViewer is ready. */
  135261. private _ready;
  135262. /** SkeletonViewer render observable. */
  135263. private _obs;
  135264. /** The Utility Layer to render the gizmos in. */
  135265. private _utilityLayer;
  135266. private _boneIndices;
  135267. /** Gets the Scene. */
  135268. get scene(): Scene;
  135269. /** Gets the utilityLayer. */
  135270. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  135271. /** Checks Ready Status. */
  135272. get isReady(): Boolean;
  135273. /** Sets Ready Status. */
  135274. set ready(value: boolean);
  135275. /** Gets the debugMesh */
  135276. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  135277. /** Sets the debugMesh */
  135278. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  135279. /** Gets the displayMode */
  135280. get displayMode(): number;
  135281. /** Sets the displayMode */
  135282. set displayMode(value: number);
  135283. /**
  135284. * Creates a new SkeletonViewer
  135285. * @param skeleton defines the skeleton to render
  135286. * @param mesh defines the mesh attached to the skeleton
  135287. * @param scene defines the hosting scene
  135288. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  135289. * @param renderingGroupId defines the rendering group id to use with the viewer
  135290. * @param options All of the extra constructor options for the SkeletonViewer
  135291. */
  135292. constructor(
  135293. /** defines the skeleton to render */
  135294. skeleton: Skeleton,
  135295. /** defines the mesh attached to the skeleton */
  135296. mesh: AbstractMesh,
  135297. /** The Scene scope*/
  135298. scene: Scene,
  135299. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  135300. autoUpdateBonesMatrices?: boolean,
  135301. /** defines the rendering group id to use with the viewer */
  135302. renderingGroupId?: number,
  135303. /** is the options for the viewer */
  135304. options?: Partial<ISkeletonViewerOptions>);
  135305. /** The Dynamic bindings for the update functions */
  135306. private _bindObs;
  135307. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  135308. update(): void;
  135309. /** Gets or sets a boolean indicating if the viewer is enabled */
  135310. set isEnabled(value: boolean);
  135311. get isEnabled(): boolean;
  135312. private _getBonePosition;
  135313. private _getLinesForBonesWithLength;
  135314. private _getLinesForBonesNoLength;
  135315. /** function to revert the mesh and scene back to the initial state. */
  135316. private _revert;
  135317. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  135318. private _getAbsoluteBindPoseToRef;
  135319. /** function to build and bind sphere joint points and spur bone representations. */
  135320. private _buildSpheresAndSpurs;
  135321. private _buildLocalAxes;
  135322. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  135323. private _displayLinesUpdate;
  135324. /** Changes the displayMode of the skeleton viewer
  135325. * @param mode The displayMode numerical value
  135326. */
  135327. changeDisplayMode(mode: number): void;
  135328. /** Sets a display option of the skeleton viewer
  135329. *
  135330. * | Option | Type | Default | Description |
  135331. * | ---------------- | ------- | ------- | ----------- |
  135332. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  135333. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  135334. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  135335. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  135336. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  135337. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  135338. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  135339. *
  135340. * @param option String of the option name
  135341. * @param value The numerical option value
  135342. */
  135343. changeDisplayOptions(option: string, value: number): void;
  135344. /** Release associated resources */
  135345. dispose(): void;
  135346. }
  135347. }
  135348. declare module BABYLON {
  135349. /**
  135350. * Enum for Device Types
  135351. */
  135352. export enum DeviceType {
  135353. /** Generic */
  135354. Generic = 0,
  135355. /** Keyboard */
  135356. Keyboard = 1,
  135357. /** Mouse */
  135358. Mouse = 2,
  135359. /** Touch Pointers */
  135360. Touch = 3,
  135361. /** PS4 Dual Shock */
  135362. DualShock = 4,
  135363. /** Xbox */
  135364. Xbox = 5,
  135365. /** Switch Controller */
  135366. Switch = 6
  135367. }
  135368. /**
  135369. * Enum for All Pointers (Touch/Mouse)
  135370. */
  135371. export enum PointerInput {
  135372. /** Horizontal Axis */
  135373. Horizontal = 0,
  135374. /** Vertical Axis */
  135375. Vertical = 1,
  135376. /** Left Click or Touch */
  135377. LeftClick = 2,
  135378. /** Middle Click */
  135379. MiddleClick = 3,
  135380. /** Right Click */
  135381. RightClick = 4,
  135382. /** Browser Back */
  135383. BrowserBack = 5,
  135384. /** Browser Forward */
  135385. BrowserForward = 6
  135386. }
  135387. /**
  135388. * Enum for Dual Shock Gamepad
  135389. */
  135390. export enum DualShockInput {
  135391. /** Cross */
  135392. Cross = 0,
  135393. /** Circle */
  135394. Circle = 1,
  135395. /** Square */
  135396. Square = 2,
  135397. /** Triangle */
  135398. Triangle = 3,
  135399. /** L1 */
  135400. L1 = 4,
  135401. /** R1 */
  135402. R1 = 5,
  135403. /** L2 */
  135404. L2 = 6,
  135405. /** R2 */
  135406. R2 = 7,
  135407. /** Share */
  135408. Share = 8,
  135409. /** Options */
  135410. Options = 9,
  135411. /** L3 */
  135412. L3 = 10,
  135413. /** R3 */
  135414. R3 = 11,
  135415. /** DPadUp */
  135416. DPadUp = 12,
  135417. /** DPadDown */
  135418. DPadDown = 13,
  135419. /** DPadLeft */
  135420. DPadLeft = 14,
  135421. /** DRight */
  135422. DPadRight = 15,
  135423. /** Home */
  135424. Home = 16,
  135425. /** TouchPad */
  135426. TouchPad = 17,
  135427. /** LStickXAxis */
  135428. LStickXAxis = 18,
  135429. /** LStickYAxis */
  135430. LStickYAxis = 19,
  135431. /** RStickXAxis */
  135432. RStickXAxis = 20,
  135433. /** RStickYAxis */
  135434. RStickYAxis = 21
  135435. }
  135436. /**
  135437. * Enum for Xbox Gamepad
  135438. */
  135439. export enum XboxInput {
  135440. /** A */
  135441. A = 0,
  135442. /** B */
  135443. B = 1,
  135444. /** X */
  135445. X = 2,
  135446. /** Y */
  135447. Y = 3,
  135448. /** LB */
  135449. LB = 4,
  135450. /** RB */
  135451. RB = 5,
  135452. /** LT */
  135453. LT = 6,
  135454. /** RT */
  135455. RT = 7,
  135456. /** Back */
  135457. Back = 8,
  135458. /** Start */
  135459. Start = 9,
  135460. /** LS */
  135461. LS = 10,
  135462. /** RS */
  135463. RS = 11,
  135464. /** DPadUp */
  135465. DPadUp = 12,
  135466. /** DPadDown */
  135467. DPadDown = 13,
  135468. /** DPadLeft */
  135469. DPadLeft = 14,
  135470. /** DRight */
  135471. DPadRight = 15,
  135472. /** Home */
  135473. Home = 16,
  135474. /** LStickXAxis */
  135475. LStickXAxis = 17,
  135476. /** LStickYAxis */
  135477. LStickYAxis = 18,
  135478. /** RStickXAxis */
  135479. RStickXAxis = 19,
  135480. /** RStickYAxis */
  135481. RStickYAxis = 20
  135482. }
  135483. /**
  135484. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  135485. */
  135486. export enum SwitchInput {
  135487. /** B */
  135488. B = 0,
  135489. /** A */
  135490. A = 1,
  135491. /** Y */
  135492. Y = 2,
  135493. /** X */
  135494. X = 3,
  135495. /** L */
  135496. L = 4,
  135497. /** R */
  135498. R = 5,
  135499. /** ZL */
  135500. ZL = 6,
  135501. /** ZR */
  135502. ZR = 7,
  135503. /** Minus */
  135504. Minus = 8,
  135505. /** Plus */
  135506. Plus = 9,
  135507. /** LS */
  135508. LS = 10,
  135509. /** RS */
  135510. RS = 11,
  135511. /** DPadUp */
  135512. DPadUp = 12,
  135513. /** DPadDown */
  135514. DPadDown = 13,
  135515. /** DPadLeft */
  135516. DPadLeft = 14,
  135517. /** DRight */
  135518. DPadRight = 15,
  135519. /** Home */
  135520. Home = 16,
  135521. /** Capture */
  135522. Capture = 17,
  135523. /** LStickXAxis */
  135524. LStickXAxis = 18,
  135525. /** LStickYAxis */
  135526. LStickYAxis = 19,
  135527. /** RStickXAxis */
  135528. RStickXAxis = 20,
  135529. /** RStickYAxis */
  135530. RStickYAxis = 21
  135531. }
  135532. }
  135533. declare module BABYLON {
  135534. /**
  135535. * This class will take all inputs from Keyboard, Pointer, and
  135536. * any Gamepads and provide a polling system that all devices
  135537. * will use. This class assumes that there will only be one
  135538. * pointer device and one keyboard.
  135539. */
  135540. export class DeviceInputSystem implements IDisposable {
  135541. /**
  135542. * Callback to be triggered when a device is connected
  135543. */
  135544. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  135545. /**
  135546. * Callback to be triggered when a device is disconnected
  135547. */
  135548. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  135549. /**
  135550. * Callback to be triggered when event driven input is updated
  135551. */
  135552. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  135553. private _inputs;
  135554. private _gamepads;
  135555. private _keyboardActive;
  135556. private _pointerActive;
  135557. private _elementToAttachTo;
  135558. private _keyboardDownEvent;
  135559. private _keyboardUpEvent;
  135560. private _pointerMoveEvent;
  135561. private _pointerDownEvent;
  135562. private _pointerUpEvent;
  135563. private _gamepadConnectedEvent;
  135564. private _gamepadDisconnectedEvent;
  135565. private static _MAX_KEYCODES;
  135566. private static _MAX_POINTER_INPUTS;
  135567. private constructor();
  135568. /**
  135569. * Creates a new DeviceInputSystem instance
  135570. * @param engine Engine to pull input element from
  135571. * @returns The new instance
  135572. */
  135573. static Create(engine: Engine): DeviceInputSystem;
  135574. /**
  135575. * Checks for current device input value, given an id and input index
  135576. * @param deviceName Id of connected device
  135577. * @param inputIndex Index of device input
  135578. * @returns Current value of input
  135579. */
  135580. /**
  135581. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  135582. * @param deviceType Enum specifiying device type
  135583. * @param deviceSlot "Slot" or index that device is referenced in
  135584. * @param inputIndex Id of input to be checked
  135585. * @returns Current value of input
  135586. */
  135587. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  135588. /**
  135589. * Dispose of all the eventlisteners
  135590. */
  135591. dispose(): void;
  135592. /**
  135593. * Add device and inputs to device array
  135594. * @param deviceType Enum specifiying device type
  135595. * @param deviceSlot "Slot" or index that device is referenced in
  135596. * @param numberOfInputs Number of input entries to create for given device
  135597. */
  135598. private _registerDevice;
  135599. /**
  135600. * Given a specific device name, remove that device from the device map
  135601. * @param deviceType Enum specifiying device type
  135602. * @param deviceSlot "Slot" or index that device is referenced in
  135603. */
  135604. private _unregisterDevice;
  135605. /**
  135606. * Handle all actions that come from keyboard interaction
  135607. */
  135608. private _handleKeyActions;
  135609. /**
  135610. * Handle all actions that come from pointer interaction
  135611. */
  135612. private _handlePointerActions;
  135613. /**
  135614. * Handle all actions that come from gamepad interaction
  135615. */
  135616. private _handleGamepadActions;
  135617. /**
  135618. * Update all non-event based devices with each frame
  135619. * @param deviceType Enum specifiying device type
  135620. * @param deviceSlot "Slot" or index that device is referenced in
  135621. * @param inputIndex Id of input to be checked
  135622. */
  135623. private _updateDevice;
  135624. /**
  135625. * Gets DeviceType from the device name
  135626. * @param deviceName Name of Device from DeviceInputSystem
  135627. * @returns DeviceType enum value
  135628. */
  135629. private _getGamepadDeviceType;
  135630. }
  135631. }
  135632. declare module BABYLON {
  135633. /**
  135634. * Type to handle enforcement of inputs
  135635. */
  135636. 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;
  135637. }
  135638. declare module BABYLON {
  135639. /**
  135640. * Class that handles all input for a specific device
  135641. */
  135642. export class DeviceSource<T extends DeviceType> {
  135643. /** Type of device */
  135644. readonly deviceType: DeviceType;
  135645. /** "Slot" or index that device is referenced in */
  135646. readonly deviceSlot: number;
  135647. /**
  135648. * Observable to handle device input changes per device
  135649. */
  135650. readonly onInputChangedObservable: Observable<{
  135651. inputIndex: DeviceInput<T>;
  135652. previousState: Nullable<number>;
  135653. currentState: Nullable<number>;
  135654. }>;
  135655. private readonly _deviceInputSystem;
  135656. /**
  135657. * Default Constructor
  135658. * @param deviceInputSystem Reference to DeviceInputSystem
  135659. * @param deviceType Type of device
  135660. * @param deviceSlot "Slot" or index that device is referenced in
  135661. */
  135662. constructor(deviceInputSystem: DeviceInputSystem,
  135663. /** Type of device */
  135664. deviceType: DeviceType,
  135665. /** "Slot" or index that device is referenced in */
  135666. deviceSlot?: number);
  135667. /**
  135668. * Get input for specific input
  135669. * @param inputIndex index of specific input on device
  135670. * @returns Input value from DeviceInputSystem
  135671. */
  135672. getInput(inputIndex: DeviceInput<T>): number;
  135673. }
  135674. /**
  135675. * Class to keep track of devices
  135676. */
  135677. export class DeviceSourceManager implements IDisposable {
  135678. /**
  135679. * Observable to be triggered when before a device is connected
  135680. */
  135681. readonly onBeforeDeviceConnectedObservable: Observable<{
  135682. deviceType: DeviceType;
  135683. deviceSlot: number;
  135684. }>;
  135685. /**
  135686. * Observable to be triggered when before a device is disconnected
  135687. */
  135688. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  135689. deviceType: DeviceType;
  135690. deviceSlot: number;
  135691. }>;
  135692. /**
  135693. * Observable to be triggered when after a device is connected
  135694. */
  135695. readonly onAfterDeviceConnectedObservable: Observable<{
  135696. deviceType: DeviceType;
  135697. deviceSlot: number;
  135698. }>;
  135699. /**
  135700. * Observable to be triggered when after a device is disconnected
  135701. */
  135702. readonly onAfterDeviceDisconnectedObservable: Observable<{
  135703. deviceType: DeviceType;
  135704. deviceSlot: number;
  135705. }>;
  135706. private readonly _devices;
  135707. private readonly _firstDevice;
  135708. private readonly _deviceInputSystem;
  135709. /**
  135710. * Default Constructor
  135711. * @param engine engine to pull input element from
  135712. */
  135713. constructor(engine: Engine);
  135714. /**
  135715. * Gets a DeviceSource, given a type and slot
  135716. * @param deviceType Enum specifying device type
  135717. * @param deviceSlot "Slot" or index that device is referenced in
  135718. * @returns DeviceSource object
  135719. */
  135720. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  135721. /**
  135722. * Gets an array of DeviceSource objects for a given device type
  135723. * @param deviceType Enum specifying device type
  135724. * @returns Array of DeviceSource objects
  135725. */
  135726. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  135727. /**
  135728. * Dispose of DeviceInputSystem and other parts
  135729. */
  135730. dispose(): void;
  135731. /**
  135732. * Function to add device name to device list
  135733. * @param deviceType Enum specifying device type
  135734. * @param deviceSlot "Slot" or index that device is referenced in
  135735. */
  135736. private _addDevice;
  135737. /**
  135738. * Function to remove device name to device list
  135739. * @param deviceType Enum specifying device type
  135740. * @param deviceSlot "Slot" or index that device is referenced in
  135741. */
  135742. private _removeDevice;
  135743. /**
  135744. * Updates array storing first connected device of each type
  135745. * @param type Type of Device
  135746. */
  135747. private _updateFirstDevices;
  135748. }
  135749. }
  135750. declare module BABYLON {
  135751. /**
  135752. * Options to create the null engine
  135753. */
  135754. export class NullEngineOptions {
  135755. /**
  135756. * Render width (Default: 512)
  135757. */
  135758. renderWidth: number;
  135759. /**
  135760. * Render height (Default: 256)
  135761. */
  135762. renderHeight: number;
  135763. /**
  135764. * Texture size (Default: 512)
  135765. */
  135766. textureSize: number;
  135767. /**
  135768. * If delta time between frames should be constant
  135769. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135770. */
  135771. deterministicLockstep: boolean;
  135772. /**
  135773. * Maximum about of steps between frames (Default: 4)
  135774. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135775. */
  135776. lockstepMaxSteps: number;
  135777. /**
  135778. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  135779. */
  135780. useHighPrecisionMatrix?: boolean;
  135781. }
  135782. /**
  135783. * The null engine class provides support for headless version of babylon.js.
  135784. * This can be used in server side scenario or for testing purposes
  135785. */
  135786. export class NullEngine extends Engine {
  135787. private _options;
  135788. /**
  135789. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  135790. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135791. * @returns true if engine is in deterministic lock step mode
  135792. */
  135793. isDeterministicLockStep(): boolean;
  135794. /**
  135795. * Gets the max steps when engine is running in deterministic lock step
  135796. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135797. * @returns the max steps
  135798. */
  135799. getLockstepMaxSteps(): number;
  135800. /**
  135801. * Gets the current hardware scaling level.
  135802. * By default the hardware scaling level is computed from the window device ratio.
  135803. * 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.
  135804. * @returns a number indicating the current hardware scaling level
  135805. */
  135806. getHardwareScalingLevel(): number;
  135807. constructor(options?: NullEngineOptions);
  135808. /**
  135809. * Creates a vertex buffer
  135810. * @param vertices the data for the vertex buffer
  135811. * @returns the new WebGL static buffer
  135812. */
  135813. createVertexBuffer(vertices: FloatArray): DataBuffer;
  135814. /**
  135815. * Creates a new index buffer
  135816. * @param indices defines the content of the index buffer
  135817. * @param updatable defines if the index buffer must be updatable
  135818. * @returns a new webGL buffer
  135819. */
  135820. createIndexBuffer(indices: IndicesArray): DataBuffer;
  135821. /**
  135822. * Clear the current render buffer or the current render target (if any is set up)
  135823. * @param color defines the color to use
  135824. * @param backBuffer defines if the back buffer must be cleared
  135825. * @param depth defines if the depth buffer must be cleared
  135826. * @param stencil defines if the stencil buffer must be cleared
  135827. */
  135828. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  135829. /**
  135830. * Gets the current render width
  135831. * @param useScreen defines if screen size must be used (or the current render target if any)
  135832. * @returns a number defining the current render width
  135833. */
  135834. getRenderWidth(useScreen?: boolean): number;
  135835. /**
  135836. * Gets the current render height
  135837. * @param useScreen defines if screen size must be used (or the current render target if any)
  135838. * @returns a number defining the current render height
  135839. */
  135840. getRenderHeight(useScreen?: boolean): number;
  135841. /**
  135842. * Set the WebGL's viewport
  135843. * @param viewport defines the viewport element to be used
  135844. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  135845. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  135846. */
  135847. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  135848. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  135849. /**
  135850. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  135851. * @param pipelineContext defines the pipeline context to use
  135852. * @param uniformsNames defines the list of uniform names
  135853. * @returns an array of webGL uniform locations
  135854. */
  135855. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  135856. /**
  135857. * Gets the lsit of active attributes for a given webGL program
  135858. * @param pipelineContext defines the pipeline context to use
  135859. * @param attributesNames defines the list of attribute names to get
  135860. * @returns an array of indices indicating the offset of each attribute
  135861. */
  135862. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  135863. /**
  135864. * Binds an effect to the webGL context
  135865. * @param effect defines the effect to bind
  135866. */
  135867. bindSamplers(effect: Effect): void;
  135868. /**
  135869. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  135870. * @param effect defines the effect to activate
  135871. */
  135872. enableEffect(effect: Effect): void;
  135873. /**
  135874. * Set various states to the webGL context
  135875. * @param culling defines backface culling state
  135876. * @param zOffset defines the value to apply to zOffset (0 by default)
  135877. * @param force defines if states must be applied even if cache is up to date
  135878. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  135879. */
  135880. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  135881. /**
  135882. * Set the value of an uniform to an array of int32
  135883. * @param uniform defines the webGL uniform location where to store the value
  135884. * @param array defines the array of int32 to store
  135885. * @returns true if value was set
  135886. */
  135887. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135888. /**
  135889. * Set the value of an uniform to an array of int32 (stored as vec2)
  135890. * @param uniform defines the webGL uniform location where to store the value
  135891. * @param array defines the array of int32 to store
  135892. * @returns true if value was set
  135893. */
  135894. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135895. /**
  135896. * Set the value of an uniform to an array of int32 (stored as vec3)
  135897. * @param uniform defines the webGL uniform location where to store the value
  135898. * @param array defines the array of int32 to store
  135899. * @returns true if value was set
  135900. */
  135901. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135902. /**
  135903. * Set the value of an uniform to an array of int32 (stored as vec4)
  135904. * @param uniform defines the webGL uniform location where to store the value
  135905. * @param array defines the array of int32 to store
  135906. * @returns true if value was set
  135907. */
  135908. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135909. /**
  135910. * Set the value of an uniform to an array of float32
  135911. * @param uniform defines the webGL uniform location where to store the value
  135912. * @param array defines the array of float32 to store
  135913. * @returns true if value was set
  135914. */
  135915. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135916. /**
  135917. * Set the value of an uniform to an array of float32 (stored as vec2)
  135918. * @param uniform defines the webGL uniform location where to store the value
  135919. * @param array defines the array of float32 to store
  135920. * @returns true if value was set
  135921. */
  135922. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135923. /**
  135924. * Set the value of an uniform to an array of float32 (stored as vec3)
  135925. * @param uniform defines the webGL uniform location where to store the value
  135926. * @param array defines the array of float32 to store
  135927. * @returns true if value was set
  135928. */
  135929. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135930. /**
  135931. * Set the value of an uniform to an array of float32 (stored as vec4)
  135932. * @param uniform defines the webGL uniform location where to store the value
  135933. * @param array defines the array of float32 to store
  135934. * @returns true if value was set
  135935. */
  135936. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135937. /**
  135938. * Set the value of an uniform to an array of number
  135939. * @param uniform defines the webGL uniform location where to store the value
  135940. * @param array defines the array of number to store
  135941. * @returns true if value was set
  135942. */
  135943. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  135944. /**
  135945. * Set the value of an uniform to an array of number (stored as vec2)
  135946. * @param uniform defines the webGL uniform location where to store the value
  135947. * @param array defines the array of number to store
  135948. * @returns true if value was set
  135949. */
  135950. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  135951. /**
  135952. * Set the value of an uniform to an array of number (stored as vec3)
  135953. * @param uniform defines the webGL uniform location where to store the value
  135954. * @param array defines the array of number to store
  135955. * @returns true if value was set
  135956. */
  135957. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  135958. /**
  135959. * Set the value of an uniform to an array of number (stored as vec4)
  135960. * @param uniform defines the webGL uniform location where to store the value
  135961. * @param array defines the array of number to store
  135962. * @returns true if value was set
  135963. */
  135964. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  135965. /**
  135966. * Set the value of an uniform to an array of float32 (stored as matrices)
  135967. * @param uniform defines the webGL uniform location where to store the value
  135968. * @param matrices defines the array of float32 to store
  135969. * @returns true if value was set
  135970. */
  135971. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  135972. /**
  135973. * Set the value of an uniform to a matrix (3x3)
  135974. * @param uniform defines the webGL uniform location where to store the value
  135975. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  135976. * @returns true if value was set
  135977. */
  135978. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  135979. /**
  135980. * Set the value of an uniform to a matrix (2x2)
  135981. * @param uniform defines the webGL uniform location where to store the value
  135982. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  135983. * @returns true if value was set
  135984. */
  135985. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  135986. /**
  135987. * Set the value of an uniform to a number (float)
  135988. * @param uniform defines the webGL uniform location where to store the value
  135989. * @param value defines the float number to store
  135990. * @returns true if value was set
  135991. */
  135992. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  135993. /**
  135994. * Set the value of an uniform to a vec2
  135995. * @param uniform defines the webGL uniform location where to store the value
  135996. * @param x defines the 1st component of the value
  135997. * @param y defines the 2nd component of the value
  135998. * @returns true if value was set
  135999. */
  136000. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  136001. /**
  136002. * Set the value of an uniform to a vec3
  136003. * @param uniform defines the webGL uniform location where to store the value
  136004. * @param x defines the 1st component of the value
  136005. * @param y defines the 2nd component of the value
  136006. * @param z defines the 3rd component of the value
  136007. * @returns true if value was set
  136008. */
  136009. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  136010. /**
  136011. * Set the value of an uniform to a boolean
  136012. * @param uniform defines the webGL uniform location where to store the value
  136013. * @param bool defines the boolean to store
  136014. * @returns true if value was set
  136015. */
  136016. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  136017. /**
  136018. * Set the value of an uniform to a vec4
  136019. * @param uniform defines the webGL uniform location where to store the value
  136020. * @param x defines the 1st component of the value
  136021. * @param y defines the 2nd component of the value
  136022. * @param z defines the 3rd component of the value
  136023. * @param w defines the 4th component of the value
  136024. * @returns true if value was set
  136025. */
  136026. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  136027. /**
  136028. * Sets the current alpha mode
  136029. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  136030. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  136031. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136032. */
  136033. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  136034. /**
  136035. * Bind webGl buffers directly to the webGL context
  136036. * @param vertexBuffers defines the vertex buffer to bind
  136037. * @param indexBuffer defines the index buffer to bind
  136038. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  136039. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  136040. * @param effect defines the effect associated with the vertex buffer
  136041. */
  136042. bindBuffers(vertexBuffers: {
  136043. [key: string]: VertexBuffer;
  136044. }, indexBuffer: DataBuffer, effect: Effect): void;
  136045. /**
  136046. * Force the entire cache to be cleared
  136047. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  136048. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  136049. */
  136050. wipeCaches(bruteForce?: boolean): void;
  136051. /**
  136052. * Send a draw order
  136053. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  136054. * @param indexStart defines the starting index
  136055. * @param indexCount defines the number of index to draw
  136056. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136057. */
  136058. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  136059. /**
  136060. * Draw a list of indexed primitives
  136061. * @param fillMode defines the primitive to use
  136062. * @param indexStart defines the starting index
  136063. * @param indexCount defines the number of index to draw
  136064. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136065. */
  136066. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  136067. /**
  136068. * Draw a list of unindexed primitives
  136069. * @param fillMode defines the primitive to use
  136070. * @param verticesStart defines the index of first vertex to draw
  136071. * @param verticesCount defines the count of vertices to draw
  136072. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136073. */
  136074. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  136075. /** @hidden */
  136076. _createTexture(): WebGLTexture;
  136077. /** @hidden */
  136078. _releaseTexture(texture: InternalTexture): void;
  136079. /**
  136080. * Usually called from Texture.ts.
  136081. * Passed information to create a WebGLTexture
  136082. * @param urlArg defines a value which contains one of the following:
  136083. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  136084. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  136085. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  136086. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  136087. * @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)
  136088. * @param scene needed for loading to the correct scene
  136089. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  136090. * @param onLoad optional callback to be called upon successful completion
  136091. * @param onError optional callback to be called upon failure
  136092. * @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
  136093. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  136094. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  136095. * @param forcedExtension defines the extension to use to pick the right loader
  136096. * @param mimeType defines an optional mime type
  136097. * @returns a InternalTexture for assignment back into BABYLON.Texture
  136098. */
  136099. 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;
  136100. /**
  136101. * Creates a new render target texture
  136102. * @param size defines the size of the texture
  136103. * @param options defines the options used to create the texture
  136104. * @returns a new render target texture stored in an InternalTexture
  136105. */
  136106. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  136107. /**
  136108. * Update the sampling mode of a given texture
  136109. * @param samplingMode defines the required sampling mode
  136110. * @param texture defines the texture to update
  136111. */
  136112. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  136113. /**
  136114. * Binds the frame buffer to the specified texture.
  136115. * @param texture The texture to render to or null for the default canvas
  136116. * @param faceIndex The face of the texture to render to in case of cube texture
  136117. * @param requiredWidth The width of the target to render to
  136118. * @param requiredHeight The height of the target to render to
  136119. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  136120. * @param lodLevel defines le lod level to bind to the frame buffer
  136121. */
  136122. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  136123. /**
  136124. * Unbind the current render target texture from the webGL context
  136125. * @param texture defines the render target texture to unbind
  136126. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  136127. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  136128. */
  136129. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  136130. /**
  136131. * Creates a dynamic vertex buffer
  136132. * @param vertices the data for the dynamic vertex buffer
  136133. * @returns the new WebGL dynamic buffer
  136134. */
  136135. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  136136. /**
  136137. * Update the content of a dynamic texture
  136138. * @param texture defines the texture to update
  136139. * @param canvas defines the canvas containing the source
  136140. * @param invertY defines if data must be stored with Y axis inverted
  136141. * @param premulAlpha defines if alpha is stored as premultiplied
  136142. * @param format defines the format of the data
  136143. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  136144. */
  136145. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  136146. /**
  136147. * Gets a boolean indicating if all created effects are ready
  136148. * @returns true if all effects are ready
  136149. */
  136150. areAllEffectsReady(): boolean;
  136151. /**
  136152. * @hidden
  136153. * Get the current error code of the webGL context
  136154. * @returns the error code
  136155. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  136156. */
  136157. getError(): number;
  136158. /** @hidden */
  136159. _getUnpackAlignement(): number;
  136160. /** @hidden */
  136161. _unpackFlipY(value: boolean): void;
  136162. /**
  136163. * Update a dynamic index buffer
  136164. * @param indexBuffer defines the target index buffer
  136165. * @param indices defines the data to update
  136166. * @param offset defines the offset in the target index buffer where update should start
  136167. */
  136168. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  136169. /**
  136170. * Updates a dynamic vertex buffer.
  136171. * @param vertexBuffer the vertex buffer to update
  136172. * @param vertices the data used to update the vertex buffer
  136173. * @param byteOffset the byte offset of the data (optional)
  136174. * @param byteLength the byte length of the data (optional)
  136175. */
  136176. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  136177. /** @hidden */
  136178. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  136179. /** @hidden */
  136180. _bindTexture(channel: number, texture: InternalTexture): void;
  136181. protected _deleteBuffer(buffer: WebGLBuffer): void;
  136182. /**
  136183. * 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
  136184. */
  136185. releaseEffects(): void;
  136186. displayLoadingUI(): void;
  136187. hideLoadingUI(): void;
  136188. /** @hidden */
  136189. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136190. /** @hidden */
  136191. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136192. /** @hidden */
  136193. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136194. /** @hidden */
  136195. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  136196. }
  136197. }
  136198. declare module BABYLON {
  136199. /**
  136200. * @hidden
  136201. **/
  136202. export class _TimeToken {
  136203. _startTimeQuery: Nullable<WebGLQuery>;
  136204. _endTimeQuery: Nullable<WebGLQuery>;
  136205. _timeElapsedQuery: Nullable<WebGLQuery>;
  136206. _timeElapsedQueryEnded: boolean;
  136207. }
  136208. }
  136209. declare module BABYLON {
  136210. /** @hidden */
  136211. export class _OcclusionDataStorage {
  136212. /** @hidden */
  136213. occlusionInternalRetryCounter: number;
  136214. /** @hidden */
  136215. isOcclusionQueryInProgress: boolean;
  136216. /** @hidden */
  136217. isOccluded: boolean;
  136218. /** @hidden */
  136219. occlusionRetryCount: number;
  136220. /** @hidden */
  136221. occlusionType: number;
  136222. /** @hidden */
  136223. occlusionQueryAlgorithmType: number;
  136224. }
  136225. interface Engine {
  136226. /**
  136227. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  136228. * @return the new query
  136229. */
  136230. createQuery(): WebGLQuery;
  136231. /**
  136232. * Delete and release a webGL query
  136233. * @param query defines the query to delete
  136234. * @return the current engine
  136235. */
  136236. deleteQuery(query: WebGLQuery): Engine;
  136237. /**
  136238. * Check if a given query has resolved and got its value
  136239. * @param query defines the query to check
  136240. * @returns true if the query got its value
  136241. */
  136242. isQueryResultAvailable(query: WebGLQuery): boolean;
  136243. /**
  136244. * Gets the value of a given query
  136245. * @param query defines the query to check
  136246. * @returns the value of the query
  136247. */
  136248. getQueryResult(query: WebGLQuery): number;
  136249. /**
  136250. * Initiates an occlusion query
  136251. * @param algorithmType defines the algorithm to use
  136252. * @param query defines the query to use
  136253. * @returns the current engine
  136254. * @see https://doc.babylonjs.com/features/occlusionquery
  136255. */
  136256. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  136257. /**
  136258. * Ends an occlusion query
  136259. * @see https://doc.babylonjs.com/features/occlusionquery
  136260. * @param algorithmType defines the algorithm to use
  136261. * @returns the current engine
  136262. */
  136263. endOcclusionQuery(algorithmType: number): Engine;
  136264. /**
  136265. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  136266. * Please note that only one query can be issued at a time
  136267. * @returns a time token used to track the time span
  136268. */
  136269. startTimeQuery(): Nullable<_TimeToken>;
  136270. /**
  136271. * Ends a time query
  136272. * @param token defines the token used to measure the time span
  136273. * @returns the time spent (in ns)
  136274. */
  136275. endTimeQuery(token: _TimeToken): int;
  136276. /** @hidden */
  136277. _currentNonTimestampToken: Nullable<_TimeToken>;
  136278. /** @hidden */
  136279. _createTimeQuery(): WebGLQuery;
  136280. /** @hidden */
  136281. _deleteTimeQuery(query: WebGLQuery): void;
  136282. /** @hidden */
  136283. _getGlAlgorithmType(algorithmType: number): number;
  136284. /** @hidden */
  136285. _getTimeQueryResult(query: WebGLQuery): any;
  136286. /** @hidden */
  136287. _getTimeQueryAvailability(query: WebGLQuery): any;
  136288. }
  136289. interface AbstractMesh {
  136290. /**
  136291. * Backing filed
  136292. * @hidden
  136293. */
  136294. __occlusionDataStorage: _OcclusionDataStorage;
  136295. /**
  136296. * Access property
  136297. * @hidden
  136298. */
  136299. _occlusionDataStorage: _OcclusionDataStorage;
  136300. /**
  136301. * 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.
  136302. * The default value is -1 which means don't break the query and wait till the result
  136303. * @see https://doc.babylonjs.com/features/occlusionquery
  136304. */
  136305. occlusionRetryCount: number;
  136306. /**
  136307. * 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:
  136308. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  136309. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  136310. * * 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.
  136311. * @see https://doc.babylonjs.com/features/occlusionquery
  136312. */
  136313. occlusionType: number;
  136314. /**
  136315. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  136316. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  136317. * * 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.
  136318. * @see https://doc.babylonjs.com/features/occlusionquery
  136319. */
  136320. occlusionQueryAlgorithmType: number;
  136321. /**
  136322. * 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
  136323. * @see https://doc.babylonjs.com/features/occlusionquery
  136324. */
  136325. isOccluded: boolean;
  136326. /**
  136327. * Flag to check the progress status of the query
  136328. * @see https://doc.babylonjs.com/features/occlusionquery
  136329. */
  136330. isOcclusionQueryInProgress: boolean;
  136331. }
  136332. }
  136333. declare module BABYLON {
  136334. /** @hidden */
  136335. export var _forceTransformFeedbackToBundle: boolean;
  136336. interface Engine {
  136337. /**
  136338. * Creates a webGL transform feedback object
  136339. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  136340. * @returns the webGL transform feedback object
  136341. */
  136342. createTransformFeedback(): WebGLTransformFeedback;
  136343. /**
  136344. * Delete a webGL transform feedback object
  136345. * @param value defines the webGL transform feedback object to delete
  136346. */
  136347. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  136348. /**
  136349. * Bind a webGL transform feedback object to the webgl context
  136350. * @param value defines the webGL transform feedback object to bind
  136351. */
  136352. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  136353. /**
  136354. * Begins a transform feedback operation
  136355. * @param usePoints defines if points or triangles must be used
  136356. */
  136357. beginTransformFeedback(usePoints: boolean): void;
  136358. /**
  136359. * Ends a transform feedback operation
  136360. */
  136361. endTransformFeedback(): void;
  136362. /**
  136363. * Specify the varyings to use with transform feedback
  136364. * @param program defines the associated webGL program
  136365. * @param value defines the list of strings representing the varying names
  136366. */
  136367. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  136368. /**
  136369. * Bind a webGL buffer for a transform feedback operation
  136370. * @param value defines the webGL buffer to bind
  136371. */
  136372. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  136373. }
  136374. }
  136375. declare module BABYLON {
  136376. /**
  136377. * Class used to define an additional view for the engine
  136378. * @see https://doc.babylonjs.com/how_to/multi_canvases
  136379. */
  136380. export class EngineView {
  136381. /** Defines the canvas where to render the view */
  136382. target: HTMLCanvasElement;
  136383. /** Defines an optional camera used to render the view (will use active camera else) */
  136384. camera?: Camera;
  136385. }
  136386. interface Engine {
  136387. /**
  136388. * Gets or sets the HTML element to use for attaching events
  136389. */
  136390. inputElement: Nullable<HTMLElement>;
  136391. /**
  136392. * Gets the current engine view
  136393. * @see https://doc.babylonjs.com/how_to/multi_canvases
  136394. */
  136395. activeView: Nullable<EngineView>;
  136396. /** Gets or sets the list of views */
  136397. views: EngineView[];
  136398. /**
  136399. * Register a new child canvas
  136400. * @param canvas defines the canvas to register
  136401. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  136402. * @returns the associated view
  136403. */
  136404. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  136405. /**
  136406. * Remove a registered child canvas
  136407. * @param canvas defines the canvas to remove
  136408. * @returns the current engine
  136409. */
  136410. unRegisterView(canvas: HTMLCanvasElement): Engine;
  136411. }
  136412. }
  136413. declare module BABYLON {
  136414. interface Engine {
  136415. /** @hidden */
  136416. _excludedCompressedTextures: string[];
  136417. /** @hidden */
  136418. _textureFormatInUse: string;
  136419. /**
  136420. * Gets the list of texture formats supported
  136421. */
  136422. readonly texturesSupported: Array<string>;
  136423. /**
  136424. * Gets the texture format in use
  136425. */
  136426. readonly textureFormatInUse: Nullable<string>;
  136427. /**
  136428. * Set the compressed texture extensions or file names to skip.
  136429. *
  136430. * @param skippedFiles defines the list of those texture files you want to skip
  136431. * Example: [".dds", ".env", "myfile.png"]
  136432. */
  136433. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  136434. /**
  136435. * Set the compressed texture format to use, based on the formats you have, and the formats
  136436. * supported by the hardware / browser.
  136437. *
  136438. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  136439. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  136440. * to API arguments needed to compressed textures. This puts the burden on the container
  136441. * generator to house the arcane code for determining these for current & future formats.
  136442. *
  136443. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  136444. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  136445. *
  136446. * Note: The result of this call is not taken into account when a texture is base64.
  136447. *
  136448. * @param formatsAvailable defines the list of those format families you have created
  136449. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  136450. *
  136451. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  136452. * @returns The extension selected.
  136453. */
  136454. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  136455. }
  136456. }
  136457. declare module BABYLON {
  136458. /** @hidden */
  136459. export var rgbdEncodePixelShader: {
  136460. name: string;
  136461. shader: string;
  136462. };
  136463. }
  136464. declare module BABYLON {
  136465. /**
  136466. * Raw texture data and descriptor sufficient for WebGL texture upload
  136467. */
  136468. export interface EnvironmentTextureInfo {
  136469. /**
  136470. * Version of the environment map
  136471. */
  136472. version: number;
  136473. /**
  136474. * Width of image
  136475. */
  136476. width: number;
  136477. /**
  136478. * Irradiance information stored in the file.
  136479. */
  136480. irradiance: any;
  136481. /**
  136482. * Specular information stored in the file.
  136483. */
  136484. specular: any;
  136485. }
  136486. /**
  136487. * Defines One Image in the file. It requires only the position in the file
  136488. * as well as the length.
  136489. */
  136490. interface BufferImageData {
  136491. /**
  136492. * Length of the image data.
  136493. */
  136494. length: number;
  136495. /**
  136496. * Position of the data from the null terminator delimiting the end of the JSON.
  136497. */
  136498. position: number;
  136499. }
  136500. /**
  136501. * Defines the specular data enclosed in the file.
  136502. * This corresponds to the version 1 of the data.
  136503. */
  136504. export interface EnvironmentTextureSpecularInfoV1 {
  136505. /**
  136506. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  136507. */
  136508. specularDataPosition?: number;
  136509. /**
  136510. * This contains all the images data needed to reconstruct the cubemap.
  136511. */
  136512. mipmaps: Array<BufferImageData>;
  136513. /**
  136514. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  136515. */
  136516. lodGenerationScale: number;
  136517. }
  136518. /**
  136519. * Sets of helpers addressing the serialization and deserialization of environment texture
  136520. * stored in a BabylonJS env file.
  136521. * Those files are usually stored as .env files.
  136522. */
  136523. export class EnvironmentTextureTools {
  136524. /**
  136525. * Magic number identifying the env file.
  136526. */
  136527. private static _MagicBytes;
  136528. /**
  136529. * Gets the environment info from an env file.
  136530. * @param data The array buffer containing the .env bytes.
  136531. * @returns the environment file info (the json header) if successfully parsed.
  136532. */
  136533. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  136534. /**
  136535. * Creates an environment texture from a loaded cube texture.
  136536. * @param texture defines the cube texture to convert in env file
  136537. * @return a promise containing the environment data if succesfull.
  136538. */
  136539. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  136540. /**
  136541. * Creates a JSON representation of the spherical data.
  136542. * @param texture defines the texture containing the polynomials
  136543. * @return the JSON representation of the spherical info
  136544. */
  136545. private static _CreateEnvTextureIrradiance;
  136546. /**
  136547. * Creates the ArrayBufferViews used for initializing environment texture image data.
  136548. * @param data the image data
  136549. * @param info parameters that determine what views will be created for accessing the underlying buffer
  136550. * @return the views described by info providing access to the underlying buffer
  136551. */
  136552. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  136553. /**
  136554. * Uploads the texture info contained in the env file to the GPU.
  136555. * @param texture defines the internal texture to upload to
  136556. * @param data defines the data to load
  136557. * @param info defines the texture info retrieved through the GetEnvInfo method
  136558. * @returns a promise
  136559. */
  136560. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  136561. private static _OnImageReadyAsync;
  136562. /**
  136563. * Uploads the levels of image data to the GPU.
  136564. * @param texture defines the internal texture to upload to
  136565. * @param imageData defines the array buffer views of image data [mipmap][face]
  136566. * @returns a promise
  136567. */
  136568. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  136569. /**
  136570. * Uploads spherical polynomials information to the texture.
  136571. * @param texture defines the texture we are trying to upload the information to
  136572. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  136573. */
  136574. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  136575. /** @hidden */
  136576. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  136577. }
  136578. }
  136579. declare module BABYLON {
  136580. /**
  136581. * Class used to inline functions in shader code
  136582. */
  136583. export class ShaderCodeInliner {
  136584. private static readonly _RegexpFindFunctionNameAndType;
  136585. private _sourceCode;
  136586. private _functionDescr;
  136587. private _numMaxIterations;
  136588. /** Gets or sets the token used to mark the functions to inline */
  136589. inlineToken: string;
  136590. /** Gets or sets the debug mode */
  136591. debug: boolean;
  136592. /** Gets the code after the inlining process */
  136593. get code(): string;
  136594. /**
  136595. * Initializes the inliner
  136596. * @param sourceCode shader code source to inline
  136597. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  136598. */
  136599. constructor(sourceCode: string, numMaxIterations?: number);
  136600. /**
  136601. * Start the processing of the shader code
  136602. */
  136603. processCode(): void;
  136604. private _collectFunctions;
  136605. private _processInlining;
  136606. private _extractBetweenMarkers;
  136607. private _skipWhitespaces;
  136608. private _removeComments;
  136609. private _replaceFunctionCallsByCode;
  136610. private _findBackward;
  136611. private _escapeRegExp;
  136612. private _replaceNames;
  136613. }
  136614. }
  136615. declare module BABYLON {
  136616. /**
  136617. * Container for accessors for natively-stored mesh data buffers.
  136618. */
  136619. class NativeDataBuffer extends DataBuffer {
  136620. /**
  136621. * Accessor value used to identify/retrieve a natively-stored index buffer.
  136622. */
  136623. nativeIndexBuffer?: any;
  136624. /**
  136625. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  136626. */
  136627. nativeVertexBuffer?: any;
  136628. }
  136629. /** @hidden */
  136630. class NativeTexture extends InternalTexture {
  136631. getInternalTexture(): InternalTexture;
  136632. getViewCount(): number;
  136633. }
  136634. /** @hidden */
  136635. export class NativeEngine extends Engine {
  136636. private readonly _native;
  136637. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  136638. private readonly INVALID_HANDLE;
  136639. private _boundBuffersVertexArray;
  136640. private _currentDepthTest;
  136641. getHardwareScalingLevel(): number;
  136642. constructor();
  136643. dispose(): void;
  136644. /**
  136645. * Can be used to override the current requestAnimationFrame requester.
  136646. * @hidden
  136647. */
  136648. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  136649. /**
  136650. * Override default engine behavior.
  136651. * @param color
  136652. * @param backBuffer
  136653. * @param depth
  136654. * @param stencil
  136655. */
  136656. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  136657. /**
  136658. * Gets host document
  136659. * @returns the host document object
  136660. */
  136661. getHostDocument(): Nullable<Document>;
  136662. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  136663. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  136664. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  136665. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  136666. [key: string]: VertexBuffer;
  136667. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  136668. bindBuffers(vertexBuffers: {
  136669. [key: string]: VertexBuffer;
  136670. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  136671. recordVertexArrayObject(vertexBuffers: {
  136672. [key: string]: VertexBuffer;
  136673. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  136674. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  136675. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  136676. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  136677. /**
  136678. * Draw a list of indexed primitives
  136679. * @param fillMode defines the primitive to use
  136680. * @param indexStart defines the starting index
  136681. * @param indexCount defines the number of index to draw
  136682. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136683. */
  136684. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  136685. /**
  136686. * Draw a list of unindexed primitives
  136687. * @param fillMode defines the primitive to use
  136688. * @param verticesStart defines the index of first vertex to draw
  136689. * @param verticesCount defines the count of vertices to draw
  136690. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136691. */
  136692. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  136693. createPipelineContext(): IPipelineContext;
  136694. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  136695. /** @hidden */
  136696. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  136697. /** @hidden */
  136698. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  136699. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  136700. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  136701. protected _setProgram(program: WebGLProgram): void;
  136702. _releaseEffect(effect: Effect): void;
  136703. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  136704. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  136705. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  136706. bindSamplers(effect: Effect): void;
  136707. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  136708. getRenderWidth(useScreen?: boolean): number;
  136709. getRenderHeight(useScreen?: boolean): number;
  136710. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  136711. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  136712. /**
  136713. * Set the z offset to apply to current rendering
  136714. * @param value defines the offset to apply
  136715. */
  136716. setZOffset(value: number): void;
  136717. /**
  136718. * Gets the current value of the zOffset
  136719. * @returns the current zOffset state
  136720. */
  136721. getZOffset(): number;
  136722. /**
  136723. * Enable or disable depth buffering
  136724. * @param enable defines the state to set
  136725. */
  136726. setDepthBuffer(enable: boolean): void;
  136727. /**
  136728. * Gets a boolean indicating if depth writing is enabled
  136729. * @returns the current depth writing state
  136730. */
  136731. getDepthWrite(): boolean;
  136732. setDepthFunctionToGreater(): void;
  136733. setDepthFunctionToGreaterOrEqual(): void;
  136734. setDepthFunctionToLess(): void;
  136735. setDepthFunctionToLessOrEqual(): void;
  136736. /**
  136737. * Enable or disable depth writing
  136738. * @param enable defines the state to set
  136739. */
  136740. setDepthWrite(enable: boolean): void;
  136741. /**
  136742. * Enable or disable color writing
  136743. * @param enable defines the state to set
  136744. */
  136745. setColorWrite(enable: boolean): void;
  136746. /**
  136747. * Gets a boolean indicating if color writing is enabled
  136748. * @returns the current color writing state
  136749. */
  136750. getColorWrite(): boolean;
  136751. /**
  136752. * Sets alpha constants used by some alpha blending modes
  136753. * @param r defines the red component
  136754. * @param g defines the green component
  136755. * @param b defines the blue component
  136756. * @param a defines the alpha component
  136757. */
  136758. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  136759. /**
  136760. * Sets the current alpha mode
  136761. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  136762. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  136763. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136764. */
  136765. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  136766. /**
  136767. * Gets the current alpha mode
  136768. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136769. * @returns the current alpha mode
  136770. */
  136771. getAlphaMode(): number;
  136772. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  136773. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136774. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136775. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136776. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136777. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136778. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136779. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136780. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136781. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  136782. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  136783. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  136784. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  136785. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  136786. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136787. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136788. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  136789. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  136790. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  136791. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  136792. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  136793. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  136794. wipeCaches(bruteForce?: boolean): void;
  136795. _createTexture(): WebGLTexture;
  136796. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  136797. /**
  136798. * Update the content of a dynamic texture
  136799. * @param texture defines the texture to update
  136800. * @param canvas defines the canvas containing the source
  136801. * @param invertY defines if data must be stored with Y axis inverted
  136802. * @param premulAlpha defines if alpha is stored as premultiplied
  136803. * @param format defines the format of the data
  136804. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  136805. */
  136806. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  136807. /**
  136808. * Usually called from Texture.ts.
  136809. * Passed information to create a WebGLTexture
  136810. * @param url defines a value which contains one of the following:
  136811. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  136812. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  136813. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  136814. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  136815. * @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)
  136816. * @param scene needed for loading to the correct scene
  136817. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  136818. * @param onLoad optional callback to be called upon successful completion
  136819. * @param onError optional callback to be called upon failure
  136820. * @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
  136821. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  136822. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  136823. * @param forcedExtension defines the extension to use to pick the right loader
  136824. * @param mimeType defines an optional mime type
  136825. * @param loaderOptions options to be passed to the loader
  136826. * @returns a InternalTexture for assignment back into BABYLON.Texture
  136827. */
  136828. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  136829. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  136830. _releaseFramebufferObjects(texture: InternalTexture): void;
  136831. /**
  136832. * Creates a cube texture
  136833. * @param rootUrl defines the url where the files to load is located
  136834. * @param scene defines the current scene
  136835. * @param files defines the list of files to load (1 per face)
  136836. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  136837. * @param onLoad defines an optional callback raised when the texture is loaded
  136838. * @param onError defines an optional callback raised if there is an issue to load the texture
  136839. * @param format defines the format of the data
  136840. * @param forcedExtension defines the extension to use to pick the right loader
  136841. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  136842. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  136843. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  136844. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  136845. * @returns the cube texture as an InternalTexture
  136846. */
  136847. 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;
  136848. createRenderTargetTexture(size: number | {
  136849. width: number;
  136850. height: number;
  136851. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  136852. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  136853. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  136854. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  136855. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  136856. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  136857. /**
  136858. * Updates a dynamic vertex buffer.
  136859. * @param vertexBuffer the vertex buffer to update
  136860. * @param data the data used to update the vertex buffer
  136861. * @param byteOffset the byte offset of the data (optional)
  136862. * @param byteLength the byte length of the data (optional)
  136863. */
  136864. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  136865. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  136866. private _updateAnisotropicLevel;
  136867. private _getAddressMode;
  136868. /** @hidden */
  136869. _bindTexture(channel: number, texture: InternalTexture): void;
  136870. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  136871. releaseEffects(): void;
  136872. /** @hidden */
  136873. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136874. /** @hidden */
  136875. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136876. /** @hidden */
  136877. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136878. /** @hidden */
  136879. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  136880. private _getNativeSamplingMode;
  136881. private _getNativeTextureFormat;
  136882. private _getNativeAlphaMode;
  136883. private _getNativeAttribType;
  136884. }
  136885. }
  136886. declare module BABYLON {
  136887. /**
  136888. * Gather the list of clipboard event types as constants.
  136889. */
  136890. export class ClipboardEventTypes {
  136891. /**
  136892. * The clipboard event is fired when a copy command is active (pressed).
  136893. */
  136894. static readonly COPY: number;
  136895. /**
  136896. * The clipboard event is fired when a cut command is active (pressed).
  136897. */
  136898. static readonly CUT: number;
  136899. /**
  136900. * The clipboard event is fired when a paste command is active (pressed).
  136901. */
  136902. static readonly PASTE: number;
  136903. }
  136904. /**
  136905. * This class is used to store clipboard related info for the onClipboardObservable event.
  136906. */
  136907. export class ClipboardInfo {
  136908. /**
  136909. * Defines the type of event (BABYLON.ClipboardEventTypes)
  136910. */
  136911. type: number;
  136912. /**
  136913. * Defines the related dom event
  136914. */
  136915. event: ClipboardEvent;
  136916. /**
  136917. *Creates an instance of ClipboardInfo.
  136918. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  136919. * @param event Defines the related dom event
  136920. */
  136921. constructor(
  136922. /**
  136923. * Defines the type of event (BABYLON.ClipboardEventTypes)
  136924. */
  136925. type: number,
  136926. /**
  136927. * Defines the related dom event
  136928. */
  136929. event: ClipboardEvent);
  136930. /**
  136931. * Get the clipboard event's type from the keycode.
  136932. * @param keyCode Defines the keyCode for the current keyboard event.
  136933. * @return {number}
  136934. */
  136935. static GetTypeFromCharacter(keyCode: number): number;
  136936. }
  136937. }
  136938. declare module BABYLON {
  136939. /**
  136940. * Google Daydream controller
  136941. */
  136942. export class DaydreamController extends WebVRController {
  136943. /**
  136944. * Base Url for the controller model.
  136945. */
  136946. static MODEL_BASE_URL: string;
  136947. /**
  136948. * File name for the controller model.
  136949. */
  136950. static MODEL_FILENAME: string;
  136951. /**
  136952. * Gamepad Id prefix used to identify Daydream Controller.
  136953. */
  136954. static readonly GAMEPAD_ID_PREFIX: string;
  136955. /**
  136956. * Creates a new DaydreamController from a gamepad
  136957. * @param vrGamepad the gamepad that the controller should be created from
  136958. */
  136959. constructor(vrGamepad: any);
  136960. /**
  136961. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136962. * @param scene scene in which to add meshes
  136963. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136964. */
  136965. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136966. /**
  136967. * Called once for each button that changed state since the last frame
  136968. * @param buttonIdx Which button index changed
  136969. * @param state New state of the button
  136970. * @param changes Which properties on the state changed since last frame
  136971. */
  136972. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136973. }
  136974. }
  136975. declare module BABYLON {
  136976. /**
  136977. * Gear VR Controller
  136978. */
  136979. export class GearVRController extends WebVRController {
  136980. /**
  136981. * Base Url for the controller model.
  136982. */
  136983. static MODEL_BASE_URL: string;
  136984. /**
  136985. * File name for the controller model.
  136986. */
  136987. static MODEL_FILENAME: string;
  136988. /**
  136989. * Gamepad Id prefix used to identify this controller.
  136990. */
  136991. static readonly GAMEPAD_ID_PREFIX: string;
  136992. private readonly _buttonIndexToObservableNameMap;
  136993. /**
  136994. * Creates a new GearVRController from a gamepad
  136995. * @param vrGamepad the gamepad that the controller should be created from
  136996. */
  136997. constructor(vrGamepad: any);
  136998. /**
  136999. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137000. * @param scene scene in which to add meshes
  137001. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137002. */
  137003. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137004. /**
  137005. * Called once for each button that changed state since the last frame
  137006. * @param buttonIdx Which button index changed
  137007. * @param state New state of the button
  137008. * @param changes Which properties on the state changed since last frame
  137009. */
  137010. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137011. }
  137012. }
  137013. declare module BABYLON {
  137014. /**
  137015. * Generic Controller
  137016. */
  137017. export class GenericController extends WebVRController {
  137018. /**
  137019. * Base Url for the controller model.
  137020. */
  137021. static readonly MODEL_BASE_URL: string;
  137022. /**
  137023. * File name for the controller model.
  137024. */
  137025. static readonly MODEL_FILENAME: string;
  137026. /**
  137027. * Creates a new GenericController from a gamepad
  137028. * @param vrGamepad the gamepad that the controller should be created from
  137029. */
  137030. constructor(vrGamepad: any);
  137031. /**
  137032. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137033. * @param scene scene in which to add meshes
  137034. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137035. */
  137036. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137037. /**
  137038. * Called once for each button that changed state since the last frame
  137039. * @param buttonIdx Which button index changed
  137040. * @param state New state of the button
  137041. * @param changes Which properties on the state changed since last frame
  137042. */
  137043. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137044. }
  137045. }
  137046. declare module BABYLON {
  137047. /**
  137048. * Oculus Touch Controller
  137049. */
  137050. export class OculusTouchController extends WebVRController {
  137051. /**
  137052. * Base Url for the controller model.
  137053. */
  137054. static MODEL_BASE_URL: string;
  137055. /**
  137056. * File name for the left controller model.
  137057. */
  137058. static MODEL_LEFT_FILENAME: string;
  137059. /**
  137060. * File name for the right controller model.
  137061. */
  137062. static MODEL_RIGHT_FILENAME: string;
  137063. /**
  137064. * Base Url for the Quest controller model.
  137065. */
  137066. static QUEST_MODEL_BASE_URL: string;
  137067. /**
  137068. * @hidden
  137069. * If the controllers are running on a device that needs the updated Quest controller models
  137070. */
  137071. static _IsQuest: boolean;
  137072. /**
  137073. * Fired when the secondary trigger on this controller is modified
  137074. */
  137075. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  137076. /**
  137077. * Fired when the thumb rest on this controller is modified
  137078. */
  137079. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  137080. /**
  137081. * Creates a new OculusTouchController from a gamepad
  137082. * @param vrGamepad the gamepad that the controller should be created from
  137083. */
  137084. constructor(vrGamepad: any);
  137085. /**
  137086. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137087. * @param scene scene in which to add meshes
  137088. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137089. */
  137090. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137091. /**
  137092. * Fired when the A button on this controller is modified
  137093. */
  137094. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137095. /**
  137096. * Fired when the B button on this controller is modified
  137097. */
  137098. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137099. /**
  137100. * Fired when the X button on this controller is modified
  137101. */
  137102. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137103. /**
  137104. * Fired when the Y button on this controller is modified
  137105. */
  137106. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137107. /**
  137108. * Called once for each button that changed state since the last frame
  137109. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  137110. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  137111. * 2) secondary trigger (same)
  137112. * 3) A (right) X (left), touch, pressed = value
  137113. * 4) B / Y
  137114. * 5) thumb rest
  137115. * @param buttonIdx Which button index changed
  137116. * @param state New state of the button
  137117. * @param changes Which properties on the state changed since last frame
  137118. */
  137119. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137120. }
  137121. }
  137122. declare module BABYLON {
  137123. /**
  137124. * Vive Controller
  137125. */
  137126. export class ViveController extends WebVRController {
  137127. /**
  137128. * Base Url for the controller model.
  137129. */
  137130. static MODEL_BASE_URL: string;
  137131. /**
  137132. * File name for the controller model.
  137133. */
  137134. static MODEL_FILENAME: string;
  137135. /**
  137136. * Creates a new ViveController from a gamepad
  137137. * @param vrGamepad the gamepad that the controller should be created from
  137138. */
  137139. constructor(vrGamepad: any);
  137140. /**
  137141. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137142. * @param scene scene in which to add meshes
  137143. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137144. */
  137145. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137146. /**
  137147. * Fired when the left button on this controller is modified
  137148. */
  137149. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137150. /**
  137151. * Fired when the right button on this controller is modified
  137152. */
  137153. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137154. /**
  137155. * Fired when the menu button on this controller is modified
  137156. */
  137157. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137158. /**
  137159. * Called once for each button that changed state since the last frame
  137160. * Vive mapping:
  137161. * 0: touchpad
  137162. * 1: trigger
  137163. * 2: left AND right buttons
  137164. * 3: menu button
  137165. * @param buttonIdx Which button index changed
  137166. * @param state New state of the button
  137167. * @param changes Which properties on the state changed since last frame
  137168. */
  137169. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137170. }
  137171. }
  137172. declare module BABYLON {
  137173. /**
  137174. * Defines the WindowsMotionController object that the state of the windows motion controller
  137175. */
  137176. export class WindowsMotionController extends WebVRController {
  137177. /**
  137178. * The base url used to load the left and right controller models
  137179. */
  137180. static MODEL_BASE_URL: string;
  137181. /**
  137182. * The name of the left controller model file
  137183. */
  137184. static MODEL_LEFT_FILENAME: string;
  137185. /**
  137186. * The name of the right controller model file
  137187. */
  137188. static MODEL_RIGHT_FILENAME: string;
  137189. /**
  137190. * The controller name prefix for this controller type
  137191. */
  137192. static readonly GAMEPAD_ID_PREFIX: string;
  137193. /**
  137194. * The controller id pattern for this controller type
  137195. */
  137196. private static readonly GAMEPAD_ID_PATTERN;
  137197. private _loadedMeshInfo;
  137198. protected readonly _mapping: {
  137199. buttons: string[];
  137200. buttonMeshNames: {
  137201. trigger: string;
  137202. menu: string;
  137203. grip: string;
  137204. thumbstick: string;
  137205. trackpad: string;
  137206. };
  137207. buttonObservableNames: {
  137208. trigger: string;
  137209. menu: string;
  137210. grip: string;
  137211. thumbstick: string;
  137212. trackpad: string;
  137213. };
  137214. axisMeshNames: string[];
  137215. pointingPoseMeshName: string;
  137216. };
  137217. /**
  137218. * Fired when the trackpad on this controller is clicked
  137219. */
  137220. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  137221. /**
  137222. * Fired when the trackpad on this controller is modified
  137223. */
  137224. onTrackpadValuesChangedObservable: Observable<StickValues>;
  137225. /**
  137226. * The current x and y values of this controller's trackpad
  137227. */
  137228. trackpad: StickValues;
  137229. /**
  137230. * Creates a new WindowsMotionController from a gamepad
  137231. * @param vrGamepad the gamepad that the controller should be created from
  137232. */
  137233. constructor(vrGamepad: any);
  137234. /**
  137235. * Fired when the trigger on this controller is modified
  137236. */
  137237. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137238. /**
  137239. * Fired when the menu button on this controller is modified
  137240. */
  137241. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137242. /**
  137243. * Fired when the grip button on this controller is modified
  137244. */
  137245. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137246. /**
  137247. * Fired when the thumbstick button on this controller is modified
  137248. */
  137249. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137250. /**
  137251. * Fired when the touchpad button on this controller is modified
  137252. */
  137253. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137254. /**
  137255. * Fired when the touchpad values on this controller are modified
  137256. */
  137257. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  137258. protected _updateTrackpad(): void;
  137259. /**
  137260. * Called once per frame by the engine.
  137261. */
  137262. update(): void;
  137263. /**
  137264. * Called once for each button that changed state since the last frame
  137265. * @param buttonIdx Which button index changed
  137266. * @param state New state of the button
  137267. * @param changes Which properties on the state changed since last frame
  137268. */
  137269. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137270. /**
  137271. * Moves the buttons on the controller mesh based on their current state
  137272. * @param buttonName the name of the button to move
  137273. * @param buttonValue the value of the button which determines the buttons new position
  137274. */
  137275. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  137276. /**
  137277. * Moves the axis on the controller mesh based on its current state
  137278. * @param axis the index of the axis
  137279. * @param axisValue the value of the axis which determines the meshes new position
  137280. * @hidden
  137281. */
  137282. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  137283. /**
  137284. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137285. * @param scene scene in which to add meshes
  137286. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137287. */
  137288. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  137289. /**
  137290. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  137291. * can be transformed by button presses and axes values, based on this._mapping.
  137292. *
  137293. * @param scene scene in which the meshes exist
  137294. * @param meshes list of meshes that make up the controller model to process
  137295. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  137296. */
  137297. private processModel;
  137298. private createMeshInfo;
  137299. /**
  137300. * Gets the ray of the controller in the direction the controller is pointing
  137301. * @param length the length the resulting ray should be
  137302. * @returns a ray in the direction the controller is pointing
  137303. */
  137304. getForwardRay(length?: number): Ray;
  137305. /**
  137306. * Disposes of the controller
  137307. */
  137308. dispose(): void;
  137309. }
  137310. /**
  137311. * This class represents a new windows motion controller in XR.
  137312. */
  137313. export class XRWindowsMotionController extends WindowsMotionController {
  137314. /**
  137315. * Changing the original WIndowsMotionController mapping to fir the new mapping
  137316. */
  137317. protected readonly _mapping: {
  137318. buttons: string[];
  137319. buttonMeshNames: {
  137320. trigger: string;
  137321. menu: string;
  137322. grip: string;
  137323. thumbstick: string;
  137324. trackpad: string;
  137325. };
  137326. buttonObservableNames: {
  137327. trigger: string;
  137328. menu: string;
  137329. grip: string;
  137330. thumbstick: string;
  137331. trackpad: string;
  137332. };
  137333. axisMeshNames: string[];
  137334. pointingPoseMeshName: string;
  137335. };
  137336. /**
  137337. * Construct a new XR-Based windows motion controller
  137338. *
  137339. * @param gamepadInfo the gamepad object from the browser
  137340. */
  137341. constructor(gamepadInfo: any);
  137342. /**
  137343. * holds the thumbstick values (X,Y)
  137344. */
  137345. thumbstickValues: StickValues;
  137346. /**
  137347. * Fired when the thumbstick on this controller is clicked
  137348. */
  137349. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  137350. /**
  137351. * Fired when the thumbstick on this controller is modified
  137352. */
  137353. onThumbstickValuesChangedObservable: Observable<StickValues>;
  137354. /**
  137355. * Fired when the touchpad button on this controller is modified
  137356. */
  137357. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  137358. /**
  137359. * Fired when the touchpad values on this controller are modified
  137360. */
  137361. onTrackpadValuesChangedObservable: Observable<StickValues>;
  137362. /**
  137363. * Fired when the thumbstick button on this controller is modified
  137364. * here to prevent breaking changes
  137365. */
  137366. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137367. /**
  137368. * updating the thumbstick(!) and not the trackpad.
  137369. * This is named this way due to the difference between WebVR and XR and to avoid
  137370. * changing the parent class.
  137371. */
  137372. protected _updateTrackpad(): void;
  137373. /**
  137374. * Disposes the class with joy
  137375. */
  137376. dispose(): void;
  137377. }
  137378. }
  137379. declare module BABYLON {
  137380. /**
  137381. * Class containing static functions to help procedurally build meshes
  137382. */
  137383. export class PolyhedronBuilder {
  137384. /**
  137385. * Creates a polyhedron mesh
  137386. * * 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
  137387. * * The parameter `size` (positive float, default 1) sets the polygon size
  137388. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  137389. * * 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`
  137390. * * 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
  137391. * * 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)`)
  137392. * * 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
  137393. * * 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
  137394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137397. * @param name defines the name of the mesh
  137398. * @param options defines the options used to create the mesh
  137399. * @param scene defines the hosting scene
  137400. * @returns the polyhedron mesh
  137401. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  137402. */
  137403. static CreatePolyhedron(name: string, options: {
  137404. type?: number;
  137405. size?: number;
  137406. sizeX?: number;
  137407. sizeY?: number;
  137408. sizeZ?: number;
  137409. custom?: any;
  137410. faceUV?: Vector4[];
  137411. faceColors?: Color4[];
  137412. flat?: boolean;
  137413. updatable?: boolean;
  137414. sideOrientation?: number;
  137415. frontUVs?: Vector4;
  137416. backUVs?: Vector4;
  137417. }, scene?: Nullable<Scene>): Mesh;
  137418. }
  137419. }
  137420. declare module BABYLON {
  137421. /**
  137422. * Gizmo that enables scaling a mesh along 3 axis
  137423. */
  137424. export class ScaleGizmo extends Gizmo {
  137425. /**
  137426. * Internal gizmo used for interactions on the x axis
  137427. */
  137428. xGizmo: AxisScaleGizmo;
  137429. /**
  137430. * Internal gizmo used for interactions on the y axis
  137431. */
  137432. yGizmo: AxisScaleGizmo;
  137433. /**
  137434. * Internal gizmo used for interactions on the z axis
  137435. */
  137436. zGizmo: AxisScaleGizmo;
  137437. /**
  137438. * Internal gizmo used to scale all axis equally
  137439. */
  137440. uniformScaleGizmo: AxisScaleGizmo;
  137441. private _meshAttached;
  137442. private _nodeAttached;
  137443. private _snapDistance;
  137444. private _uniformScalingMesh;
  137445. private _octahedron;
  137446. private _sensitivity;
  137447. /** Fires an event when any of it's sub gizmos are dragged */
  137448. onDragStartObservable: Observable<unknown>;
  137449. /** Fires an event when any of it's sub gizmos are released from dragging */
  137450. onDragEndObservable: Observable<unknown>;
  137451. get attachedMesh(): Nullable<AbstractMesh>;
  137452. set attachedMesh(mesh: Nullable<AbstractMesh>);
  137453. get attachedNode(): Nullable<Node>;
  137454. set attachedNode(node: Nullable<Node>);
  137455. /**
  137456. * True when the mouse pointer is hovering a gizmo mesh
  137457. */
  137458. get isHovered(): boolean;
  137459. /**
  137460. * Creates a ScaleGizmo
  137461. * @param gizmoLayer The utility layer the gizmo will be added to
  137462. * @param thickness display gizmo axis thickness
  137463. */
  137464. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  137465. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  137466. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  137467. /**
  137468. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137469. */
  137470. set snapDistance(value: number);
  137471. get snapDistance(): number;
  137472. /**
  137473. * Ratio for the scale of the gizmo (Default: 1)
  137474. */
  137475. set scaleRatio(value: number);
  137476. get scaleRatio(): number;
  137477. /**
  137478. * Sensitivity factor for dragging (Default: 1)
  137479. */
  137480. set sensitivity(value: number);
  137481. get sensitivity(): number;
  137482. /**
  137483. * Disposes of the gizmo
  137484. */
  137485. dispose(): void;
  137486. }
  137487. }
  137488. declare module BABYLON {
  137489. /**
  137490. * Single axis scale gizmo
  137491. */
  137492. export class AxisScaleGizmo extends Gizmo {
  137493. /**
  137494. * Drag behavior responsible for the gizmos dragging interactions
  137495. */
  137496. dragBehavior: PointerDragBehavior;
  137497. private _pointerObserver;
  137498. /**
  137499. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137500. */
  137501. snapDistance: number;
  137502. /**
  137503. * Event that fires each time the gizmo snaps to a new location.
  137504. * * snapDistance is the the change in distance
  137505. */
  137506. onSnapObservable: Observable<{
  137507. snapDistance: number;
  137508. }>;
  137509. /**
  137510. * If the scaling operation should be done on all axis (default: false)
  137511. */
  137512. uniformScaling: boolean;
  137513. /**
  137514. * Custom sensitivity value for the drag strength
  137515. */
  137516. sensitivity: number;
  137517. private _isEnabled;
  137518. private _parent;
  137519. private _arrow;
  137520. private _coloredMaterial;
  137521. private _hoverMaterial;
  137522. /**
  137523. * Creates an AxisScaleGizmo
  137524. * @param gizmoLayer The utility layer the gizmo will be added to
  137525. * @param dragAxis The axis which the gizmo will be able to scale on
  137526. * @param color The color of the gizmo
  137527. * @param thickness display gizmo axis thickness
  137528. */
  137529. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  137530. protected _attachedNodeChanged(value: Nullable<Node>): void;
  137531. /**
  137532. * If the gizmo is enabled
  137533. */
  137534. set isEnabled(value: boolean);
  137535. get isEnabled(): boolean;
  137536. /**
  137537. * Disposes of the gizmo
  137538. */
  137539. dispose(): void;
  137540. /**
  137541. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  137542. * @param mesh The mesh to replace the default mesh of the gizmo
  137543. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  137544. */
  137545. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  137546. }
  137547. }
  137548. declare module BABYLON {
  137549. /**
  137550. * Bounding box gizmo
  137551. */
  137552. export class BoundingBoxGizmo extends Gizmo {
  137553. private _lineBoundingBox;
  137554. private _rotateSpheresParent;
  137555. private _scaleBoxesParent;
  137556. private _boundingDimensions;
  137557. private _renderObserver;
  137558. private _pointerObserver;
  137559. private _scaleDragSpeed;
  137560. private _tmpQuaternion;
  137561. private _tmpVector;
  137562. private _tmpRotationMatrix;
  137563. /**
  137564. * 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)
  137565. */
  137566. ignoreChildren: boolean;
  137567. /**
  137568. * 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)
  137569. */
  137570. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  137571. /**
  137572. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  137573. */
  137574. rotationSphereSize: number;
  137575. /**
  137576. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  137577. */
  137578. scaleBoxSize: number;
  137579. /**
  137580. * 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)
  137581. */
  137582. fixedDragMeshScreenSize: boolean;
  137583. /**
  137584. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  137585. */
  137586. fixedDragMeshScreenSizeDistanceFactor: number;
  137587. /**
  137588. * Fired when a rotation sphere or scale box is dragged
  137589. */
  137590. onDragStartObservable: Observable<{}>;
  137591. /**
  137592. * Fired when a scale box is dragged
  137593. */
  137594. onScaleBoxDragObservable: Observable<{}>;
  137595. /**
  137596. * Fired when a scale box drag is ended
  137597. */
  137598. onScaleBoxDragEndObservable: Observable<{}>;
  137599. /**
  137600. * Fired when a rotation sphere is dragged
  137601. */
  137602. onRotationSphereDragObservable: Observable<{}>;
  137603. /**
  137604. * Fired when a rotation sphere drag is ended
  137605. */
  137606. onRotationSphereDragEndObservable: Observable<{}>;
  137607. /**
  137608. * 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)
  137609. */
  137610. scalePivot: Nullable<Vector3>;
  137611. /**
  137612. * Mesh used as a pivot to rotate the attached node
  137613. */
  137614. private _anchorMesh;
  137615. private _existingMeshScale;
  137616. private _dragMesh;
  137617. private pointerDragBehavior;
  137618. private coloredMaterial;
  137619. private hoverColoredMaterial;
  137620. /**
  137621. * Sets the color of the bounding box gizmo
  137622. * @param color the color to set
  137623. */
  137624. setColor(color: Color3): void;
  137625. /**
  137626. * Creates an BoundingBoxGizmo
  137627. * @param gizmoLayer The utility layer the gizmo will be added to
  137628. * @param color The color of the gizmo
  137629. */
  137630. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  137631. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  137632. private _selectNode;
  137633. /**
  137634. * Updates the bounding box information for the Gizmo
  137635. */
  137636. updateBoundingBox(): void;
  137637. private _updateRotationSpheres;
  137638. private _updateScaleBoxes;
  137639. /**
  137640. * Enables rotation on the specified axis and disables rotation on the others
  137641. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  137642. */
  137643. setEnabledRotationAxis(axis: string): void;
  137644. /**
  137645. * Enables/disables scaling
  137646. * @param enable if scaling should be enabled
  137647. * @param homogeneousScaling defines if scaling should only be homogeneous
  137648. */
  137649. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  137650. private _updateDummy;
  137651. /**
  137652. * Enables a pointer drag behavior on the bounding box of the gizmo
  137653. */
  137654. enableDragBehavior(): void;
  137655. /**
  137656. * Disposes of the gizmo
  137657. */
  137658. dispose(): void;
  137659. /**
  137660. * 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)
  137661. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  137662. * @returns the bounding box mesh with the passed in mesh as a child
  137663. */
  137664. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  137665. /**
  137666. * CustomMeshes are not supported by this gizmo
  137667. * @param mesh The mesh to replace the default mesh of the gizmo
  137668. */
  137669. setCustomMesh(mesh: Mesh): void;
  137670. }
  137671. }
  137672. declare module BABYLON {
  137673. /**
  137674. * Single plane rotation gizmo
  137675. */
  137676. export class PlaneRotationGizmo extends Gizmo {
  137677. /**
  137678. * Drag behavior responsible for the gizmos dragging interactions
  137679. */
  137680. dragBehavior: PointerDragBehavior;
  137681. private _pointerObserver;
  137682. /**
  137683. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  137684. */
  137685. snapDistance: number;
  137686. /**
  137687. * Event that fires each time the gizmo snaps to a new location.
  137688. * * snapDistance is the the change in distance
  137689. */
  137690. onSnapObservable: Observable<{
  137691. snapDistance: number;
  137692. }>;
  137693. private _isEnabled;
  137694. private _parent;
  137695. /**
  137696. * Creates a PlaneRotationGizmo
  137697. * @param gizmoLayer The utility layer the gizmo will be added to
  137698. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  137699. * @param color The color of the gizmo
  137700. * @param tessellation Amount of tessellation to be used when creating rotation circles
  137701. * @param useEulerRotation Use and update Euler angle instead of quaternion
  137702. * @param thickness display gizmo axis thickness
  137703. */
  137704. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  137705. protected _attachedNodeChanged(value: Nullable<Node>): void;
  137706. /**
  137707. * If the gizmo is enabled
  137708. */
  137709. set isEnabled(value: boolean);
  137710. get isEnabled(): boolean;
  137711. /**
  137712. * Disposes of the gizmo
  137713. */
  137714. dispose(): void;
  137715. }
  137716. }
  137717. declare module BABYLON {
  137718. /**
  137719. * Gizmo that enables rotating a mesh along 3 axis
  137720. */
  137721. export class RotationGizmo extends Gizmo {
  137722. /**
  137723. * Internal gizmo used for interactions on the x axis
  137724. */
  137725. xGizmo: PlaneRotationGizmo;
  137726. /**
  137727. * Internal gizmo used for interactions on the y axis
  137728. */
  137729. yGizmo: PlaneRotationGizmo;
  137730. /**
  137731. * Internal gizmo used for interactions on the z axis
  137732. */
  137733. zGizmo: PlaneRotationGizmo;
  137734. /** Fires an event when any of it's sub gizmos are dragged */
  137735. onDragStartObservable: Observable<unknown>;
  137736. /** Fires an event when any of it's sub gizmos are released from dragging */
  137737. onDragEndObservable: Observable<unknown>;
  137738. private _meshAttached;
  137739. private _nodeAttached;
  137740. get attachedMesh(): Nullable<AbstractMesh>;
  137741. set attachedMesh(mesh: Nullable<AbstractMesh>);
  137742. get attachedNode(): Nullable<Node>;
  137743. set attachedNode(node: Nullable<Node>);
  137744. protected _checkBillboardTransform(): void;
  137745. /**
  137746. * True when the mouse pointer is hovering a gizmo mesh
  137747. */
  137748. get isHovered(): boolean;
  137749. /**
  137750. * Creates a RotationGizmo
  137751. * @param gizmoLayer The utility layer the gizmo will be added to
  137752. * @param tessellation Amount of tessellation to be used when creating rotation circles
  137753. * @param useEulerRotation Use and update Euler angle instead of quaternion
  137754. * @param thickness display gizmo axis thickness
  137755. */
  137756. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  137757. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  137758. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  137759. /**
  137760. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137761. */
  137762. set snapDistance(value: number);
  137763. get snapDistance(): number;
  137764. /**
  137765. * Ratio for the scale of the gizmo (Default: 1)
  137766. */
  137767. set scaleRatio(value: number);
  137768. get scaleRatio(): number;
  137769. /**
  137770. * Disposes of the gizmo
  137771. */
  137772. dispose(): void;
  137773. /**
  137774. * CustomMeshes are not supported by this gizmo
  137775. * @param mesh The mesh to replace the default mesh of the gizmo
  137776. */
  137777. setCustomMesh(mesh: Mesh): void;
  137778. }
  137779. }
  137780. declare module BABYLON {
  137781. /**
  137782. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  137783. */
  137784. export class GizmoManager implements IDisposable {
  137785. private scene;
  137786. /**
  137787. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  137788. */
  137789. gizmos: {
  137790. positionGizmo: Nullable<PositionGizmo>;
  137791. rotationGizmo: Nullable<RotationGizmo>;
  137792. scaleGizmo: Nullable<ScaleGizmo>;
  137793. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  137794. };
  137795. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  137796. clearGizmoOnEmptyPointerEvent: boolean;
  137797. /** Fires an event when the manager is attached to a mesh */
  137798. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  137799. /** Fires an event when the manager is attached to a node */
  137800. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  137801. private _gizmosEnabled;
  137802. private _pointerObserver;
  137803. private _attachedMesh;
  137804. private _attachedNode;
  137805. private _boundingBoxColor;
  137806. private _defaultUtilityLayer;
  137807. private _defaultKeepDepthUtilityLayer;
  137808. private _thickness;
  137809. /**
  137810. * When bounding box gizmo is enabled, this can be used to track drag/end events
  137811. */
  137812. boundingBoxDragBehavior: SixDofDragBehavior;
  137813. /**
  137814. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  137815. */
  137816. attachableMeshes: Nullable<Array<AbstractMesh>>;
  137817. /**
  137818. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  137819. */
  137820. attachableNodes: Nullable<Array<Node>>;
  137821. /**
  137822. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  137823. */
  137824. usePointerToAttachGizmos: boolean;
  137825. /**
  137826. * Utility layer that the bounding box gizmo belongs to
  137827. */
  137828. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  137829. /**
  137830. * Utility layer that all gizmos besides bounding box belong to
  137831. */
  137832. get utilityLayer(): UtilityLayerRenderer;
  137833. /**
  137834. * True when the mouse pointer is hovering a gizmo mesh
  137835. */
  137836. get isHovered(): boolean;
  137837. /**
  137838. * Instatiates a gizmo manager
  137839. * @param scene the scene to overlay the gizmos on top of
  137840. * @param thickness display gizmo axis thickness
  137841. */
  137842. constructor(scene: Scene, thickness?: number);
  137843. /**
  137844. * Attaches a set of gizmos to the specified mesh
  137845. * @param mesh The mesh the gizmo's should be attached to
  137846. */
  137847. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  137848. /**
  137849. * Attaches a set of gizmos to the specified node
  137850. * @param node The node the gizmo's should be attached to
  137851. */
  137852. attachToNode(node: Nullable<Node>): void;
  137853. /**
  137854. * If the position gizmo is enabled
  137855. */
  137856. set positionGizmoEnabled(value: boolean);
  137857. get positionGizmoEnabled(): boolean;
  137858. /**
  137859. * If the rotation gizmo is enabled
  137860. */
  137861. set rotationGizmoEnabled(value: boolean);
  137862. get rotationGizmoEnabled(): boolean;
  137863. /**
  137864. * If the scale gizmo is enabled
  137865. */
  137866. set scaleGizmoEnabled(value: boolean);
  137867. get scaleGizmoEnabled(): boolean;
  137868. /**
  137869. * If the boundingBox gizmo is enabled
  137870. */
  137871. set boundingBoxGizmoEnabled(value: boolean);
  137872. get boundingBoxGizmoEnabled(): boolean;
  137873. /**
  137874. * Disposes of the gizmo manager
  137875. */
  137876. dispose(): void;
  137877. }
  137878. }
  137879. declare module BABYLON {
  137880. /**
  137881. * A directional light is defined by a direction (what a surprise!).
  137882. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  137883. * 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.
  137884. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137885. */
  137886. export class DirectionalLight extends ShadowLight {
  137887. private _shadowFrustumSize;
  137888. /**
  137889. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  137890. */
  137891. get shadowFrustumSize(): number;
  137892. /**
  137893. * Specifies a fix frustum size for the shadow generation.
  137894. */
  137895. set shadowFrustumSize(value: number);
  137896. private _shadowOrthoScale;
  137897. /**
  137898. * Gets the shadow projection scale against the optimal computed one.
  137899. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  137900. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  137901. */
  137902. get shadowOrthoScale(): number;
  137903. /**
  137904. * Sets the shadow projection scale against the optimal computed one.
  137905. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  137906. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  137907. */
  137908. set shadowOrthoScale(value: number);
  137909. /**
  137910. * Automatically compute the projection matrix to best fit (including all the casters)
  137911. * on each frame.
  137912. */
  137913. autoUpdateExtends: boolean;
  137914. /**
  137915. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  137916. * on each frame. autoUpdateExtends must be set to true for this to work
  137917. */
  137918. autoCalcShadowZBounds: boolean;
  137919. private _orthoLeft;
  137920. private _orthoRight;
  137921. private _orthoTop;
  137922. private _orthoBottom;
  137923. /**
  137924. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  137925. * The directional light is emitted from everywhere in the given direction.
  137926. * It can cast shadows.
  137927. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137928. * @param name The friendly name of the light
  137929. * @param direction The direction of the light
  137930. * @param scene The scene the light belongs to
  137931. */
  137932. constructor(name: string, direction: Vector3, scene: Scene);
  137933. /**
  137934. * Returns the string "DirectionalLight".
  137935. * @return The class name
  137936. */
  137937. getClassName(): string;
  137938. /**
  137939. * Returns the integer 1.
  137940. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137941. */
  137942. getTypeID(): number;
  137943. /**
  137944. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  137945. * Returns the DirectionalLight Shadow projection matrix.
  137946. */
  137947. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137948. /**
  137949. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  137950. * Returns the DirectionalLight Shadow projection matrix.
  137951. */
  137952. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  137953. /**
  137954. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  137955. * Returns the DirectionalLight Shadow projection matrix.
  137956. */
  137957. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137958. protected _buildUniformLayout(): void;
  137959. /**
  137960. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  137961. * @param effect The effect to update
  137962. * @param lightIndex The index of the light in the effect to update
  137963. * @returns The directional light
  137964. */
  137965. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  137966. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  137967. /**
  137968. * Gets the minZ used for shadow according to both the scene and the light.
  137969. *
  137970. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  137971. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  137972. * @param activeCamera The camera we are returning the min for
  137973. * @returns the depth min z
  137974. */
  137975. getDepthMinZ(activeCamera: Camera): number;
  137976. /**
  137977. * Gets the maxZ used for shadow according to both the scene and the light.
  137978. *
  137979. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  137980. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  137981. * @param activeCamera The camera we are returning the max for
  137982. * @returns the depth max z
  137983. */
  137984. getDepthMaxZ(activeCamera: Camera): number;
  137985. /**
  137986. * Prepares the list of defines specific to the light type.
  137987. * @param defines the list of defines
  137988. * @param lightIndex defines the index of the light for the effect
  137989. */
  137990. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137991. }
  137992. }
  137993. declare module BABYLON {
  137994. /**
  137995. * Class containing static functions to help procedurally build meshes
  137996. */
  137997. export class HemisphereBuilder {
  137998. /**
  137999. * Creates a hemisphere mesh
  138000. * @param name defines the name of the mesh
  138001. * @param options defines the options used to create the mesh
  138002. * @param scene defines the hosting scene
  138003. * @returns the hemisphere mesh
  138004. */
  138005. static CreateHemisphere(name: string, options: {
  138006. segments?: number;
  138007. diameter?: number;
  138008. sideOrientation?: number;
  138009. }, scene: any): Mesh;
  138010. }
  138011. }
  138012. declare module BABYLON {
  138013. /**
  138014. * A spot light is defined by a position, a direction, an angle, and an exponent.
  138015. * These values define a cone of light starting from the position, emitting toward the direction.
  138016. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  138017. * and the exponent defines the speed of the decay of the light with distance (reach).
  138018. * Documentation: https://doc.babylonjs.com/babylon101/lights
  138019. */
  138020. export class SpotLight extends ShadowLight {
  138021. private _angle;
  138022. private _innerAngle;
  138023. private _cosHalfAngle;
  138024. private _lightAngleScale;
  138025. private _lightAngleOffset;
  138026. /**
  138027. * Gets the cone angle of the spot light in Radians.
  138028. */
  138029. get angle(): number;
  138030. /**
  138031. * Sets the cone angle of the spot light in Radians.
  138032. */
  138033. set angle(value: number);
  138034. /**
  138035. * Only used in gltf falloff mode, this defines the angle where
  138036. * the directional falloff will start before cutting at angle which could be seen
  138037. * as outer angle.
  138038. */
  138039. get innerAngle(): number;
  138040. /**
  138041. * Only used in gltf falloff mode, this defines the angle where
  138042. * the directional falloff will start before cutting at angle which could be seen
  138043. * as outer angle.
  138044. */
  138045. set innerAngle(value: number);
  138046. private _shadowAngleScale;
  138047. /**
  138048. * Allows scaling the angle of the light for shadow generation only.
  138049. */
  138050. get shadowAngleScale(): number;
  138051. /**
  138052. * Allows scaling the angle of the light for shadow generation only.
  138053. */
  138054. set shadowAngleScale(value: number);
  138055. /**
  138056. * The light decay speed with the distance from the emission spot.
  138057. */
  138058. exponent: number;
  138059. private _projectionTextureMatrix;
  138060. /**
  138061. * Allows reading the projecton texture
  138062. */
  138063. get projectionTextureMatrix(): Matrix;
  138064. protected _projectionTextureLightNear: number;
  138065. /**
  138066. * Gets the near clip of the Spotlight for texture projection.
  138067. */
  138068. get projectionTextureLightNear(): number;
  138069. /**
  138070. * Sets the near clip of the Spotlight for texture projection.
  138071. */
  138072. set projectionTextureLightNear(value: number);
  138073. protected _projectionTextureLightFar: number;
  138074. /**
  138075. * Gets the far clip of the Spotlight for texture projection.
  138076. */
  138077. get projectionTextureLightFar(): number;
  138078. /**
  138079. * Sets the far clip of the Spotlight for texture projection.
  138080. */
  138081. set projectionTextureLightFar(value: number);
  138082. protected _projectionTextureUpDirection: Vector3;
  138083. /**
  138084. * Gets the Up vector of the Spotlight for texture projection.
  138085. */
  138086. get projectionTextureUpDirection(): Vector3;
  138087. /**
  138088. * Sets the Up vector of the Spotlight for texture projection.
  138089. */
  138090. set projectionTextureUpDirection(value: Vector3);
  138091. private _projectionTexture;
  138092. /**
  138093. * Gets the projection texture of the light.
  138094. */
  138095. get projectionTexture(): Nullable<BaseTexture>;
  138096. /**
  138097. * Sets the projection texture of the light.
  138098. */
  138099. set projectionTexture(value: Nullable<BaseTexture>);
  138100. private _projectionTextureViewLightDirty;
  138101. private _projectionTextureProjectionLightDirty;
  138102. private _projectionTextureDirty;
  138103. private _projectionTextureViewTargetVector;
  138104. private _projectionTextureViewLightMatrix;
  138105. private _projectionTextureProjectionLightMatrix;
  138106. private _projectionTextureScalingMatrix;
  138107. /**
  138108. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  138109. * It can cast shadows.
  138110. * Documentation : https://doc.babylonjs.com/babylon101/lights
  138111. * @param name The light friendly name
  138112. * @param position The position of the spot light in the scene
  138113. * @param direction The direction of the light in the scene
  138114. * @param angle The cone angle of the light in Radians
  138115. * @param exponent The light decay speed with the distance from the emission spot
  138116. * @param scene The scene the lights belongs to
  138117. */
  138118. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  138119. /**
  138120. * Returns the string "SpotLight".
  138121. * @returns the class name
  138122. */
  138123. getClassName(): string;
  138124. /**
  138125. * Returns the integer 2.
  138126. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  138127. */
  138128. getTypeID(): number;
  138129. /**
  138130. * Overrides the direction setter to recompute the projection texture view light Matrix.
  138131. */
  138132. protected _setDirection(value: Vector3): void;
  138133. /**
  138134. * Overrides the position setter to recompute the projection texture view light Matrix.
  138135. */
  138136. protected _setPosition(value: Vector3): void;
  138137. /**
  138138. * 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.
  138139. * Returns the SpotLight.
  138140. */
  138141. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138142. protected _computeProjectionTextureViewLightMatrix(): void;
  138143. protected _computeProjectionTextureProjectionLightMatrix(): void;
  138144. /**
  138145. * Main function for light texture projection matrix computing.
  138146. */
  138147. protected _computeProjectionTextureMatrix(): void;
  138148. protected _buildUniformLayout(): void;
  138149. private _computeAngleValues;
  138150. /**
  138151. * Sets the passed Effect "effect" with the Light textures.
  138152. * @param effect The effect to update
  138153. * @param lightIndex The index of the light in the effect to update
  138154. * @returns The light
  138155. */
  138156. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  138157. /**
  138158. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  138159. * @param effect The effect to update
  138160. * @param lightIndex The index of the light in the effect to update
  138161. * @returns The spot light
  138162. */
  138163. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  138164. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  138165. /**
  138166. * Disposes the light and the associated resources.
  138167. */
  138168. dispose(): void;
  138169. /**
  138170. * Prepares the list of defines specific to the light type.
  138171. * @param defines the list of defines
  138172. * @param lightIndex defines the index of the light for the effect
  138173. */
  138174. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  138175. }
  138176. }
  138177. declare module BABYLON {
  138178. /**
  138179. * Gizmo that enables viewing a light
  138180. */
  138181. export class LightGizmo extends Gizmo {
  138182. private _lightMesh;
  138183. private _material;
  138184. private _cachedPosition;
  138185. private _cachedForward;
  138186. private _attachedMeshParent;
  138187. private _pointerObserver;
  138188. /**
  138189. * Event that fires each time the gizmo is clicked
  138190. */
  138191. onClickedObservable: Observable<Light>;
  138192. /**
  138193. * Creates a LightGizmo
  138194. * @param gizmoLayer The utility layer the gizmo will be added to
  138195. */
  138196. constructor(gizmoLayer?: UtilityLayerRenderer);
  138197. private _light;
  138198. /**
  138199. * The light that the gizmo is attached to
  138200. */
  138201. set light(light: Nullable<Light>);
  138202. get light(): Nullable<Light>;
  138203. /**
  138204. * Gets the material used to render the light gizmo
  138205. */
  138206. get material(): StandardMaterial;
  138207. /**
  138208. * @hidden
  138209. * Updates the gizmo to match the attached mesh's position/rotation
  138210. */
  138211. protected _update(): void;
  138212. private static _Scale;
  138213. /**
  138214. * Creates the lines for a light mesh
  138215. */
  138216. private static _CreateLightLines;
  138217. /**
  138218. * Disposes of the light gizmo
  138219. */
  138220. dispose(): void;
  138221. private static _CreateHemisphericLightMesh;
  138222. private static _CreatePointLightMesh;
  138223. private static _CreateSpotLightMesh;
  138224. private static _CreateDirectionalLightMesh;
  138225. }
  138226. }
  138227. declare module BABYLON {
  138228. /**
  138229. * Gizmo that enables viewing a camera
  138230. */
  138231. export class CameraGizmo extends Gizmo {
  138232. private _cameraMesh;
  138233. private _cameraLinesMesh;
  138234. private _material;
  138235. private _pointerObserver;
  138236. /**
  138237. * Event that fires each time the gizmo is clicked
  138238. */
  138239. onClickedObservable: Observable<Camera>;
  138240. /**
  138241. * Creates a CameraGizmo
  138242. * @param gizmoLayer The utility layer the gizmo will be added to
  138243. */
  138244. constructor(gizmoLayer?: UtilityLayerRenderer);
  138245. private _camera;
  138246. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  138247. get displayFrustum(): boolean;
  138248. set displayFrustum(value: boolean);
  138249. /**
  138250. * The camera that the gizmo is attached to
  138251. */
  138252. set camera(camera: Nullable<Camera>);
  138253. get camera(): Nullable<Camera>;
  138254. /**
  138255. * Gets the material used to render the camera gizmo
  138256. */
  138257. get material(): StandardMaterial;
  138258. /**
  138259. * @hidden
  138260. * Updates the gizmo to match the attached mesh's position/rotation
  138261. */
  138262. protected _update(): void;
  138263. private static _Scale;
  138264. private _invProjection;
  138265. /**
  138266. * Disposes of the camera gizmo
  138267. */
  138268. dispose(): void;
  138269. private static _CreateCameraMesh;
  138270. private static _CreateCameraFrustum;
  138271. }
  138272. }
  138273. declare module BABYLON {
  138274. /** @hidden */
  138275. export var backgroundFragmentDeclaration: {
  138276. name: string;
  138277. shader: string;
  138278. };
  138279. }
  138280. declare module BABYLON {
  138281. /** @hidden */
  138282. export var backgroundUboDeclaration: {
  138283. name: string;
  138284. shader: string;
  138285. };
  138286. }
  138287. declare module BABYLON {
  138288. /** @hidden */
  138289. export var backgroundPixelShader: {
  138290. name: string;
  138291. shader: string;
  138292. };
  138293. }
  138294. declare module BABYLON {
  138295. /** @hidden */
  138296. export var backgroundVertexDeclaration: {
  138297. name: string;
  138298. shader: string;
  138299. };
  138300. }
  138301. declare module BABYLON {
  138302. /** @hidden */
  138303. export var backgroundVertexShader: {
  138304. name: string;
  138305. shader: string;
  138306. };
  138307. }
  138308. declare module BABYLON {
  138309. /**
  138310. * Background material used to create an efficient environement around your scene.
  138311. */
  138312. export class BackgroundMaterial extends PushMaterial {
  138313. /**
  138314. * Standard reflectance value at parallel view angle.
  138315. */
  138316. static StandardReflectance0: number;
  138317. /**
  138318. * Standard reflectance value at grazing angle.
  138319. */
  138320. static StandardReflectance90: number;
  138321. protected _primaryColor: Color3;
  138322. /**
  138323. * Key light Color (multiply against the environement texture)
  138324. */
  138325. primaryColor: Color3;
  138326. protected __perceptualColor: Nullable<Color3>;
  138327. /**
  138328. * Experimental Internal Use Only.
  138329. *
  138330. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  138331. * This acts as a helper to set the primary color to a more "human friendly" value.
  138332. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  138333. * output color as close as possible from the chosen value.
  138334. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  138335. * part of lighting setup.)
  138336. */
  138337. get _perceptualColor(): Nullable<Color3>;
  138338. set _perceptualColor(value: Nullable<Color3>);
  138339. protected _primaryColorShadowLevel: float;
  138340. /**
  138341. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  138342. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  138343. */
  138344. get primaryColorShadowLevel(): float;
  138345. set primaryColorShadowLevel(value: float);
  138346. protected _primaryColorHighlightLevel: float;
  138347. /**
  138348. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  138349. * The primary color is used at the level chosen to define what the white area would look.
  138350. */
  138351. get primaryColorHighlightLevel(): float;
  138352. set primaryColorHighlightLevel(value: float);
  138353. protected _reflectionTexture: Nullable<BaseTexture>;
  138354. /**
  138355. * Reflection Texture used in the material.
  138356. * Should be author in a specific way for the best result (refer to the documentation).
  138357. */
  138358. reflectionTexture: Nullable<BaseTexture>;
  138359. protected _reflectionBlur: float;
  138360. /**
  138361. * Reflection Texture level of blur.
  138362. *
  138363. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  138364. * texture twice.
  138365. */
  138366. reflectionBlur: float;
  138367. protected _diffuseTexture: Nullable<BaseTexture>;
  138368. /**
  138369. * Diffuse Texture used in the material.
  138370. * Should be author in a specific way for the best result (refer to the documentation).
  138371. */
  138372. diffuseTexture: Nullable<BaseTexture>;
  138373. protected _shadowLights: Nullable<IShadowLight[]>;
  138374. /**
  138375. * Specify the list of lights casting shadow on the material.
  138376. * All scene shadow lights will be included if null.
  138377. */
  138378. shadowLights: Nullable<IShadowLight[]>;
  138379. protected _shadowLevel: float;
  138380. /**
  138381. * Helps adjusting the shadow to a softer level if required.
  138382. * 0 means black shadows and 1 means no shadows.
  138383. */
  138384. shadowLevel: float;
  138385. protected _sceneCenter: Vector3;
  138386. /**
  138387. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  138388. * It is usually zero but might be interesting to modify according to your setup.
  138389. */
  138390. sceneCenter: Vector3;
  138391. protected _opacityFresnel: boolean;
  138392. /**
  138393. * This helps specifying that the material is falling off to the sky box at grazing angle.
  138394. * This helps ensuring a nice transition when the camera goes under the ground.
  138395. */
  138396. opacityFresnel: boolean;
  138397. protected _reflectionFresnel: boolean;
  138398. /**
  138399. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  138400. * This helps adding a mirror texture on the ground.
  138401. */
  138402. reflectionFresnel: boolean;
  138403. protected _reflectionFalloffDistance: number;
  138404. /**
  138405. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  138406. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  138407. */
  138408. reflectionFalloffDistance: number;
  138409. protected _reflectionAmount: number;
  138410. /**
  138411. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  138412. */
  138413. reflectionAmount: number;
  138414. protected _reflectionReflectance0: number;
  138415. /**
  138416. * This specifies the weight of the reflection at grazing angle.
  138417. */
  138418. reflectionReflectance0: number;
  138419. protected _reflectionReflectance90: number;
  138420. /**
  138421. * This specifies the weight of the reflection at a perpendicular point of view.
  138422. */
  138423. reflectionReflectance90: number;
  138424. /**
  138425. * Sets the reflection reflectance fresnel values according to the default standard
  138426. * empirically know to work well :-)
  138427. */
  138428. set reflectionStandardFresnelWeight(value: number);
  138429. protected _useRGBColor: boolean;
  138430. /**
  138431. * Helps to directly use the maps channels instead of their level.
  138432. */
  138433. useRGBColor: boolean;
  138434. protected _enableNoise: boolean;
  138435. /**
  138436. * This helps reducing the banding effect that could occur on the background.
  138437. */
  138438. enableNoise: boolean;
  138439. /**
  138440. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  138441. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  138442. * Recommended to be keep at 1.0 except for special cases.
  138443. */
  138444. get fovMultiplier(): number;
  138445. set fovMultiplier(value: number);
  138446. private _fovMultiplier;
  138447. /**
  138448. * Enable the FOV adjustment feature controlled by fovMultiplier.
  138449. */
  138450. useEquirectangularFOV: boolean;
  138451. private _maxSimultaneousLights;
  138452. /**
  138453. * Number of Simultaneous lights allowed on the material.
  138454. */
  138455. maxSimultaneousLights: int;
  138456. private _shadowOnly;
  138457. /**
  138458. * Make the material only render shadows
  138459. */
  138460. shadowOnly: boolean;
  138461. /**
  138462. * Default configuration related to image processing available in the Background Material.
  138463. */
  138464. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  138465. /**
  138466. * Keep track of the image processing observer to allow dispose and replace.
  138467. */
  138468. private _imageProcessingObserver;
  138469. /**
  138470. * Attaches a new image processing configuration to the PBR Material.
  138471. * @param configuration (if null the scene configuration will be use)
  138472. */
  138473. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  138474. /**
  138475. * Gets the image processing configuration used either in this material.
  138476. */
  138477. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  138478. /**
  138479. * Sets the Default image processing configuration used either in the this material.
  138480. *
  138481. * If sets to null, the scene one is in use.
  138482. */
  138483. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  138484. /**
  138485. * Gets wether the color curves effect is enabled.
  138486. */
  138487. get cameraColorCurvesEnabled(): boolean;
  138488. /**
  138489. * Sets wether the color curves effect is enabled.
  138490. */
  138491. set cameraColorCurvesEnabled(value: boolean);
  138492. /**
  138493. * Gets wether the color grading effect is enabled.
  138494. */
  138495. get cameraColorGradingEnabled(): boolean;
  138496. /**
  138497. * Gets wether the color grading effect is enabled.
  138498. */
  138499. set cameraColorGradingEnabled(value: boolean);
  138500. /**
  138501. * Gets wether tonemapping is enabled or not.
  138502. */
  138503. get cameraToneMappingEnabled(): boolean;
  138504. /**
  138505. * Sets wether tonemapping is enabled or not
  138506. */
  138507. set cameraToneMappingEnabled(value: boolean);
  138508. /**
  138509. * The camera exposure used on this material.
  138510. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138511. * This corresponds to a photographic exposure.
  138512. */
  138513. get cameraExposure(): float;
  138514. /**
  138515. * The camera exposure used on this material.
  138516. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138517. * This corresponds to a photographic exposure.
  138518. */
  138519. set cameraExposure(value: float);
  138520. /**
  138521. * Gets The camera contrast used on this material.
  138522. */
  138523. get cameraContrast(): float;
  138524. /**
  138525. * Sets The camera contrast used on this material.
  138526. */
  138527. set cameraContrast(value: float);
  138528. /**
  138529. * Gets the Color Grading 2D Lookup Texture.
  138530. */
  138531. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  138532. /**
  138533. * Sets the Color Grading 2D Lookup Texture.
  138534. */
  138535. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  138536. /**
  138537. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138538. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138539. * 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;
  138540. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138541. */
  138542. get cameraColorCurves(): Nullable<ColorCurves>;
  138543. /**
  138544. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138545. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138546. * 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;
  138547. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138548. */
  138549. set cameraColorCurves(value: Nullable<ColorCurves>);
  138550. /**
  138551. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  138552. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  138553. */
  138554. switchToBGR: boolean;
  138555. private _renderTargets;
  138556. private _reflectionControls;
  138557. private _white;
  138558. private _primaryShadowColor;
  138559. private _primaryHighlightColor;
  138560. /**
  138561. * Instantiates a Background Material in the given scene
  138562. * @param name The friendly name of the material
  138563. * @param scene The scene to add the material to
  138564. */
  138565. constructor(name: string, scene: Scene);
  138566. /**
  138567. * Gets a boolean indicating that current material needs to register RTT
  138568. */
  138569. get hasRenderTargetTextures(): boolean;
  138570. /**
  138571. * The entire material has been created in order to prevent overdraw.
  138572. * @returns false
  138573. */
  138574. needAlphaTesting(): boolean;
  138575. /**
  138576. * The entire material has been created in order to prevent overdraw.
  138577. * @returns true if blending is enable
  138578. */
  138579. needAlphaBlending(): boolean;
  138580. /**
  138581. * Checks wether the material is ready to be rendered for a given mesh.
  138582. * @param mesh The mesh to render
  138583. * @param subMesh The submesh to check against
  138584. * @param useInstances Specify wether or not the material is used with instances
  138585. * @returns true if all the dependencies are ready (Textures, Effects...)
  138586. */
  138587. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  138588. /**
  138589. * Compute the primary color according to the chosen perceptual color.
  138590. */
  138591. private _computePrimaryColorFromPerceptualColor;
  138592. /**
  138593. * Compute the highlights and shadow colors according to their chosen levels.
  138594. */
  138595. private _computePrimaryColors;
  138596. /**
  138597. * Build the uniform buffer used in the material.
  138598. */
  138599. buildUniformLayout(): void;
  138600. /**
  138601. * Unbind the material.
  138602. */
  138603. unbind(): void;
  138604. /**
  138605. * Bind only the world matrix to the material.
  138606. * @param world The world matrix to bind.
  138607. */
  138608. bindOnlyWorldMatrix(world: Matrix): void;
  138609. /**
  138610. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  138611. * @param world The world matrix to bind.
  138612. * @param subMesh The submesh to bind for.
  138613. */
  138614. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  138615. /**
  138616. * Checks to see if a texture is used in the material.
  138617. * @param texture - Base texture to use.
  138618. * @returns - Boolean specifying if a texture is used in the material.
  138619. */
  138620. hasTexture(texture: BaseTexture): boolean;
  138621. /**
  138622. * Dispose the material.
  138623. * @param forceDisposeEffect Force disposal of the associated effect.
  138624. * @param forceDisposeTextures Force disposal of the associated textures.
  138625. */
  138626. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  138627. /**
  138628. * Clones the material.
  138629. * @param name The cloned name.
  138630. * @returns The cloned material.
  138631. */
  138632. clone(name: string): BackgroundMaterial;
  138633. /**
  138634. * Serializes the current material to its JSON representation.
  138635. * @returns The JSON representation.
  138636. */
  138637. serialize(): any;
  138638. /**
  138639. * Gets the class name of the material
  138640. * @returns "BackgroundMaterial"
  138641. */
  138642. getClassName(): string;
  138643. /**
  138644. * Parse a JSON input to create back a background material.
  138645. * @param source The JSON data to parse
  138646. * @param scene The scene to create the parsed material in
  138647. * @param rootUrl The root url of the assets the material depends upon
  138648. * @returns the instantiated BackgroundMaterial.
  138649. */
  138650. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  138651. }
  138652. }
  138653. declare module BABYLON {
  138654. /**
  138655. * Represents the different options available during the creation of
  138656. * a Environment helper.
  138657. *
  138658. * This can control the default ground, skybox and image processing setup of your scene.
  138659. */
  138660. export interface IEnvironmentHelperOptions {
  138661. /**
  138662. * Specifies whether or not to create a ground.
  138663. * True by default.
  138664. */
  138665. createGround: boolean;
  138666. /**
  138667. * Specifies the ground size.
  138668. * 15 by default.
  138669. */
  138670. groundSize: number;
  138671. /**
  138672. * The texture used on the ground for the main color.
  138673. * Comes from the BabylonJS CDN by default.
  138674. *
  138675. * Remarks: Can be either a texture or a url.
  138676. */
  138677. groundTexture: string | BaseTexture;
  138678. /**
  138679. * The color mixed in the ground texture by default.
  138680. * BabylonJS clearColor by default.
  138681. */
  138682. groundColor: Color3;
  138683. /**
  138684. * Specifies the ground opacity.
  138685. * 1 by default.
  138686. */
  138687. groundOpacity: number;
  138688. /**
  138689. * Enables the ground to receive shadows.
  138690. * True by default.
  138691. */
  138692. enableGroundShadow: boolean;
  138693. /**
  138694. * Helps preventing the shadow to be fully black on the ground.
  138695. * 0.5 by default.
  138696. */
  138697. groundShadowLevel: number;
  138698. /**
  138699. * Creates a mirror texture attach to the ground.
  138700. * false by default.
  138701. */
  138702. enableGroundMirror: boolean;
  138703. /**
  138704. * Specifies the ground mirror size ratio.
  138705. * 0.3 by default as the default kernel is 64.
  138706. */
  138707. groundMirrorSizeRatio: number;
  138708. /**
  138709. * Specifies the ground mirror blur kernel size.
  138710. * 64 by default.
  138711. */
  138712. groundMirrorBlurKernel: number;
  138713. /**
  138714. * Specifies the ground mirror visibility amount.
  138715. * 1 by default
  138716. */
  138717. groundMirrorAmount: number;
  138718. /**
  138719. * Specifies the ground mirror reflectance weight.
  138720. * This uses the standard weight of the background material to setup the fresnel effect
  138721. * of the mirror.
  138722. * 1 by default.
  138723. */
  138724. groundMirrorFresnelWeight: number;
  138725. /**
  138726. * Specifies the ground mirror Falloff distance.
  138727. * This can helps reducing the size of the reflection.
  138728. * 0 by Default.
  138729. */
  138730. groundMirrorFallOffDistance: number;
  138731. /**
  138732. * Specifies the ground mirror texture type.
  138733. * Unsigned Int by Default.
  138734. */
  138735. groundMirrorTextureType: number;
  138736. /**
  138737. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  138738. * the shown objects.
  138739. */
  138740. groundYBias: number;
  138741. /**
  138742. * Specifies whether or not to create a skybox.
  138743. * True by default.
  138744. */
  138745. createSkybox: boolean;
  138746. /**
  138747. * Specifies the skybox size.
  138748. * 20 by default.
  138749. */
  138750. skyboxSize: number;
  138751. /**
  138752. * The texture used on the skybox for the main color.
  138753. * Comes from the BabylonJS CDN by default.
  138754. *
  138755. * Remarks: Can be either a texture or a url.
  138756. */
  138757. skyboxTexture: string | BaseTexture;
  138758. /**
  138759. * The color mixed in the skybox texture by default.
  138760. * BabylonJS clearColor by default.
  138761. */
  138762. skyboxColor: Color3;
  138763. /**
  138764. * The background rotation around the Y axis of the scene.
  138765. * This helps aligning the key lights of your scene with the background.
  138766. * 0 by default.
  138767. */
  138768. backgroundYRotation: number;
  138769. /**
  138770. * Compute automatically the size of the elements to best fit with the scene.
  138771. */
  138772. sizeAuto: boolean;
  138773. /**
  138774. * Default position of the rootMesh if autoSize is not true.
  138775. */
  138776. rootPosition: Vector3;
  138777. /**
  138778. * Sets up the image processing in the scene.
  138779. * true by default.
  138780. */
  138781. setupImageProcessing: boolean;
  138782. /**
  138783. * The texture used as your environment texture in the scene.
  138784. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  138785. *
  138786. * Remarks: Can be either a texture or a url.
  138787. */
  138788. environmentTexture: string | BaseTexture;
  138789. /**
  138790. * The value of the exposure to apply to the scene.
  138791. * 0.6 by default if setupImageProcessing is true.
  138792. */
  138793. cameraExposure: number;
  138794. /**
  138795. * The value of the contrast to apply to the scene.
  138796. * 1.6 by default if setupImageProcessing is true.
  138797. */
  138798. cameraContrast: number;
  138799. /**
  138800. * Specifies whether or not tonemapping should be enabled in the scene.
  138801. * true by default if setupImageProcessing is true.
  138802. */
  138803. toneMappingEnabled: boolean;
  138804. }
  138805. /**
  138806. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  138807. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  138808. * It also helps with the default setup of your imageProcessing configuration.
  138809. */
  138810. export class EnvironmentHelper {
  138811. /**
  138812. * Default ground texture URL.
  138813. */
  138814. private static _groundTextureCDNUrl;
  138815. /**
  138816. * Default skybox texture URL.
  138817. */
  138818. private static _skyboxTextureCDNUrl;
  138819. /**
  138820. * Default environment texture URL.
  138821. */
  138822. private static _environmentTextureCDNUrl;
  138823. /**
  138824. * Creates the default options for the helper.
  138825. */
  138826. private static _getDefaultOptions;
  138827. private _rootMesh;
  138828. /**
  138829. * Gets the root mesh created by the helper.
  138830. */
  138831. get rootMesh(): Mesh;
  138832. private _skybox;
  138833. /**
  138834. * Gets the skybox created by the helper.
  138835. */
  138836. get skybox(): Nullable<Mesh>;
  138837. private _skyboxTexture;
  138838. /**
  138839. * Gets the skybox texture created by the helper.
  138840. */
  138841. get skyboxTexture(): Nullable<BaseTexture>;
  138842. private _skyboxMaterial;
  138843. /**
  138844. * Gets the skybox material created by the helper.
  138845. */
  138846. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  138847. private _ground;
  138848. /**
  138849. * Gets the ground mesh created by the helper.
  138850. */
  138851. get ground(): Nullable<Mesh>;
  138852. private _groundTexture;
  138853. /**
  138854. * Gets the ground texture created by the helper.
  138855. */
  138856. get groundTexture(): Nullable<BaseTexture>;
  138857. private _groundMirror;
  138858. /**
  138859. * Gets the ground mirror created by the helper.
  138860. */
  138861. get groundMirror(): Nullable<MirrorTexture>;
  138862. /**
  138863. * Gets the ground mirror render list to helps pushing the meshes
  138864. * you wish in the ground reflection.
  138865. */
  138866. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  138867. private _groundMaterial;
  138868. /**
  138869. * Gets the ground material created by the helper.
  138870. */
  138871. get groundMaterial(): Nullable<BackgroundMaterial>;
  138872. /**
  138873. * Stores the creation options.
  138874. */
  138875. private readonly _scene;
  138876. private _options;
  138877. /**
  138878. * This observable will be notified with any error during the creation of the environment,
  138879. * mainly texture creation errors.
  138880. */
  138881. onErrorObservable: Observable<{
  138882. message?: string;
  138883. exception?: any;
  138884. }>;
  138885. /**
  138886. * constructor
  138887. * @param options Defines the options we want to customize the helper
  138888. * @param scene The scene to add the material to
  138889. */
  138890. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  138891. /**
  138892. * Updates the background according to the new options
  138893. * @param options
  138894. */
  138895. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  138896. /**
  138897. * Sets the primary color of all the available elements.
  138898. * @param color the main color to affect to the ground and the background
  138899. */
  138900. setMainColor(color: Color3): void;
  138901. /**
  138902. * Setup the image processing according to the specified options.
  138903. */
  138904. private _setupImageProcessing;
  138905. /**
  138906. * Setup the environment texture according to the specified options.
  138907. */
  138908. private _setupEnvironmentTexture;
  138909. /**
  138910. * Setup the background according to the specified options.
  138911. */
  138912. private _setupBackground;
  138913. /**
  138914. * Get the scene sizes according to the setup.
  138915. */
  138916. private _getSceneSize;
  138917. /**
  138918. * Setup the ground according to the specified options.
  138919. */
  138920. private _setupGround;
  138921. /**
  138922. * Setup the ground material according to the specified options.
  138923. */
  138924. private _setupGroundMaterial;
  138925. /**
  138926. * Setup the ground diffuse texture according to the specified options.
  138927. */
  138928. private _setupGroundDiffuseTexture;
  138929. /**
  138930. * Setup the ground mirror texture according to the specified options.
  138931. */
  138932. private _setupGroundMirrorTexture;
  138933. /**
  138934. * Setup the ground to receive the mirror texture.
  138935. */
  138936. private _setupMirrorInGroundMaterial;
  138937. /**
  138938. * Setup the skybox according to the specified options.
  138939. */
  138940. private _setupSkybox;
  138941. /**
  138942. * Setup the skybox material according to the specified options.
  138943. */
  138944. private _setupSkyboxMaterial;
  138945. /**
  138946. * Setup the skybox reflection texture according to the specified options.
  138947. */
  138948. private _setupSkyboxReflectionTexture;
  138949. private _errorHandler;
  138950. /**
  138951. * Dispose all the elements created by the Helper.
  138952. */
  138953. dispose(): void;
  138954. }
  138955. }
  138956. declare module BABYLON {
  138957. /**
  138958. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  138959. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  138960. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  138961. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138962. */
  138963. export abstract class TextureDome<T extends Texture> extends TransformNode {
  138964. protected onError: Nullable<(message?: string, exception?: any) => void>;
  138965. /**
  138966. * Define the source as a Monoscopic panoramic 360/180.
  138967. */
  138968. static readonly MODE_MONOSCOPIC: number;
  138969. /**
  138970. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  138971. */
  138972. static readonly MODE_TOPBOTTOM: number;
  138973. /**
  138974. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  138975. */
  138976. static readonly MODE_SIDEBYSIDE: number;
  138977. private _halfDome;
  138978. private _crossEye;
  138979. protected _useDirectMapping: boolean;
  138980. /**
  138981. * The texture being displayed on the sphere
  138982. */
  138983. protected _texture: T;
  138984. /**
  138985. * Gets the texture being displayed on the sphere
  138986. */
  138987. get texture(): T;
  138988. /**
  138989. * Sets the texture being displayed on the sphere
  138990. */
  138991. set texture(newTexture: T);
  138992. /**
  138993. * The skybox material
  138994. */
  138995. protected _material: BackgroundMaterial;
  138996. /**
  138997. * The surface used for the dome
  138998. */
  138999. protected _mesh: Mesh;
  139000. /**
  139001. * Gets the mesh used for the dome.
  139002. */
  139003. get mesh(): Mesh;
  139004. /**
  139005. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  139006. */
  139007. private _halfDomeMask;
  139008. /**
  139009. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  139010. * Also see the options.resolution property.
  139011. */
  139012. get fovMultiplier(): number;
  139013. set fovMultiplier(value: number);
  139014. protected _textureMode: number;
  139015. /**
  139016. * Gets or set the current texture mode for the texture. It can be:
  139017. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139018. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139019. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139020. */
  139021. get textureMode(): number;
  139022. /**
  139023. * Sets the current texture mode for the texture. It can be:
  139024. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139025. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139026. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139027. */
  139028. set textureMode(value: number);
  139029. /**
  139030. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  139031. */
  139032. get halfDome(): boolean;
  139033. /**
  139034. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  139035. */
  139036. set halfDome(enabled: boolean);
  139037. /**
  139038. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  139039. */
  139040. set crossEye(enabled: boolean);
  139041. /**
  139042. * Is it a cross-eye texture?
  139043. */
  139044. get crossEye(): boolean;
  139045. /**
  139046. * The background material of this dome.
  139047. */
  139048. get material(): BackgroundMaterial;
  139049. /**
  139050. * Oberserver used in Stereoscopic VR Mode.
  139051. */
  139052. private _onBeforeCameraRenderObserver;
  139053. /**
  139054. * Observable raised when an error occured while loading the 360 image
  139055. */
  139056. onLoadErrorObservable: Observable<string>;
  139057. /**
  139058. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  139059. * @param name Element's name, child elements will append suffixes for their own names.
  139060. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  139061. * @param options An object containing optional or exposed sub element properties
  139062. */
  139063. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  139064. resolution?: number;
  139065. clickToPlay?: boolean;
  139066. autoPlay?: boolean;
  139067. loop?: boolean;
  139068. size?: number;
  139069. poster?: string;
  139070. faceForward?: boolean;
  139071. useDirectMapping?: boolean;
  139072. halfDomeMode?: boolean;
  139073. crossEyeMode?: boolean;
  139074. generateMipMaps?: boolean;
  139075. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  139076. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  139077. protected _changeTextureMode(value: number): void;
  139078. /**
  139079. * Releases resources associated with this node.
  139080. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  139081. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  139082. */
  139083. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  139084. }
  139085. }
  139086. declare module BABYLON {
  139087. /**
  139088. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  139089. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  139090. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  139091. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  139092. */
  139093. export class PhotoDome extends TextureDome<Texture> {
  139094. /**
  139095. * Define the image as a Monoscopic panoramic 360 image.
  139096. */
  139097. static readonly MODE_MONOSCOPIC: number;
  139098. /**
  139099. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  139100. */
  139101. static readonly MODE_TOPBOTTOM: number;
  139102. /**
  139103. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  139104. */
  139105. static readonly MODE_SIDEBYSIDE: number;
  139106. /**
  139107. * Gets or sets the texture being displayed on the sphere
  139108. */
  139109. get photoTexture(): Texture;
  139110. /**
  139111. * sets the texture being displayed on the sphere
  139112. */
  139113. set photoTexture(value: Texture);
  139114. /**
  139115. * Gets the current video mode for the video. It can be:
  139116. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139117. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139118. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139119. */
  139120. get imageMode(): number;
  139121. /**
  139122. * Sets the current video mode for the video. It can be:
  139123. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139124. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139125. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139126. */
  139127. set imageMode(value: number);
  139128. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  139129. }
  139130. }
  139131. declare module BABYLON {
  139132. /**
  139133. * Direct draw surface info
  139134. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  139135. */
  139136. export interface DDSInfo {
  139137. /**
  139138. * Width of the texture
  139139. */
  139140. width: number;
  139141. /**
  139142. * Width of the texture
  139143. */
  139144. height: number;
  139145. /**
  139146. * Number of Mipmaps for the texture
  139147. * @see https://en.wikipedia.org/wiki/Mipmap
  139148. */
  139149. mipmapCount: number;
  139150. /**
  139151. * If the textures format is a known fourCC format
  139152. * @see https://www.fourcc.org/
  139153. */
  139154. isFourCC: boolean;
  139155. /**
  139156. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  139157. */
  139158. isRGB: boolean;
  139159. /**
  139160. * If the texture is a lumincance format
  139161. */
  139162. isLuminance: boolean;
  139163. /**
  139164. * If this is a cube texture
  139165. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  139166. */
  139167. isCube: boolean;
  139168. /**
  139169. * If the texture is a compressed format eg. FOURCC_DXT1
  139170. */
  139171. isCompressed: boolean;
  139172. /**
  139173. * The dxgiFormat of the texture
  139174. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  139175. */
  139176. dxgiFormat: number;
  139177. /**
  139178. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  139179. */
  139180. textureType: number;
  139181. /**
  139182. * Sphericle polynomial created for the dds texture
  139183. */
  139184. sphericalPolynomial?: SphericalPolynomial;
  139185. }
  139186. /**
  139187. * Class used to provide DDS decompression tools
  139188. */
  139189. export class DDSTools {
  139190. /**
  139191. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  139192. */
  139193. static StoreLODInAlphaChannel: boolean;
  139194. /**
  139195. * Gets DDS information from an array buffer
  139196. * @param data defines the array buffer view to read data from
  139197. * @returns the DDS information
  139198. */
  139199. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  139200. private static _FloatView;
  139201. private static _Int32View;
  139202. private static _ToHalfFloat;
  139203. private static _FromHalfFloat;
  139204. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  139205. private static _GetHalfFloatRGBAArrayBuffer;
  139206. private static _GetFloatRGBAArrayBuffer;
  139207. private static _GetFloatAsUIntRGBAArrayBuffer;
  139208. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  139209. private static _GetRGBAArrayBuffer;
  139210. private static _ExtractLongWordOrder;
  139211. private static _GetRGBArrayBuffer;
  139212. private static _GetLuminanceArrayBuffer;
  139213. /**
  139214. * Uploads DDS Levels to a Babylon Texture
  139215. * @hidden
  139216. */
  139217. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  139218. }
  139219. interface ThinEngine {
  139220. /**
  139221. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  139222. * @param rootUrl defines the url where the file to load is located
  139223. * @param scene defines the current scene
  139224. * @param lodScale defines scale to apply to the mip map selection
  139225. * @param lodOffset defines offset to apply to the mip map selection
  139226. * @param onLoad defines an optional callback raised when the texture is loaded
  139227. * @param onError defines an optional callback raised if there is an issue to load the texture
  139228. * @param format defines the format of the data
  139229. * @param forcedExtension defines the extension to use to pick the right loader
  139230. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  139231. * @returns the cube texture as an InternalTexture
  139232. */
  139233. 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;
  139234. }
  139235. }
  139236. declare module BABYLON {
  139237. /**
  139238. * Implementation of the DDS Texture Loader.
  139239. * @hidden
  139240. */
  139241. export class _DDSTextureLoader implements IInternalTextureLoader {
  139242. /**
  139243. * Defines wether the loader supports cascade loading the different faces.
  139244. */
  139245. readonly supportCascades: boolean;
  139246. /**
  139247. * This returns if the loader support the current file information.
  139248. * @param extension defines the file extension of the file being loaded
  139249. * @returns true if the loader can load the specified file
  139250. */
  139251. canLoad(extension: string): boolean;
  139252. /**
  139253. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139254. * @param data contains the texture data
  139255. * @param texture defines the BabylonJS internal texture
  139256. * @param createPolynomials will be true if polynomials have been requested
  139257. * @param onLoad defines the callback to trigger once the texture is ready
  139258. * @param onError defines the callback to trigger in case of error
  139259. */
  139260. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139261. /**
  139262. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139263. * @param data contains the texture data
  139264. * @param texture defines the BabylonJS internal texture
  139265. * @param callback defines the method to call once ready to upload
  139266. */
  139267. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139268. }
  139269. }
  139270. declare module BABYLON {
  139271. /**
  139272. * Implementation of the ENV Texture Loader.
  139273. * @hidden
  139274. */
  139275. export class _ENVTextureLoader implements IInternalTextureLoader {
  139276. /**
  139277. * Defines wether the loader supports cascade loading the different faces.
  139278. */
  139279. readonly supportCascades: boolean;
  139280. /**
  139281. * This returns if the loader support the current file information.
  139282. * @param extension defines the file extension of the file being loaded
  139283. * @returns true if the loader can load the specified file
  139284. */
  139285. canLoad(extension: string): boolean;
  139286. /**
  139287. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139288. * @param data contains the texture data
  139289. * @param texture defines the BabylonJS internal texture
  139290. * @param createPolynomials will be true if polynomials have been requested
  139291. * @param onLoad defines the callback to trigger once the texture is ready
  139292. * @param onError defines the callback to trigger in case of error
  139293. */
  139294. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139295. /**
  139296. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139297. * @param data contains the texture data
  139298. * @param texture defines the BabylonJS internal texture
  139299. * @param callback defines the method to call once ready to upload
  139300. */
  139301. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139302. }
  139303. }
  139304. declare module BABYLON {
  139305. /**
  139306. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  139307. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  139308. */
  139309. export class KhronosTextureContainer {
  139310. /** contents of the KTX container file */
  139311. data: ArrayBufferView;
  139312. private static HEADER_LEN;
  139313. private static COMPRESSED_2D;
  139314. private static COMPRESSED_3D;
  139315. private static TEX_2D;
  139316. private static TEX_3D;
  139317. /**
  139318. * Gets the openGL type
  139319. */
  139320. glType: number;
  139321. /**
  139322. * Gets the openGL type size
  139323. */
  139324. glTypeSize: number;
  139325. /**
  139326. * Gets the openGL format
  139327. */
  139328. glFormat: number;
  139329. /**
  139330. * Gets the openGL internal format
  139331. */
  139332. glInternalFormat: number;
  139333. /**
  139334. * Gets the base internal format
  139335. */
  139336. glBaseInternalFormat: number;
  139337. /**
  139338. * Gets image width in pixel
  139339. */
  139340. pixelWidth: number;
  139341. /**
  139342. * Gets image height in pixel
  139343. */
  139344. pixelHeight: number;
  139345. /**
  139346. * Gets image depth in pixels
  139347. */
  139348. pixelDepth: number;
  139349. /**
  139350. * Gets the number of array elements
  139351. */
  139352. numberOfArrayElements: number;
  139353. /**
  139354. * Gets the number of faces
  139355. */
  139356. numberOfFaces: number;
  139357. /**
  139358. * Gets the number of mipmap levels
  139359. */
  139360. numberOfMipmapLevels: number;
  139361. /**
  139362. * Gets the bytes of key value data
  139363. */
  139364. bytesOfKeyValueData: number;
  139365. /**
  139366. * Gets the load type
  139367. */
  139368. loadType: number;
  139369. /**
  139370. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  139371. */
  139372. isInvalid: boolean;
  139373. /**
  139374. * Creates a new KhronosTextureContainer
  139375. * @param data contents of the KTX container file
  139376. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  139377. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  139378. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  139379. */
  139380. constructor(
  139381. /** contents of the KTX container file */
  139382. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  139383. /**
  139384. * Uploads KTX content to a Babylon Texture.
  139385. * It is assumed that the texture has already been created & is currently bound
  139386. * @hidden
  139387. */
  139388. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  139389. private _upload2DCompressedLevels;
  139390. /**
  139391. * Checks if the given data starts with a KTX file identifier.
  139392. * @param data the data to check
  139393. * @returns true if the data is a KTX file or false otherwise
  139394. */
  139395. static IsValid(data: ArrayBufferView): boolean;
  139396. }
  139397. }
  139398. declare module BABYLON {
  139399. /**
  139400. * Helper class to push actions to a pool of workers.
  139401. */
  139402. export class WorkerPool implements IDisposable {
  139403. private _workerInfos;
  139404. private _pendingActions;
  139405. /**
  139406. * Constructor
  139407. * @param workers Array of workers to use for actions
  139408. */
  139409. constructor(workers: Array<Worker>);
  139410. /**
  139411. * Terminates all workers and clears any pending actions.
  139412. */
  139413. dispose(): void;
  139414. /**
  139415. * Pushes an action to the worker pool. If all the workers are active, the action will be
  139416. * pended until a worker has completed its action.
  139417. * @param action The action to perform. Call onComplete when the action is complete.
  139418. */
  139419. push(action: (worker: Worker, onComplete: () => void) => void): void;
  139420. private _execute;
  139421. }
  139422. }
  139423. declare module BABYLON {
  139424. /**
  139425. * Class for loading KTX2 files
  139426. */
  139427. export class KhronosTextureContainer2 {
  139428. private static _WorkerPoolPromise?;
  139429. private static _Initialized;
  139430. private static _Ktx2Decoder;
  139431. /**
  139432. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  139433. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  139434. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  139435. * Urls you can change:
  139436. * URLConfig.jsDecoderModule
  139437. * URLConfig.wasmUASTCToASTC
  139438. * URLConfig.wasmUASTCToBC7
  139439. * URLConfig.jsMSCTranscoder
  139440. * URLConfig.wasmMSCTranscoder
  139441. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  139442. */
  139443. static URLConfig: {
  139444. jsDecoderModule: string;
  139445. wasmUASTCToASTC: null;
  139446. wasmUASTCToBC7: null;
  139447. jsMSCTranscoder: null;
  139448. wasmMSCTranscoder: null;
  139449. };
  139450. /**
  139451. * Default number of workers used to handle data decoding
  139452. */
  139453. static DefaultNumWorkers: number;
  139454. private static GetDefaultNumWorkers;
  139455. private _engine;
  139456. private static _CreateWorkerPool;
  139457. /**
  139458. * Constructor
  139459. * @param engine The engine to use
  139460. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  139461. */
  139462. constructor(engine: ThinEngine, numWorkers?: number);
  139463. /** @hidden */
  139464. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  139465. /**
  139466. * Stop all async operations and release resources.
  139467. */
  139468. dispose(): void;
  139469. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  139470. /**
  139471. * Checks if the given data starts with a KTX2 file identifier.
  139472. * @param data the data to check
  139473. * @returns true if the data is a KTX2 file or false otherwise
  139474. */
  139475. static IsValid(data: ArrayBufferView): boolean;
  139476. }
  139477. }
  139478. declare module BABYLON {
  139479. /**
  139480. * Implementation of the KTX Texture Loader.
  139481. * @hidden
  139482. */
  139483. export class _KTXTextureLoader implements IInternalTextureLoader {
  139484. /**
  139485. * Defines wether the loader supports cascade loading the different faces.
  139486. */
  139487. readonly supportCascades: boolean;
  139488. /**
  139489. * This returns if the loader support the current file information.
  139490. * @param extension defines the file extension of the file being loaded
  139491. * @param mimeType defines the optional mime type of the file being loaded
  139492. * @returns true if the loader can load the specified file
  139493. */
  139494. canLoad(extension: string, mimeType?: string): boolean;
  139495. /**
  139496. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139497. * @param data contains the texture data
  139498. * @param texture defines the BabylonJS internal texture
  139499. * @param createPolynomials will be true if polynomials have been requested
  139500. * @param onLoad defines the callback to trigger once the texture is ready
  139501. * @param onError defines the callback to trigger in case of error
  139502. */
  139503. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139504. /**
  139505. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139506. * @param data contains the texture data
  139507. * @param texture defines the BabylonJS internal texture
  139508. * @param callback defines the method to call once ready to upload
  139509. */
  139510. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  139511. }
  139512. }
  139513. declare module BABYLON {
  139514. /** @hidden */
  139515. export var _forceSceneHelpersToBundle: boolean;
  139516. interface Scene {
  139517. /**
  139518. * Creates a default light for the scene.
  139519. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  139520. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  139521. */
  139522. createDefaultLight(replace?: boolean): void;
  139523. /**
  139524. * Creates a default camera for the scene.
  139525. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  139526. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  139527. * @param replace has default false, when true replaces the active camera in the scene
  139528. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  139529. */
  139530. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  139531. /**
  139532. * Creates a default camera and a default light.
  139533. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  139534. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  139535. * @param replace has the default false, when true replaces the active camera/light in the scene
  139536. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  139537. */
  139538. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  139539. /**
  139540. * Creates a new sky box
  139541. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  139542. * @param environmentTexture defines the texture to use as environment texture
  139543. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  139544. * @param scale defines the overall scale of the skybox
  139545. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  139546. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  139547. * @returns a new mesh holding the sky box
  139548. */
  139549. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  139550. /**
  139551. * Creates a new environment
  139552. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  139553. * @param options defines the options you can use to configure the environment
  139554. * @returns the new EnvironmentHelper
  139555. */
  139556. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  139557. /**
  139558. * Creates a new VREXperienceHelper
  139559. * @see https://doc.babylonjs.com/how_to/webvr_helper
  139560. * @param webVROptions defines the options used to create the new VREXperienceHelper
  139561. * @returns a new VREXperienceHelper
  139562. */
  139563. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  139564. /**
  139565. * Creates a new WebXRDefaultExperience
  139566. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  139567. * @param options experience options
  139568. * @returns a promise for a new WebXRDefaultExperience
  139569. */
  139570. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  139571. }
  139572. }
  139573. declare module BABYLON {
  139574. /**
  139575. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  139576. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  139577. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  139578. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  139579. */
  139580. export class VideoDome extends TextureDome<VideoTexture> {
  139581. /**
  139582. * Define the video source as a Monoscopic panoramic 360 video.
  139583. */
  139584. static readonly MODE_MONOSCOPIC: number;
  139585. /**
  139586. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  139587. */
  139588. static readonly MODE_TOPBOTTOM: number;
  139589. /**
  139590. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  139591. */
  139592. static readonly MODE_SIDEBYSIDE: number;
  139593. /**
  139594. * Get the video texture associated with this video dome
  139595. */
  139596. get videoTexture(): VideoTexture;
  139597. /**
  139598. * Get the video mode of this dome
  139599. */
  139600. get videoMode(): number;
  139601. /**
  139602. * Set the video mode of this dome.
  139603. * @see textureMode
  139604. */
  139605. set videoMode(value: number);
  139606. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  139607. }
  139608. }
  139609. declare module BABYLON {
  139610. /**
  139611. * This class can be used to get instrumentation data from a Babylon engine
  139612. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  139613. */
  139614. export class EngineInstrumentation implements IDisposable {
  139615. /**
  139616. * Define the instrumented engine.
  139617. */
  139618. engine: Engine;
  139619. private _captureGPUFrameTime;
  139620. private _gpuFrameTimeToken;
  139621. private _gpuFrameTime;
  139622. private _captureShaderCompilationTime;
  139623. private _shaderCompilationTime;
  139624. private _onBeginFrameObserver;
  139625. private _onEndFrameObserver;
  139626. private _onBeforeShaderCompilationObserver;
  139627. private _onAfterShaderCompilationObserver;
  139628. /**
  139629. * Gets the perf counter used for GPU frame time
  139630. */
  139631. get gpuFrameTimeCounter(): PerfCounter;
  139632. /**
  139633. * Gets the GPU frame time capture status
  139634. */
  139635. get captureGPUFrameTime(): boolean;
  139636. /**
  139637. * Enable or disable the GPU frame time capture
  139638. */
  139639. set captureGPUFrameTime(value: boolean);
  139640. /**
  139641. * Gets the perf counter used for shader compilation time
  139642. */
  139643. get shaderCompilationTimeCounter(): PerfCounter;
  139644. /**
  139645. * Gets the shader compilation time capture status
  139646. */
  139647. get captureShaderCompilationTime(): boolean;
  139648. /**
  139649. * Enable or disable the shader compilation time capture
  139650. */
  139651. set captureShaderCompilationTime(value: boolean);
  139652. /**
  139653. * Instantiates a new engine instrumentation.
  139654. * This class can be used to get instrumentation data from a Babylon engine
  139655. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  139656. * @param engine Defines the engine to instrument
  139657. */
  139658. constructor(
  139659. /**
  139660. * Define the instrumented engine.
  139661. */
  139662. engine: Engine);
  139663. /**
  139664. * Dispose and release associated resources.
  139665. */
  139666. dispose(): void;
  139667. }
  139668. }
  139669. declare module BABYLON {
  139670. /**
  139671. * This class can be used to get instrumentation data from a Babylon engine
  139672. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  139673. */
  139674. export class SceneInstrumentation implements IDisposable {
  139675. /**
  139676. * Defines the scene to instrument
  139677. */
  139678. scene: Scene;
  139679. private _captureActiveMeshesEvaluationTime;
  139680. private _activeMeshesEvaluationTime;
  139681. private _captureRenderTargetsRenderTime;
  139682. private _renderTargetsRenderTime;
  139683. private _captureFrameTime;
  139684. private _frameTime;
  139685. private _captureRenderTime;
  139686. private _renderTime;
  139687. private _captureInterFrameTime;
  139688. private _interFrameTime;
  139689. private _captureParticlesRenderTime;
  139690. private _particlesRenderTime;
  139691. private _captureSpritesRenderTime;
  139692. private _spritesRenderTime;
  139693. private _capturePhysicsTime;
  139694. private _physicsTime;
  139695. private _captureAnimationsTime;
  139696. private _animationsTime;
  139697. private _captureCameraRenderTime;
  139698. private _cameraRenderTime;
  139699. private _onBeforeActiveMeshesEvaluationObserver;
  139700. private _onAfterActiveMeshesEvaluationObserver;
  139701. private _onBeforeRenderTargetsRenderObserver;
  139702. private _onAfterRenderTargetsRenderObserver;
  139703. private _onAfterRenderObserver;
  139704. private _onBeforeDrawPhaseObserver;
  139705. private _onAfterDrawPhaseObserver;
  139706. private _onBeforeAnimationsObserver;
  139707. private _onBeforeParticlesRenderingObserver;
  139708. private _onAfterParticlesRenderingObserver;
  139709. private _onBeforeSpritesRenderingObserver;
  139710. private _onAfterSpritesRenderingObserver;
  139711. private _onBeforePhysicsObserver;
  139712. private _onAfterPhysicsObserver;
  139713. private _onAfterAnimationsObserver;
  139714. private _onBeforeCameraRenderObserver;
  139715. private _onAfterCameraRenderObserver;
  139716. /**
  139717. * Gets the perf counter used for active meshes evaluation time
  139718. */
  139719. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  139720. /**
  139721. * Gets the active meshes evaluation time capture status
  139722. */
  139723. get captureActiveMeshesEvaluationTime(): boolean;
  139724. /**
  139725. * Enable or disable the active meshes evaluation time capture
  139726. */
  139727. set captureActiveMeshesEvaluationTime(value: boolean);
  139728. /**
  139729. * Gets the perf counter used for render targets render time
  139730. */
  139731. get renderTargetsRenderTimeCounter(): PerfCounter;
  139732. /**
  139733. * Gets the render targets render time capture status
  139734. */
  139735. get captureRenderTargetsRenderTime(): boolean;
  139736. /**
  139737. * Enable or disable the render targets render time capture
  139738. */
  139739. set captureRenderTargetsRenderTime(value: boolean);
  139740. /**
  139741. * Gets the perf counter used for particles render time
  139742. */
  139743. get particlesRenderTimeCounter(): PerfCounter;
  139744. /**
  139745. * Gets the particles render time capture status
  139746. */
  139747. get captureParticlesRenderTime(): boolean;
  139748. /**
  139749. * Enable or disable the particles render time capture
  139750. */
  139751. set captureParticlesRenderTime(value: boolean);
  139752. /**
  139753. * Gets the perf counter used for sprites render time
  139754. */
  139755. get spritesRenderTimeCounter(): PerfCounter;
  139756. /**
  139757. * Gets the sprites render time capture status
  139758. */
  139759. get captureSpritesRenderTime(): boolean;
  139760. /**
  139761. * Enable or disable the sprites render time capture
  139762. */
  139763. set captureSpritesRenderTime(value: boolean);
  139764. /**
  139765. * Gets the perf counter used for physics time
  139766. */
  139767. get physicsTimeCounter(): PerfCounter;
  139768. /**
  139769. * Gets the physics time capture status
  139770. */
  139771. get capturePhysicsTime(): boolean;
  139772. /**
  139773. * Enable or disable the physics time capture
  139774. */
  139775. set capturePhysicsTime(value: boolean);
  139776. /**
  139777. * Gets the perf counter used for animations time
  139778. */
  139779. get animationsTimeCounter(): PerfCounter;
  139780. /**
  139781. * Gets the animations time capture status
  139782. */
  139783. get captureAnimationsTime(): boolean;
  139784. /**
  139785. * Enable or disable the animations time capture
  139786. */
  139787. set captureAnimationsTime(value: boolean);
  139788. /**
  139789. * Gets the perf counter used for frame time capture
  139790. */
  139791. get frameTimeCounter(): PerfCounter;
  139792. /**
  139793. * Gets the frame time capture status
  139794. */
  139795. get captureFrameTime(): boolean;
  139796. /**
  139797. * Enable or disable the frame time capture
  139798. */
  139799. set captureFrameTime(value: boolean);
  139800. /**
  139801. * Gets the perf counter used for inter-frames time capture
  139802. */
  139803. get interFrameTimeCounter(): PerfCounter;
  139804. /**
  139805. * Gets the inter-frames time capture status
  139806. */
  139807. get captureInterFrameTime(): boolean;
  139808. /**
  139809. * Enable or disable the inter-frames time capture
  139810. */
  139811. set captureInterFrameTime(value: boolean);
  139812. /**
  139813. * Gets the perf counter used for render time capture
  139814. */
  139815. get renderTimeCounter(): PerfCounter;
  139816. /**
  139817. * Gets the render time capture status
  139818. */
  139819. get captureRenderTime(): boolean;
  139820. /**
  139821. * Enable or disable the render time capture
  139822. */
  139823. set captureRenderTime(value: boolean);
  139824. /**
  139825. * Gets the perf counter used for camera render time capture
  139826. */
  139827. get cameraRenderTimeCounter(): PerfCounter;
  139828. /**
  139829. * Gets the camera render time capture status
  139830. */
  139831. get captureCameraRenderTime(): boolean;
  139832. /**
  139833. * Enable or disable the camera render time capture
  139834. */
  139835. set captureCameraRenderTime(value: boolean);
  139836. /**
  139837. * Gets the perf counter used for draw calls
  139838. */
  139839. get drawCallsCounter(): PerfCounter;
  139840. /**
  139841. * Instantiates a new scene instrumentation.
  139842. * This class can be used to get instrumentation data from a Babylon engine
  139843. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  139844. * @param scene Defines the scene to instrument
  139845. */
  139846. constructor(
  139847. /**
  139848. * Defines the scene to instrument
  139849. */
  139850. scene: Scene);
  139851. /**
  139852. * Dispose and release associated resources.
  139853. */
  139854. dispose(): void;
  139855. }
  139856. }
  139857. declare module BABYLON {
  139858. /** @hidden */
  139859. export var glowMapGenerationPixelShader: {
  139860. name: string;
  139861. shader: string;
  139862. };
  139863. }
  139864. declare module BABYLON {
  139865. /** @hidden */
  139866. export var glowMapGenerationVertexShader: {
  139867. name: string;
  139868. shader: string;
  139869. };
  139870. }
  139871. declare module BABYLON {
  139872. /**
  139873. * Effect layer options. This helps customizing the behaviour
  139874. * of the effect layer.
  139875. */
  139876. export interface IEffectLayerOptions {
  139877. /**
  139878. * Multiplication factor apply to the canvas size to compute the render target size
  139879. * used to generated the objects (the smaller the faster).
  139880. */
  139881. mainTextureRatio: number;
  139882. /**
  139883. * Enforces a fixed size texture to ensure effect stability across devices.
  139884. */
  139885. mainTextureFixedSize?: number;
  139886. /**
  139887. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  139888. */
  139889. alphaBlendingMode: number;
  139890. /**
  139891. * The camera attached to the layer.
  139892. */
  139893. camera: Nullable<Camera>;
  139894. /**
  139895. * The rendering group to draw the layer in.
  139896. */
  139897. renderingGroupId: number;
  139898. }
  139899. /**
  139900. * The effect layer Helps adding post process effect blended with the main pass.
  139901. *
  139902. * This can be for instance use to generate glow or higlight effects on the scene.
  139903. *
  139904. * The effect layer class can not be used directly and is intented to inherited from to be
  139905. * customized per effects.
  139906. */
  139907. export abstract class EffectLayer {
  139908. private _vertexBuffers;
  139909. private _indexBuffer;
  139910. private _cachedDefines;
  139911. private _effectLayerMapGenerationEffect;
  139912. private _effectLayerOptions;
  139913. private _mergeEffect;
  139914. protected _scene: Scene;
  139915. protected _engine: Engine;
  139916. protected _maxSize: number;
  139917. protected _mainTextureDesiredSize: ISize;
  139918. protected _mainTexture: RenderTargetTexture;
  139919. protected _shouldRender: boolean;
  139920. protected _postProcesses: PostProcess[];
  139921. protected _textures: BaseTexture[];
  139922. protected _emissiveTextureAndColor: {
  139923. texture: Nullable<BaseTexture>;
  139924. color: Color4;
  139925. };
  139926. /**
  139927. * The name of the layer
  139928. */
  139929. name: string;
  139930. /**
  139931. * The clear color of the texture used to generate the glow map.
  139932. */
  139933. neutralColor: Color4;
  139934. /**
  139935. * Specifies whether the highlight layer is enabled or not.
  139936. */
  139937. isEnabled: boolean;
  139938. /**
  139939. * Gets the camera attached to the layer.
  139940. */
  139941. get camera(): Nullable<Camera>;
  139942. /**
  139943. * Gets the rendering group id the layer should render in.
  139944. */
  139945. get renderingGroupId(): number;
  139946. set renderingGroupId(renderingGroupId: number);
  139947. /**
  139948. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  139949. */
  139950. disableBoundingBoxesFromEffectLayer: boolean;
  139951. /**
  139952. * An event triggered when the effect layer has been disposed.
  139953. */
  139954. onDisposeObservable: Observable<EffectLayer>;
  139955. /**
  139956. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  139957. */
  139958. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  139959. /**
  139960. * An event triggered when the generated texture is being merged in the scene.
  139961. */
  139962. onBeforeComposeObservable: Observable<EffectLayer>;
  139963. /**
  139964. * An event triggered when the mesh is rendered into the effect render target.
  139965. */
  139966. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  139967. /**
  139968. * An event triggered after the mesh has been rendered into the effect render target.
  139969. */
  139970. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  139971. /**
  139972. * An event triggered when the generated texture has been merged in the scene.
  139973. */
  139974. onAfterComposeObservable: Observable<EffectLayer>;
  139975. /**
  139976. * An event triggered when the efffect layer changes its size.
  139977. */
  139978. onSizeChangedObservable: Observable<EffectLayer>;
  139979. /** @hidden */
  139980. static _SceneComponentInitialization: (scene: Scene) => void;
  139981. /**
  139982. * Instantiates a new effect Layer and references it in the scene.
  139983. * @param name The name of the layer
  139984. * @param scene The scene to use the layer in
  139985. */
  139986. constructor(
  139987. /** The Friendly of the effect in the scene */
  139988. name: string, scene: Scene);
  139989. /**
  139990. * Get the effect name of the layer.
  139991. * @return The effect name
  139992. */
  139993. abstract getEffectName(): string;
  139994. /**
  139995. * Checks for the readiness of the element composing the layer.
  139996. * @param subMesh the mesh to check for
  139997. * @param useInstances specify whether or not to use instances to render the mesh
  139998. * @return true if ready otherwise, false
  139999. */
  140000. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140001. /**
  140002. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  140003. * @returns true if the effect requires stencil during the main canvas render pass.
  140004. */
  140005. abstract needStencil(): boolean;
  140006. /**
  140007. * Create the merge effect. This is the shader use to blit the information back
  140008. * to the main canvas at the end of the scene rendering.
  140009. * @returns The effect containing the shader used to merge the effect on the main canvas
  140010. */
  140011. protected abstract _createMergeEffect(): Effect;
  140012. /**
  140013. * Creates the render target textures and post processes used in the effect layer.
  140014. */
  140015. protected abstract _createTextureAndPostProcesses(): void;
  140016. /**
  140017. * Implementation specific of rendering the generating effect on the main canvas.
  140018. * @param effect The effect used to render through
  140019. */
  140020. protected abstract _internalRender(effect: Effect): void;
  140021. /**
  140022. * Sets the required values for both the emissive texture and and the main color.
  140023. */
  140024. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140025. /**
  140026. * Free any resources and references associated to a mesh.
  140027. * Internal use
  140028. * @param mesh The mesh to free.
  140029. */
  140030. abstract _disposeMesh(mesh: Mesh): void;
  140031. /**
  140032. * Serializes this layer (Glow or Highlight for example)
  140033. * @returns a serialized layer object
  140034. */
  140035. abstract serialize?(): any;
  140036. /**
  140037. * Initializes the effect layer with the required options.
  140038. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  140039. */
  140040. protected _init(options: Partial<IEffectLayerOptions>): void;
  140041. /**
  140042. * Generates the index buffer of the full screen quad blending to the main canvas.
  140043. */
  140044. private _generateIndexBuffer;
  140045. /**
  140046. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  140047. */
  140048. private _generateVertexBuffer;
  140049. /**
  140050. * Sets the main texture desired size which is the closest power of two
  140051. * of the engine canvas size.
  140052. */
  140053. private _setMainTextureSize;
  140054. /**
  140055. * Creates the main texture for the effect layer.
  140056. */
  140057. protected _createMainTexture(): void;
  140058. /**
  140059. * Adds specific effects defines.
  140060. * @param defines The defines to add specifics to.
  140061. */
  140062. protected _addCustomEffectDefines(defines: string[]): void;
  140063. /**
  140064. * Checks for the readiness of the element composing the layer.
  140065. * @param subMesh the mesh to check for
  140066. * @param useInstances specify whether or not to use instances to render the mesh
  140067. * @param emissiveTexture the associated emissive texture used to generate the glow
  140068. * @return true if ready otherwise, false
  140069. */
  140070. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  140071. /**
  140072. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  140073. */
  140074. render(): void;
  140075. /**
  140076. * Determine if a given mesh will be used in the current effect.
  140077. * @param mesh mesh to test
  140078. * @returns true if the mesh will be used
  140079. */
  140080. hasMesh(mesh: AbstractMesh): boolean;
  140081. /**
  140082. * Returns true if the layer contains information to display, otherwise false.
  140083. * @returns true if the glow layer should be rendered
  140084. */
  140085. shouldRender(): boolean;
  140086. /**
  140087. * Returns true if the mesh should render, otherwise false.
  140088. * @param mesh The mesh to render
  140089. * @returns true if it should render otherwise false
  140090. */
  140091. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  140092. /**
  140093. * Returns true if the mesh can be rendered, otherwise false.
  140094. * @param mesh The mesh to render
  140095. * @param material The material used on the mesh
  140096. * @returns true if it can be rendered otherwise false
  140097. */
  140098. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140099. /**
  140100. * Returns true if the mesh should render, otherwise false.
  140101. * @param mesh The mesh to render
  140102. * @returns true if it should render otherwise false
  140103. */
  140104. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  140105. /**
  140106. * Renders the submesh passed in parameter to the generation map.
  140107. */
  140108. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  140109. /**
  140110. * Defines whether the current material of the mesh should be use to render the effect.
  140111. * @param mesh defines the current mesh to render
  140112. */
  140113. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  140114. /**
  140115. * Rebuild the required buffers.
  140116. * @hidden Internal use only.
  140117. */
  140118. _rebuild(): void;
  140119. /**
  140120. * Dispose only the render target textures and post process.
  140121. */
  140122. private _disposeTextureAndPostProcesses;
  140123. /**
  140124. * Dispose the highlight layer and free resources.
  140125. */
  140126. dispose(): void;
  140127. /**
  140128. * Gets the class name of the effect layer
  140129. * @returns the string with the class name of the effect layer
  140130. */
  140131. getClassName(): string;
  140132. /**
  140133. * Creates an effect layer from parsed effect layer data
  140134. * @param parsedEffectLayer defines effect layer data
  140135. * @param scene defines the current scene
  140136. * @param rootUrl defines the root URL containing the effect layer information
  140137. * @returns a parsed effect Layer
  140138. */
  140139. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  140140. }
  140141. }
  140142. declare module BABYLON {
  140143. interface AbstractScene {
  140144. /**
  140145. * The list of effect layers (highlights/glow) added to the scene
  140146. * @see https://doc.babylonjs.com/how_to/highlight_layer
  140147. * @see https://doc.babylonjs.com/how_to/glow_layer
  140148. */
  140149. effectLayers: Array<EffectLayer>;
  140150. /**
  140151. * Removes the given effect layer from this scene.
  140152. * @param toRemove defines the effect layer to remove
  140153. * @returns the index of the removed effect layer
  140154. */
  140155. removeEffectLayer(toRemove: EffectLayer): number;
  140156. /**
  140157. * Adds the given effect layer to this scene
  140158. * @param newEffectLayer defines the effect layer to add
  140159. */
  140160. addEffectLayer(newEffectLayer: EffectLayer): void;
  140161. }
  140162. /**
  140163. * Defines the layer scene component responsible to manage any effect layers
  140164. * in a given scene.
  140165. */
  140166. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  140167. /**
  140168. * The component name helpfull to identify the component in the list of scene components.
  140169. */
  140170. readonly name: string;
  140171. /**
  140172. * The scene the component belongs to.
  140173. */
  140174. scene: Scene;
  140175. private _engine;
  140176. private _renderEffects;
  140177. private _needStencil;
  140178. private _previousStencilState;
  140179. /**
  140180. * Creates a new instance of the component for the given scene
  140181. * @param scene Defines the scene to register the component in
  140182. */
  140183. constructor(scene: Scene);
  140184. /**
  140185. * Registers the component in a given scene
  140186. */
  140187. register(): void;
  140188. /**
  140189. * Rebuilds the elements related to this component in case of
  140190. * context lost for instance.
  140191. */
  140192. rebuild(): void;
  140193. /**
  140194. * Serializes the component data to the specified json object
  140195. * @param serializationObject The object to serialize to
  140196. */
  140197. serialize(serializationObject: any): void;
  140198. /**
  140199. * Adds all the elements from the container to the scene
  140200. * @param container the container holding the elements
  140201. */
  140202. addFromContainer(container: AbstractScene): void;
  140203. /**
  140204. * Removes all the elements in the container from the scene
  140205. * @param container contains the elements to remove
  140206. * @param dispose if the removed element should be disposed (default: false)
  140207. */
  140208. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140209. /**
  140210. * Disposes the component and the associated ressources.
  140211. */
  140212. dispose(): void;
  140213. private _isReadyForMesh;
  140214. private _renderMainTexture;
  140215. private _setStencil;
  140216. private _setStencilBack;
  140217. private _draw;
  140218. private _drawCamera;
  140219. private _drawRenderingGroup;
  140220. }
  140221. }
  140222. declare module BABYLON {
  140223. /** @hidden */
  140224. export var glowMapMergePixelShader: {
  140225. name: string;
  140226. shader: string;
  140227. };
  140228. }
  140229. declare module BABYLON {
  140230. /** @hidden */
  140231. export var glowMapMergeVertexShader: {
  140232. name: string;
  140233. shader: string;
  140234. };
  140235. }
  140236. declare module BABYLON {
  140237. interface AbstractScene {
  140238. /**
  140239. * Return a the first highlight layer of the scene with a given name.
  140240. * @param name The name of the highlight layer to look for.
  140241. * @return The highlight layer if found otherwise null.
  140242. */
  140243. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  140244. }
  140245. /**
  140246. * Glow layer options. This helps customizing the behaviour
  140247. * of the glow layer.
  140248. */
  140249. export interface IGlowLayerOptions {
  140250. /**
  140251. * Multiplication factor apply to the canvas size to compute the render target size
  140252. * used to generated the glowing objects (the smaller the faster).
  140253. */
  140254. mainTextureRatio: number;
  140255. /**
  140256. * Enforces a fixed size texture to ensure resize independant blur.
  140257. */
  140258. mainTextureFixedSize?: number;
  140259. /**
  140260. * How big is the kernel of the blur texture.
  140261. */
  140262. blurKernelSize: number;
  140263. /**
  140264. * The camera attached to the layer.
  140265. */
  140266. camera: Nullable<Camera>;
  140267. /**
  140268. * Enable MSAA by chosing the number of samples.
  140269. */
  140270. mainTextureSamples?: number;
  140271. /**
  140272. * The rendering group to draw the layer in.
  140273. */
  140274. renderingGroupId: number;
  140275. }
  140276. /**
  140277. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  140278. *
  140279. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  140280. *
  140281. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  140282. */
  140283. export class GlowLayer extends EffectLayer {
  140284. /**
  140285. * Effect Name of the layer.
  140286. */
  140287. static readonly EffectName: string;
  140288. /**
  140289. * The default blur kernel size used for the glow.
  140290. */
  140291. static DefaultBlurKernelSize: number;
  140292. /**
  140293. * The default texture size ratio used for the glow.
  140294. */
  140295. static DefaultTextureRatio: number;
  140296. /**
  140297. * Sets the kernel size of the blur.
  140298. */
  140299. set blurKernelSize(value: number);
  140300. /**
  140301. * Gets the kernel size of the blur.
  140302. */
  140303. get blurKernelSize(): number;
  140304. /**
  140305. * Sets the glow intensity.
  140306. */
  140307. set intensity(value: number);
  140308. /**
  140309. * Gets the glow intensity.
  140310. */
  140311. get intensity(): number;
  140312. private _options;
  140313. private _intensity;
  140314. private _horizontalBlurPostprocess1;
  140315. private _verticalBlurPostprocess1;
  140316. private _horizontalBlurPostprocess2;
  140317. private _verticalBlurPostprocess2;
  140318. private _blurTexture1;
  140319. private _blurTexture2;
  140320. private _postProcesses1;
  140321. private _postProcesses2;
  140322. private _includedOnlyMeshes;
  140323. private _excludedMeshes;
  140324. private _meshesUsingTheirOwnMaterials;
  140325. /**
  140326. * Callback used to let the user override the color selection on a per mesh basis
  140327. */
  140328. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  140329. /**
  140330. * Callback used to let the user override the texture selection on a per mesh basis
  140331. */
  140332. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  140333. /**
  140334. * Instantiates a new glow Layer and references it to the scene.
  140335. * @param name The name of the layer
  140336. * @param scene The scene to use the layer in
  140337. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  140338. */
  140339. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  140340. /**
  140341. * Get the effect name of the layer.
  140342. * @return The effect name
  140343. */
  140344. getEffectName(): string;
  140345. /**
  140346. * Create the merge effect. This is the shader use to blit the information back
  140347. * to the main canvas at the end of the scene rendering.
  140348. */
  140349. protected _createMergeEffect(): Effect;
  140350. /**
  140351. * Creates the render target textures and post processes used in the glow layer.
  140352. */
  140353. protected _createTextureAndPostProcesses(): void;
  140354. /**
  140355. * Checks for the readiness of the element composing the layer.
  140356. * @param subMesh the mesh to check for
  140357. * @param useInstances specify wether or not to use instances to render the mesh
  140358. * @param emissiveTexture the associated emissive texture used to generate the glow
  140359. * @return true if ready otherwise, false
  140360. */
  140361. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140362. /**
  140363. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  140364. */
  140365. needStencil(): boolean;
  140366. /**
  140367. * Returns true if the mesh can be rendered, otherwise false.
  140368. * @param mesh The mesh to render
  140369. * @param material The material used on the mesh
  140370. * @returns true if it can be rendered otherwise false
  140371. */
  140372. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140373. /**
  140374. * Implementation specific of rendering the generating effect on the main canvas.
  140375. * @param effect The effect used to render through
  140376. */
  140377. protected _internalRender(effect: Effect): void;
  140378. /**
  140379. * Sets the required values for both the emissive texture and and the main color.
  140380. */
  140381. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140382. /**
  140383. * Returns true if the mesh should render, otherwise false.
  140384. * @param mesh The mesh to render
  140385. * @returns true if it should render otherwise false
  140386. */
  140387. protected _shouldRenderMesh(mesh: Mesh): boolean;
  140388. /**
  140389. * Adds specific effects defines.
  140390. * @param defines The defines to add specifics to.
  140391. */
  140392. protected _addCustomEffectDefines(defines: string[]): void;
  140393. /**
  140394. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  140395. * @param mesh The mesh to exclude from the glow layer
  140396. */
  140397. addExcludedMesh(mesh: Mesh): void;
  140398. /**
  140399. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  140400. * @param mesh The mesh to remove
  140401. */
  140402. removeExcludedMesh(mesh: Mesh): void;
  140403. /**
  140404. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  140405. * @param mesh The mesh to include in the glow layer
  140406. */
  140407. addIncludedOnlyMesh(mesh: Mesh): void;
  140408. /**
  140409. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  140410. * @param mesh The mesh to remove
  140411. */
  140412. removeIncludedOnlyMesh(mesh: Mesh): void;
  140413. /**
  140414. * Determine if a given mesh will be used in the glow layer
  140415. * @param mesh The mesh to test
  140416. * @returns true if the mesh will be highlighted by the current glow layer
  140417. */
  140418. hasMesh(mesh: AbstractMesh): boolean;
  140419. /**
  140420. * Defines whether the current material of the mesh should be use to render the effect.
  140421. * @param mesh defines the current mesh to render
  140422. */
  140423. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  140424. /**
  140425. * Add a mesh to be rendered through its own material and not with emissive only.
  140426. * @param mesh The mesh for which we need to use its material
  140427. */
  140428. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  140429. /**
  140430. * Remove a mesh from being rendered through its own material and not with emissive only.
  140431. * @param mesh The mesh for which we need to not use its material
  140432. */
  140433. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  140434. /**
  140435. * Free any resources and references associated to a mesh.
  140436. * Internal use
  140437. * @param mesh The mesh to free.
  140438. * @hidden
  140439. */
  140440. _disposeMesh(mesh: Mesh): void;
  140441. /**
  140442. * Gets the class name of the effect layer
  140443. * @returns the string with the class name of the effect layer
  140444. */
  140445. getClassName(): string;
  140446. /**
  140447. * Serializes this glow layer
  140448. * @returns a serialized glow layer object
  140449. */
  140450. serialize(): any;
  140451. /**
  140452. * Creates a Glow Layer from parsed glow layer data
  140453. * @param parsedGlowLayer defines glow layer data
  140454. * @param scene defines the current scene
  140455. * @param rootUrl defines the root URL containing the glow layer information
  140456. * @returns a parsed Glow Layer
  140457. */
  140458. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  140459. }
  140460. }
  140461. declare module BABYLON {
  140462. /** @hidden */
  140463. export var glowBlurPostProcessPixelShader: {
  140464. name: string;
  140465. shader: string;
  140466. };
  140467. }
  140468. declare module BABYLON {
  140469. interface AbstractScene {
  140470. /**
  140471. * Return a the first highlight layer of the scene with a given name.
  140472. * @param name The name of the highlight layer to look for.
  140473. * @return The highlight layer if found otherwise null.
  140474. */
  140475. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  140476. }
  140477. /**
  140478. * Highlight layer options. This helps customizing the behaviour
  140479. * of the highlight layer.
  140480. */
  140481. export interface IHighlightLayerOptions {
  140482. /**
  140483. * Multiplication factor apply to the canvas size to compute the render target size
  140484. * used to generated the glowing objects (the smaller the faster).
  140485. */
  140486. mainTextureRatio: number;
  140487. /**
  140488. * Enforces a fixed size texture to ensure resize independant blur.
  140489. */
  140490. mainTextureFixedSize?: number;
  140491. /**
  140492. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  140493. * of the picture to blur (the smaller the faster).
  140494. */
  140495. blurTextureSizeRatio: number;
  140496. /**
  140497. * How big in texel of the blur texture is the vertical blur.
  140498. */
  140499. blurVerticalSize: number;
  140500. /**
  140501. * How big in texel of the blur texture is the horizontal blur.
  140502. */
  140503. blurHorizontalSize: number;
  140504. /**
  140505. * Alpha blending mode used to apply the blur. Default is combine.
  140506. */
  140507. alphaBlendingMode: number;
  140508. /**
  140509. * The camera attached to the layer.
  140510. */
  140511. camera: Nullable<Camera>;
  140512. /**
  140513. * Should we display highlight as a solid stroke?
  140514. */
  140515. isStroke?: boolean;
  140516. /**
  140517. * The rendering group to draw the layer in.
  140518. */
  140519. renderingGroupId: number;
  140520. }
  140521. /**
  140522. * The highlight layer Helps adding a glow effect around a mesh.
  140523. *
  140524. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  140525. * glowy meshes to your scene.
  140526. *
  140527. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  140528. */
  140529. export class HighlightLayer extends EffectLayer {
  140530. name: string;
  140531. /**
  140532. * Effect Name of the highlight layer.
  140533. */
  140534. static readonly EffectName: string;
  140535. /**
  140536. * The neutral color used during the preparation of the glow effect.
  140537. * This is black by default as the blend operation is a blend operation.
  140538. */
  140539. static NeutralColor: Color4;
  140540. /**
  140541. * Stencil value used for glowing meshes.
  140542. */
  140543. static GlowingMeshStencilReference: number;
  140544. /**
  140545. * Stencil value used for the other meshes in the scene.
  140546. */
  140547. static NormalMeshStencilReference: number;
  140548. /**
  140549. * Specifies whether or not the inner glow is ACTIVE in the layer.
  140550. */
  140551. innerGlow: boolean;
  140552. /**
  140553. * Specifies whether or not the outer glow is ACTIVE in the layer.
  140554. */
  140555. outerGlow: boolean;
  140556. /**
  140557. * Specifies the horizontal size of the blur.
  140558. */
  140559. set blurHorizontalSize(value: number);
  140560. /**
  140561. * Specifies the vertical size of the blur.
  140562. */
  140563. set blurVerticalSize(value: number);
  140564. /**
  140565. * Gets the horizontal size of the blur.
  140566. */
  140567. get blurHorizontalSize(): number;
  140568. /**
  140569. * Gets the vertical size of the blur.
  140570. */
  140571. get blurVerticalSize(): number;
  140572. /**
  140573. * An event triggered when the highlight layer is being blurred.
  140574. */
  140575. onBeforeBlurObservable: Observable<HighlightLayer>;
  140576. /**
  140577. * An event triggered when the highlight layer has been blurred.
  140578. */
  140579. onAfterBlurObservable: Observable<HighlightLayer>;
  140580. private _instanceGlowingMeshStencilReference;
  140581. private _options;
  140582. private _downSamplePostprocess;
  140583. private _horizontalBlurPostprocess;
  140584. private _verticalBlurPostprocess;
  140585. private _blurTexture;
  140586. private _meshes;
  140587. private _excludedMeshes;
  140588. /**
  140589. * Instantiates a new highlight Layer and references it to the scene..
  140590. * @param name The name of the layer
  140591. * @param scene The scene to use the layer in
  140592. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  140593. */
  140594. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  140595. /**
  140596. * Get the effect name of the layer.
  140597. * @return The effect name
  140598. */
  140599. getEffectName(): string;
  140600. /**
  140601. * Create the merge effect. This is the shader use to blit the information back
  140602. * to the main canvas at the end of the scene rendering.
  140603. */
  140604. protected _createMergeEffect(): Effect;
  140605. /**
  140606. * Creates the render target textures and post processes used in the highlight layer.
  140607. */
  140608. protected _createTextureAndPostProcesses(): void;
  140609. /**
  140610. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  140611. */
  140612. needStencil(): boolean;
  140613. /**
  140614. * Checks for the readiness of the element composing the layer.
  140615. * @param subMesh the mesh to check for
  140616. * @param useInstances specify wether or not to use instances to render the mesh
  140617. * @param emissiveTexture the associated emissive texture used to generate the glow
  140618. * @return true if ready otherwise, false
  140619. */
  140620. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140621. /**
  140622. * Implementation specific of rendering the generating effect on the main canvas.
  140623. * @param effect The effect used to render through
  140624. */
  140625. protected _internalRender(effect: Effect): void;
  140626. /**
  140627. * Returns true if the layer contains information to display, otherwise false.
  140628. */
  140629. shouldRender(): boolean;
  140630. /**
  140631. * Returns true if the mesh should render, otherwise false.
  140632. * @param mesh The mesh to render
  140633. * @returns true if it should render otherwise false
  140634. */
  140635. protected _shouldRenderMesh(mesh: Mesh): boolean;
  140636. /**
  140637. * Returns true if the mesh can be rendered, otherwise false.
  140638. * @param mesh The mesh to render
  140639. * @param material The material used on the mesh
  140640. * @returns true if it can be rendered otherwise false
  140641. */
  140642. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140643. /**
  140644. * Adds specific effects defines.
  140645. * @param defines The defines to add specifics to.
  140646. */
  140647. protected _addCustomEffectDefines(defines: string[]): void;
  140648. /**
  140649. * Sets the required values for both the emissive texture and and the main color.
  140650. */
  140651. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140652. /**
  140653. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  140654. * @param mesh The mesh to exclude from the highlight layer
  140655. */
  140656. addExcludedMesh(mesh: Mesh): void;
  140657. /**
  140658. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  140659. * @param mesh The mesh to highlight
  140660. */
  140661. removeExcludedMesh(mesh: Mesh): void;
  140662. /**
  140663. * Determine if a given mesh will be highlighted by the current HighlightLayer
  140664. * @param mesh mesh to test
  140665. * @returns true if the mesh will be highlighted by the current HighlightLayer
  140666. */
  140667. hasMesh(mesh: AbstractMesh): boolean;
  140668. /**
  140669. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  140670. * @param mesh The mesh to highlight
  140671. * @param color The color of the highlight
  140672. * @param glowEmissiveOnly Extract the glow from the emissive texture
  140673. */
  140674. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  140675. /**
  140676. * Remove a mesh from the highlight layer in order to make it stop glowing.
  140677. * @param mesh The mesh to highlight
  140678. */
  140679. removeMesh(mesh: Mesh): void;
  140680. /**
  140681. * Remove all the meshes currently referenced in the highlight layer
  140682. */
  140683. removeAllMeshes(): void;
  140684. /**
  140685. * Force the stencil to the normal expected value for none glowing parts
  140686. */
  140687. private _defaultStencilReference;
  140688. /**
  140689. * Free any resources and references associated to a mesh.
  140690. * Internal use
  140691. * @param mesh The mesh to free.
  140692. * @hidden
  140693. */
  140694. _disposeMesh(mesh: Mesh): void;
  140695. /**
  140696. * Dispose the highlight layer and free resources.
  140697. */
  140698. dispose(): void;
  140699. /**
  140700. * Gets the class name of the effect layer
  140701. * @returns the string with the class name of the effect layer
  140702. */
  140703. getClassName(): string;
  140704. /**
  140705. * Serializes this Highlight layer
  140706. * @returns a serialized Highlight layer object
  140707. */
  140708. serialize(): any;
  140709. /**
  140710. * Creates a Highlight layer from parsed Highlight layer data
  140711. * @param parsedHightlightLayer defines the Highlight layer data
  140712. * @param scene defines the current scene
  140713. * @param rootUrl defines the root URL containing the Highlight layer information
  140714. * @returns a parsed Highlight layer
  140715. */
  140716. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  140717. }
  140718. }
  140719. declare module BABYLON {
  140720. interface AbstractScene {
  140721. /**
  140722. * The list of layers (background and foreground) of the scene
  140723. */
  140724. layers: Array<Layer>;
  140725. }
  140726. /**
  140727. * Defines the layer scene component responsible to manage any layers
  140728. * in a given scene.
  140729. */
  140730. export class LayerSceneComponent implements ISceneComponent {
  140731. /**
  140732. * The component name helpfull to identify the component in the list of scene components.
  140733. */
  140734. readonly name: string;
  140735. /**
  140736. * The scene the component belongs to.
  140737. */
  140738. scene: Scene;
  140739. private _engine;
  140740. /**
  140741. * Creates a new instance of the component for the given scene
  140742. * @param scene Defines the scene to register the component in
  140743. */
  140744. constructor(scene: Scene);
  140745. /**
  140746. * Registers the component in a given scene
  140747. */
  140748. register(): void;
  140749. /**
  140750. * Rebuilds the elements related to this component in case of
  140751. * context lost for instance.
  140752. */
  140753. rebuild(): void;
  140754. /**
  140755. * Disposes the component and the associated ressources.
  140756. */
  140757. dispose(): void;
  140758. private _draw;
  140759. private _drawCameraPredicate;
  140760. private _drawCameraBackground;
  140761. private _drawCameraForeground;
  140762. private _drawRenderTargetPredicate;
  140763. private _drawRenderTargetBackground;
  140764. private _drawRenderTargetForeground;
  140765. /**
  140766. * Adds all the elements from the container to the scene
  140767. * @param container the container holding the elements
  140768. */
  140769. addFromContainer(container: AbstractScene): void;
  140770. /**
  140771. * Removes all the elements in the container from the scene
  140772. * @param container contains the elements to remove
  140773. * @param dispose if the removed element should be disposed (default: false)
  140774. */
  140775. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140776. }
  140777. }
  140778. declare module BABYLON {
  140779. /** @hidden */
  140780. export var layerPixelShader: {
  140781. name: string;
  140782. shader: string;
  140783. };
  140784. }
  140785. declare module BABYLON {
  140786. /** @hidden */
  140787. export var layerVertexShader: {
  140788. name: string;
  140789. shader: string;
  140790. };
  140791. }
  140792. declare module BABYLON {
  140793. /**
  140794. * This represents a full screen 2d layer.
  140795. * This can be useful to display a picture in the background of your scene for instance.
  140796. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140797. */
  140798. export class Layer {
  140799. /**
  140800. * Define the name of the layer.
  140801. */
  140802. name: string;
  140803. /**
  140804. * Define the texture the layer should display.
  140805. */
  140806. texture: Nullable<Texture>;
  140807. /**
  140808. * Is the layer in background or foreground.
  140809. */
  140810. isBackground: boolean;
  140811. /**
  140812. * Define the color of the layer (instead of texture).
  140813. */
  140814. color: Color4;
  140815. /**
  140816. * Define the scale of the layer in order to zoom in out of the texture.
  140817. */
  140818. scale: Vector2;
  140819. /**
  140820. * Define an offset for the layer in order to shift the texture.
  140821. */
  140822. offset: Vector2;
  140823. /**
  140824. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  140825. */
  140826. alphaBlendingMode: number;
  140827. /**
  140828. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  140829. * Alpha test will not mix with the background color in case of transparency.
  140830. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  140831. */
  140832. alphaTest: boolean;
  140833. /**
  140834. * Define a mask to restrict the layer to only some of the scene cameras.
  140835. */
  140836. layerMask: number;
  140837. /**
  140838. * Define the list of render target the layer is visible into.
  140839. */
  140840. renderTargetTextures: RenderTargetTexture[];
  140841. /**
  140842. * Define if the layer is only used in renderTarget or if it also
  140843. * renders in the main frame buffer of the canvas.
  140844. */
  140845. renderOnlyInRenderTargetTextures: boolean;
  140846. private _scene;
  140847. private _vertexBuffers;
  140848. private _indexBuffer;
  140849. private _effect;
  140850. private _previousDefines;
  140851. /**
  140852. * An event triggered when the layer is disposed.
  140853. */
  140854. onDisposeObservable: Observable<Layer>;
  140855. private _onDisposeObserver;
  140856. /**
  140857. * Back compatibility with callback before the onDisposeObservable existed.
  140858. * The set callback will be triggered when the layer has been disposed.
  140859. */
  140860. set onDispose(callback: () => void);
  140861. /**
  140862. * An event triggered before rendering the scene
  140863. */
  140864. onBeforeRenderObservable: Observable<Layer>;
  140865. private _onBeforeRenderObserver;
  140866. /**
  140867. * Back compatibility with callback before the onBeforeRenderObservable existed.
  140868. * The set callback will be triggered just before rendering the layer.
  140869. */
  140870. set onBeforeRender(callback: () => void);
  140871. /**
  140872. * An event triggered after rendering the scene
  140873. */
  140874. onAfterRenderObservable: Observable<Layer>;
  140875. private _onAfterRenderObserver;
  140876. /**
  140877. * Back compatibility with callback before the onAfterRenderObservable existed.
  140878. * The set callback will be triggered just after rendering the layer.
  140879. */
  140880. set onAfterRender(callback: () => void);
  140881. /**
  140882. * Instantiates a new layer.
  140883. * This represents a full screen 2d layer.
  140884. * This can be useful to display a picture in the background of your scene for instance.
  140885. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140886. * @param name Define the name of the layer in the scene
  140887. * @param imgUrl Define the url of the texture to display in the layer
  140888. * @param scene Define the scene the layer belongs to
  140889. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  140890. * @param color Defines a color for the layer
  140891. */
  140892. constructor(
  140893. /**
  140894. * Define the name of the layer.
  140895. */
  140896. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  140897. private _createIndexBuffer;
  140898. /** @hidden */
  140899. _rebuild(): void;
  140900. /**
  140901. * Renders the layer in the scene.
  140902. */
  140903. render(): void;
  140904. /**
  140905. * Disposes and releases the associated ressources.
  140906. */
  140907. dispose(): void;
  140908. }
  140909. }
  140910. declare module BABYLON {
  140911. /** @hidden */
  140912. export var lensFlarePixelShader: {
  140913. name: string;
  140914. shader: string;
  140915. };
  140916. }
  140917. declare module BABYLON {
  140918. /** @hidden */
  140919. export var lensFlareVertexShader: {
  140920. name: string;
  140921. shader: string;
  140922. };
  140923. }
  140924. declare module BABYLON {
  140925. /**
  140926. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140927. * It is usually composed of several `lensFlare`.
  140928. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140929. */
  140930. export class LensFlareSystem {
  140931. /**
  140932. * Define the name of the lens flare system
  140933. */
  140934. name: string;
  140935. /**
  140936. * List of lens flares used in this system.
  140937. */
  140938. lensFlares: LensFlare[];
  140939. /**
  140940. * Define a limit from the border the lens flare can be visible.
  140941. */
  140942. borderLimit: number;
  140943. /**
  140944. * Define a viewport border we do not want to see the lens flare in.
  140945. */
  140946. viewportBorder: number;
  140947. /**
  140948. * Define a predicate which could limit the list of meshes able to occlude the effect.
  140949. */
  140950. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  140951. /**
  140952. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  140953. */
  140954. layerMask: number;
  140955. /**
  140956. * Define the id of the lens flare system in the scene.
  140957. * (equal to name by default)
  140958. */
  140959. id: string;
  140960. private _scene;
  140961. private _emitter;
  140962. private _vertexBuffers;
  140963. private _indexBuffer;
  140964. private _effect;
  140965. private _positionX;
  140966. private _positionY;
  140967. private _isEnabled;
  140968. /** @hidden */
  140969. static _SceneComponentInitialization: (scene: Scene) => void;
  140970. /**
  140971. * Instantiates a lens flare system.
  140972. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140973. * It is usually composed of several `lensFlare`.
  140974. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140975. * @param name Define the name of the lens flare system in the scene
  140976. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  140977. * @param scene Define the scene the lens flare system belongs to
  140978. */
  140979. constructor(
  140980. /**
  140981. * Define the name of the lens flare system
  140982. */
  140983. name: string, emitter: any, scene: Scene);
  140984. /**
  140985. * Define if the lens flare system is enabled.
  140986. */
  140987. get isEnabled(): boolean;
  140988. set isEnabled(value: boolean);
  140989. /**
  140990. * Get the scene the effects belongs to.
  140991. * @returns the scene holding the lens flare system
  140992. */
  140993. getScene(): Scene;
  140994. /**
  140995. * Get the emitter of the lens flare system.
  140996. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140997. * @returns the emitter of the lens flare system
  140998. */
  140999. getEmitter(): any;
  141000. /**
  141001. * Set the emitter of the lens flare system.
  141002. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  141003. * @param newEmitter Define the new emitter of the system
  141004. */
  141005. setEmitter(newEmitter: any): void;
  141006. /**
  141007. * Get the lens flare system emitter position.
  141008. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  141009. * @returns the position
  141010. */
  141011. getEmitterPosition(): Vector3;
  141012. /**
  141013. * @hidden
  141014. */
  141015. computeEffectivePosition(globalViewport: Viewport): boolean;
  141016. /** @hidden */
  141017. _isVisible(): boolean;
  141018. /**
  141019. * @hidden
  141020. */
  141021. render(): boolean;
  141022. /**
  141023. * Dispose and release the lens flare with its associated resources.
  141024. */
  141025. dispose(): void;
  141026. /**
  141027. * Parse a lens flare system from a JSON repressentation
  141028. * @param parsedLensFlareSystem Define the JSON to parse
  141029. * @param scene Define the scene the parsed system should be instantiated in
  141030. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  141031. * @returns the parsed system
  141032. */
  141033. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  141034. /**
  141035. * Serialize the current Lens Flare System into a JSON representation.
  141036. * @returns the serialized JSON
  141037. */
  141038. serialize(): any;
  141039. }
  141040. }
  141041. declare module BABYLON {
  141042. /**
  141043. * This represents one of the lens effect in a `lensFlareSystem`.
  141044. * It controls one of the indiviual texture used in the effect.
  141045. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141046. */
  141047. export class LensFlare {
  141048. /**
  141049. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  141050. */
  141051. size: number;
  141052. /**
  141053. * 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.
  141054. */
  141055. position: number;
  141056. /**
  141057. * Define the lens color.
  141058. */
  141059. color: Color3;
  141060. /**
  141061. * Define the lens texture.
  141062. */
  141063. texture: Nullable<Texture>;
  141064. /**
  141065. * Define the alpha mode to render this particular lens.
  141066. */
  141067. alphaMode: number;
  141068. private _system;
  141069. /**
  141070. * Creates a new Lens Flare.
  141071. * This represents one of the lens effect in a `lensFlareSystem`.
  141072. * It controls one of the indiviual texture used in the effect.
  141073. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141074. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  141075. * @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.
  141076. * @param color Define the lens color
  141077. * @param imgUrl Define the lens texture url
  141078. * @param system Define the `lensFlareSystem` this flare is part of
  141079. * @returns The newly created Lens Flare
  141080. */
  141081. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  141082. /**
  141083. * Instantiates a new Lens Flare.
  141084. * This represents one of the lens effect in a `lensFlareSystem`.
  141085. * It controls one of the indiviual texture used in the effect.
  141086. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141087. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  141088. * @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.
  141089. * @param color Define the lens color
  141090. * @param imgUrl Define the lens texture url
  141091. * @param system Define the `lensFlareSystem` this flare is part of
  141092. */
  141093. constructor(
  141094. /**
  141095. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  141096. */
  141097. size: number,
  141098. /**
  141099. * 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.
  141100. */
  141101. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  141102. /**
  141103. * Dispose and release the lens flare with its associated resources.
  141104. */
  141105. dispose(): void;
  141106. }
  141107. }
  141108. declare module BABYLON {
  141109. interface AbstractScene {
  141110. /**
  141111. * The list of lens flare system added to the scene
  141112. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141113. */
  141114. lensFlareSystems: Array<LensFlareSystem>;
  141115. /**
  141116. * Removes the given lens flare system from this scene.
  141117. * @param toRemove The lens flare system to remove
  141118. * @returns The index of the removed lens flare system
  141119. */
  141120. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  141121. /**
  141122. * Adds the given lens flare system to this scene
  141123. * @param newLensFlareSystem The lens flare system to add
  141124. */
  141125. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  141126. /**
  141127. * Gets a lens flare system using its name
  141128. * @param name defines the name to look for
  141129. * @returns the lens flare system or null if not found
  141130. */
  141131. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  141132. /**
  141133. * Gets a lens flare system using its id
  141134. * @param id defines the id to look for
  141135. * @returns the lens flare system or null if not found
  141136. */
  141137. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  141138. }
  141139. /**
  141140. * Defines the lens flare scene component responsible to manage any lens flares
  141141. * in a given scene.
  141142. */
  141143. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  141144. /**
  141145. * The component name helpfull to identify the component in the list of scene components.
  141146. */
  141147. readonly name: string;
  141148. /**
  141149. * The scene the component belongs to.
  141150. */
  141151. scene: Scene;
  141152. /**
  141153. * Creates a new instance of the component for the given scene
  141154. * @param scene Defines the scene to register the component in
  141155. */
  141156. constructor(scene: Scene);
  141157. /**
  141158. * Registers the component in a given scene
  141159. */
  141160. register(): void;
  141161. /**
  141162. * Rebuilds the elements related to this component in case of
  141163. * context lost for instance.
  141164. */
  141165. rebuild(): void;
  141166. /**
  141167. * Adds all the elements from the container to the scene
  141168. * @param container the container holding the elements
  141169. */
  141170. addFromContainer(container: AbstractScene): void;
  141171. /**
  141172. * Removes all the elements in the container from the scene
  141173. * @param container contains the elements to remove
  141174. * @param dispose if the removed element should be disposed (default: false)
  141175. */
  141176. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141177. /**
  141178. * Serializes the component data to the specified json object
  141179. * @param serializationObject The object to serialize to
  141180. */
  141181. serialize(serializationObject: any): void;
  141182. /**
  141183. * Disposes the component and the associated ressources.
  141184. */
  141185. dispose(): void;
  141186. private _draw;
  141187. }
  141188. }
  141189. declare module BABYLON {
  141190. /** @hidden */
  141191. export var depthPixelShader: {
  141192. name: string;
  141193. shader: string;
  141194. };
  141195. }
  141196. declare module BABYLON {
  141197. /** @hidden */
  141198. export var depthVertexShader: {
  141199. name: string;
  141200. shader: string;
  141201. };
  141202. }
  141203. declare module BABYLON {
  141204. /**
  141205. * This represents a depth renderer in Babylon.
  141206. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  141207. */
  141208. export class DepthRenderer {
  141209. private _scene;
  141210. private _depthMap;
  141211. private _effect;
  141212. private readonly _storeNonLinearDepth;
  141213. private readonly _clearColor;
  141214. /** Get if the depth renderer is using packed depth or not */
  141215. readonly isPacked: boolean;
  141216. private _cachedDefines;
  141217. private _camera;
  141218. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  141219. enabled: boolean;
  141220. /**
  141221. * Specifiess that the depth renderer will only be used within
  141222. * the camera it is created for.
  141223. * This can help forcing its rendering during the camera processing.
  141224. */
  141225. useOnlyInActiveCamera: boolean;
  141226. /** @hidden */
  141227. static _SceneComponentInitialization: (scene: Scene) => void;
  141228. /**
  141229. * Instantiates a depth renderer
  141230. * @param scene The scene the renderer belongs to
  141231. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  141232. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  141233. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  141234. */
  141235. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  141236. /**
  141237. * Creates the depth rendering effect and checks if the effect is ready.
  141238. * @param subMesh The submesh to be used to render the depth map of
  141239. * @param useInstances If multiple world instances should be used
  141240. * @returns if the depth renderer is ready to render the depth map
  141241. */
  141242. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141243. /**
  141244. * Gets the texture which the depth map will be written to.
  141245. * @returns The depth map texture
  141246. */
  141247. getDepthMap(): RenderTargetTexture;
  141248. /**
  141249. * Disposes of the depth renderer.
  141250. */
  141251. dispose(): void;
  141252. }
  141253. }
  141254. declare module BABYLON {
  141255. /** @hidden */
  141256. export var minmaxReduxPixelShader: {
  141257. name: string;
  141258. shader: string;
  141259. };
  141260. }
  141261. declare module BABYLON {
  141262. /**
  141263. * This class computes a min/max reduction from a texture: it means it computes the minimum
  141264. * and maximum values from all values of the texture.
  141265. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  141266. * The source values are read from the red channel of the texture.
  141267. */
  141268. export class MinMaxReducer {
  141269. /**
  141270. * Observable triggered when the computation has been performed
  141271. */
  141272. onAfterReductionPerformed: Observable<{
  141273. min: number;
  141274. max: number;
  141275. }>;
  141276. protected _camera: Camera;
  141277. protected _sourceTexture: Nullable<RenderTargetTexture>;
  141278. protected _reductionSteps: Nullable<Array<PostProcess>>;
  141279. protected _postProcessManager: PostProcessManager;
  141280. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  141281. protected _forceFullscreenViewport: boolean;
  141282. /**
  141283. * Creates a min/max reducer
  141284. * @param camera The camera to use for the post processes
  141285. */
  141286. constructor(camera: Camera);
  141287. /**
  141288. * Gets the texture used to read the values from.
  141289. */
  141290. get sourceTexture(): Nullable<RenderTargetTexture>;
  141291. /**
  141292. * Sets the source texture to read the values from.
  141293. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  141294. * because in such textures '1' value must not be taken into account to compute the maximum
  141295. * as this value is used to clear the texture.
  141296. * Note that the computation is not activated by calling this function, you must call activate() for that!
  141297. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  141298. * @param depthRedux Indicates if the texture is a depth texture or not
  141299. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  141300. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  141301. */
  141302. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  141303. /**
  141304. * Defines the refresh rate of the computation.
  141305. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  141306. */
  141307. get refreshRate(): number;
  141308. set refreshRate(value: number);
  141309. protected _activated: boolean;
  141310. /**
  141311. * Gets the activation status of the reducer
  141312. */
  141313. get activated(): boolean;
  141314. /**
  141315. * Activates the reduction computation.
  141316. * When activated, the observers registered in onAfterReductionPerformed are
  141317. * called after the compuation is performed
  141318. */
  141319. activate(): void;
  141320. /**
  141321. * Deactivates the reduction computation.
  141322. */
  141323. deactivate(): void;
  141324. /**
  141325. * Disposes the min/max reducer
  141326. * @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.
  141327. */
  141328. dispose(disposeAll?: boolean): void;
  141329. }
  141330. }
  141331. declare module BABYLON {
  141332. /**
  141333. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  141334. */
  141335. export class DepthReducer extends MinMaxReducer {
  141336. private _depthRenderer;
  141337. private _depthRendererId;
  141338. /**
  141339. * Gets the depth renderer used for the computation.
  141340. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  141341. */
  141342. get depthRenderer(): Nullable<DepthRenderer>;
  141343. /**
  141344. * Creates a depth reducer
  141345. * @param camera The camera used to render the depth texture
  141346. */
  141347. constructor(camera: Camera);
  141348. /**
  141349. * Sets the depth renderer to use to generate the depth map
  141350. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  141351. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  141352. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  141353. */
  141354. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  141355. /** @hidden */
  141356. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  141357. /**
  141358. * Activates the reduction computation.
  141359. * When activated, the observers registered in onAfterReductionPerformed are
  141360. * called after the compuation is performed
  141361. */
  141362. activate(): void;
  141363. /**
  141364. * Deactivates the reduction computation.
  141365. */
  141366. deactivate(): void;
  141367. /**
  141368. * Disposes the depth reducer
  141369. * @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.
  141370. */
  141371. dispose(disposeAll?: boolean): void;
  141372. }
  141373. }
  141374. declare module BABYLON {
  141375. /**
  141376. * A CSM implementation allowing casting shadows on large scenes.
  141377. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  141378. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  141379. */
  141380. export class CascadedShadowGenerator extends ShadowGenerator {
  141381. private static readonly frustumCornersNDCSpace;
  141382. /**
  141383. * Name of the CSM class
  141384. */
  141385. static CLASSNAME: string;
  141386. /**
  141387. * Defines the default number of cascades used by the CSM.
  141388. */
  141389. static readonly DEFAULT_CASCADES_COUNT: number;
  141390. /**
  141391. * Defines the minimum number of cascades used by the CSM.
  141392. */
  141393. static readonly MIN_CASCADES_COUNT: number;
  141394. /**
  141395. * Defines the maximum number of cascades used by the CSM.
  141396. */
  141397. static readonly MAX_CASCADES_COUNT: number;
  141398. protected _validateFilter(filter: number): number;
  141399. /**
  141400. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  141401. */
  141402. penumbraDarkness: number;
  141403. private _numCascades;
  141404. /**
  141405. * Gets or set the number of cascades used by the CSM.
  141406. */
  141407. get numCascades(): number;
  141408. set numCascades(value: number);
  141409. /**
  141410. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  141411. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  141412. */
  141413. stabilizeCascades: boolean;
  141414. private _freezeShadowCastersBoundingInfo;
  141415. private _freezeShadowCastersBoundingInfoObservable;
  141416. /**
  141417. * Enables or disables the shadow casters bounding info computation.
  141418. * If your shadow casters don't move, you can disable this feature.
  141419. * If it is enabled, the bounding box computation is done every frame.
  141420. */
  141421. get freezeShadowCastersBoundingInfo(): boolean;
  141422. set freezeShadowCastersBoundingInfo(freeze: boolean);
  141423. private _scbiMin;
  141424. private _scbiMax;
  141425. protected _computeShadowCastersBoundingInfo(): void;
  141426. protected _shadowCastersBoundingInfo: BoundingInfo;
  141427. /**
  141428. * Gets or sets the shadow casters bounding info.
  141429. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  141430. * so that the system won't overwrite the bounds you provide
  141431. */
  141432. get shadowCastersBoundingInfo(): BoundingInfo;
  141433. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  141434. protected _breaksAreDirty: boolean;
  141435. protected _minDistance: number;
  141436. protected _maxDistance: number;
  141437. /**
  141438. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  141439. *
  141440. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  141441. * If you don't know these values, simply leave them to their defaults and don't call this function.
  141442. * @param min minimal distance for the breaks (default to 0.)
  141443. * @param max maximal distance for the breaks (default to 1.)
  141444. */
  141445. setMinMaxDistance(min: number, max: number): void;
  141446. /** Gets the minimal distance used in the cascade break computation */
  141447. get minDistance(): number;
  141448. /** Gets the maximal distance used in the cascade break computation */
  141449. get maxDistance(): number;
  141450. /**
  141451. * Gets the class name of that object
  141452. * @returns "CascadedShadowGenerator"
  141453. */
  141454. getClassName(): string;
  141455. private _cascadeMinExtents;
  141456. private _cascadeMaxExtents;
  141457. /**
  141458. * Gets a cascade minimum extents
  141459. * @param cascadeIndex index of the cascade
  141460. * @returns the minimum cascade extents
  141461. */
  141462. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  141463. /**
  141464. * Gets a cascade maximum extents
  141465. * @param cascadeIndex index of the cascade
  141466. * @returns the maximum cascade extents
  141467. */
  141468. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  141469. private _cascades;
  141470. private _currentLayer;
  141471. private _viewSpaceFrustumsZ;
  141472. private _viewMatrices;
  141473. private _projectionMatrices;
  141474. private _transformMatrices;
  141475. private _transformMatricesAsArray;
  141476. private _frustumLengths;
  141477. private _lightSizeUVCorrection;
  141478. private _depthCorrection;
  141479. private _frustumCornersWorldSpace;
  141480. private _frustumCenter;
  141481. private _shadowCameraPos;
  141482. private _shadowMaxZ;
  141483. /**
  141484. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  141485. * It defaults to camera.maxZ
  141486. */
  141487. get shadowMaxZ(): number;
  141488. /**
  141489. * Sets the shadow max z distance.
  141490. */
  141491. set shadowMaxZ(value: number);
  141492. protected _debug: boolean;
  141493. /**
  141494. * Gets or sets the debug flag.
  141495. * When enabled, the cascades are materialized by different colors on the screen.
  141496. */
  141497. get debug(): boolean;
  141498. set debug(dbg: boolean);
  141499. private _depthClamp;
  141500. /**
  141501. * Gets or sets the depth clamping value.
  141502. *
  141503. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  141504. * to account for the shadow casters far away.
  141505. *
  141506. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  141507. */
  141508. get depthClamp(): boolean;
  141509. set depthClamp(value: boolean);
  141510. private _cascadeBlendPercentage;
  141511. /**
  141512. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  141513. * It defaults to 0.1 (10% blending).
  141514. */
  141515. get cascadeBlendPercentage(): number;
  141516. set cascadeBlendPercentage(value: number);
  141517. private _lambda;
  141518. /**
  141519. * Gets or set the lambda parameter.
  141520. * This parameter is used to split the camera frustum and create the cascades.
  141521. * 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.
  141522. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  141523. */
  141524. get lambda(): number;
  141525. set lambda(value: number);
  141526. /**
  141527. * Gets the view matrix corresponding to a given cascade
  141528. * @param cascadeNum cascade to retrieve the view matrix from
  141529. * @returns the cascade view matrix
  141530. */
  141531. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  141532. /**
  141533. * Gets the projection matrix corresponding to a given cascade
  141534. * @param cascadeNum cascade to retrieve the projection matrix from
  141535. * @returns the cascade projection matrix
  141536. */
  141537. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  141538. /**
  141539. * Gets the transformation matrix corresponding to a given cascade
  141540. * @param cascadeNum cascade to retrieve the transformation matrix from
  141541. * @returns the cascade transformation matrix
  141542. */
  141543. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  141544. private _depthRenderer;
  141545. /**
  141546. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  141547. *
  141548. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  141549. *
  141550. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  141551. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  141552. * @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
  141553. */
  141554. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  141555. private _depthReducer;
  141556. private _autoCalcDepthBounds;
  141557. /**
  141558. * Gets or sets the autoCalcDepthBounds property.
  141559. *
  141560. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  141561. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  141562. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  141563. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  141564. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  141565. */
  141566. get autoCalcDepthBounds(): boolean;
  141567. set autoCalcDepthBounds(value: boolean);
  141568. /**
  141569. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  141570. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  141571. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  141572. * for setting the refresh rate on the renderer yourself!
  141573. */
  141574. get autoCalcDepthBoundsRefreshRate(): number;
  141575. set autoCalcDepthBoundsRefreshRate(value: number);
  141576. /**
  141577. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  141578. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  141579. * you change the camera near/far planes!
  141580. */
  141581. splitFrustum(): void;
  141582. private _splitFrustum;
  141583. private _computeMatrices;
  141584. private _computeFrustumInWorldSpace;
  141585. private _computeCascadeFrustum;
  141586. /**
  141587. * Support test.
  141588. */
  141589. static get IsSupported(): boolean;
  141590. /** @hidden */
  141591. static _SceneComponentInitialization: (scene: Scene) => void;
  141592. /**
  141593. * Creates a Cascaded Shadow Generator object.
  141594. * A ShadowGenerator is the required tool to use the shadows.
  141595. * Each directional light casting shadows needs to use its own ShadowGenerator.
  141596. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  141597. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  141598. * @param light The directional light object generating the shadows.
  141599. * @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.
  141600. */
  141601. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  141602. protected _initializeGenerator(): void;
  141603. protected _createTargetRenderTexture(): void;
  141604. protected _initializeShadowMap(): void;
  141605. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  141606. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  141607. /**
  141608. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  141609. * @param defines Defines of the material we want to update
  141610. * @param lightIndex Index of the light in the enabled light list of the material
  141611. */
  141612. prepareDefines(defines: any, lightIndex: number): void;
  141613. /**
  141614. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  141615. * defined in the generator but impacting the effect).
  141616. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  141617. * @param effect The effect we are binfing the information for
  141618. */
  141619. bindShadowLight(lightIndex: string, effect: Effect): void;
  141620. /**
  141621. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  141622. * (eq to view projection * shadow projection matrices)
  141623. * @returns The transform matrix used to create the shadow map
  141624. */
  141625. getTransformMatrix(): Matrix;
  141626. /**
  141627. * Disposes the ShadowGenerator.
  141628. * Returns nothing.
  141629. */
  141630. dispose(): void;
  141631. /**
  141632. * Serializes the shadow generator setup to a json object.
  141633. * @returns The serialized JSON object
  141634. */
  141635. serialize(): any;
  141636. /**
  141637. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  141638. * @param parsedShadowGenerator The JSON object to parse
  141639. * @param scene The scene to create the shadow map for
  141640. * @returns The parsed shadow generator
  141641. */
  141642. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  141643. }
  141644. }
  141645. declare module BABYLON {
  141646. /**
  141647. * Defines the shadow generator component responsible to manage any shadow generators
  141648. * in a given scene.
  141649. */
  141650. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  141651. /**
  141652. * The component name helpfull to identify the component in the list of scene components.
  141653. */
  141654. readonly name: string;
  141655. /**
  141656. * The scene the component belongs to.
  141657. */
  141658. scene: Scene;
  141659. /**
  141660. * Creates a new instance of the component for the given scene
  141661. * @param scene Defines the scene to register the component in
  141662. */
  141663. constructor(scene: Scene);
  141664. /**
  141665. * Registers the component in a given scene
  141666. */
  141667. register(): void;
  141668. /**
  141669. * Rebuilds the elements related to this component in case of
  141670. * context lost for instance.
  141671. */
  141672. rebuild(): void;
  141673. /**
  141674. * Serializes the component data to the specified json object
  141675. * @param serializationObject The object to serialize to
  141676. */
  141677. serialize(serializationObject: any): void;
  141678. /**
  141679. * Adds all the elements from the container to the scene
  141680. * @param container the container holding the elements
  141681. */
  141682. addFromContainer(container: AbstractScene): void;
  141683. /**
  141684. * Removes all the elements in the container from the scene
  141685. * @param container contains the elements to remove
  141686. * @param dispose if the removed element should be disposed (default: false)
  141687. */
  141688. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141689. /**
  141690. * Rebuilds the elements related to this component in case of
  141691. * context lost for instance.
  141692. */
  141693. dispose(): void;
  141694. private _gatherRenderTargets;
  141695. }
  141696. }
  141697. declare module BABYLON {
  141698. /**
  141699. * A point light is a light defined by an unique point in world space.
  141700. * The light is emitted in every direction from this point.
  141701. * A good example of a point light is a standard light bulb.
  141702. * Documentation: https://doc.babylonjs.com/babylon101/lights
  141703. */
  141704. export class PointLight extends ShadowLight {
  141705. private _shadowAngle;
  141706. /**
  141707. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141708. * This specifies what angle the shadow will use to be created.
  141709. *
  141710. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  141711. */
  141712. get shadowAngle(): number;
  141713. /**
  141714. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141715. * This specifies what angle the shadow will use to be created.
  141716. *
  141717. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  141718. */
  141719. set shadowAngle(value: number);
  141720. /**
  141721. * Gets the direction if it has been set.
  141722. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141723. */
  141724. get direction(): Vector3;
  141725. /**
  141726. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141727. */
  141728. set direction(value: Vector3);
  141729. /**
  141730. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  141731. * A PointLight emits the light in every direction.
  141732. * It can cast shadows.
  141733. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  141734. * ```javascript
  141735. * var pointLight = new PointLight("pl", camera.position, scene);
  141736. * ```
  141737. * Documentation : https://doc.babylonjs.com/babylon101/lights
  141738. * @param name The light friendly name
  141739. * @param position The position of the point light in the scene
  141740. * @param scene The scene the lights belongs to
  141741. */
  141742. constructor(name: string, position: Vector3, scene: Scene);
  141743. /**
  141744. * Returns the string "PointLight"
  141745. * @returns the class name
  141746. */
  141747. getClassName(): string;
  141748. /**
  141749. * Returns the integer 0.
  141750. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  141751. */
  141752. getTypeID(): number;
  141753. /**
  141754. * Specifies wether or not the shadowmap should be a cube texture.
  141755. * @returns true if the shadowmap needs to be a cube texture.
  141756. */
  141757. needCube(): boolean;
  141758. /**
  141759. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  141760. * @param faceIndex The index of the face we are computed the direction to generate shadow
  141761. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  141762. */
  141763. getShadowDirection(faceIndex?: number): Vector3;
  141764. /**
  141765. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  141766. * - fov = PI / 2
  141767. * - aspect ratio : 1.0
  141768. * - z-near and far equal to the active camera minZ and maxZ.
  141769. * Returns the PointLight.
  141770. */
  141771. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  141772. protected _buildUniformLayout(): void;
  141773. /**
  141774. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  141775. * @param effect The effect to update
  141776. * @param lightIndex The index of the light in the effect to update
  141777. * @returns The point light
  141778. */
  141779. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  141780. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  141781. /**
  141782. * Prepares the list of defines specific to the light type.
  141783. * @param defines the list of defines
  141784. * @param lightIndex defines the index of the light for the effect
  141785. */
  141786. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  141787. }
  141788. }
  141789. declare module BABYLON {
  141790. /**
  141791. * Header information of HDR texture files.
  141792. */
  141793. export interface HDRInfo {
  141794. /**
  141795. * The height of the texture in pixels.
  141796. */
  141797. height: number;
  141798. /**
  141799. * The width of the texture in pixels.
  141800. */
  141801. width: number;
  141802. /**
  141803. * The index of the beginning of the data in the binary file.
  141804. */
  141805. dataPosition: number;
  141806. }
  141807. /**
  141808. * This groups tools to convert HDR texture to native colors array.
  141809. */
  141810. export class HDRTools {
  141811. private static Ldexp;
  141812. private static Rgbe2float;
  141813. private static readStringLine;
  141814. /**
  141815. * Reads header information from an RGBE texture stored in a native array.
  141816. * More information on this format are available here:
  141817. * https://en.wikipedia.org/wiki/RGBE_image_format
  141818. *
  141819. * @param uint8array The binary file stored in native array.
  141820. * @return The header information.
  141821. */
  141822. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  141823. /**
  141824. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  141825. * This RGBE texture needs to store the information as a panorama.
  141826. *
  141827. * More information on this format are available here:
  141828. * https://en.wikipedia.org/wiki/RGBE_image_format
  141829. *
  141830. * @param buffer The binary file stored in an array buffer.
  141831. * @param size The expected size of the extracted cubemap.
  141832. * @return The Cube Map information.
  141833. */
  141834. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  141835. /**
  141836. * Returns the pixels data extracted from an RGBE texture.
  141837. * This pixels will be stored left to right up to down in the R G B order in one array.
  141838. *
  141839. * More information on this format are available here:
  141840. * https://en.wikipedia.org/wiki/RGBE_image_format
  141841. *
  141842. * @param uint8array The binary file stored in an array buffer.
  141843. * @param hdrInfo The header information of the file.
  141844. * @return The pixels data in RGB right to left up to down order.
  141845. */
  141846. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  141847. private static RGBE_ReadPixels_RLE;
  141848. private static RGBE_ReadPixels_NOT_RLE;
  141849. }
  141850. }
  141851. declare module BABYLON {
  141852. /**
  141853. * Effect Render Options
  141854. */
  141855. export interface IEffectRendererOptions {
  141856. /**
  141857. * Defines the vertices positions.
  141858. */
  141859. positions?: number[];
  141860. /**
  141861. * Defines the indices.
  141862. */
  141863. indices?: number[];
  141864. }
  141865. /**
  141866. * Helper class to render one or more effects.
  141867. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  141868. */
  141869. export class EffectRenderer {
  141870. private engine;
  141871. private static _DefaultOptions;
  141872. private _vertexBuffers;
  141873. private _indexBuffer;
  141874. private _fullscreenViewport;
  141875. /**
  141876. * Creates an effect renderer
  141877. * @param engine the engine to use for rendering
  141878. * @param options defines the options of the effect renderer
  141879. */
  141880. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  141881. /**
  141882. * Sets the current viewport in normalized coordinates 0-1
  141883. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  141884. */
  141885. setViewport(viewport?: Viewport): void;
  141886. /**
  141887. * Binds the embedded attributes buffer to the effect.
  141888. * @param effect Defines the effect to bind the attributes for
  141889. */
  141890. bindBuffers(effect: Effect): void;
  141891. /**
  141892. * Sets the current effect wrapper to use during draw.
  141893. * The effect needs to be ready before calling this api.
  141894. * This also sets the default full screen position attribute.
  141895. * @param effectWrapper Defines the effect to draw with
  141896. */
  141897. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  141898. /**
  141899. * Restores engine states
  141900. */
  141901. restoreStates(): void;
  141902. /**
  141903. * Draws a full screen quad.
  141904. */
  141905. draw(): void;
  141906. private isRenderTargetTexture;
  141907. /**
  141908. * renders one or more effects to a specified texture
  141909. * @param effectWrapper the effect to renderer
  141910. * @param outputTexture texture to draw to, if null it will render to the screen.
  141911. */
  141912. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  141913. /**
  141914. * Disposes of the effect renderer
  141915. */
  141916. dispose(): void;
  141917. }
  141918. /**
  141919. * Options to create an EffectWrapper
  141920. */
  141921. interface EffectWrapperCreationOptions {
  141922. /**
  141923. * Engine to use to create the effect
  141924. */
  141925. engine: ThinEngine;
  141926. /**
  141927. * Fragment shader for the effect
  141928. */
  141929. fragmentShader: string;
  141930. /**
  141931. * Use the shader store instead of direct source code
  141932. */
  141933. useShaderStore?: boolean;
  141934. /**
  141935. * Vertex shader for the effect
  141936. */
  141937. vertexShader?: string;
  141938. /**
  141939. * Attributes to use in the shader
  141940. */
  141941. attributeNames?: Array<string>;
  141942. /**
  141943. * Uniforms to use in the shader
  141944. */
  141945. uniformNames?: Array<string>;
  141946. /**
  141947. * Texture sampler names to use in the shader
  141948. */
  141949. samplerNames?: Array<string>;
  141950. /**
  141951. * Defines to use in the shader
  141952. */
  141953. defines?: Array<string>;
  141954. /**
  141955. * Callback when effect is compiled
  141956. */
  141957. onCompiled?: Nullable<(effect: Effect) => void>;
  141958. /**
  141959. * The friendly name of the effect displayed in Spector.
  141960. */
  141961. name?: string;
  141962. }
  141963. /**
  141964. * Wraps an effect to be used for rendering
  141965. */
  141966. export class EffectWrapper {
  141967. /**
  141968. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  141969. */
  141970. onApplyObservable: Observable<{}>;
  141971. /**
  141972. * The underlying effect
  141973. */
  141974. effect: Effect;
  141975. /**
  141976. * Creates an effect to be renderer
  141977. * @param creationOptions options to create the effect
  141978. */
  141979. constructor(creationOptions: EffectWrapperCreationOptions);
  141980. /**
  141981. * Disposes of the effect wrapper
  141982. */
  141983. dispose(): void;
  141984. }
  141985. }
  141986. declare module BABYLON {
  141987. /** @hidden */
  141988. export var hdrFilteringVertexShader: {
  141989. name: string;
  141990. shader: string;
  141991. };
  141992. }
  141993. declare module BABYLON {
  141994. /** @hidden */
  141995. export var hdrFilteringPixelShader: {
  141996. name: string;
  141997. shader: string;
  141998. };
  141999. }
  142000. declare module BABYLON {
  142001. /**
  142002. * Options for texture filtering
  142003. */
  142004. interface IHDRFilteringOptions {
  142005. /**
  142006. * Scales pixel intensity for the input HDR map.
  142007. */
  142008. hdrScale?: number;
  142009. /**
  142010. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  142011. */
  142012. quality?: number;
  142013. }
  142014. /**
  142015. * Filters HDR maps to get correct renderings of PBR reflections
  142016. */
  142017. export class HDRFiltering {
  142018. private _engine;
  142019. private _effectRenderer;
  142020. private _effectWrapper;
  142021. private _lodGenerationOffset;
  142022. private _lodGenerationScale;
  142023. /**
  142024. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  142025. * you care about baking speed.
  142026. */
  142027. quality: number;
  142028. /**
  142029. * Scales pixel intensity for the input HDR map.
  142030. */
  142031. hdrScale: number;
  142032. /**
  142033. * Instantiates HDR filter for reflection maps
  142034. *
  142035. * @param engine Thin engine
  142036. * @param options Options
  142037. */
  142038. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  142039. private _createRenderTarget;
  142040. private _prefilterInternal;
  142041. private _createEffect;
  142042. /**
  142043. * Get a value indicating if the filter is ready to be used
  142044. * @param texture Texture to filter
  142045. * @returns true if the filter is ready
  142046. */
  142047. isReady(texture: BaseTexture): boolean;
  142048. /**
  142049. * Prefilters a cube texture to have mipmap levels representing roughness values.
  142050. * Prefiltering will be invoked at the end of next rendering pass.
  142051. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  142052. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  142053. * @param texture Texture to filter
  142054. * @param onFinished Callback when filtering is done
  142055. * @return Promise called when prefiltering is done
  142056. */
  142057. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  142058. }
  142059. }
  142060. declare module BABYLON {
  142061. /**
  142062. * This represents a texture coming from an HDR input.
  142063. *
  142064. * The only supported format is currently panorama picture stored in RGBE format.
  142065. * Example of such files can be found on HDRLib: http://hdrlib.com/
  142066. */
  142067. export class HDRCubeTexture extends BaseTexture {
  142068. private static _facesMapping;
  142069. private _generateHarmonics;
  142070. private _noMipmap;
  142071. private _prefilterOnLoad;
  142072. private _textureMatrix;
  142073. private _size;
  142074. private _onLoad;
  142075. private _onError;
  142076. /**
  142077. * The texture URL.
  142078. */
  142079. url: string;
  142080. protected _isBlocking: boolean;
  142081. /**
  142082. * Sets wether or not the texture is blocking during loading.
  142083. */
  142084. set isBlocking(value: boolean);
  142085. /**
  142086. * Gets wether or not the texture is blocking during loading.
  142087. */
  142088. get isBlocking(): boolean;
  142089. protected _rotationY: number;
  142090. /**
  142091. * Sets texture matrix rotation angle around Y axis in radians.
  142092. */
  142093. set rotationY(value: number);
  142094. /**
  142095. * Gets texture matrix rotation angle around Y axis radians.
  142096. */
  142097. get rotationY(): number;
  142098. /**
  142099. * Gets or sets the center of the bounding box associated with the cube texture
  142100. * It must define where the camera used to render the texture was set
  142101. */
  142102. boundingBoxPosition: Vector3;
  142103. private _boundingBoxSize;
  142104. /**
  142105. * Gets or sets the size of the bounding box associated with the cube texture
  142106. * When defined, the cubemap will switch to local mode
  142107. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  142108. * @example https://www.babylonjs-playground.com/#RNASML
  142109. */
  142110. set boundingBoxSize(value: Vector3);
  142111. get boundingBoxSize(): Vector3;
  142112. /**
  142113. * Instantiates an HDRTexture from the following parameters.
  142114. *
  142115. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  142116. * @param sceneOrEngine The scene or engine the texture will be used in
  142117. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  142118. * @param noMipmap Forces to not generate the mipmap if true
  142119. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  142120. * @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)
  142121. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  142122. */
  142123. 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>);
  142124. /**
  142125. * Get the current class name of the texture useful for serialization or dynamic coding.
  142126. * @returns "HDRCubeTexture"
  142127. */
  142128. getClassName(): string;
  142129. /**
  142130. * Occurs when the file is raw .hdr file.
  142131. */
  142132. private loadTexture;
  142133. clone(): HDRCubeTexture;
  142134. delayLoad(): void;
  142135. /**
  142136. * Get the texture reflection matrix used to rotate/transform the reflection.
  142137. * @returns the reflection matrix
  142138. */
  142139. getReflectionTextureMatrix(): Matrix;
  142140. /**
  142141. * Set the texture reflection matrix used to rotate/transform the reflection.
  142142. * @param value Define the reflection matrix to set
  142143. */
  142144. setReflectionTextureMatrix(value: Matrix): void;
  142145. /**
  142146. * Parses a JSON representation of an HDR Texture in order to create the texture
  142147. * @param parsedTexture Define the JSON representation
  142148. * @param scene Define the scene the texture should be created in
  142149. * @param rootUrl Define the root url in case we need to load relative dependencies
  142150. * @returns the newly created texture after parsing
  142151. */
  142152. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  142153. serialize(): any;
  142154. }
  142155. }
  142156. declare module BABYLON {
  142157. /**
  142158. * Class used to control physics engine
  142159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  142160. */
  142161. export class PhysicsEngine implements IPhysicsEngine {
  142162. private _physicsPlugin;
  142163. /**
  142164. * Global value used to control the smallest number supported by the simulation
  142165. */
  142166. static Epsilon: number;
  142167. private _impostors;
  142168. private _joints;
  142169. private _subTimeStep;
  142170. /**
  142171. * Gets the gravity vector used by the simulation
  142172. */
  142173. gravity: Vector3;
  142174. /**
  142175. * Factory used to create the default physics plugin.
  142176. * @returns The default physics plugin
  142177. */
  142178. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  142179. /**
  142180. * Creates a new Physics Engine
  142181. * @param gravity defines the gravity vector used by the simulation
  142182. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  142183. */
  142184. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  142185. /**
  142186. * Sets the gravity vector used by the simulation
  142187. * @param gravity defines the gravity vector to use
  142188. */
  142189. setGravity(gravity: Vector3): void;
  142190. /**
  142191. * Set the time step of the physics engine.
  142192. * Default is 1/60.
  142193. * To slow it down, enter 1/600 for example.
  142194. * To speed it up, 1/30
  142195. * @param newTimeStep defines the new timestep to apply to this world.
  142196. */
  142197. setTimeStep(newTimeStep?: number): void;
  142198. /**
  142199. * Get the time step of the physics engine.
  142200. * @returns the current time step
  142201. */
  142202. getTimeStep(): number;
  142203. /**
  142204. * Set the sub time step of the physics engine.
  142205. * Default is 0 meaning there is no sub steps
  142206. * To increase physics resolution precision, set a small value (like 1 ms)
  142207. * @param subTimeStep defines the new sub timestep used for physics resolution.
  142208. */
  142209. setSubTimeStep(subTimeStep?: number): void;
  142210. /**
  142211. * Get the sub time step of the physics engine.
  142212. * @returns the current sub time step
  142213. */
  142214. getSubTimeStep(): number;
  142215. /**
  142216. * Release all resources
  142217. */
  142218. dispose(): void;
  142219. /**
  142220. * Gets the name of the current physics plugin
  142221. * @returns the name of the plugin
  142222. */
  142223. getPhysicsPluginName(): string;
  142224. /**
  142225. * Adding a new impostor for the impostor tracking.
  142226. * This will be done by the impostor itself.
  142227. * @param impostor the impostor to add
  142228. */
  142229. addImpostor(impostor: PhysicsImpostor): void;
  142230. /**
  142231. * Remove an impostor from the engine.
  142232. * This impostor and its mesh will not longer be updated by the physics engine.
  142233. * @param impostor the impostor to remove
  142234. */
  142235. removeImpostor(impostor: PhysicsImpostor): void;
  142236. /**
  142237. * Add a joint to the physics engine
  142238. * @param mainImpostor defines the main impostor to which the joint is added.
  142239. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  142240. * @param joint defines the joint that will connect both impostors.
  142241. */
  142242. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  142243. /**
  142244. * Removes a joint from the simulation
  142245. * @param mainImpostor defines the impostor used with the joint
  142246. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  142247. * @param joint defines the joint to remove
  142248. */
  142249. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  142250. /**
  142251. * Called by the scene. No need to call it.
  142252. * @param delta defines the timespam between frames
  142253. */
  142254. _step(delta: number): void;
  142255. /**
  142256. * Gets the current plugin used to run the simulation
  142257. * @returns current plugin
  142258. */
  142259. getPhysicsPlugin(): IPhysicsEnginePlugin;
  142260. /**
  142261. * Gets the list of physic impostors
  142262. * @returns an array of PhysicsImpostor
  142263. */
  142264. getImpostors(): Array<PhysicsImpostor>;
  142265. /**
  142266. * Gets the impostor for a physics enabled object
  142267. * @param object defines the object impersonated by the impostor
  142268. * @returns the PhysicsImpostor or null if not found
  142269. */
  142270. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  142271. /**
  142272. * Gets the impostor for a physics body object
  142273. * @param body defines physics body used by the impostor
  142274. * @returns the PhysicsImpostor or null if not found
  142275. */
  142276. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  142277. /**
  142278. * Does a raycast in the physics world
  142279. * @param from when should the ray start?
  142280. * @param to when should the ray end?
  142281. * @returns PhysicsRaycastResult
  142282. */
  142283. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142284. }
  142285. }
  142286. declare module BABYLON {
  142287. /** @hidden */
  142288. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  142289. private _useDeltaForWorldStep;
  142290. world: any;
  142291. name: string;
  142292. private _physicsMaterials;
  142293. private _fixedTimeStep;
  142294. private _cannonRaycastResult;
  142295. private _raycastResult;
  142296. private _physicsBodysToRemoveAfterStep;
  142297. private _firstFrame;
  142298. BJSCANNON: any;
  142299. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  142300. setGravity(gravity: Vector3): void;
  142301. setTimeStep(timeStep: number): void;
  142302. getTimeStep(): number;
  142303. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142304. private _removeMarkedPhysicsBodiesFromWorld;
  142305. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142306. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142307. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142308. private _processChildMeshes;
  142309. removePhysicsBody(impostor: PhysicsImpostor): void;
  142310. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142311. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142312. private _addMaterial;
  142313. private _checkWithEpsilon;
  142314. private _createShape;
  142315. private _createHeightmap;
  142316. private _minus90X;
  142317. private _plus90X;
  142318. private _tmpPosition;
  142319. private _tmpDeltaPosition;
  142320. private _tmpUnityRotation;
  142321. private _updatePhysicsBodyTransformation;
  142322. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142323. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142324. isSupported(): boolean;
  142325. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142326. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142327. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142328. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142329. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142330. getBodyMass(impostor: PhysicsImpostor): number;
  142331. getBodyFriction(impostor: PhysicsImpostor): number;
  142332. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142333. getBodyRestitution(impostor: PhysicsImpostor): number;
  142334. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142335. sleepBody(impostor: PhysicsImpostor): void;
  142336. wakeUpBody(impostor: PhysicsImpostor): void;
  142337. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  142338. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  142339. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  142340. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142341. getRadius(impostor: PhysicsImpostor): number;
  142342. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142343. dispose(): void;
  142344. private _extendNamespace;
  142345. /**
  142346. * Does a raycast in the physics world
  142347. * @param from when should the ray start?
  142348. * @param to when should the ray end?
  142349. * @returns PhysicsRaycastResult
  142350. */
  142351. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142352. }
  142353. }
  142354. declare module BABYLON {
  142355. /** @hidden */
  142356. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  142357. private _useDeltaForWorldStep;
  142358. world: any;
  142359. name: string;
  142360. BJSOIMO: any;
  142361. private _raycastResult;
  142362. private _fixedTimeStep;
  142363. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  142364. setGravity(gravity: Vector3): void;
  142365. setTimeStep(timeStep: number): void;
  142366. getTimeStep(): number;
  142367. private _tmpImpostorsArray;
  142368. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142369. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142370. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142371. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142372. private _tmpPositionVector;
  142373. removePhysicsBody(impostor: PhysicsImpostor): void;
  142374. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142375. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142376. isSupported(): boolean;
  142377. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142378. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142379. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142380. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142381. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142382. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142383. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142384. getBodyMass(impostor: PhysicsImpostor): number;
  142385. getBodyFriction(impostor: PhysicsImpostor): number;
  142386. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142387. getBodyRestitution(impostor: PhysicsImpostor): number;
  142388. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142389. sleepBody(impostor: PhysicsImpostor): void;
  142390. wakeUpBody(impostor: PhysicsImpostor): void;
  142391. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  142392. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  142393. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  142394. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142395. getRadius(impostor: PhysicsImpostor): number;
  142396. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142397. dispose(): void;
  142398. /**
  142399. * Does a raycast in the physics world
  142400. * @param from when should the ray start?
  142401. * @param to when should the ray end?
  142402. * @returns PhysicsRaycastResult
  142403. */
  142404. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142405. }
  142406. }
  142407. declare module BABYLON {
  142408. /**
  142409. * AmmoJS Physics plugin
  142410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  142411. * @see https://github.com/kripken/ammo.js/
  142412. */
  142413. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  142414. private _useDeltaForWorldStep;
  142415. /**
  142416. * Reference to the Ammo library
  142417. */
  142418. bjsAMMO: any;
  142419. /**
  142420. * Created ammoJS world which physics bodies are added to
  142421. */
  142422. world: any;
  142423. /**
  142424. * Name of the plugin
  142425. */
  142426. name: string;
  142427. private _timeStep;
  142428. private _fixedTimeStep;
  142429. private _maxSteps;
  142430. private _tmpQuaternion;
  142431. private _tmpAmmoTransform;
  142432. private _tmpAmmoQuaternion;
  142433. private _tmpAmmoConcreteContactResultCallback;
  142434. private _collisionConfiguration;
  142435. private _dispatcher;
  142436. private _overlappingPairCache;
  142437. private _solver;
  142438. private _softBodySolver;
  142439. private _tmpAmmoVectorA;
  142440. private _tmpAmmoVectorB;
  142441. private _tmpAmmoVectorC;
  142442. private _tmpAmmoVectorD;
  142443. private _tmpContactCallbackResult;
  142444. private _tmpAmmoVectorRCA;
  142445. private _tmpAmmoVectorRCB;
  142446. private _raycastResult;
  142447. private _tmpContactPoint;
  142448. private static readonly DISABLE_COLLISION_FLAG;
  142449. private static readonly KINEMATIC_FLAG;
  142450. private static readonly DISABLE_DEACTIVATION_FLAG;
  142451. /**
  142452. * Initializes the ammoJS plugin
  142453. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  142454. * @param ammoInjection can be used to inject your own ammo reference
  142455. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  142456. */
  142457. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  142458. /**
  142459. * Sets the gravity of the physics world (m/(s^2))
  142460. * @param gravity Gravity to set
  142461. */
  142462. setGravity(gravity: Vector3): void;
  142463. /**
  142464. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  142465. * @param timeStep timestep to use in seconds
  142466. */
  142467. setTimeStep(timeStep: number): void;
  142468. /**
  142469. * 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)
  142470. * @param fixedTimeStep fixedTimeStep to use in seconds
  142471. */
  142472. setFixedTimeStep(fixedTimeStep: number): void;
  142473. /**
  142474. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  142475. * @param maxSteps the maximum number of steps by the physics engine per frame
  142476. */
  142477. setMaxSteps(maxSteps: number): void;
  142478. /**
  142479. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  142480. * @returns the current timestep in seconds
  142481. */
  142482. getTimeStep(): number;
  142483. /**
  142484. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  142485. */
  142486. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  142487. private _isImpostorInContact;
  142488. private _isImpostorPairInContact;
  142489. private _stepSimulation;
  142490. /**
  142491. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  142492. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  142493. * After the step the babylon meshes are set to the position of the physics imposters
  142494. * @param delta amount of time to step forward
  142495. * @param impostors array of imposters to update before/after the step
  142496. */
  142497. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142498. /**
  142499. * Update babylon mesh to match physics world object
  142500. * @param impostor imposter to match
  142501. */
  142502. private _afterSoftStep;
  142503. /**
  142504. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  142505. * @param impostor imposter to match
  142506. */
  142507. private _ropeStep;
  142508. /**
  142509. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  142510. * @param impostor imposter to match
  142511. */
  142512. private _softbodyOrClothStep;
  142513. private _tmpMatrix;
  142514. /**
  142515. * Applies an impulse on the imposter
  142516. * @param impostor imposter to apply impulse to
  142517. * @param force amount of force to be applied to the imposter
  142518. * @param contactPoint the location to apply the impulse on the imposter
  142519. */
  142520. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142521. /**
  142522. * Applies a force on the imposter
  142523. * @param impostor imposter to apply force
  142524. * @param force amount of force to be applied to the imposter
  142525. * @param contactPoint the location to apply the force on the imposter
  142526. */
  142527. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142528. /**
  142529. * Creates a physics body using the plugin
  142530. * @param impostor the imposter to create the physics body on
  142531. */
  142532. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142533. /**
  142534. * Removes the physics body from the imposter and disposes of the body's memory
  142535. * @param impostor imposter to remove the physics body from
  142536. */
  142537. removePhysicsBody(impostor: PhysicsImpostor): void;
  142538. /**
  142539. * Generates a joint
  142540. * @param impostorJoint the imposter joint to create the joint with
  142541. */
  142542. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142543. /**
  142544. * Removes a joint
  142545. * @param impostorJoint the imposter joint to remove the joint from
  142546. */
  142547. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142548. private _addMeshVerts;
  142549. /**
  142550. * Initialise the soft body vertices to match its object's (mesh) vertices
  142551. * Softbody vertices (nodes) are in world space and to match this
  142552. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  142553. * @param impostor to create the softbody for
  142554. */
  142555. private _softVertexData;
  142556. /**
  142557. * Create an impostor's soft body
  142558. * @param impostor to create the softbody for
  142559. */
  142560. private _createSoftbody;
  142561. /**
  142562. * Create cloth for an impostor
  142563. * @param impostor to create the softbody for
  142564. */
  142565. private _createCloth;
  142566. /**
  142567. * Create rope for an impostor
  142568. * @param impostor to create the softbody for
  142569. */
  142570. private _createRope;
  142571. /**
  142572. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  142573. * @param impostor to create the custom physics shape for
  142574. */
  142575. private _createCustom;
  142576. private _addHullVerts;
  142577. private _createShape;
  142578. /**
  142579. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  142580. * @param impostor imposter containing the physics body and babylon object
  142581. */
  142582. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142583. /**
  142584. * Sets the babylon object's position/rotation from the physics body's position/rotation
  142585. * @param impostor imposter containing the physics body and babylon object
  142586. * @param newPosition new position
  142587. * @param newRotation new rotation
  142588. */
  142589. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142590. /**
  142591. * If this plugin is supported
  142592. * @returns true if its supported
  142593. */
  142594. isSupported(): boolean;
  142595. /**
  142596. * Sets the linear velocity of the physics body
  142597. * @param impostor imposter to set the velocity on
  142598. * @param velocity velocity to set
  142599. */
  142600. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142601. /**
  142602. * Sets the angular velocity of the physics body
  142603. * @param impostor imposter to set the velocity on
  142604. * @param velocity velocity to set
  142605. */
  142606. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142607. /**
  142608. * gets the linear velocity
  142609. * @param impostor imposter to get linear velocity from
  142610. * @returns linear velocity
  142611. */
  142612. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142613. /**
  142614. * gets the angular velocity
  142615. * @param impostor imposter to get angular velocity from
  142616. * @returns angular velocity
  142617. */
  142618. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142619. /**
  142620. * Sets the mass of physics body
  142621. * @param impostor imposter to set the mass on
  142622. * @param mass mass to set
  142623. */
  142624. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142625. /**
  142626. * Gets the mass of the physics body
  142627. * @param impostor imposter to get the mass from
  142628. * @returns mass
  142629. */
  142630. getBodyMass(impostor: PhysicsImpostor): number;
  142631. /**
  142632. * Gets friction of the impostor
  142633. * @param impostor impostor to get friction from
  142634. * @returns friction value
  142635. */
  142636. getBodyFriction(impostor: PhysicsImpostor): number;
  142637. /**
  142638. * Sets friction of the impostor
  142639. * @param impostor impostor to set friction on
  142640. * @param friction friction value
  142641. */
  142642. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142643. /**
  142644. * Gets restitution of the impostor
  142645. * @param impostor impostor to get restitution from
  142646. * @returns restitution value
  142647. */
  142648. getBodyRestitution(impostor: PhysicsImpostor): number;
  142649. /**
  142650. * Sets resitution of the impostor
  142651. * @param impostor impostor to set resitution on
  142652. * @param restitution resitution value
  142653. */
  142654. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142655. /**
  142656. * Gets pressure inside the impostor
  142657. * @param impostor impostor to get pressure from
  142658. * @returns pressure value
  142659. */
  142660. getBodyPressure(impostor: PhysicsImpostor): number;
  142661. /**
  142662. * Sets pressure inside a soft body impostor
  142663. * Cloth and rope must remain 0 pressure
  142664. * @param impostor impostor to set pressure on
  142665. * @param pressure pressure value
  142666. */
  142667. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  142668. /**
  142669. * Gets stiffness of the impostor
  142670. * @param impostor impostor to get stiffness from
  142671. * @returns pressure value
  142672. */
  142673. getBodyStiffness(impostor: PhysicsImpostor): number;
  142674. /**
  142675. * Sets stiffness of the impostor
  142676. * @param impostor impostor to set stiffness on
  142677. * @param stiffness stiffness value from 0 to 1
  142678. */
  142679. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  142680. /**
  142681. * Gets velocityIterations of the impostor
  142682. * @param impostor impostor to get velocity iterations from
  142683. * @returns velocityIterations value
  142684. */
  142685. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  142686. /**
  142687. * Sets velocityIterations of the impostor
  142688. * @param impostor impostor to set velocity iterations on
  142689. * @param velocityIterations velocityIterations value
  142690. */
  142691. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  142692. /**
  142693. * Gets positionIterations of the impostor
  142694. * @param impostor impostor to get position iterations from
  142695. * @returns positionIterations value
  142696. */
  142697. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  142698. /**
  142699. * Sets positionIterations of the impostor
  142700. * @param impostor impostor to set position on
  142701. * @param positionIterations positionIterations value
  142702. */
  142703. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  142704. /**
  142705. * Append an anchor to a cloth object
  142706. * @param impostor is the cloth impostor to add anchor to
  142707. * @param otherImpostor is the rigid impostor to anchor to
  142708. * @param width ratio across width from 0 to 1
  142709. * @param height ratio up height from 0 to 1
  142710. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  142711. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  142712. */
  142713. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  142714. /**
  142715. * Append an hook to a rope object
  142716. * @param impostor is the rope impostor to add hook to
  142717. * @param otherImpostor is the rigid impostor to hook to
  142718. * @param length ratio along the rope from 0 to 1
  142719. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  142720. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  142721. */
  142722. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  142723. /**
  142724. * Sleeps the physics body and stops it from being active
  142725. * @param impostor impostor to sleep
  142726. */
  142727. sleepBody(impostor: PhysicsImpostor): void;
  142728. /**
  142729. * Activates the physics body
  142730. * @param impostor impostor to activate
  142731. */
  142732. wakeUpBody(impostor: PhysicsImpostor): void;
  142733. /**
  142734. * Updates the distance parameters of the joint
  142735. * @param joint joint to update
  142736. * @param maxDistance maximum distance of the joint
  142737. * @param minDistance minimum distance of the joint
  142738. */
  142739. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  142740. /**
  142741. * Sets a motor on the joint
  142742. * @param joint joint to set motor on
  142743. * @param speed speed of the motor
  142744. * @param maxForce maximum force of the motor
  142745. * @param motorIndex index of the motor
  142746. */
  142747. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  142748. /**
  142749. * Sets the motors limit
  142750. * @param joint joint to set limit on
  142751. * @param upperLimit upper limit
  142752. * @param lowerLimit lower limit
  142753. */
  142754. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  142755. /**
  142756. * Syncs the position and rotation of a mesh with the impostor
  142757. * @param mesh mesh to sync
  142758. * @param impostor impostor to update the mesh with
  142759. */
  142760. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142761. /**
  142762. * Gets the radius of the impostor
  142763. * @param impostor impostor to get radius from
  142764. * @returns the radius
  142765. */
  142766. getRadius(impostor: PhysicsImpostor): number;
  142767. /**
  142768. * Gets the box size of the impostor
  142769. * @param impostor impostor to get box size from
  142770. * @param result the resulting box size
  142771. */
  142772. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142773. /**
  142774. * Disposes of the impostor
  142775. */
  142776. dispose(): void;
  142777. /**
  142778. * Does a raycast in the physics world
  142779. * @param from when should the ray start?
  142780. * @param to when should the ray end?
  142781. * @returns PhysicsRaycastResult
  142782. */
  142783. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142784. }
  142785. }
  142786. declare module BABYLON {
  142787. interface AbstractScene {
  142788. /**
  142789. * The list of reflection probes added to the scene
  142790. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  142791. */
  142792. reflectionProbes: Array<ReflectionProbe>;
  142793. /**
  142794. * Removes the given reflection probe from this scene.
  142795. * @param toRemove The reflection probe to remove
  142796. * @returns The index of the removed reflection probe
  142797. */
  142798. removeReflectionProbe(toRemove: ReflectionProbe): number;
  142799. /**
  142800. * Adds the given reflection probe to this scene.
  142801. * @param newReflectionProbe The reflection probe to add
  142802. */
  142803. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  142804. }
  142805. /**
  142806. * Class used to generate realtime reflection / refraction cube textures
  142807. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  142808. */
  142809. export class ReflectionProbe {
  142810. /** defines the name of the probe */
  142811. name: string;
  142812. private _scene;
  142813. private _renderTargetTexture;
  142814. private _projectionMatrix;
  142815. private _viewMatrix;
  142816. private _target;
  142817. private _add;
  142818. private _attachedMesh;
  142819. private _invertYAxis;
  142820. /** Gets or sets probe position (center of the cube map) */
  142821. position: Vector3;
  142822. /**
  142823. * Creates a new reflection probe
  142824. * @param name defines the name of the probe
  142825. * @param size defines the texture resolution (for each face)
  142826. * @param scene defines the hosting scene
  142827. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  142828. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  142829. */
  142830. constructor(
  142831. /** defines the name of the probe */
  142832. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  142833. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  142834. get samples(): number;
  142835. set samples(value: number);
  142836. /** Gets or sets the refresh rate to use (on every frame by default) */
  142837. get refreshRate(): number;
  142838. set refreshRate(value: number);
  142839. /**
  142840. * Gets the hosting scene
  142841. * @returns a Scene
  142842. */
  142843. getScene(): Scene;
  142844. /** Gets the internal CubeTexture used to render to */
  142845. get cubeTexture(): RenderTargetTexture;
  142846. /** Gets the list of meshes to render */
  142847. get renderList(): Nullable<AbstractMesh[]>;
  142848. /**
  142849. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  142850. * @param mesh defines the mesh to attach to
  142851. */
  142852. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  142853. /**
  142854. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  142855. * @param renderingGroupId The rendering group id corresponding to its index
  142856. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  142857. */
  142858. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  142859. /**
  142860. * Clean all associated resources
  142861. */
  142862. dispose(): void;
  142863. /**
  142864. * Converts the reflection probe information to a readable string for debug purpose.
  142865. * @param fullDetails Supports for multiple levels of logging within scene loading
  142866. * @returns the human readable reflection probe info
  142867. */
  142868. toString(fullDetails?: boolean): string;
  142869. /**
  142870. * Get the class name of the relfection probe.
  142871. * @returns "ReflectionProbe"
  142872. */
  142873. getClassName(): string;
  142874. /**
  142875. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  142876. * @returns The JSON representation of the texture
  142877. */
  142878. serialize(): any;
  142879. /**
  142880. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  142881. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  142882. * @param scene Define the scene the parsed reflection probe should be instantiated in
  142883. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  142884. * @returns The parsed reflection probe if successful
  142885. */
  142886. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  142887. }
  142888. }
  142889. declare module BABYLON {
  142890. /** @hidden */
  142891. export var _BabylonLoaderRegistered: boolean;
  142892. /**
  142893. * Helps setting up some configuration for the babylon file loader.
  142894. */
  142895. export class BabylonFileLoaderConfiguration {
  142896. /**
  142897. * The loader does not allow injecting custom physix engine into the plugins.
  142898. * Unfortunately in ES6, we need to manually inject them into the plugin.
  142899. * So you could set this variable to your engine import to make it work.
  142900. */
  142901. static LoaderInjectedPhysicsEngine: any;
  142902. }
  142903. }
  142904. declare module BABYLON {
  142905. /**
  142906. * The Physically based simple base material of BJS.
  142907. *
  142908. * This enables better naming and convention enforcements on top of the pbrMaterial.
  142909. * It is used as the base class for both the specGloss and metalRough conventions.
  142910. */
  142911. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  142912. /**
  142913. * Number of Simultaneous lights allowed on the material.
  142914. */
  142915. maxSimultaneousLights: number;
  142916. /**
  142917. * If sets to true, disables all the lights affecting the material.
  142918. */
  142919. disableLighting: boolean;
  142920. /**
  142921. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  142922. */
  142923. environmentTexture: BaseTexture;
  142924. /**
  142925. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  142926. */
  142927. invertNormalMapX: boolean;
  142928. /**
  142929. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  142930. */
  142931. invertNormalMapY: boolean;
  142932. /**
  142933. * Normal map used in the model.
  142934. */
  142935. normalTexture: BaseTexture;
  142936. /**
  142937. * Emissivie color used to self-illuminate the model.
  142938. */
  142939. emissiveColor: Color3;
  142940. /**
  142941. * Emissivie texture used to self-illuminate the model.
  142942. */
  142943. emissiveTexture: BaseTexture;
  142944. /**
  142945. * Occlusion Channel Strenght.
  142946. */
  142947. occlusionStrength: number;
  142948. /**
  142949. * Occlusion Texture of the material (adding extra occlusion effects).
  142950. */
  142951. occlusionTexture: BaseTexture;
  142952. /**
  142953. * Defines the alpha limits in alpha test mode.
  142954. */
  142955. alphaCutOff: number;
  142956. /**
  142957. * Gets the current double sided mode.
  142958. */
  142959. get doubleSided(): boolean;
  142960. /**
  142961. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  142962. */
  142963. set doubleSided(value: boolean);
  142964. /**
  142965. * Stores the pre-calculated light information of a mesh in a texture.
  142966. */
  142967. lightmapTexture: BaseTexture;
  142968. /**
  142969. * If true, the light map contains occlusion information instead of lighting info.
  142970. */
  142971. useLightmapAsShadowmap: boolean;
  142972. /**
  142973. * Instantiates a new PBRMaterial instance.
  142974. *
  142975. * @param name The material name
  142976. * @param scene The scene the material will be use in.
  142977. */
  142978. constructor(name: string, scene: Scene);
  142979. getClassName(): string;
  142980. }
  142981. }
  142982. declare module BABYLON {
  142983. /**
  142984. * The PBR material of BJS following the metal roughness convention.
  142985. *
  142986. * This fits to the PBR convention in the GLTF definition:
  142987. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  142988. */
  142989. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  142990. /**
  142991. * The base color has two different interpretations depending on the value of metalness.
  142992. * When the material is a metal, the base color is the specific measured reflectance value
  142993. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  142994. * of the material.
  142995. */
  142996. baseColor: Color3;
  142997. /**
  142998. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  142999. * well as opacity information in the alpha channel.
  143000. */
  143001. baseTexture: BaseTexture;
  143002. /**
  143003. * Specifies the metallic scalar value of the material.
  143004. * Can also be used to scale the metalness values of the metallic texture.
  143005. */
  143006. metallic: number;
  143007. /**
  143008. * Specifies the roughness scalar value of the material.
  143009. * Can also be used to scale the roughness values of the metallic texture.
  143010. */
  143011. roughness: number;
  143012. /**
  143013. * Texture containing both the metallic value in the B channel and the
  143014. * roughness value in the G channel to keep better precision.
  143015. */
  143016. metallicRoughnessTexture: BaseTexture;
  143017. /**
  143018. * Instantiates a new PBRMetalRoughnessMaterial instance.
  143019. *
  143020. * @param name The material name
  143021. * @param scene The scene the material will be use in.
  143022. */
  143023. constructor(name: string, scene: Scene);
  143024. /**
  143025. * Return the currrent class name of the material.
  143026. */
  143027. getClassName(): string;
  143028. /**
  143029. * Makes a duplicate of the current material.
  143030. * @param name - name to use for the new material.
  143031. */
  143032. clone(name: string): PBRMetallicRoughnessMaterial;
  143033. /**
  143034. * Serialize the material to a parsable JSON object.
  143035. */
  143036. serialize(): any;
  143037. /**
  143038. * Parses a JSON object correponding to the serialize function.
  143039. */
  143040. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  143041. }
  143042. }
  143043. declare module BABYLON {
  143044. /**
  143045. * The PBR material of BJS following the specular glossiness convention.
  143046. *
  143047. * This fits to the PBR convention in the GLTF definition:
  143048. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  143049. */
  143050. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  143051. /**
  143052. * Specifies the diffuse color of the material.
  143053. */
  143054. diffuseColor: Color3;
  143055. /**
  143056. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  143057. * channel.
  143058. */
  143059. diffuseTexture: BaseTexture;
  143060. /**
  143061. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  143062. */
  143063. specularColor: Color3;
  143064. /**
  143065. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  143066. */
  143067. glossiness: number;
  143068. /**
  143069. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  143070. */
  143071. specularGlossinessTexture: BaseTexture;
  143072. /**
  143073. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  143074. *
  143075. * @param name The material name
  143076. * @param scene The scene the material will be use in.
  143077. */
  143078. constructor(name: string, scene: Scene);
  143079. /**
  143080. * Return the currrent class name of the material.
  143081. */
  143082. getClassName(): string;
  143083. /**
  143084. * Makes a duplicate of the current material.
  143085. * @param name - name to use for the new material.
  143086. */
  143087. clone(name: string): PBRSpecularGlossinessMaterial;
  143088. /**
  143089. * Serialize the material to a parsable JSON object.
  143090. */
  143091. serialize(): any;
  143092. /**
  143093. * Parses a JSON object correponding to the serialize function.
  143094. */
  143095. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  143096. }
  143097. }
  143098. declare module BABYLON {
  143099. /**
  143100. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  143101. * It can help converting any input color in a desired output one. This can then be used to create effects
  143102. * from sepia, black and white to sixties or futuristic rendering...
  143103. *
  143104. * The only supported format is currently 3dl.
  143105. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  143106. */
  143107. export class ColorGradingTexture extends BaseTexture {
  143108. /**
  143109. * The texture URL.
  143110. */
  143111. url: string;
  143112. /**
  143113. * Empty line regex stored for GC.
  143114. */
  143115. private static _noneEmptyLineRegex;
  143116. private _textureMatrix;
  143117. private _onLoad;
  143118. /**
  143119. * Instantiates a ColorGradingTexture from the following parameters.
  143120. *
  143121. * @param url The location of the color gradind data (currently only supporting 3dl)
  143122. * @param sceneOrEngine The scene or engine the texture will be used in
  143123. * @param onLoad defines a callback triggered when the texture has been loaded
  143124. */
  143125. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  143126. /**
  143127. * Fires the onload event from the constructor if requested.
  143128. */
  143129. private _triggerOnLoad;
  143130. /**
  143131. * Returns the texture matrix used in most of the material.
  143132. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  143133. */
  143134. getTextureMatrix(): Matrix;
  143135. /**
  143136. * Occurs when the file being loaded is a .3dl LUT file.
  143137. */
  143138. private load3dlTexture;
  143139. /**
  143140. * Starts the loading process of the texture.
  143141. */
  143142. private loadTexture;
  143143. /**
  143144. * Clones the color gradind texture.
  143145. */
  143146. clone(): ColorGradingTexture;
  143147. /**
  143148. * Called during delayed load for textures.
  143149. */
  143150. delayLoad(): void;
  143151. /**
  143152. * Parses a color grading texture serialized by Babylon.
  143153. * @param parsedTexture The texture information being parsedTexture
  143154. * @param scene The scene to load the texture in
  143155. * @param rootUrl The root url of the data assets to load
  143156. * @return A color gradind texture
  143157. */
  143158. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  143159. /**
  143160. * Serializes the LUT texture to json format.
  143161. */
  143162. serialize(): any;
  143163. }
  143164. }
  143165. declare module BABYLON {
  143166. /**
  143167. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  143168. */
  143169. export class EquiRectangularCubeTexture extends BaseTexture {
  143170. /** The six faces of the cube. */
  143171. private static _FacesMapping;
  143172. private _noMipmap;
  143173. private _onLoad;
  143174. private _onError;
  143175. /** The size of the cubemap. */
  143176. private _size;
  143177. /** The buffer of the image. */
  143178. private _buffer;
  143179. /** The width of the input image. */
  143180. private _width;
  143181. /** The height of the input image. */
  143182. private _height;
  143183. /** The URL to the image. */
  143184. url: string;
  143185. /**
  143186. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  143187. * @param url The location of the image
  143188. * @param scene The scene the texture will be used in
  143189. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  143190. * @param noMipmap Forces to not generate the mipmap if true
  143191. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  143192. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  143193. * @param onLoad — defines a callback called when texture is loaded
  143194. * @param onError — defines a callback called if there is an error
  143195. */
  143196. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  143197. /**
  143198. * Load the image data, by putting the image on a canvas and extracting its buffer.
  143199. */
  143200. private loadImage;
  143201. /**
  143202. * Convert the image buffer into a cubemap and create a CubeTexture.
  143203. */
  143204. private loadTexture;
  143205. /**
  143206. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  143207. * @param buffer The ArrayBuffer that should be converted.
  143208. * @returns The buffer as Float32Array.
  143209. */
  143210. private getFloat32ArrayFromArrayBuffer;
  143211. /**
  143212. * Get the current class name of the texture useful for serialization or dynamic coding.
  143213. * @returns "EquiRectangularCubeTexture"
  143214. */
  143215. getClassName(): string;
  143216. /**
  143217. * Create a clone of the current EquiRectangularCubeTexture and return it.
  143218. * @returns A clone of the current EquiRectangularCubeTexture.
  143219. */
  143220. clone(): EquiRectangularCubeTexture;
  143221. }
  143222. }
  143223. declare module BABYLON {
  143224. /**
  143225. * Defines the options related to the creation of an HtmlElementTexture
  143226. */
  143227. export interface IHtmlElementTextureOptions {
  143228. /**
  143229. * Defines wether mip maps should be created or not.
  143230. */
  143231. generateMipMaps?: boolean;
  143232. /**
  143233. * Defines the sampling mode of the texture.
  143234. */
  143235. samplingMode?: number;
  143236. /**
  143237. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  143238. */
  143239. engine: Nullable<ThinEngine>;
  143240. /**
  143241. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  143242. */
  143243. scene: Nullable<Scene>;
  143244. }
  143245. /**
  143246. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  143247. * To be as efficient as possible depending on your constraints nothing aside the first upload
  143248. * is automatically managed.
  143249. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  143250. * in your application.
  143251. *
  143252. * As the update is not automatic, you need to call them manually.
  143253. */
  143254. export class HtmlElementTexture extends BaseTexture {
  143255. /**
  143256. * The texture URL.
  143257. */
  143258. element: HTMLVideoElement | HTMLCanvasElement;
  143259. private static readonly DefaultOptions;
  143260. private _textureMatrix;
  143261. private _isVideo;
  143262. private _generateMipMaps;
  143263. private _samplingMode;
  143264. /**
  143265. * Instantiates a HtmlElementTexture from the following parameters.
  143266. *
  143267. * @param name Defines the name of the texture
  143268. * @param element Defines the video or canvas the texture is filled with
  143269. * @param options Defines the other none mandatory texture creation options
  143270. */
  143271. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  143272. private _createInternalTexture;
  143273. /**
  143274. * Returns the texture matrix used in most of the material.
  143275. */
  143276. getTextureMatrix(): Matrix;
  143277. /**
  143278. * Updates the content of the texture.
  143279. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  143280. */
  143281. update(invertY?: Nullable<boolean>): void;
  143282. }
  143283. }
  143284. declare module BABYLON {
  143285. /**
  143286. * Based on jsTGALoader - Javascript loader for TGA file
  143287. * By Vincent Thibault
  143288. * @see http://blog.robrowser.com/javascript-tga-loader.html
  143289. */
  143290. export class TGATools {
  143291. private static _TYPE_INDEXED;
  143292. private static _TYPE_RGB;
  143293. private static _TYPE_GREY;
  143294. private static _TYPE_RLE_INDEXED;
  143295. private static _TYPE_RLE_RGB;
  143296. private static _TYPE_RLE_GREY;
  143297. private static _ORIGIN_MASK;
  143298. private static _ORIGIN_SHIFT;
  143299. private static _ORIGIN_BL;
  143300. private static _ORIGIN_BR;
  143301. private static _ORIGIN_UL;
  143302. private static _ORIGIN_UR;
  143303. /**
  143304. * Gets the header of a TGA file
  143305. * @param data defines the TGA data
  143306. * @returns the header
  143307. */
  143308. static GetTGAHeader(data: Uint8Array): any;
  143309. /**
  143310. * Uploads TGA content to a Babylon Texture
  143311. * @hidden
  143312. */
  143313. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  143314. /** @hidden */
  143315. 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;
  143316. /** @hidden */
  143317. 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;
  143318. /** @hidden */
  143319. 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;
  143320. /** @hidden */
  143321. 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;
  143322. /** @hidden */
  143323. 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;
  143324. /** @hidden */
  143325. 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;
  143326. }
  143327. }
  143328. declare module BABYLON {
  143329. /**
  143330. * Implementation of the TGA Texture Loader.
  143331. * @hidden
  143332. */
  143333. export class _TGATextureLoader implements IInternalTextureLoader {
  143334. /**
  143335. * Defines wether the loader supports cascade loading the different faces.
  143336. */
  143337. readonly supportCascades: boolean;
  143338. /**
  143339. * This returns if the loader support the current file information.
  143340. * @param extension defines the file extension of the file being loaded
  143341. * @returns true if the loader can load the specified file
  143342. */
  143343. canLoad(extension: string): boolean;
  143344. /**
  143345. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  143346. * @param data contains the texture data
  143347. * @param texture defines the BabylonJS internal texture
  143348. * @param createPolynomials will be true if polynomials have been requested
  143349. * @param onLoad defines the callback to trigger once the texture is ready
  143350. * @param onError defines the callback to trigger in case of error
  143351. */
  143352. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  143353. /**
  143354. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  143355. * @param data contains the texture data
  143356. * @param texture defines the BabylonJS internal texture
  143357. * @param callback defines the method to call once ready to upload
  143358. */
  143359. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  143360. }
  143361. }
  143362. declare module BABYLON {
  143363. /**
  143364. * Info about the .basis files
  143365. */
  143366. class BasisFileInfo {
  143367. /**
  143368. * If the file has alpha
  143369. */
  143370. hasAlpha: boolean;
  143371. /**
  143372. * Info about each image of the basis file
  143373. */
  143374. images: Array<{
  143375. levels: Array<{
  143376. width: number;
  143377. height: number;
  143378. transcodedPixels: ArrayBufferView;
  143379. }>;
  143380. }>;
  143381. }
  143382. /**
  143383. * Result of transcoding a basis file
  143384. */
  143385. class TranscodeResult {
  143386. /**
  143387. * Info about the .basis file
  143388. */
  143389. fileInfo: BasisFileInfo;
  143390. /**
  143391. * Format to use when loading the file
  143392. */
  143393. format: number;
  143394. }
  143395. /**
  143396. * Configuration options for the Basis transcoder
  143397. */
  143398. export class BasisTranscodeConfiguration {
  143399. /**
  143400. * Supported compression formats used to determine the supported output format of the transcoder
  143401. */
  143402. supportedCompressionFormats?: {
  143403. /**
  143404. * etc1 compression format
  143405. */
  143406. etc1?: boolean;
  143407. /**
  143408. * s3tc compression format
  143409. */
  143410. s3tc?: boolean;
  143411. /**
  143412. * pvrtc compression format
  143413. */
  143414. pvrtc?: boolean;
  143415. /**
  143416. * etc2 compression format
  143417. */
  143418. etc2?: boolean;
  143419. };
  143420. /**
  143421. * If mipmap levels should be loaded for transcoded images (Default: true)
  143422. */
  143423. loadMipmapLevels?: boolean;
  143424. /**
  143425. * Index of a single image to load (Default: all images)
  143426. */
  143427. loadSingleImage?: number;
  143428. }
  143429. /**
  143430. * Used to load .Basis files
  143431. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  143432. */
  143433. export class BasisTools {
  143434. private static _IgnoreSupportedFormats;
  143435. /**
  143436. * URL to use when loading the basis transcoder
  143437. */
  143438. static JSModuleURL: string;
  143439. /**
  143440. * URL to use when loading the wasm module for the transcoder
  143441. */
  143442. static WasmModuleURL: string;
  143443. /**
  143444. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  143445. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  143446. * @returns internal format corresponding to the Basis format
  143447. */
  143448. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  143449. private static _WorkerPromise;
  143450. private static _Worker;
  143451. private static _actionId;
  143452. private static _CreateWorkerAsync;
  143453. /**
  143454. * Transcodes a loaded image file to compressed pixel data
  143455. * @param data image data to transcode
  143456. * @param config configuration options for the transcoding
  143457. * @returns a promise resulting in the transcoded image
  143458. */
  143459. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  143460. /**
  143461. * Loads a texture from the transcode result
  143462. * @param texture texture load to
  143463. * @param transcodeResult the result of transcoding the basis file to load from
  143464. */
  143465. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  143466. }
  143467. }
  143468. declare module BABYLON {
  143469. /**
  143470. * Loader for .basis file format
  143471. */
  143472. export class _BasisTextureLoader implements IInternalTextureLoader {
  143473. /**
  143474. * Defines whether the loader supports cascade loading the different faces.
  143475. */
  143476. readonly supportCascades: boolean;
  143477. /**
  143478. * This returns if the loader support the current file information.
  143479. * @param extension defines the file extension of the file being loaded
  143480. * @returns true if the loader can load the specified file
  143481. */
  143482. canLoad(extension: string): boolean;
  143483. /**
  143484. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  143485. * @param data contains the texture data
  143486. * @param texture defines the BabylonJS internal texture
  143487. * @param createPolynomials will be true if polynomials have been requested
  143488. * @param onLoad defines the callback to trigger once the texture is ready
  143489. * @param onError defines the callback to trigger in case of error
  143490. */
  143491. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  143492. /**
  143493. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  143494. * @param data contains the texture data
  143495. * @param texture defines the BabylonJS internal texture
  143496. * @param callback defines the method to call once ready to upload
  143497. */
  143498. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  143499. }
  143500. }
  143501. declare module BABYLON {
  143502. /**
  143503. * Defines the basic options interface of a TexturePacker Frame
  143504. */
  143505. export interface ITexturePackerFrame {
  143506. /**
  143507. * The frame ID
  143508. */
  143509. id: number;
  143510. /**
  143511. * The frames Scale
  143512. */
  143513. scale: Vector2;
  143514. /**
  143515. * The Frames offset
  143516. */
  143517. offset: Vector2;
  143518. }
  143519. /**
  143520. * This is a support class for frame Data on texture packer sets.
  143521. */
  143522. export class TexturePackerFrame implements ITexturePackerFrame {
  143523. /**
  143524. * The frame ID
  143525. */
  143526. id: number;
  143527. /**
  143528. * The frames Scale
  143529. */
  143530. scale: Vector2;
  143531. /**
  143532. * The Frames offset
  143533. */
  143534. offset: Vector2;
  143535. /**
  143536. * Initializes a texture package frame.
  143537. * @param id The numerical frame identifier
  143538. * @param scale Scalar Vector2 for UV frame
  143539. * @param offset Vector2 for the frame position in UV units.
  143540. * @returns TexturePackerFrame
  143541. */
  143542. constructor(id: number, scale: Vector2, offset: Vector2);
  143543. }
  143544. }
  143545. declare module BABYLON {
  143546. /**
  143547. * Defines the basic options interface of a TexturePacker
  143548. */
  143549. export interface ITexturePackerOptions {
  143550. /**
  143551. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  143552. */
  143553. map?: string[];
  143554. /**
  143555. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  143556. */
  143557. uvsIn?: string;
  143558. /**
  143559. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  143560. */
  143561. uvsOut?: string;
  143562. /**
  143563. * number representing the layout style. Defaults to LAYOUT_STRIP
  143564. */
  143565. layout?: number;
  143566. /**
  143567. * number of columns if using custom column count layout(2). This defaults to 4.
  143568. */
  143569. colnum?: number;
  143570. /**
  143571. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  143572. */
  143573. updateInputMeshes?: boolean;
  143574. /**
  143575. * boolean flag to dispose all the source textures. Defaults to true.
  143576. */
  143577. disposeSources?: boolean;
  143578. /**
  143579. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  143580. */
  143581. fillBlanks?: boolean;
  143582. /**
  143583. * string value representing the context fill style color. Defaults to 'black'.
  143584. */
  143585. customFillColor?: string;
  143586. /**
  143587. * Width and Height Value of each Frame in the TexturePacker Sets
  143588. */
  143589. frameSize?: number;
  143590. /**
  143591. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  143592. */
  143593. paddingRatio?: number;
  143594. /**
  143595. * Number that declares the fill method for the padding gutter.
  143596. */
  143597. paddingMode?: number;
  143598. /**
  143599. * If in SUBUV_COLOR padding mode what color to use.
  143600. */
  143601. paddingColor?: Color3 | Color4;
  143602. }
  143603. /**
  143604. * Defines the basic interface of a TexturePacker JSON File
  143605. */
  143606. export interface ITexturePackerJSON {
  143607. /**
  143608. * The frame ID
  143609. */
  143610. name: string;
  143611. /**
  143612. * The base64 channel data
  143613. */
  143614. sets: any;
  143615. /**
  143616. * The options of the Packer
  143617. */
  143618. options: ITexturePackerOptions;
  143619. /**
  143620. * The frame data of the Packer
  143621. */
  143622. frames: Array<number>;
  143623. }
  143624. /**
  143625. * This is a support class that generates a series of packed texture sets.
  143626. * @see https://doc.babylonjs.com/babylon101/materials
  143627. */
  143628. export class TexturePacker {
  143629. /** Packer Layout Constant 0 */
  143630. static readonly LAYOUT_STRIP: number;
  143631. /** Packer Layout Constant 1 */
  143632. static readonly LAYOUT_POWER2: number;
  143633. /** Packer Layout Constant 2 */
  143634. static readonly LAYOUT_COLNUM: number;
  143635. /** Packer Layout Constant 0 */
  143636. static readonly SUBUV_WRAP: number;
  143637. /** Packer Layout Constant 1 */
  143638. static readonly SUBUV_EXTEND: number;
  143639. /** Packer Layout Constant 2 */
  143640. static readonly SUBUV_COLOR: number;
  143641. /** The Name of the Texture Package */
  143642. name: string;
  143643. /** The scene scope of the TexturePacker */
  143644. scene: Scene;
  143645. /** The Meshes to target */
  143646. meshes: AbstractMesh[];
  143647. /** Arguments passed with the Constructor */
  143648. options: ITexturePackerOptions;
  143649. /** The promise that is started upon initialization */
  143650. promise: Nullable<Promise<TexturePacker | string>>;
  143651. /** The Container object for the channel sets that are generated */
  143652. sets: object;
  143653. /** The Container array for the frames that are generated */
  143654. frames: TexturePackerFrame[];
  143655. /** The expected number of textures the system is parsing. */
  143656. private _expecting;
  143657. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  143658. private _paddingValue;
  143659. /**
  143660. * Initializes a texture package series from an array of meshes or a single mesh.
  143661. * @param name The name of the package
  143662. * @param meshes The target meshes to compose the package from
  143663. * @param options The arguments that texture packer should follow while building.
  143664. * @param scene The scene which the textures are scoped to.
  143665. * @returns TexturePacker
  143666. */
  143667. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  143668. /**
  143669. * Starts the package process
  143670. * @param resolve The promises resolution function
  143671. * @returns TexturePacker
  143672. */
  143673. private _createFrames;
  143674. /**
  143675. * Calculates the Size of the Channel Sets
  143676. * @returns Vector2
  143677. */
  143678. private _calculateSize;
  143679. /**
  143680. * Calculates the UV data for the frames.
  143681. * @param baseSize the base frameSize
  143682. * @param padding the base frame padding
  143683. * @param dtSize size of the Dynamic Texture for that channel
  143684. * @param dtUnits is 1/dtSize
  143685. * @param update flag to update the input meshes
  143686. */
  143687. private _calculateMeshUVFrames;
  143688. /**
  143689. * Calculates the frames Offset.
  143690. * @param index of the frame
  143691. * @returns Vector2
  143692. */
  143693. private _getFrameOffset;
  143694. /**
  143695. * Updates a Mesh to the frame data
  143696. * @param mesh that is the target
  143697. * @param frameID or the frame index
  143698. */
  143699. private _updateMeshUV;
  143700. /**
  143701. * Updates a Meshes materials to use the texture packer channels
  143702. * @param m is the mesh to target
  143703. * @param force all channels on the packer to be set.
  143704. */
  143705. private _updateTextureReferences;
  143706. /**
  143707. * Public method to set a Mesh to a frame
  143708. * @param m that is the target
  143709. * @param frameID or the frame index
  143710. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  143711. */
  143712. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  143713. /**
  143714. * Starts the async promise to compile the texture packer.
  143715. * @returns Promise<void>
  143716. */
  143717. processAsync(): Promise<void>;
  143718. /**
  143719. * Disposes all textures associated with this packer
  143720. */
  143721. dispose(): void;
  143722. /**
  143723. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  143724. * @param imageType is the image type to use.
  143725. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  143726. */
  143727. download(imageType?: string, quality?: number): void;
  143728. /**
  143729. * Public method to load a texturePacker JSON file.
  143730. * @param data of the JSON file in string format.
  143731. */
  143732. updateFromJSON(data: string): void;
  143733. }
  143734. }
  143735. declare module BABYLON {
  143736. /**
  143737. * 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.
  143738. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  143739. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  143740. */
  143741. export class CustomProceduralTexture extends ProceduralTexture {
  143742. private _animate;
  143743. private _time;
  143744. private _config;
  143745. private _texturePath;
  143746. /**
  143747. * Instantiates a new Custom Procedural Texture.
  143748. * 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.
  143749. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  143750. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  143751. * @param name Define the name of the texture
  143752. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  143753. * @param size Define the size of the texture to create
  143754. * @param scene Define the scene the texture belongs to
  143755. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  143756. * @param generateMipMaps Define if the texture should creates mip maps or not
  143757. */
  143758. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  143759. private _loadJson;
  143760. /**
  143761. * Is the texture ready to be used ? (rendered at least once)
  143762. * @returns true if ready, otherwise, false.
  143763. */
  143764. isReady(): boolean;
  143765. /**
  143766. * Render the texture to its associated render target.
  143767. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  143768. */
  143769. render(useCameraPostProcess?: boolean): void;
  143770. /**
  143771. * Update the list of dependant textures samplers in the shader.
  143772. */
  143773. updateTextures(): void;
  143774. /**
  143775. * Update the uniform values of the procedural texture in the shader.
  143776. */
  143777. updateShaderUniforms(): void;
  143778. /**
  143779. * Define if the texture animates or not.
  143780. */
  143781. get animate(): boolean;
  143782. set animate(value: boolean);
  143783. }
  143784. }
  143785. declare module BABYLON {
  143786. /** @hidden */
  143787. export var noisePixelShader: {
  143788. name: string;
  143789. shader: string;
  143790. };
  143791. }
  143792. declare module BABYLON {
  143793. /**
  143794. * Class used to generate noise procedural textures
  143795. */
  143796. export class NoiseProceduralTexture extends ProceduralTexture {
  143797. /** Gets or sets the start time (default is 0) */
  143798. time: number;
  143799. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  143800. brightness: number;
  143801. /** Defines the number of octaves to process */
  143802. octaves: number;
  143803. /** Defines the level of persistence (0.8 by default) */
  143804. persistence: number;
  143805. /** Gets or sets animation speed factor (default is 1) */
  143806. animationSpeedFactor: number;
  143807. /**
  143808. * Creates a new NoiseProceduralTexture
  143809. * @param name defines the name fo the texture
  143810. * @param size defines the size of the texture (default is 256)
  143811. * @param scene defines the hosting scene
  143812. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  143813. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  143814. */
  143815. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  143816. private _updateShaderUniforms;
  143817. protected _getDefines(): string;
  143818. /** Generate the current state of the procedural texture */
  143819. render(useCameraPostProcess?: boolean): void;
  143820. /**
  143821. * Serializes this noise procedural texture
  143822. * @returns a serialized noise procedural texture object
  143823. */
  143824. serialize(): any;
  143825. /**
  143826. * Clone the texture.
  143827. * @returns the cloned texture
  143828. */
  143829. clone(): NoiseProceduralTexture;
  143830. /**
  143831. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  143832. * @param parsedTexture defines parsed texture data
  143833. * @param scene defines the current scene
  143834. * @param rootUrl defines the root URL containing noise procedural texture information
  143835. * @returns a parsed NoiseProceduralTexture
  143836. */
  143837. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  143838. }
  143839. }
  143840. declare module BABYLON {
  143841. /**
  143842. * Raw cube texture where the raw buffers are passed in
  143843. */
  143844. export class RawCubeTexture extends CubeTexture {
  143845. /**
  143846. * Creates a cube texture where the raw buffers are passed in.
  143847. * @param scene defines the scene the texture is attached to
  143848. * @param data defines the array of data to use to create each face
  143849. * @param size defines the size of the textures
  143850. * @param format defines the format of the data
  143851. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  143852. * @param generateMipMaps defines if the engine should generate the mip levels
  143853. * @param invertY defines if data must be stored with Y axis inverted
  143854. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  143855. * @param compression defines the compression used (null by default)
  143856. */
  143857. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  143858. /**
  143859. * Updates the raw cube texture.
  143860. * @param data defines the data to store
  143861. * @param format defines the data format
  143862. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  143863. * @param invertY defines if data must be stored with Y axis inverted
  143864. * @param compression defines the compression used (null by default)
  143865. * @param level defines which level of the texture to update
  143866. */
  143867. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  143868. /**
  143869. * Updates a raw cube texture with RGBD encoded data.
  143870. * @param data defines the array of data [mipmap][face] to use to create each face
  143871. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  143872. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  143873. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  143874. * @returns a promsie that resolves when the operation is complete
  143875. */
  143876. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  143877. /**
  143878. * Clones the raw cube texture.
  143879. * @return a new cube texture
  143880. */
  143881. clone(): CubeTexture;
  143882. /** @hidden */
  143883. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  143884. }
  143885. }
  143886. declare module BABYLON {
  143887. /**
  143888. * Class used to store 2D array textures containing user data
  143889. */
  143890. export class RawTexture2DArray extends Texture {
  143891. /** Gets or sets the texture format to use */
  143892. format: number;
  143893. /**
  143894. * Create a new RawTexture2DArray
  143895. * @param data defines the data of the texture
  143896. * @param width defines the width of the texture
  143897. * @param height defines the height of the texture
  143898. * @param depth defines the number of layers of the texture
  143899. * @param format defines the texture format to use
  143900. * @param scene defines the hosting scene
  143901. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143902. * @param invertY defines if texture must be stored with Y axis inverted
  143903. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143904. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143905. */
  143906. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143907. /** Gets or sets the texture format to use */
  143908. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143909. /**
  143910. * Update the texture with new data
  143911. * @param data defines the data to store in the texture
  143912. */
  143913. update(data: ArrayBufferView): void;
  143914. }
  143915. }
  143916. declare module BABYLON {
  143917. /**
  143918. * Class used to store 3D textures containing user data
  143919. */
  143920. export class RawTexture3D extends Texture {
  143921. /** Gets or sets the texture format to use */
  143922. format: number;
  143923. /**
  143924. * Create a new RawTexture3D
  143925. * @param data defines the data of the texture
  143926. * @param width defines the width of the texture
  143927. * @param height defines the height of the texture
  143928. * @param depth defines the depth of the texture
  143929. * @param format defines the texture format to use
  143930. * @param scene defines the hosting scene
  143931. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143932. * @param invertY defines if texture must be stored with Y axis inverted
  143933. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143934. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143935. */
  143936. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143937. /** Gets or sets the texture format to use */
  143938. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143939. /**
  143940. * Update the texture with new data
  143941. * @param data defines the data to store in the texture
  143942. */
  143943. update(data: ArrayBufferView): void;
  143944. }
  143945. }
  143946. declare module BABYLON {
  143947. /**
  143948. * Creates a refraction texture used by refraction channel of the standard material.
  143949. * It is like a mirror but to see through a material.
  143950. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143951. */
  143952. export class RefractionTexture extends RenderTargetTexture {
  143953. /**
  143954. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  143955. * 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.
  143956. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143957. */
  143958. refractionPlane: Plane;
  143959. /**
  143960. * Define how deep under the surface we should see.
  143961. */
  143962. depth: number;
  143963. /**
  143964. * Creates a refraction texture used by refraction channel of the standard material.
  143965. * It is like a mirror but to see through a material.
  143966. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143967. * @param name Define the texture name
  143968. * @param size Define the size of the underlying texture
  143969. * @param scene Define the scene the refraction belongs to
  143970. * @param generateMipMaps Define if we need to generate mips level for the refraction
  143971. */
  143972. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  143973. /**
  143974. * Clone the refraction texture.
  143975. * @returns the cloned texture
  143976. */
  143977. clone(): RefractionTexture;
  143978. /**
  143979. * Serialize the texture to a JSON representation you could use in Parse later on
  143980. * @returns the serialized JSON representation
  143981. */
  143982. serialize(): any;
  143983. }
  143984. }
  143985. declare module BABYLON {
  143986. /**
  143987. * Block used to add support for vertex skinning (bones)
  143988. */
  143989. export class BonesBlock extends NodeMaterialBlock {
  143990. /**
  143991. * Creates a new BonesBlock
  143992. * @param name defines the block name
  143993. */
  143994. constructor(name: string);
  143995. /**
  143996. * Initialize the block and prepare the context for build
  143997. * @param state defines the state that will be used for the build
  143998. */
  143999. initialize(state: NodeMaterialBuildState): void;
  144000. /**
  144001. * Gets the current class name
  144002. * @returns the class name
  144003. */
  144004. getClassName(): string;
  144005. /**
  144006. * Gets the matrix indices input component
  144007. */
  144008. get matricesIndices(): NodeMaterialConnectionPoint;
  144009. /**
  144010. * Gets the matrix weights input component
  144011. */
  144012. get matricesWeights(): NodeMaterialConnectionPoint;
  144013. /**
  144014. * Gets the extra matrix indices input component
  144015. */
  144016. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  144017. /**
  144018. * Gets the extra matrix weights input component
  144019. */
  144020. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  144021. /**
  144022. * Gets the world input component
  144023. */
  144024. get world(): NodeMaterialConnectionPoint;
  144025. /**
  144026. * Gets the output component
  144027. */
  144028. get output(): NodeMaterialConnectionPoint;
  144029. autoConfigure(material: NodeMaterial): void;
  144030. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  144031. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144032. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144033. protected _buildBlock(state: NodeMaterialBuildState): this;
  144034. }
  144035. }
  144036. declare module BABYLON {
  144037. /**
  144038. * Block used to add support for instances
  144039. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  144040. */
  144041. export class InstancesBlock extends NodeMaterialBlock {
  144042. /**
  144043. * Creates a new InstancesBlock
  144044. * @param name defines the block name
  144045. */
  144046. constructor(name: string);
  144047. /**
  144048. * Gets the current class name
  144049. * @returns the class name
  144050. */
  144051. getClassName(): string;
  144052. /**
  144053. * Gets the first world row input component
  144054. */
  144055. get world0(): NodeMaterialConnectionPoint;
  144056. /**
  144057. * Gets the second world row input component
  144058. */
  144059. get world1(): NodeMaterialConnectionPoint;
  144060. /**
  144061. * Gets the third world row input component
  144062. */
  144063. get world2(): NodeMaterialConnectionPoint;
  144064. /**
  144065. * Gets the forth world row input component
  144066. */
  144067. get world3(): NodeMaterialConnectionPoint;
  144068. /**
  144069. * Gets the world input component
  144070. */
  144071. get world(): NodeMaterialConnectionPoint;
  144072. /**
  144073. * Gets the output component
  144074. */
  144075. get output(): NodeMaterialConnectionPoint;
  144076. /**
  144077. * Gets the isntanceID component
  144078. */
  144079. get instanceID(): NodeMaterialConnectionPoint;
  144080. autoConfigure(material: NodeMaterial): void;
  144081. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  144082. protected _buildBlock(state: NodeMaterialBuildState): this;
  144083. }
  144084. }
  144085. declare module BABYLON {
  144086. /**
  144087. * Block used to add morph targets support to vertex shader
  144088. */
  144089. export class MorphTargetsBlock extends NodeMaterialBlock {
  144090. private _repeatableContentAnchor;
  144091. /**
  144092. * Create a new MorphTargetsBlock
  144093. * @param name defines the block name
  144094. */
  144095. constructor(name: string);
  144096. /**
  144097. * Gets the current class name
  144098. * @returns the class name
  144099. */
  144100. getClassName(): string;
  144101. /**
  144102. * Gets the position input component
  144103. */
  144104. get position(): NodeMaterialConnectionPoint;
  144105. /**
  144106. * Gets the normal input component
  144107. */
  144108. get normal(): NodeMaterialConnectionPoint;
  144109. /**
  144110. * Gets the tangent input component
  144111. */
  144112. get tangent(): NodeMaterialConnectionPoint;
  144113. /**
  144114. * Gets the tangent input component
  144115. */
  144116. get uv(): NodeMaterialConnectionPoint;
  144117. /**
  144118. * Gets the position output component
  144119. */
  144120. get positionOutput(): NodeMaterialConnectionPoint;
  144121. /**
  144122. * Gets the normal output component
  144123. */
  144124. get normalOutput(): NodeMaterialConnectionPoint;
  144125. /**
  144126. * Gets the tangent output component
  144127. */
  144128. get tangentOutput(): NodeMaterialConnectionPoint;
  144129. /**
  144130. * Gets the tangent output component
  144131. */
  144132. get uvOutput(): NodeMaterialConnectionPoint;
  144133. initialize(state: NodeMaterialBuildState): void;
  144134. autoConfigure(material: NodeMaterial): void;
  144135. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144136. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144137. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  144138. protected _buildBlock(state: NodeMaterialBuildState): this;
  144139. }
  144140. }
  144141. declare module BABYLON {
  144142. /**
  144143. * Block used to get data information from a light
  144144. */
  144145. export class LightInformationBlock extends NodeMaterialBlock {
  144146. private _lightDataUniformName;
  144147. private _lightColorUniformName;
  144148. private _lightTypeDefineName;
  144149. /**
  144150. * Gets or sets the light associated with this block
  144151. */
  144152. light: Nullable<Light>;
  144153. /**
  144154. * Creates a new LightInformationBlock
  144155. * @param name defines the block name
  144156. */
  144157. constructor(name: string);
  144158. /**
  144159. * Gets the current class name
  144160. * @returns the class name
  144161. */
  144162. getClassName(): string;
  144163. /**
  144164. * Gets the world position input component
  144165. */
  144166. get worldPosition(): NodeMaterialConnectionPoint;
  144167. /**
  144168. * Gets the direction output component
  144169. */
  144170. get direction(): NodeMaterialConnectionPoint;
  144171. /**
  144172. * Gets the direction output component
  144173. */
  144174. get color(): NodeMaterialConnectionPoint;
  144175. /**
  144176. * Gets the direction output component
  144177. */
  144178. get intensity(): NodeMaterialConnectionPoint;
  144179. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144180. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144181. protected _buildBlock(state: NodeMaterialBuildState): this;
  144182. serialize(): any;
  144183. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144184. }
  144185. }
  144186. declare module BABYLON {
  144187. /**
  144188. * Block used to add image processing support to fragment shader
  144189. */
  144190. export class ImageProcessingBlock extends NodeMaterialBlock {
  144191. /**
  144192. * Create a new ImageProcessingBlock
  144193. * @param name defines the block name
  144194. */
  144195. constructor(name: string);
  144196. /**
  144197. * Gets the current class name
  144198. * @returns the class name
  144199. */
  144200. getClassName(): string;
  144201. /**
  144202. * Gets the color input component
  144203. */
  144204. get color(): NodeMaterialConnectionPoint;
  144205. /**
  144206. * Gets the output component
  144207. */
  144208. get output(): NodeMaterialConnectionPoint;
  144209. /**
  144210. * Initialize the block and prepare the context for build
  144211. * @param state defines the state that will be used for the build
  144212. */
  144213. initialize(state: NodeMaterialBuildState): void;
  144214. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  144215. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144216. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144217. protected _buildBlock(state: NodeMaterialBuildState): this;
  144218. }
  144219. }
  144220. declare module BABYLON {
  144221. /**
  144222. * Block used to pertub normals based on a normal map
  144223. */
  144224. export class PerturbNormalBlock extends NodeMaterialBlock {
  144225. private _tangentSpaceParameterName;
  144226. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  144227. invertX: boolean;
  144228. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  144229. invertY: boolean;
  144230. /**
  144231. * Create a new PerturbNormalBlock
  144232. * @param name defines the block name
  144233. */
  144234. constructor(name: string);
  144235. /**
  144236. * Gets the current class name
  144237. * @returns the class name
  144238. */
  144239. getClassName(): string;
  144240. /**
  144241. * Gets the world position input component
  144242. */
  144243. get worldPosition(): NodeMaterialConnectionPoint;
  144244. /**
  144245. * Gets the world normal input component
  144246. */
  144247. get worldNormal(): NodeMaterialConnectionPoint;
  144248. /**
  144249. * Gets the world tangent input component
  144250. */
  144251. get worldTangent(): NodeMaterialConnectionPoint;
  144252. /**
  144253. * Gets the uv input component
  144254. */
  144255. get uv(): NodeMaterialConnectionPoint;
  144256. /**
  144257. * Gets the normal map color input component
  144258. */
  144259. get normalMapColor(): NodeMaterialConnectionPoint;
  144260. /**
  144261. * Gets the strength input component
  144262. */
  144263. get strength(): NodeMaterialConnectionPoint;
  144264. /**
  144265. * Gets the output component
  144266. */
  144267. get output(): NodeMaterialConnectionPoint;
  144268. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144269. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144270. autoConfigure(material: NodeMaterial): void;
  144271. protected _buildBlock(state: NodeMaterialBuildState): this;
  144272. protected _dumpPropertiesCode(): string;
  144273. serialize(): any;
  144274. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144275. }
  144276. }
  144277. declare module BABYLON {
  144278. /**
  144279. * Block used to discard a pixel if a value is smaller than a cutoff
  144280. */
  144281. export class DiscardBlock extends NodeMaterialBlock {
  144282. /**
  144283. * Create a new DiscardBlock
  144284. * @param name defines the block name
  144285. */
  144286. constructor(name: string);
  144287. /**
  144288. * Gets the current class name
  144289. * @returns the class name
  144290. */
  144291. getClassName(): string;
  144292. /**
  144293. * Gets the color input component
  144294. */
  144295. get value(): NodeMaterialConnectionPoint;
  144296. /**
  144297. * Gets the cutoff input component
  144298. */
  144299. get cutoff(): NodeMaterialConnectionPoint;
  144300. protected _buildBlock(state: NodeMaterialBuildState): this;
  144301. }
  144302. }
  144303. declare module BABYLON {
  144304. /**
  144305. * Block used to test if the fragment shader is front facing
  144306. */
  144307. export class FrontFacingBlock extends NodeMaterialBlock {
  144308. /**
  144309. * Creates a new FrontFacingBlock
  144310. * @param name defines the block name
  144311. */
  144312. constructor(name: string);
  144313. /**
  144314. * Gets the current class name
  144315. * @returns the class name
  144316. */
  144317. getClassName(): string;
  144318. /**
  144319. * Gets the output component
  144320. */
  144321. get output(): NodeMaterialConnectionPoint;
  144322. protected _buildBlock(state: NodeMaterialBuildState): this;
  144323. }
  144324. }
  144325. declare module BABYLON {
  144326. /**
  144327. * Block used to get the derivative value on x and y of a given input
  144328. */
  144329. export class DerivativeBlock extends NodeMaterialBlock {
  144330. /**
  144331. * Create a new DerivativeBlock
  144332. * @param name defines the block name
  144333. */
  144334. constructor(name: string);
  144335. /**
  144336. * Gets the current class name
  144337. * @returns the class name
  144338. */
  144339. getClassName(): string;
  144340. /**
  144341. * Gets the input component
  144342. */
  144343. get input(): NodeMaterialConnectionPoint;
  144344. /**
  144345. * Gets the derivative output on x
  144346. */
  144347. get dx(): NodeMaterialConnectionPoint;
  144348. /**
  144349. * Gets the derivative output on y
  144350. */
  144351. get dy(): NodeMaterialConnectionPoint;
  144352. protected _buildBlock(state: NodeMaterialBuildState): this;
  144353. }
  144354. }
  144355. declare module BABYLON {
  144356. /**
  144357. * Block used to make gl_FragCoord available
  144358. */
  144359. export class FragCoordBlock extends NodeMaterialBlock {
  144360. /**
  144361. * Creates a new FragCoordBlock
  144362. * @param name defines the block name
  144363. */
  144364. constructor(name: string);
  144365. /**
  144366. * Gets the current class name
  144367. * @returns the class name
  144368. */
  144369. getClassName(): string;
  144370. /**
  144371. * Gets the xy component
  144372. */
  144373. get xy(): NodeMaterialConnectionPoint;
  144374. /**
  144375. * Gets the xyz component
  144376. */
  144377. get xyz(): NodeMaterialConnectionPoint;
  144378. /**
  144379. * Gets the xyzw component
  144380. */
  144381. get xyzw(): NodeMaterialConnectionPoint;
  144382. /**
  144383. * Gets the x component
  144384. */
  144385. get x(): NodeMaterialConnectionPoint;
  144386. /**
  144387. * Gets the y component
  144388. */
  144389. get y(): NodeMaterialConnectionPoint;
  144390. /**
  144391. * Gets the z component
  144392. */
  144393. get z(): NodeMaterialConnectionPoint;
  144394. /**
  144395. * Gets the w component
  144396. */
  144397. get output(): NodeMaterialConnectionPoint;
  144398. protected writeOutputs(state: NodeMaterialBuildState): string;
  144399. protected _buildBlock(state: NodeMaterialBuildState): this;
  144400. }
  144401. }
  144402. declare module BABYLON {
  144403. /**
  144404. * Block used to get the screen sizes
  144405. */
  144406. export class ScreenSizeBlock extends NodeMaterialBlock {
  144407. private _varName;
  144408. private _scene;
  144409. /**
  144410. * Creates a new ScreenSizeBlock
  144411. * @param name defines the block name
  144412. */
  144413. constructor(name: string);
  144414. /**
  144415. * Gets the current class name
  144416. * @returns the class name
  144417. */
  144418. getClassName(): string;
  144419. /**
  144420. * Gets the xy component
  144421. */
  144422. get xy(): NodeMaterialConnectionPoint;
  144423. /**
  144424. * Gets the x component
  144425. */
  144426. get x(): NodeMaterialConnectionPoint;
  144427. /**
  144428. * Gets the y component
  144429. */
  144430. get y(): NodeMaterialConnectionPoint;
  144431. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144432. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  144433. protected _buildBlock(state: NodeMaterialBuildState): this;
  144434. }
  144435. }
  144436. declare module BABYLON {
  144437. /**
  144438. * Block used to add support for scene fog
  144439. */
  144440. export class FogBlock extends NodeMaterialBlock {
  144441. private _fogDistanceName;
  144442. private _fogParameters;
  144443. /**
  144444. * Create a new FogBlock
  144445. * @param name defines the block name
  144446. */
  144447. constructor(name: string);
  144448. /**
  144449. * Gets the current class name
  144450. * @returns the class name
  144451. */
  144452. getClassName(): string;
  144453. /**
  144454. * Gets the world position input component
  144455. */
  144456. get worldPosition(): NodeMaterialConnectionPoint;
  144457. /**
  144458. * Gets the view input component
  144459. */
  144460. get view(): NodeMaterialConnectionPoint;
  144461. /**
  144462. * Gets the color input component
  144463. */
  144464. get input(): NodeMaterialConnectionPoint;
  144465. /**
  144466. * Gets the fog color input component
  144467. */
  144468. get fogColor(): NodeMaterialConnectionPoint;
  144469. /**
  144470. * Gets the output component
  144471. */
  144472. get output(): NodeMaterialConnectionPoint;
  144473. autoConfigure(material: NodeMaterial): void;
  144474. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144475. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144476. protected _buildBlock(state: NodeMaterialBuildState): this;
  144477. }
  144478. }
  144479. declare module BABYLON {
  144480. /**
  144481. * Block used to add light in the fragment shader
  144482. */
  144483. export class LightBlock extends NodeMaterialBlock {
  144484. private _lightId;
  144485. /**
  144486. * Gets or sets the light associated with this block
  144487. */
  144488. light: Nullable<Light>;
  144489. /**
  144490. * Create a new LightBlock
  144491. * @param name defines the block name
  144492. */
  144493. constructor(name: string);
  144494. /**
  144495. * Gets the current class name
  144496. * @returns the class name
  144497. */
  144498. getClassName(): string;
  144499. /**
  144500. * Gets the world position input component
  144501. */
  144502. get worldPosition(): NodeMaterialConnectionPoint;
  144503. /**
  144504. * Gets the world normal input component
  144505. */
  144506. get worldNormal(): NodeMaterialConnectionPoint;
  144507. /**
  144508. * Gets the camera (or eye) position component
  144509. */
  144510. get cameraPosition(): NodeMaterialConnectionPoint;
  144511. /**
  144512. * Gets the glossiness component
  144513. */
  144514. get glossiness(): NodeMaterialConnectionPoint;
  144515. /**
  144516. * Gets the glossinness power component
  144517. */
  144518. get glossPower(): NodeMaterialConnectionPoint;
  144519. /**
  144520. * Gets the diffuse color component
  144521. */
  144522. get diffuseColor(): NodeMaterialConnectionPoint;
  144523. /**
  144524. * Gets the specular color component
  144525. */
  144526. get specularColor(): NodeMaterialConnectionPoint;
  144527. /**
  144528. * Gets the view matrix component
  144529. */
  144530. get view(): NodeMaterialConnectionPoint;
  144531. /**
  144532. * Gets the diffuse output component
  144533. */
  144534. get diffuseOutput(): NodeMaterialConnectionPoint;
  144535. /**
  144536. * Gets the specular output component
  144537. */
  144538. get specularOutput(): NodeMaterialConnectionPoint;
  144539. /**
  144540. * Gets the shadow output component
  144541. */
  144542. get shadow(): NodeMaterialConnectionPoint;
  144543. autoConfigure(material: NodeMaterial): void;
  144544. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144545. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  144546. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144547. private _injectVertexCode;
  144548. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144549. serialize(): any;
  144550. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144551. }
  144552. }
  144553. declare module BABYLON {
  144554. /**
  144555. * Block used to read a reflection texture from a sampler
  144556. */
  144557. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  144558. /**
  144559. * Create a new ReflectionTextureBlock
  144560. * @param name defines the block name
  144561. */
  144562. constructor(name: string);
  144563. /**
  144564. * Gets the current class name
  144565. * @returns the class name
  144566. */
  144567. getClassName(): string;
  144568. /**
  144569. * Gets the world position input component
  144570. */
  144571. get position(): NodeMaterialConnectionPoint;
  144572. /**
  144573. * Gets the world position input component
  144574. */
  144575. get worldPosition(): NodeMaterialConnectionPoint;
  144576. /**
  144577. * Gets the world normal input component
  144578. */
  144579. get worldNormal(): NodeMaterialConnectionPoint;
  144580. /**
  144581. * Gets the world input component
  144582. */
  144583. get world(): NodeMaterialConnectionPoint;
  144584. /**
  144585. * Gets the camera (or eye) position component
  144586. */
  144587. get cameraPosition(): NodeMaterialConnectionPoint;
  144588. /**
  144589. * Gets the view input component
  144590. */
  144591. get view(): NodeMaterialConnectionPoint;
  144592. /**
  144593. * Gets the rgb output component
  144594. */
  144595. get rgb(): NodeMaterialConnectionPoint;
  144596. /**
  144597. * Gets the rgba output component
  144598. */
  144599. get rgba(): NodeMaterialConnectionPoint;
  144600. /**
  144601. * Gets the r output component
  144602. */
  144603. get r(): NodeMaterialConnectionPoint;
  144604. /**
  144605. * Gets the g output component
  144606. */
  144607. get g(): NodeMaterialConnectionPoint;
  144608. /**
  144609. * Gets the b output component
  144610. */
  144611. get b(): NodeMaterialConnectionPoint;
  144612. /**
  144613. * Gets the a output component
  144614. */
  144615. get a(): NodeMaterialConnectionPoint;
  144616. autoConfigure(material: NodeMaterial): void;
  144617. protected _buildBlock(state: NodeMaterialBuildState): this;
  144618. }
  144619. }
  144620. declare module BABYLON {
  144621. /**
  144622. * Block used to add 2 vectors
  144623. */
  144624. export class AddBlock extends NodeMaterialBlock {
  144625. /**
  144626. * Creates a new AddBlock
  144627. * @param name defines the block name
  144628. */
  144629. constructor(name: string);
  144630. /**
  144631. * Gets the current class name
  144632. * @returns the class name
  144633. */
  144634. getClassName(): string;
  144635. /**
  144636. * Gets the left operand input component
  144637. */
  144638. get left(): NodeMaterialConnectionPoint;
  144639. /**
  144640. * Gets the right operand input component
  144641. */
  144642. get right(): NodeMaterialConnectionPoint;
  144643. /**
  144644. * Gets the output component
  144645. */
  144646. get output(): NodeMaterialConnectionPoint;
  144647. protected _buildBlock(state: NodeMaterialBuildState): this;
  144648. }
  144649. }
  144650. declare module BABYLON {
  144651. /**
  144652. * Block used to scale a vector by a float
  144653. */
  144654. export class ScaleBlock extends NodeMaterialBlock {
  144655. /**
  144656. * Creates a new ScaleBlock
  144657. * @param name defines the block name
  144658. */
  144659. constructor(name: string);
  144660. /**
  144661. * Gets the current class name
  144662. * @returns the class name
  144663. */
  144664. getClassName(): string;
  144665. /**
  144666. * Gets the input component
  144667. */
  144668. get input(): NodeMaterialConnectionPoint;
  144669. /**
  144670. * Gets the factor input component
  144671. */
  144672. get factor(): NodeMaterialConnectionPoint;
  144673. /**
  144674. * Gets the output component
  144675. */
  144676. get output(): NodeMaterialConnectionPoint;
  144677. protected _buildBlock(state: NodeMaterialBuildState): this;
  144678. }
  144679. }
  144680. declare module BABYLON {
  144681. /**
  144682. * Block used to clamp a float
  144683. */
  144684. export class ClampBlock extends NodeMaterialBlock {
  144685. /** Gets or sets the minimum range */
  144686. minimum: number;
  144687. /** Gets or sets the maximum range */
  144688. maximum: number;
  144689. /**
  144690. * Creates a new ClampBlock
  144691. * @param name defines the block name
  144692. */
  144693. constructor(name: string);
  144694. /**
  144695. * Gets the current class name
  144696. * @returns the class name
  144697. */
  144698. getClassName(): string;
  144699. /**
  144700. * Gets the value input component
  144701. */
  144702. get value(): NodeMaterialConnectionPoint;
  144703. /**
  144704. * Gets the output component
  144705. */
  144706. get output(): NodeMaterialConnectionPoint;
  144707. protected _buildBlock(state: NodeMaterialBuildState): this;
  144708. protected _dumpPropertiesCode(): string;
  144709. serialize(): any;
  144710. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144711. }
  144712. }
  144713. declare module BABYLON {
  144714. /**
  144715. * Block used to apply a cross product between 2 vectors
  144716. */
  144717. export class CrossBlock extends NodeMaterialBlock {
  144718. /**
  144719. * Creates a new CrossBlock
  144720. * @param name defines the block name
  144721. */
  144722. constructor(name: string);
  144723. /**
  144724. * Gets the current class name
  144725. * @returns the class name
  144726. */
  144727. getClassName(): string;
  144728. /**
  144729. * Gets the left operand input component
  144730. */
  144731. get left(): NodeMaterialConnectionPoint;
  144732. /**
  144733. * Gets the right operand input component
  144734. */
  144735. get right(): NodeMaterialConnectionPoint;
  144736. /**
  144737. * Gets the output component
  144738. */
  144739. get output(): NodeMaterialConnectionPoint;
  144740. protected _buildBlock(state: NodeMaterialBuildState): this;
  144741. }
  144742. }
  144743. declare module BABYLON {
  144744. /**
  144745. * Block used to apply a dot product between 2 vectors
  144746. */
  144747. export class DotBlock extends NodeMaterialBlock {
  144748. /**
  144749. * Creates a new DotBlock
  144750. * @param name defines the block name
  144751. */
  144752. constructor(name: string);
  144753. /**
  144754. * Gets the current class name
  144755. * @returns the class name
  144756. */
  144757. getClassName(): string;
  144758. /**
  144759. * Gets the left operand input component
  144760. */
  144761. get left(): NodeMaterialConnectionPoint;
  144762. /**
  144763. * Gets the right operand input component
  144764. */
  144765. get right(): NodeMaterialConnectionPoint;
  144766. /**
  144767. * Gets the output component
  144768. */
  144769. get output(): NodeMaterialConnectionPoint;
  144770. protected _buildBlock(state: NodeMaterialBuildState): this;
  144771. }
  144772. }
  144773. declare module BABYLON {
  144774. /**
  144775. * Block used to normalize a vector
  144776. */
  144777. export class NormalizeBlock extends NodeMaterialBlock {
  144778. /**
  144779. * Creates a new NormalizeBlock
  144780. * @param name defines the block name
  144781. */
  144782. constructor(name: string);
  144783. /**
  144784. * Gets the current class name
  144785. * @returns the class name
  144786. */
  144787. getClassName(): string;
  144788. /**
  144789. * Gets the input component
  144790. */
  144791. get input(): NodeMaterialConnectionPoint;
  144792. /**
  144793. * Gets the output component
  144794. */
  144795. get output(): NodeMaterialConnectionPoint;
  144796. protected _buildBlock(state: NodeMaterialBuildState): this;
  144797. }
  144798. }
  144799. declare module BABYLON {
  144800. /**
  144801. * Block used to create a Color3/4 out of individual inputs (one for each component)
  144802. */
  144803. export class ColorMergerBlock extends NodeMaterialBlock {
  144804. /**
  144805. * Create a new ColorMergerBlock
  144806. * @param name defines the block name
  144807. */
  144808. constructor(name: string);
  144809. /**
  144810. * Gets the current class name
  144811. * @returns the class name
  144812. */
  144813. getClassName(): string;
  144814. /**
  144815. * Gets the rgb component (input)
  144816. */
  144817. get rgbIn(): NodeMaterialConnectionPoint;
  144818. /**
  144819. * Gets the r component (input)
  144820. */
  144821. get r(): NodeMaterialConnectionPoint;
  144822. /**
  144823. * Gets the g component (input)
  144824. */
  144825. get g(): NodeMaterialConnectionPoint;
  144826. /**
  144827. * Gets the b component (input)
  144828. */
  144829. get b(): NodeMaterialConnectionPoint;
  144830. /**
  144831. * Gets the a component (input)
  144832. */
  144833. get a(): NodeMaterialConnectionPoint;
  144834. /**
  144835. * Gets the rgba component (output)
  144836. */
  144837. get rgba(): NodeMaterialConnectionPoint;
  144838. /**
  144839. * Gets the rgb component (output)
  144840. */
  144841. get rgbOut(): NodeMaterialConnectionPoint;
  144842. /**
  144843. * Gets the rgb component (output)
  144844. * @deprecated Please use rgbOut instead.
  144845. */
  144846. get rgb(): NodeMaterialConnectionPoint;
  144847. protected _buildBlock(state: NodeMaterialBuildState): this;
  144848. }
  144849. }
  144850. declare module BABYLON {
  144851. /**
  144852. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  144853. */
  144854. export class VectorSplitterBlock extends NodeMaterialBlock {
  144855. /**
  144856. * Create a new VectorSplitterBlock
  144857. * @param name defines the block name
  144858. */
  144859. constructor(name: string);
  144860. /**
  144861. * Gets the current class name
  144862. * @returns the class name
  144863. */
  144864. getClassName(): string;
  144865. /**
  144866. * Gets the xyzw component (input)
  144867. */
  144868. get xyzw(): NodeMaterialConnectionPoint;
  144869. /**
  144870. * Gets the xyz component (input)
  144871. */
  144872. get xyzIn(): NodeMaterialConnectionPoint;
  144873. /**
  144874. * Gets the xy component (input)
  144875. */
  144876. get xyIn(): NodeMaterialConnectionPoint;
  144877. /**
  144878. * Gets the xyz component (output)
  144879. */
  144880. get xyzOut(): NodeMaterialConnectionPoint;
  144881. /**
  144882. * Gets the xy component (output)
  144883. */
  144884. get xyOut(): NodeMaterialConnectionPoint;
  144885. /**
  144886. * Gets the x component (output)
  144887. */
  144888. get x(): NodeMaterialConnectionPoint;
  144889. /**
  144890. * Gets the y component (output)
  144891. */
  144892. get y(): NodeMaterialConnectionPoint;
  144893. /**
  144894. * Gets the z component (output)
  144895. */
  144896. get z(): NodeMaterialConnectionPoint;
  144897. /**
  144898. * Gets the w component (output)
  144899. */
  144900. get w(): NodeMaterialConnectionPoint;
  144901. protected _inputRename(name: string): string;
  144902. protected _outputRename(name: string): string;
  144903. protected _buildBlock(state: NodeMaterialBuildState): this;
  144904. }
  144905. }
  144906. declare module BABYLON {
  144907. /**
  144908. * Block used to lerp between 2 values
  144909. */
  144910. export class LerpBlock extends NodeMaterialBlock {
  144911. /**
  144912. * Creates a new LerpBlock
  144913. * @param name defines the block name
  144914. */
  144915. constructor(name: string);
  144916. /**
  144917. * Gets the current class name
  144918. * @returns the class name
  144919. */
  144920. getClassName(): string;
  144921. /**
  144922. * Gets the left operand input component
  144923. */
  144924. get left(): NodeMaterialConnectionPoint;
  144925. /**
  144926. * Gets the right operand input component
  144927. */
  144928. get right(): NodeMaterialConnectionPoint;
  144929. /**
  144930. * Gets the gradient operand input component
  144931. */
  144932. get gradient(): NodeMaterialConnectionPoint;
  144933. /**
  144934. * Gets the output component
  144935. */
  144936. get output(): NodeMaterialConnectionPoint;
  144937. protected _buildBlock(state: NodeMaterialBuildState): this;
  144938. }
  144939. }
  144940. declare module BABYLON {
  144941. /**
  144942. * Block used to divide 2 vectors
  144943. */
  144944. export class DivideBlock extends NodeMaterialBlock {
  144945. /**
  144946. * Creates a new DivideBlock
  144947. * @param name defines the block name
  144948. */
  144949. constructor(name: string);
  144950. /**
  144951. * Gets the current class name
  144952. * @returns the class name
  144953. */
  144954. getClassName(): string;
  144955. /**
  144956. * Gets the left operand input component
  144957. */
  144958. get left(): NodeMaterialConnectionPoint;
  144959. /**
  144960. * Gets the right operand input component
  144961. */
  144962. get right(): NodeMaterialConnectionPoint;
  144963. /**
  144964. * Gets the output component
  144965. */
  144966. get output(): NodeMaterialConnectionPoint;
  144967. protected _buildBlock(state: NodeMaterialBuildState): this;
  144968. }
  144969. }
  144970. declare module BABYLON {
  144971. /**
  144972. * Block used to subtract 2 vectors
  144973. */
  144974. export class SubtractBlock extends NodeMaterialBlock {
  144975. /**
  144976. * Creates a new SubtractBlock
  144977. * @param name defines the block name
  144978. */
  144979. constructor(name: string);
  144980. /**
  144981. * Gets the current class name
  144982. * @returns the class name
  144983. */
  144984. getClassName(): string;
  144985. /**
  144986. * Gets the left operand input component
  144987. */
  144988. get left(): NodeMaterialConnectionPoint;
  144989. /**
  144990. * Gets the right operand input component
  144991. */
  144992. get right(): NodeMaterialConnectionPoint;
  144993. /**
  144994. * Gets the output component
  144995. */
  144996. get output(): NodeMaterialConnectionPoint;
  144997. protected _buildBlock(state: NodeMaterialBuildState): this;
  144998. }
  144999. }
  145000. declare module BABYLON {
  145001. /**
  145002. * Block used to step a value
  145003. */
  145004. export class StepBlock extends NodeMaterialBlock {
  145005. /**
  145006. * Creates a new StepBlock
  145007. * @param name defines the block name
  145008. */
  145009. constructor(name: string);
  145010. /**
  145011. * Gets the current class name
  145012. * @returns the class name
  145013. */
  145014. getClassName(): string;
  145015. /**
  145016. * Gets the value operand input component
  145017. */
  145018. get value(): NodeMaterialConnectionPoint;
  145019. /**
  145020. * Gets the edge operand input component
  145021. */
  145022. get edge(): NodeMaterialConnectionPoint;
  145023. /**
  145024. * Gets the output component
  145025. */
  145026. get output(): NodeMaterialConnectionPoint;
  145027. protected _buildBlock(state: NodeMaterialBuildState): this;
  145028. }
  145029. }
  145030. declare module BABYLON {
  145031. /**
  145032. * Block used to get the opposite (1 - x) of a value
  145033. */
  145034. export class OneMinusBlock extends NodeMaterialBlock {
  145035. /**
  145036. * Creates a new OneMinusBlock
  145037. * @param name defines the block name
  145038. */
  145039. constructor(name: string);
  145040. /**
  145041. * Gets the current class name
  145042. * @returns the class name
  145043. */
  145044. getClassName(): string;
  145045. /**
  145046. * Gets the input component
  145047. */
  145048. get input(): NodeMaterialConnectionPoint;
  145049. /**
  145050. * Gets the output component
  145051. */
  145052. get output(): NodeMaterialConnectionPoint;
  145053. protected _buildBlock(state: NodeMaterialBuildState): this;
  145054. }
  145055. }
  145056. declare module BABYLON {
  145057. /**
  145058. * Block used to get the view direction
  145059. */
  145060. export class ViewDirectionBlock extends NodeMaterialBlock {
  145061. /**
  145062. * Creates a new ViewDirectionBlock
  145063. * @param name defines the block name
  145064. */
  145065. constructor(name: string);
  145066. /**
  145067. * Gets the current class name
  145068. * @returns the class name
  145069. */
  145070. getClassName(): string;
  145071. /**
  145072. * Gets the world position component
  145073. */
  145074. get worldPosition(): NodeMaterialConnectionPoint;
  145075. /**
  145076. * Gets the camera position component
  145077. */
  145078. get cameraPosition(): NodeMaterialConnectionPoint;
  145079. /**
  145080. * Gets the output component
  145081. */
  145082. get output(): NodeMaterialConnectionPoint;
  145083. autoConfigure(material: NodeMaterial): void;
  145084. protected _buildBlock(state: NodeMaterialBuildState): this;
  145085. }
  145086. }
  145087. declare module BABYLON {
  145088. /**
  145089. * Block used to compute fresnel value
  145090. */
  145091. export class FresnelBlock extends NodeMaterialBlock {
  145092. /**
  145093. * Create a new FresnelBlock
  145094. * @param name defines the block name
  145095. */
  145096. constructor(name: string);
  145097. /**
  145098. * Gets the current class name
  145099. * @returns the class name
  145100. */
  145101. getClassName(): string;
  145102. /**
  145103. * Gets the world normal input component
  145104. */
  145105. get worldNormal(): NodeMaterialConnectionPoint;
  145106. /**
  145107. * Gets the view direction input component
  145108. */
  145109. get viewDirection(): NodeMaterialConnectionPoint;
  145110. /**
  145111. * Gets the bias input component
  145112. */
  145113. get bias(): NodeMaterialConnectionPoint;
  145114. /**
  145115. * Gets the camera (or eye) position component
  145116. */
  145117. get power(): NodeMaterialConnectionPoint;
  145118. /**
  145119. * Gets the fresnel output component
  145120. */
  145121. get fresnel(): NodeMaterialConnectionPoint;
  145122. autoConfigure(material: NodeMaterial): void;
  145123. protected _buildBlock(state: NodeMaterialBuildState): this;
  145124. }
  145125. }
  145126. declare module BABYLON {
  145127. /**
  145128. * Block used to get the max of 2 values
  145129. */
  145130. export class MaxBlock extends NodeMaterialBlock {
  145131. /**
  145132. * Creates a new MaxBlock
  145133. * @param name defines the block name
  145134. */
  145135. constructor(name: string);
  145136. /**
  145137. * Gets the current class name
  145138. * @returns the class name
  145139. */
  145140. getClassName(): string;
  145141. /**
  145142. * Gets the left operand input component
  145143. */
  145144. get left(): NodeMaterialConnectionPoint;
  145145. /**
  145146. * Gets the right operand input component
  145147. */
  145148. get right(): NodeMaterialConnectionPoint;
  145149. /**
  145150. * Gets the output component
  145151. */
  145152. get output(): NodeMaterialConnectionPoint;
  145153. protected _buildBlock(state: NodeMaterialBuildState): this;
  145154. }
  145155. }
  145156. declare module BABYLON {
  145157. /**
  145158. * Block used to get the min of 2 values
  145159. */
  145160. export class MinBlock extends NodeMaterialBlock {
  145161. /**
  145162. * Creates a new MinBlock
  145163. * @param name defines the block name
  145164. */
  145165. constructor(name: string);
  145166. /**
  145167. * Gets the current class name
  145168. * @returns the class name
  145169. */
  145170. getClassName(): string;
  145171. /**
  145172. * Gets the left operand input component
  145173. */
  145174. get left(): NodeMaterialConnectionPoint;
  145175. /**
  145176. * Gets the right operand input component
  145177. */
  145178. get right(): NodeMaterialConnectionPoint;
  145179. /**
  145180. * Gets the output component
  145181. */
  145182. get output(): NodeMaterialConnectionPoint;
  145183. protected _buildBlock(state: NodeMaterialBuildState): this;
  145184. }
  145185. }
  145186. declare module BABYLON {
  145187. /**
  145188. * Block used to get the distance between 2 values
  145189. */
  145190. export class DistanceBlock extends NodeMaterialBlock {
  145191. /**
  145192. * Creates a new DistanceBlock
  145193. * @param name defines the block name
  145194. */
  145195. constructor(name: string);
  145196. /**
  145197. * Gets the current class name
  145198. * @returns the class name
  145199. */
  145200. getClassName(): string;
  145201. /**
  145202. * Gets the left operand input component
  145203. */
  145204. get left(): NodeMaterialConnectionPoint;
  145205. /**
  145206. * Gets the right operand input component
  145207. */
  145208. get right(): NodeMaterialConnectionPoint;
  145209. /**
  145210. * Gets the output component
  145211. */
  145212. get output(): NodeMaterialConnectionPoint;
  145213. protected _buildBlock(state: NodeMaterialBuildState): this;
  145214. }
  145215. }
  145216. declare module BABYLON {
  145217. /**
  145218. * Block used to get the length of a vector
  145219. */
  145220. export class LengthBlock extends NodeMaterialBlock {
  145221. /**
  145222. * Creates a new LengthBlock
  145223. * @param name defines the block name
  145224. */
  145225. constructor(name: string);
  145226. /**
  145227. * Gets the current class name
  145228. * @returns the class name
  145229. */
  145230. getClassName(): string;
  145231. /**
  145232. * Gets the value input component
  145233. */
  145234. get value(): NodeMaterialConnectionPoint;
  145235. /**
  145236. * Gets the output component
  145237. */
  145238. get output(): NodeMaterialConnectionPoint;
  145239. protected _buildBlock(state: NodeMaterialBuildState): this;
  145240. }
  145241. }
  145242. declare module BABYLON {
  145243. /**
  145244. * Block used to get negative version of a value (i.e. x * -1)
  145245. */
  145246. export class NegateBlock extends NodeMaterialBlock {
  145247. /**
  145248. * Creates a new NegateBlock
  145249. * @param name defines the block name
  145250. */
  145251. constructor(name: string);
  145252. /**
  145253. * Gets the current class name
  145254. * @returns the class name
  145255. */
  145256. getClassName(): string;
  145257. /**
  145258. * Gets the value input component
  145259. */
  145260. get value(): NodeMaterialConnectionPoint;
  145261. /**
  145262. * Gets the output component
  145263. */
  145264. get output(): NodeMaterialConnectionPoint;
  145265. protected _buildBlock(state: NodeMaterialBuildState): this;
  145266. }
  145267. }
  145268. declare module BABYLON {
  145269. /**
  145270. * Block used to get the value of the first parameter raised to the power of the second
  145271. */
  145272. export class PowBlock extends NodeMaterialBlock {
  145273. /**
  145274. * Creates a new PowBlock
  145275. * @param name defines the block name
  145276. */
  145277. constructor(name: string);
  145278. /**
  145279. * Gets the current class name
  145280. * @returns the class name
  145281. */
  145282. getClassName(): string;
  145283. /**
  145284. * Gets the value operand input component
  145285. */
  145286. get value(): NodeMaterialConnectionPoint;
  145287. /**
  145288. * Gets the power operand input component
  145289. */
  145290. get power(): NodeMaterialConnectionPoint;
  145291. /**
  145292. * Gets the output component
  145293. */
  145294. get output(): NodeMaterialConnectionPoint;
  145295. protected _buildBlock(state: NodeMaterialBuildState): this;
  145296. }
  145297. }
  145298. declare module BABYLON {
  145299. /**
  145300. * Block used to get a random number
  145301. */
  145302. export class RandomNumberBlock extends NodeMaterialBlock {
  145303. /**
  145304. * Creates a new RandomNumberBlock
  145305. * @param name defines the block name
  145306. */
  145307. constructor(name: string);
  145308. /**
  145309. * Gets the current class name
  145310. * @returns the class name
  145311. */
  145312. getClassName(): string;
  145313. /**
  145314. * Gets the seed input component
  145315. */
  145316. get seed(): NodeMaterialConnectionPoint;
  145317. /**
  145318. * Gets the output component
  145319. */
  145320. get output(): NodeMaterialConnectionPoint;
  145321. protected _buildBlock(state: NodeMaterialBuildState): this;
  145322. }
  145323. }
  145324. declare module BABYLON {
  145325. /**
  145326. * Block used to compute arc tangent of 2 values
  145327. */
  145328. export class ArcTan2Block extends NodeMaterialBlock {
  145329. /**
  145330. * Creates a new ArcTan2Block
  145331. * @param name defines the block name
  145332. */
  145333. constructor(name: string);
  145334. /**
  145335. * Gets the current class name
  145336. * @returns the class name
  145337. */
  145338. getClassName(): string;
  145339. /**
  145340. * Gets the x operand input component
  145341. */
  145342. get x(): NodeMaterialConnectionPoint;
  145343. /**
  145344. * Gets the y operand input component
  145345. */
  145346. get y(): NodeMaterialConnectionPoint;
  145347. /**
  145348. * Gets the output component
  145349. */
  145350. get output(): NodeMaterialConnectionPoint;
  145351. protected _buildBlock(state: NodeMaterialBuildState): this;
  145352. }
  145353. }
  145354. declare module BABYLON {
  145355. /**
  145356. * Block used to smooth step a value
  145357. */
  145358. export class SmoothStepBlock extends NodeMaterialBlock {
  145359. /**
  145360. * Creates a new SmoothStepBlock
  145361. * @param name defines the block name
  145362. */
  145363. constructor(name: string);
  145364. /**
  145365. * Gets the current class name
  145366. * @returns the class name
  145367. */
  145368. getClassName(): string;
  145369. /**
  145370. * Gets the value operand input component
  145371. */
  145372. get value(): NodeMaterialConnectionPoint;
  145373. /**
  145374. * Gets the first edge operand input component
  145375. */
  145376. get edge0(): NodeMaterialConnectionPoint;
  145377. /**
  145378. * Gets the second edge operand input component
  145379. */
  145380. get edge1(): NodeMaterialConnectionPoint;
  145381. /**
  145382. * Gets the output component
  145383. */
  145384. get output(): NodeMaterialConnectionPoint;
  145385. protected _buildBlock(state: NodeMaterialBuildState): this;
  145386. }
  145387. }
  145388. declare module BABYLON {
  145389. /**
  145390. * Block used to get the reciprocal (1 / x) of a value
  145391. */
  145392. export class ReciprocalBlock extends NodeMaterialBlock {
  145393. /**
  145394. * Creates a new ReciprocalBlock
  145395. * @param name defines the block name
  145396. */
  145397. constructor(name: string);
  145398. /**
  145399. * Gets the current class name
  145400. * @returns the class name
  145401. */
  145402. getClassName(): string;
  145403. /**
  145404. * Gets the input component
  145405. */
  145406. get input(): NodeMaterialConnectionPoint;
  145407. /**
  145408. * Gets the output component
  145409. */
  145410. get output(): NodeMaterialConnectionPoint;
  145411. protected _buildBlock(state: NodeMaterialBuildState): this;
  145412. }
  145413. }
  145414. declare module BABYLON {
  145415. /**
  145416. * Block used to replace a color by another one
  145417. */
  145418. export class ReplaceColorBlock extends NodeMaterialBlock {
  145419. /**
  145420. * Creates a new ReplaceColorBlock
  145421. * @param name defines the block name
  145422. */
  145423. constructor(name: string);
  145424. /**
  145425. * Gets the current class name
  145426. * @returns the class name
  145427. */
  145428. getClassName(): string;
  145429. /**
  145430. * Gets the value input component
  145431. */
  145432. get value(): NodeMaterialConnectionPoint;
  145433. /**
  145434. * Gets the reference input component
  145435. */
  145436. get reference(): NodeMaterialConnectionPoint;
  145437. /**
  145438. * Gets the distance input component
  145439. */
  145440. get distance(): NodeMaterialConnectionPoint;
  145441. /**
  145442. * Gets the replacement input component
  145443. */
  145444. get replacement(): NodeMaterialConnectionPoint;
  145445. /**
  145446. * Gets the output component
  145447. */
  145448. get output(): NodeMaterialConnectionPoint;
  145449. protected _buildBlock(state: NodeMaterialBuildState): this;
  145450. }
  145451. }
  145452. declare module BABYLON {
  145453. /**
  145454. * Block used to posterize a value
  145455. * @see https://en.wikipedia.org/wiki/Posterization
  145456. */
  145457. export class PosterizeBlock extends NodeMaterialBlock {
  145458. /**
  145459. * Creates a new PosterizeBlock
  145460. * @param name defines the block name
  145461. */
  145462. constructor(name: string);
  145463. /**
  145464. * Gets the current class name
  145465. * @returns the class name
  145466. */
  145467. getClassName(): string;
  145468. /**
  145469. * Gets the value input component
  145470. */
  145471. get value(): NodeMaterialConnectionPoint;
  145472. /**
  145473. * Gets the steps input component
  145474. */
  145475. get steps(): NodeMaterialConnectionPoint;
  145476. /**
  145477. * Gets the output component
  145478. */
  145479. get output(): NodeMaterialConnectionPoint;
  145480. protected _buildBlock(state: NodeMaterialBuildState): this;
  145481. }
  145482. }
  145483. declare module BABYLON {
  145484. /**
  145485. * Operations supported by the Wave block
  145486. */
  145487. export enum WaveBlockKind {
  145488. /** SawTooth */
  145489. SawTooth = 0,
  145490. /** Square */
  145491. Square = 1,
  145492. /** Triangle */
  145493. Triangle = 2
  145494. }
  145495. /**
  145496. * Block used to apply wave operation to floats
  145497. */
  145498. export class WaveBlock extends NodeMaterialBlock {
  145499. /**
  145500. * Gets or sets the kibnd of wave to be applied by the block
  145501. */
  145502. kind: WaveBlockKind;
  145503. /**
  145504. * Creates a new WaveBlock
  145505. * @param name defines the block name
  145506. */
  145507. constructor(name: string);
  145508. /**
  145509. * Gets the current class name
  145510. * @returns the class name
  145511. */
  145512. getClassName(): string;
  145513. /**
  145514. * Gets the input component
  145515. */
  145516. get input(): NodeMaterialConnectionPoint;
  145517. /**
  145518. * Gets the output component
  145519. */
  145520. get output(): NodeMaterialConnectionPoint;
  145521. protected _buildBlock(state: NodeMaterialBuildState): this;
  145522. serialize(): any;
  145523. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145524. }
  145525. }
  145526. declare module BABYLON {
  145527. /**
  145528. * Class used to store a color step for the GradientBlock
  145529. */
  145530. export class GradientBlockColorStep {
  145531. private _step;
  145532. /**
  145533. * Gets value indicating which step this color is associated with (between 0 and 1)
  145534. */
  145535. get step(): number;
  145536. /**
  145537. * Sets a value indicating which step this color is associated with (between 0 and 1)
  145538. */
  145539. set step(val: number);
  145540. private _color;
  145541. /**
  145542. * Gets the color associated with this step
  145543. */
  145544. get color(): Color3;
  145545. /**
  145546. * Sets the color associated with this step
  145547. */
  145548. set color(val: Color3);
  145549. /**
  145550. * Creates a new GradientBlockColorStep
  145551. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  145552. * @param color defines the color associated with this step
  145553. */
  145554. constructor(step: number, color: Color3);
  145555. }
  145556. /**
  145557. * Block used to return a color from a gradient based on an input value between 0 and 1
  145558. */
  145559. export class GradientBlock extends NodeMaterialBlock {
  145560. /**
  145561. * Gets or sets the list of color steps
  145562. */
  145563. colorSteps: GradientBlockColorStep[];
  145564. /** Gets an observable raised when the value is changed */
  145565. onValueChangedObservable: Observable<GradientBlock>;
  145566. /** calls observable when the value is changed*/
  145567. colorStepsUpdated(): void;
  145568. /**
  145569. * Creates a new GradientBlock
  145570. * @param name defines the block name
  145571. */
  145572. constructor(name: string);
  145573. /**
  145574. * Gets the current class name
  145575. * @returns the class name
  145576. */
  145577. getClassName(): string;
  145578. /**
  145579. * Gets the gradient input component
  145580. */
  145581. get gradient(): NodeMaterialConnectionPoint;
  145582. /**
  145583. * Gets the output component
  145584. */
  145585. get output(): NodeMaterialConnectionPoint;
  145586. private _writeColorConstant;
  145587. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145588. serialize(): any;
  145589. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145590. protected _dumpPropertiesCode(): string;
  145591. }
  145592. }
  145593. declare module BABYLON {
  145594. /**
  145595. * Block used to normalize lerp between 2 values
  145596. */
  145597. export class NLerpBlock extends NodeMaterialBlock {
  145598. /**
  145599. * Creates a new NLerpBlock
  145600. * @param name defines the block name
  145601. */
  145602. constructor(name: string);
  145603. /**
  145604. * Gets the current class name
  145605. * @returns the class name
  145606. */
  145607. getClassName(): string;
  145608. /**
  145609. * Gets the left operand input component
  145610. */
  145611. get left(): NodeMaterialConnectionPoint;
  145612. /**
  145613. * Gets the right operand input component
  145614. */
  145615. get right(): NodeMaterialConnectionPoint;
  145616. /**
  145617. * Gets the gradient operand input component
  145618. */
  145619. get gradient(): NodeMaterialConnectionPoint;
  145620. /**
  145621. * Gets the output component
  145622. */
  145623. get output(): NodeMaterialConnectionPoint;
  145624. protected _buildBlock(state: NodeMaterialBuildState): this;
  145625. }
  145626. }
  145627. declare module BABYLON {
  145628. /**
  145629. * block used to Generate a Worley Noise 3D Noise Pattern
  145630. */
  145631. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  145632. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  145633. manhattanDistance: boolean;
  145634. /**
  145635. * Creates a new WorleyNoise3DBlock
  145636. * @param name defines the block name
  145637. */
  145638. constructor(name: string);
  145639. /**
  145640. * Gets the current class name
  145641. * @returns the class name
  145642. */
  145643. getClassName(): string;
  145644. /**
  145645. * Gets the seed input component
  145646. */
  145647. get seed(): NodeMaterialConnectionPoint;
  145648. /**
  145649. * Gets the jitter input component
  145650. */
  145651. get jitter(): NodeMaterialConnectionPoint;
  145652. /**
  145653. * Gets the output component
  145654. */
  145655. get output(): NodeMaterialConnectionPoint;
  145656. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145657. /**
  145658. * Exposes the properties to the UI?
  145659. */
  145660. protected _dumpPropertiesCode(): string;
  145661. /**
  145662. * Exposes the properties to the Seralize?
  145663. */
  145664. serialize(): any;
  145665. /**
  145666. * Exposes the properties to the deseralize?
  145667. */
  145668. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145669. }
  145670. }
  145671. declare module BABYLON {
  145672. /**
  145673. * block used to Generate a Simplex Perlin 3d Noise Pattern
  145674. */
  145675. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  145676. /**
  145677. * Creates a new SimplexPerlin3DBlock
  145678. * @param name defines the block name
  145679. */
  145680. constructor(name: string);
  145681. /**
  145682. * Gets the current class name
  145683. * @returns the class name
  145684. */
  145685. getClassName(): string;
  145686. /**
  145687. * Gets the seed operand input component
  145688. */
  145689. get seed(): NodeMaterialConnectionPoint;
  145690. /**
  145691. * Gets the output component
  145692. */
  145693. get output(): NodeMaterialConnectionPoint;
  145694. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145695. }
  145696. }
  145697. declare module BABYLON {
  145698. /**
  145699. * Block used to blend normals
  145700. */
  145701. export class NormalBlendBlock extends NodeMaterialBlock {
  145702. /**
  145703. * Creates a new NormalBlendBlock
  145704. * @param name defines the block name
  145705. */
  145706. constructor(name: string);
  145707. /**
  145708. * Gets the current class name
  145709. * @returns the class name
  145710. */
  145711. getClassName(): string;
  145712. /**
  145713. * Gets the first input component
  145714. */
  145715. get normalMap0(): NodeMaterialConnectionPoint;
  145716. /**
  145717. * Gets the second input component
  145718. */
  145719. get normalMap1(): NodeMaterialConnectionPoint;
  145720. /**
  145721. * Gets the output component
  145722. */
  145723. get output(): NodeMaterialConnectionPoint;
  145724. protected _buildBlock(state: NodeMaterialBuildState): this;
  145725. }
  145726. }
  145727. declare module BABYLON {
  145728. /**
  145729. * Block used to rotate a 2d vector by a given angle
  145730. */
  145731. export class Rotate2dBlock extends NodeMaterialBlock {
  145732. /**
  145733. * Creates a new Rotate2dBlock
  145734. * @param name defines the block name
  145735. */
  145736. constructor(name: string);
  145737. /**
  145738. * Gets the current class name
  145739. * @returns the class name
  145740. */
  145741. getClassName(): string;
  145742. /**
  145743. * Gets the input vector
  145744. */
  145745. get input(): NodeMaterialConnectionPoint;
  145746. /**
  145747. * Gets the input angle
  145748. */
  145749. get angle(): NodeMaterialConnectionPoint;
  145750. /**
  145751. * Gets the output component
  145752. */
  145753. get output(): NodeMaterialConnectionPoint;
  145754. autoConfigure(material: NodeMaterial): void;
  145755. protected _buildBlock(state: NodeMaterialBuildState): this;
  145756. }
  145757. }
  145758. declare module BABYLON {
  145759. /**
  145760. * Block used to get the reflected vector from a direction and a normal
  145761. */
  145762. export class ReflectBlock extends NodeMaterialBlock {
  145763. /**
  145764. * Creates a new ReflectBlock
  145765. * @param name defines the block name
  145766. */
  145767. constructor(name: string);
  145768. /**
  145769. * Gets the current class name
  145770. * @returns the class name
  145771. */
  145772. getClassName(): string;
  145773. /**
  145774. * Gets the incident component
  145775. */
  145776. get incident(): NodeMaterialConnectionPoint;
  145777. /**
  145778. * Gets the normal component
  145779. */
  145780. get normal(): NodeMaterialConnectionPoint;
  145781. /**
  145782. * Gets the output component
  145783. */
  145784. get output(): NodeMaterialConnectionPoint;
  145785. protected _buildBlock(state: NodeMaterialBuildState): this;
  145786. }
  145787. }
  145788. declare module BABYLON {
  145789. /**
  145790. * Block used to get the refracted vector from a direction and a normal
  145791. */
  145792. export class RefractBlock extends NodeMaterialBlock {
  145793. /**
  145794. * Creates a new RefractBlock
  145795. * @param name defines the block name
  145796. */
  145797. constructor(name: string);
  145798. /**
  145799. * Gets the current class name
  145800. * @returns the class name
  145801. */
  145802. getClassName(): string;
  145803. /**
  145804. * Gets the incident component
  145805. */
  145806. get incident(): NodeMaterialConnectionPoint;
  145807. /**
  145808. * Gets the normal component
  145809. */
  145810. get normal(): NodeMaterialConnectionPoint;
  145811. /**
  145812. * Gets the index of refraction component
  145813. */
  145814. get ior(): NodeMaterialConnectionPoint;
  145815. /**
  145816. * Gets the output component
  145817. */
  145818. get output(): NodeMaterialConnectionPoint;
  145819. protected _buildBlock(state: NodeMaterialBuildState): this;
  145820. }
  145821. }
  145822. declare module BABYLON {
  145823. /**
  145824. * Block used to desaturate a color
  145825. */
  145826. export class DesaturateBlock extends NodeMaterialBlock {
  145827. /**
  145828. * Creates a new DesaturateBlock
  145829. * @param name defines the block name
  145830. */
  145831. constructor(name: string);
  145832. /**
  145833. * Gets the current class name
  145834. * @returns the class name
  145835. */
  145836. getClassName(): string;
  145837. /**
  145838. * Gets the color operand input component
  145839. */
  145840. get color(): NodeMaterialConnectionPoint;
  145841. /**
  145842. * Gets the level operand input component
  145843. */
  145844. get level(): NodeMaterialConnectionPoint;
  145845. /**
  145846. * Gets the output component
  145847. */
  145848. get output(): NodeMaterialConnectionPoint;
  145849. protected _buildBlock(state: NodeMaterialBuildState): this;
  145850. }
  145851. }
  145852. declare module BABYLON {
  145853. /**
  145854. * Block used to implement the ambient occlusion module of the PBR material
  145855. */
  145856. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  145857. /**
  145858. * Create a new AmbientOcclusionBlock
  145859. * @param name defines the block name
  145860. */
  145861. constructor(name: string);
  145862. /**
  145863. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  145864. */
  145865. useAmbientInGrayScale: boolean;
  145866. /**
  145867. * Initialize the block and prepare the context for build
  145868. * @param state defines the state that will be used for the build
  145869. */
  145870. initialize(state: NodeMaterialBuildState): void;
  145871. /**
  145872. * Gets the current class name
  145873. * @returns the class name
  145874. */
  145875. getClassName(): string;
  145876. /**
  145877. * Gets the texture input component
  145878. */
  145879. get texture(): NodeMaterialConnectionPoint;
  145880. /**
  145881. * Gets the texture intensity component
  145882. */
  145883. get intensity(): NodeMaterialConnectionPoint;
  145884. /**
  145885. * Gets the direct light intensity input component
  145886. */
  145887. get directLightIntensity(): NodeMaterialConnectionPoint;
  145888. /**
  145889. * Gets the ambient occlusion object output component
  145890. */
  145891. get ambientOcc(): NodeMaterialConnectionPoint;
  145892. /**
  145893. * Gets the main code of the block (fragment side)
  145894. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  145895. * @returns the shader code
  145896. */
  145897. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  145898. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145899. protected _buildBlock(state: NodeMaterialBuildState): this;
  145900. protected _dumpPropertiesCode(): string;
  145901. serialize(): any;
  145902. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145903. }
  145904. }
  145905. declare module BABYLON {
  145906. /**
  145907. * Block used to implement the reflection module of the PBR material
  145908. */
  145909. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  145910. /** @hidden */
  145911. _defineLODReflectionAlpha: string;
  145912. /** @hidden */
  145913. _defineLinearSpecularReflection: string;
  145914. private _vEnvironmentIrradianceName;
  145915. /** @hidden */
  145916. _vReflectionMicrosurfaceInfosName: string;
  145917. /** @hidden */
  145918. _vReflectionInfosName: string;
  145919. /** @hidden */
  145920. _vReflectionFilteringInfoName: string;
  145921. private _scene;
  145922. /**
  145923. * The three properties below are set by the main PBR block prior to calling methods of this class.
  145924. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  145925. * It's less burden on the user side in the editor part.
  145926. */
  145927. /** @hidden */
  145928. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  145929. /** @hidden */
  145930. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  145931. /** @hidden */
  145932. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  145933. /**
  145934. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  145935. * diffuse part of the IBL.
  145936. */
  145937. useSphericalHarmonics: boolean;
  145938. /**
  145939. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  145940. */
  145941. forceIrradianceInFragment: boolean;
  145942. /**
  145943. * Create a new ReflectionBlock
  145944. * @param name defines the block name
  145945. */
  145946. constructor(name: string);
  145947. /**
  145948. * Gets the current class name
  145949. * @returns the class name
  145950. */
  145951. getClassName(): string;
  145952. /**
  145953. * Gets the position input component
  145954. */
  145955. get position(): NodeMaterialConnectionPoint;
  145956. /**
  145957. * Gets the world position input component
  145958. */
  145959. get worldPosition(): NodeMaterialConnectionPoint;
  145960. /**
  145961. * Gets the world normal input component
  145962. */
  145963. get worldNormal(): NodeMaterialConnectionPoint;
  145964. /**
  145965. * Gets the world input component
  145966. */
  145967. get world(): NodeMaterialConnectionPoint;
  145968. /**
  145969. * Gets the camera (or eye) position component
  145970. */
  145971. get cameraPosition(): NodeMaterialConnectionPoint;
  145972. /**
  145973. * Gets the view input component
  145974. */
  145975. get view(): NodeMaterialConnectionPoint;
  145976. /**
  145977. * Gets the color input component
  145978. */
  145979. get color(): NodeMaterialConnectionPoint;
  145980. /**
  145981. * Gets the reflection object output component
  145982. */
  145983. get reflection(): NodeMaterialConnectionPoint;
  145984. /**
  145985. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  145986. */
  145987. get hasTexture(): boolean;
  145988. /**
  145989. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  145990. */
  145991. get reflectionColor(): string;
  145992. protected _getTexture(): Nullable<BaseTexture>;
  145993. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145994. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145995. /**
  145996. * Gets the code to inject in the vertex shader
  145997. * @param state current state of the node material building
  145998. * @returns the shader code
  145999. */
  146000. handleVertexSide(state: NodeMaterialBuildState): string;
  146001. /**
  146002. * Gets the main code of the block (fragment side)
  146003. * @param state current state of the node material building
  146004. * @param normalVarName name of the existing variable corresponding to the normal
  146005. * @returns the shader code
  146006. */
  146007. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  146008. protected _buildBlock(state: NodeMaterialBuildState): this;
  146009. protected _dumpPropertiesCode(): string;
  146010. serialize(): any;
  146011. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146012. }
  146013. }
  146014. declare module BABYLON {
  146015. /**
  146016. * Block used to implement the sheen module of the PBR material
  146017. */
  146018. export class SheenBlock extends NodeMaterialBlock {
  146019. /**
  146020. * Create a new SheenBlock
  146021. * @param name defines the block name
  146022. */
  146023. constructor(name: string);
  146024. /**
  146025. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  146026. * It allows the strength of the sheen effect to not depend on the base color of the material,
  146027. * making it easier to setup and tweak the effect
  146028. */
  146029. albedoScaling: boolean;
  146030. /**
  146031. * Defines if the sheen is linked to the sheen color.
  146032. */
  146033. linkSheenWithAlbedo: boolean;
  146034. /**
  146035. * Initialize the block and prepare the context for build
  146036. * @param state defines the state that will be used for the build
  146037. */
  146038. initialize(state: NodeMaterialBuildState): void;
  146039. /**
  146040. * Gets the current class name
  146041. * @returns the class name
  146042. */
  146043. getClassName(): string;
  146044. /**
  146045. * Gets the intensity input component
  146046. */
  146047. get intensity(): NodeMaterialConnectionPoint;
  146048. /**
  146049. * Gets the color input component
  146050. */
  146051. get color(): NodeMaterialConnectionPoint;
  146052. /**
  146053. * Gets the roughness input component
  146054. */
  146055. get roughness(): NodeMaterialConnectionPoint;
  146056. /**
  146057. * Gets the sheen object output component
  146058. */
  146059. get sheen(): NodeMaterialConnectionPoint;
  146060. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146061. /**
  146062. * Gets the main code of the block (fragment side)
  146063. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146064. * @returns the shader code
  146065. */
  146066. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  146067. protected _buildBlock(state: NodeMaterialBuildState): this;
  146068. protected _dumpPropertiesCode(): string;
  146069. serialize(): any;
  146070. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146071. }
  146072. }
  146073. declare module BABYLON {
  146074. /**
  146075. * Block used to implement the reflectivity module of the PBR material
  146076. */
  146077. export class ReflectivityBlock extends NodeMaterialBlock {
  146078. private _metallicReflectanceColor;
  146079. private _metallicF0Factor;
  146080. /** @hidden */
  146081. _vMetallicReflectanceFactorsName: string;
  146082. /**
  146083. * The property below is set by the main PBR block prior to calling methods of this class.
  146084. */
  146085. /** @hidden */
  146086. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  146087. /**
  146088. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  146089. */
  146090. useAmbientOcclusionFromMetallicTextureRed: boolean;
  146091. /**
  146092. * Specifies if the metallic texture contains the metallness information in its blue channel.
  146093. */
  146094. useMetallnessFromMetallicTextureBlue: boolean;
  146095. /**
  146096. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  146097. */
  146098. useRoughnessFromMetallicTextureAlpha: boolean;
  146099. /**
  146100. * Specifies if the metallic texture contains the roughness information in its green channel.
  146101. */
  146102. useRoughnessFromMetallicTextureGreen: boolean;
  146103. /**
  146104. * Create a new ReflectivityBlock
  146105. * @param name defines the block name
  146106. */
  146107. constructor(name: string);
  146108. /**
  146109. * Initialize the block and prepare the context for build
  146110. * @param state defines the state that will be used for the build
  146111. */
  146112. initialize(state: NodeMaterialBuildState): void;
  146113. /**
  146114. * Gets the current class name
  146115. * @returns the class name
  146116. */
  146117. getClassName(): string;
  146118. /**
  146119. * Gets the metallic input component
  146120. */
  146121. get metallic(): NodeMaterialConnectionPoint;
  146122. /**
  146123. * Gets the roughness input component
  146124. */
  146125. get roughness(): NodeMaterialConnectionPoint;
  146126. /**
  146127. * Gets the texture input component
  146128. */
  146129. get texture(): NodeMaterialConnectionPoint;
  146130. /**
  146131. * Gets the reflectivity object output component
  146132. */
  146133. get reflectivity(): NodeMaterialConnectionPoint;
  146134. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146135. /**
  146136. * Gets the main code of the block (fragment side)
  146137. * @param state current state of the node material building
  146138. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  146139. * @returns the shader code
  146140. */
  146141. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  146142. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146143. protected _buildBlock(state: NodeMaterialBuildState): this;
  146144. protected _dumpPropertiesCode(): string;
  146145. serialize(): any;
  146146. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146147. }
  146148. }
  146149. declare module BABYLON {
  146150. /**
  146151. * Block used to implement the anisotropy module of the PBR material
  146152. */
  146153. export class AnisotropyBlock extends NodeMaterialBlock {
  146154. /**
  146155. * The two properties below are set by the main PBR block prior to calling methods of this class.
  146156. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  146157. * It's less burden on the user side in the editor part.
  146158. */
  146159. /** @hidden */
  146160. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  146161. /** @hidden */
  146162. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  146163. /**
  146164. * Create a new AnisotropyBlock
  146165. * @param name defines the block name
  146166. */
  146167. constructor(name: string);
  146168. /**
  146169. * Initialize the block and prepare the context for build
  146170. * @param state defines the state that will be used for the build
  146171. */
  146172. initialize(state: NodeMaterialBuildState): void;
  146173. /**
  146174. * Gets the current class name
  146175. * @returns the class name
  146176. */
  146177. getClassName(): string;
  146178. /**
  146179. * Gets the intensity input component
  146180. */
  146181. get intensity(): NodeMaterialConnectionPoint;
  146182. /**
  146183. * Gets the direction input component
  146184. */
  146185. get direction(): NodeMaterialConnectionPoint;
  146186. /**
  146187. * Gets the texture input component
  146188. */
  146189. get texture(): NodeMaterialConnectionPoint;
  146190. /**
  146191. * Gets the uv input component
  146192. */
  146193. get uv(): NodeMaterialConnectionPoint;
  146194. /**
  146195. * Gets the worldTangent input component
  146196. */
  146197. get worldTangent(): NodeMaterialConnectionPoint;
  146198. /**
  146199. * Gets the anisotropy object output component
  146200. */
  146201. get anisotropy(): NodeMaterialConnectionPoint;
  146202. private _generateTBNSpace;
  146203. /**
  146204. * Gets the main code of the block (fragment side)
  146205. * @param state current state of the node material building
  146206. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  146207. * @returns the shader code
  146208. */
  146209. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  146210. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146211. protected _buildBlock(state: NodeMaterialBuildState): this;
  146212. }
  146213. }
  146214. declare module BABYLON {
  146215. /**
  146216. * Block used to implement the clear coat module of the PBR material
  146217. */
  146218. export class ClearCoatBlock extends NodeMaterialBlock {
  146219. private _scene;
  146220. /**
  146221. * Create a new ClearCoatBlock
  146222. * @param name defines the block name
  146223. */
  146224. constructor(name: string);
  146225. /**
  146226. * Initialize the block and prepare the context for build
  146227. * @param state defines the state that will be used for the build
  146228. */
  146229. initialize(state: NodeMaterialBuildState): void;
  146230. /**
  146231. * Gets the current class name
  146232. * @returns the class name
  146233. */
  146234. getClassName(): string;
  146235. /**
  146236. * Gets the intensity input component
  146237. */
  146238. get intensity(): NodeMaterialConnectionPoint;
  146239. /**
  146240. * Gets the roughness input component
  146241. */
  146242. get roughness(): NodeMaterialConnectionPoint;
  146243. /**
  146244. * Gets the ior input component
  146245. */
  146246. get ior(): NodeMaterialConnectionPoint;
  146247. /**
  146248. * Gets the texture input component
  146249. */
  146250. get texture(): NodeMaterialConnectionPoint;
  146251. /**
  146252. * Gets the bump texture input component
  146253. */
  146254. get bumpTexture(): NodeMaterialConnectionPoint;
  146255. /**
  146256. * Gets the uv input component
  146257. */
  146258. get uv(): NodeMaterialConnectionPoint;
  146259. /**
  146260. * Gets the tint color input component
  146261. */
  146262. get tintColor(): NodeMaterialConnectionPoint;
  146263. /**
  146264. * Gets the tint "at distance" input component
  146265. */
  146266. get tintAtDistance(): NodeMaterialConnectionPoint;
  146267. /**
  146268. * Gets the tint thickness input component
  146269. */
  146270. get tintThickness(): NodeMaterialConnectionPoint;
  146271. /**
  146272. * Gets the world tangent input component
  146273. */
  146274. get worldTangent(): NodeMaterialConnectionPoint;
  146275. /**
  146276. * Gets the clear coat object output component
  146277. */
  146278. get clearcoat(): NodeMaterialConnectionPoint;
  146279. autoConfigure(material: NodeMaterial): void;
  146280. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146281. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146282. private _generateTBNSpace;
  146283. /**
  146284. * Gets the main code of the block (fragment side)
  146285. * @param state current state of the node material building
  146286. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  146287. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146288. * @param worldPosVarName name of the variable holding the world position
  146289. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  146290. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  146291. * @param worldNormalVarName name of the variable holding the world normal
  146292. * @returns the shader code
  146293. */
  146294. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  146295. protected _buildBlock(state: NodeMaterialBuildState): this;
  146296. }
  146297. }
  146298. declare module BABYLON {
  146299. /**
  146300. * Block used to implement the sub surface module of the PBR material
  146301. */
  146302. export class SubSurfaceBlock extends NodeMaterialBlock {
  146303. /**
  146304. * Create a new SubSurfaceBlock
  146305. * @param name defines the block name
  146306. */
  146307. constructor(name: string);
  146308. /**
  146309. * Stores the intensity of the different subsurface effects in the thickness texture.
  146310. * * the green channel is the translucency intensity.
  146311. * * the blue channel is the scattering intensity.
  146312. * * the alpha channel is the refraction intensity.
  146313. */
  146314. useMaskFromThicknessTexture: boolean;
  146315. /**
  146316. * Initialize the block and prepare the context for build
  146317. * @param state defines the state that will be used for the build
  146318. */
  146319. initialize(state: NodeMaterialBuildState): void;
  146320. /**
  146321. * Gets the current class name
  146322. * @returns the class name
  146323. */
  146324. getClassName(): string;
  146325. /**
  146326. * Gets the min thickness input component
  146327. */
  146328. get minThickness(): NodeMaterialConnectionPoint;
  146329. /**
  146330. * Gets the max thickness input component
  146331. */
  146332. get maxThickness(): NodeMaterialConnectionPoint;
  146333. /**
  146334. * Gets the thickness texture component
  146335. */
  146336. get thicknessTexture(): NodeMaterialConnectionPoint;
  146337. /**
  146338. * Gets the tint color input component
  146339. */
  146340. get tintColor(): NodeMaterialConnectionPoint;
  146341. /**
  146342. * Gets the translucency intensity input component
  146343. */
  146344. get translucencyIntensity(): NodeMaterialConnectionPoint;
  146345. /**
  146346. * Gets the translucency diffusion distance input component
  146347. */
  146348. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  146349. /**
  146350. * Gets the refraction object parameters
  146351. */
  146352. get refraction(): NodeMaterialConnectionPoint;
  146353. /**
  146354. * Gets the sub surface object output component
  146355. */
  146356. get subsurface(): NodeMaterialConnectionPoint;
  146357. autoConfigure(material: NodeMaterial): void;
  146358. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146359. /**
  146360. * Gets the main code of the block (fragment side)
  146361. * @param state current state of the node material building
  146362. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  146363. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146364. * @param worldPosVarName name of the variable holding the world position
  146365. * @returns the shader code
  146366. */
  146367. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  146368. protected _buildBlock(state: NodeMaterialBuildState): this;
  146369. }
  146370. }
  146371. declare module BABYLON {
  146372. /**
  146373. * Block used to implement the PBR metallic/roughness model
  146374. */
  146375. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  146376. /**
  146377. * Gets or sets the light associated with this block
  146378. */
  146379. light: Nullable<Light>;
  146380. private _lightId;
  146381. private _scene;
  146382. private _environmentBRDFTexture;
  146383. private _environmentBrdfSamplerName;
  146384. private _vNormalWName;
  146385. private _invertNormalName;
  146386. /**
  146387. * Create a new ReflectionBlock
  146388. * @param name defines the block name
  146389. */
  146390. constructor(name: string);
  146391. /**
  146392. * Intensity of the direct lights e.g. the four lights available in your scene.
  146393. * This impacts both the direct diffuse and specular highlights.
  146394. */
  146395. directIntensity: number;
  146396. /**
  146397. * Intensity of the environment e.g. how much the environment will light the object
  146398. * either through harmonics for rough material or through the refelction for shiny ones.
  146399. */
  146400. environmentIntensity: number;
  146401. /**
  146402. * This is a special control allowing the reduction of the specular highlights coming from the
  146403. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  146404. */
  146405. specularIntensity: number;
  146406. /**
  146407. * Defines the falloff type used in this material.
  146408. * It by default is Physical.
  146409. */
  146410. lightFalloff: number;
  146411. /**
  146412. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  146413. */
  146414. useAlphaFromAlbedoTexture: boolean;
  146415. /**
  146416. * Specifies that alpha test should be used
  146417. */
  146418. useAlphaTest: boolean;
  146419. /**
  146420. * Defines the alpha limits in alpha test mode.
  146421. */
  146422. alphaTestCutoff: number;
  146423. /**
  146424. * Specifies that alpha blending should be used
  146425. */
  146426. useAlphaBlending: boolean;
  146427. /**
  146428. * Defines if the alpha value should be determined via the rgb values.
  146429. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  146430. */
  146431. opacityRGB: boolean;
  146432. /**
  146433. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  146434. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  146435. */
  146436. useRadianceOverAlpha: boolean;
  146437. /**
  146438. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  146439. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  146440. */
  146441. useSpecularOverAlpha: boolean;
  146442. /**
  146443. * Enables specular anti aliasing in the PBR shader.
  146444. * It will both interacts on the Geometry for analytical and IBL lighting.
  146445. * It also prefilter the roughness map based on the bump values.
  146446. */
  146447. enableSpecularAntiAliasing: boolean;
  146448. /**
  146449. * Enables realtime filtering on the texture.
  146450. */
  146451. realTimeFiltering: boolean;
  146452. /**
  146453. * Quality switch for realtime filtering
  146454. */
  146455. realTimeFilteringQuality: number;
  146456. /**
  146457. * Defines if the material uses energy conservation.
  146458. */
  146459. useEnergyConservation: boolean;
  146460. /**
  146461. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  146462. * too much the area relying on ambient texture to define their ambient occlusion.
  146463. */
  146464. useRadianceOcclusion: boolean;
  146465. /**
  146466. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  146467. * makes the reflect vector face the model (under horizon).
  146468. */
  146469. useHorizonOcclusion: boolean;
  146470. /**
  146471. * If set to true, no lighting calculations will be applied.
  146472. */
  146473. unlit: boolean;
  146474. /**
  146475. * Force normal to face away from face.
  146476. */
  146477. forceNormalForward: boolean;
  146478. /**
  146479. * Defines the material debug mode.
  146480. * It helps seeing only some components of the material while troubleshooting.
  146481. */
  146482. debugMode: number;
  146483. /**
  146484. * Specify from where on screen the debug mode should start.
  146485. * The value goes from -1 (full screen) to 1 (not visible)
  146486. * It helps with side by side comparison against the final render
  146487. * This defaults to 0
  146488. */
  146489. debugLimit: number;
  146490. /**
  146491. * As the default viewing range might not be enough (if the ambient is really small for instance)
  146492. * You can use the factor to better multiply the final value.
  146493. */
  146494. debugFactor: number;
  146495. /**
  146496. * Initialize the block and prepare the context for build
  146497. * @param state defines the state that will be used for the build
  146498. */
  146499. initialize(state: NodeMaterialBuildState): void;
  146500. /**
  146501. * Gets the current class name
  146502. * @returns the class name
  146503. */
  146504. getClassName(): string;
  146505. /**
  146506. * Gets the world position input component
  146507. */
  146508. get worldPosition(): NodeMaterialConnectionPoint;
  146509. /**
  146510. * Gets the world normal input component
  146511. */
  146512. get worldNormal(): NodeMaterialConnectionPoint;
  146513. /**
  146514. * Gets the perturbed normal input component
  146515. */
  146516. get perturbedNormal(): NodeMaterialConnectionPoint;
  146517. /**
  146518. * Gets the camera position input component
  146519. */
  146520. get cameraPosition(): NodeMaterialConnectionPoint;
  146521. /**
  146522. * Gets the base color input component
  146523. */
  146524. get baseColor(): NodeMaterialConnectionPoint;
  146525. /**
  146526. * Gets the opacity texture input component
  146527. */
  146528. get opacityTexture(): NodeMaterialConnectionPoint;
  146529. /**
  146530. * Gets the ambient color input component
  146531. */
  146532. get ambientColor(): NodeMaterialConnectionPoint;
  146533. /**
  146534. * Gets the reflectivity object parameters
  146535. */
  146536. get reflectivity(): NodeMaterialConnectionPoint;
  146537. /**
  146538. * Gets the ambient occlusion object parameters
  146539. */
  146540. get ambientOcc(): NodeMaterialConnectionPoint;
  146541. /**
  146542. * Gets the reflection object parameters
  146543. */
  146544. get reflection(): NodeMaterialConnectionPoint;
  146545. /**
  146546. * Gets the sheen object parameters
  146547. */
  146548. get sheen(): NodeMaterialConnectionPoint;
  146549. /**
  146550. * Gets the clear coat object parameters
  146551. */
  146552. get clearcoat(): NodeMaterialConnectionPoint;
  146553. /**
  146554. * Gets the sub surface object parameters
  146555. */
  146556. get subsurface(): NodeMaterialConnectionPoint;
  146557. /**
  146558. * Gets the anisotropy object parameters
  146559. */
  146560. get anisotropy(): NodeMaterialConnectionPoint;
  146561. /**
  146562. * Gets the view matrix parameter
  146563. */
  146564. get view(): NodeMaterialConnectionPoint;
  146565. /**
  146566. * Gets the ambient output component
  146567. */
  146568. get ambient(): NodeMaterialConnectionPoint;
  146569. /**
  146570. * Gets the diffuse output component
  146571. */
  146572. get diffuse(): NodeMaterialConnectionPoint;
  146573. /**
  146574. * Gets the specular output component
  146575. */
  146576. get specular(): NodeMaterialConnectionPoint;
  146577. /**
  146578. * Gets the sheen output component
  146579. */
  146580. get sheenDir(): NodeMaterialConnectionPoint;
  146581. /**
  146582. * Gets the clear coat output component
  146583. */
  146584. get clearcoatDir(): NodeMaterialConnectionPoint;
  146585. /**
  146586. * Gets the indirect diffuse output component
  146587. */
  146588. get diffuseIndirect(): NodeMaterialConnectionPoint;
  146589. /**
  146590. * Gets the indirect specular output component
  146591. */
  146592. get specularIndirect(): NodeMaterialConnectionPoint;
  146593. /**
  146594. * Gets the indirect sheen output component
  146595. */
  146596. get sheenIndirect(): NodeMaterialConnectionPoint;
  146597. /**
  146598. * Gets the indirect clear coat output component
  146599. */
  146600. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  146601. /**
  146602. * Gets the refraction output component
  146603. */
  146604. get refraction(): NodeMaterialConnectionPoint;
  146605. /**
  146606. * Gets the global lighting output component
  146607. */
  146608. get lighting(): NodeMaterialConnectionPoint;
  146609. /**
  146610. * Gets the shadow output component
  146611. */
  146612. get shadow(): NodeMaterialConnectionPoint;
  146613. /**
  146614. * Gets the alpha output component
  146615. */
  146616. get alpha(): NodeMaterialConnectionPoint;
  146617. autoConfigure(material: NodeMaterial): void;
  146618. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146619. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  146620. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  146621. private _injectVertexCode;
  146622. /**
  146623. * Gets the code corresponding to the albedo/opacity module
  146624. * @returns the shader code
  146625. */
  146626. getAlbedoOpacityCode(): string;
  146627. protected _buildBlock(state: NodeMaterialBuildState): this;
  146628. protected _dumpPropertiesCode(): string;
  146629. serialize(): any;
  146630. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146631. }
  146632. }
  146633. declare module BABYLON {
  146634. /**
  146635. * Block used to compute value of one parameter modulo another
  146636. */
  146637. export class ModBlock extends NodeMaterialBlock {
  146638. /**
  146639. * Creates a new ModBlock
  146640. * @param name defines the block name
  146641. */
  146642. constructor(name: string);
  146643. /**
  146644. * Gets the current class name
  146645. * @returns the class name
  146646. */
  146647. getClassName(): string;
  146648. /**
  146649. * Gets the left operand input component
  146650. */
  146651. get left(): NodeMaterialConnectionPoint;
  146652. /**
  146653. * Gets the right operand input component
  146654. */
  146655. get right(): NodeMaterialConnectionPoint;
  146656. /**
  146657. * Gets the output component
  146658. */
  146659. get output(): NodeMaterialConnectionPoint;
  146660. protected _buildBlock(state: NodeMaterialBuildState): this;
  146661. }
  146662. }
  146663. declare module BABYLON {
  146664. /**
  146665. * Configuration for Draco compression
  146666. */
  146667. export interface IDracoCompressionConfiguration {
  146668. /**
  146669. * Configuration for the decoder.
  146670. */
  146671. decoder: {
  146672. /**
  146673. * The url to the WebAssembly module.
  146674. */
  146675. wasmUrl?: string;
  146676. /**
  146677. * The url to the WebAssembly binary.
  146678. */
  146679. wasmBinaryUrl?: string;
  146680. /**
  146681. * The url to the fallback JavaScript module.
  146682. */
  146683. fallbackUrl?: string;
  146684. };
  146685. }
  146686. /**
  146687. * Draco compression (https://google.github.io/draco/)
  146688. *
  146689. * This class wraps the Draco module.
  146690. *
  146691. * **Encoder**
  146692. *
  146693. * The encoder is not currently implemented.
  146694. *
  146695. * **Decoder**
  146696. *
  146697. * 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.
  146698. *
  146699. * To update the configuration, use the following code:
  146700. * ```javascript
  146701. * DracoCompression.Configuration = {
  146702. * decoder: {
  146703. * wasmUrl: "<url to the WebAssembly library>",
  146704. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  146705. * fallbackUrl: "<url to the fallback JavaScript library>",
  146706. * }
  146707. * };
  146708. * ```
  146709. *
  146710. * 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.
  146711. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  146712. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  146713. *
  146714. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  146715. * ```javascript
  146716. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  146717. * ```
  146718. *
  146719. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  146720. */
  146721. export class DracoCompression implements IDisposable {
  146722. private _workerPoolPromise?;
  146723. private _decoderModulePromise?;
  146724. /**
  146725. * The configuration. Defaults to the following urls:
  146726. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  146727. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  146728. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  146729. */
  146730. static Configuration: IDracoCompressionConfiguration;
  146731. /**
  146732. * Returns true if the decoder configuration is available.
  146733. */
  146734. static get DecoderAvailable(): boolean;
  146735. /**
  146736. * Default number of workers to create when creating the draco compression object.
  146737. */
  146738. static DefaultNumWorkers: number;
  146739. private static GetDefaultNumWorkers;
  146740. private static _Default;
  146741. /**
  146742. * Default instance for the draco compression object.
  146743. */
  146744. static get Default(): DracoCompression;
  146745. /**
  146746. * Constructor
  146747. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  146748. */
  146749. constructor(numWorkers?: number);
  146750. /**
  146751. * Stop all async operations and release resources.
  146752. */
  146753. dispose(): void;
  146754. /**
  146755. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  146756. * @returns a promise that resolves when ready
  146757. */
  146758. whenReadyAsync(): Promise<void>;
  146759. /**
  146760. * Decode Draco compressed mesh data to vertex data.
  146761. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  146762. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  146763. * @returns A promise that resolves with the decoded vertex data
  146764. */
  146765. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  146766. [kind: string]: number;
  146767. }): Promise<VertexData>;
  146768. }
  146769. }
  146770. declare module BABYLON {
  146771. /**
  146772. * Class for building Constructive Solid Geometry
  146773. */
  146774. export class CSG {
  146775. private polygons;
  146776. /**
  146777. * The world matrix
  146778. */
  146779. matrix: Matrix;
  146780. /**
  146781. * Stores the position
  146782. */
  146783. position: Vector3;
  146784. /**
  146785. * Stores the rotation
  146786. */
  146787. rotation: Vector3;
  146788. /**
  146789. * Stores the rotation quaternion
  146790. */
  146791. rotationQuaternion: Nullable<Quaternion>;
  146792. /**
  146793. * Stores the scaling vector
  146794. */
  146795. scaling: Vector3;
  146796. /**
  146797. * Convert the Mesh to CSG
  146798. * @param mesh The Mesh to convert to CSG
  146799. * @returns A new CSG from the Mesh
  146800. */
  146801. static FromMesh(mesh: Mesh): CSG;
  146802. /**
  146803. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  146804. * @param polygons Polygons used to construct a CSG solid
  146805. */
  146806. private static FromPolygons;
  146807. /**
  146808. * Clones, or makes a deep copy, of the CSG
  146809. * @returns A new CSG
  146810. */
  146811. clone(): CSG;
  146812. /**
  146813. * Unions this CSG with another CSG
  146814. * @param csg The CSG to union against this CSG
  146815. * @returns The unioned CSG
  146816. */
  146817. union(csg: CSG): CSG;
  146818. /**
  146819. * Unions this CSG with another CSG in place
  146820. * @param csg The CSG to union against this CSG
  146821. */
  146822. unionInPlace(csg: CSG): void;
  146823. /**
  146824. * Subtracts this CSG with another CSG
  146825. * @param csg The CSG to subtract against this CSG
  146826. * @returns A new CSG
  146827. */
  146828. subtract(csg: CSG): CSG;
  146829. /**
  146830. * Subtracts this CSG with another CSG in place
  146831. * @param csg The CSG to subtact against this CSG
  146832. */
  146833. subtractInPlace(csg: CSG): void;
  146834. /**
  146835. * Intersect this CSG with another CSG
  146836. * @param csg The CSG to intersect against this CSG
  146837. * @returns A new CSG
  146838. */
  146839. intersect(csg: CSG): CSG;
  146840. /**
  146841. * Intersects this CSG with another CSG in place
  146842. * @param csg The CSG to intersect against this CSG
  146843. */
  146844. intersectInPlace(csg: CSG): void;
  146845. /**
  146846. * Return a new CSG solid with solid and empty space switched. This solid is
  146847. * not modified.
  146848. * @returns A new CSG solid with solid and empty space switched
  146849. */
  146850. inverse(): CSG;
  146851. /**
  146852. * Inverses the CSG in place
  146853. */
  146854. inverseInPlace(): void;
  146855. /**
  146856. * This is used to keep meshes transformations so they can be restored
  146857. * when we build back a Babylon Mesh
  146858. * NB : All CSG operations are performed in world coordinates
  146859. * @param csg The CSG to copy the transform attributes from
  146860. * @returns This CSG
  146861. */
  146862. copyTransformAttributes(csg: CSG): CSG;
  146863. /**
  146864. * Build Raw mesh from CSG
  146865. * Coordinates here are in world space
  146866. * @param name The name of the mesh geometry
  146867. * @param scene The Scene
  146868. * @param keepSubMeshes Specifies if the submeshes should be kept
  146869. * @returns A new Mesh
  146870. */
  146871. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146872. /**
  146873. * Build Mesh from CSG taking material and transforms into account
  146874. * @param name The name of the Mesh
  146875. * @param material The material of the Mesh
  146876. * @param scene The Scene
  146877. * @param keepSubMeshes Specifies if submeshes should be kept
  146878. * @returns The new Mesh
  146879. */
  146880. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146881. }
  146882. }
  146883. declare module BABYLON {
  146884. /**
  146885. * Class used to create a trail following a mesh
  146886. */
  146887. export class TrailMesh extends Mesh {
  146888. private _generator;
  146889. private _autoStart;
  146890. private _running;
  146891. private _diameter;
  146892. private _length;
  146893. private _sectionPolygonPointsCount;
  146894. private _sectionVectors;
  146895. private _sectionNormalVectors;
  146896. private _beforeRenderObserver;
  146897. /**
  146898. * @constructor
  146899. * @param name The value used by scene.getMeshByName() to do a lookup.
  146900. * @param generator The mesh or transform node to generate a trail.
  146901. * @param scene The scene to add this mesh to.
  146902. * @param diameter Diameter of trailing mesh. Default is 1.
  146903. * @param length Length of trailing mesh. Default is 60.
  146904. * @param autoStart Automatically start trailing mesh. Default true.
  146905. */
  146906. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  146907. /**
  146908. * "TrailMesh"
  146909. * @returns "TrailMesh"
  146910. */
  146911. getClassName(): string;
  146912. private _createMesh;
  146913. /**
  146914. * Start trailing mesh.
  146915. */
  146916. start(): void;
  146917. /**
  146918. * Stop trailing mesh.
  146919. */
  146920. stop(): void;
  146921. /**
  146922. * Update trailing mesh geometry.
  146923. */
  146924. update(): void;
  146925. /**
  146926. * Returns a new TrailMesh object.
  146927. * @param name is a string, the name given to the new mesh
  146928. * @param newGenerator use new generator object for cloned trail mesh
  146929. * @returns a new mesh
  146930. */
  146931. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  146932. /**
  146933. * Serializes this trail mesh
  146934. * @param serializationObject object to write serialization to
  146935. */
  146936. serialize(serializationObject: any): void;
  146937. /**
  146938. * Parses a serialized trail mesh
  146939. * @param parsedMesh the serialized mesh
  146940. * @param scene the scene to create the trail mesh in
  146941. * @returns the created trail mesh
  146942. */
  146943. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  146944. }
  146945. }
  146946. declare module BABYLON {
  146947. /**
  146948. * Class containing static functions to help procedurally build meshes
  146949. */
  146950. export class TiledBoxBuilder {
  146951. /**
  146952. * Creates a box mesh
  146953. * 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)
  146954. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146956. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146958. * @param name defines the name of the mesh
  146959. * @param options defines the options used to create the mesh
  146960. * @param scene defines the hosting scene
  146961. * @returns the box mesh
  146962. */
  146963. static CreateTiledBox(name: string, options: {
  146964. pattern?: number;
  146965. width?: number;
  146966. height?: number;
  146967. depth?: number;
  146968. tileSize?: number;
  146969. tileWidth?: number;
  146970. tileHeight?: number;
  146971. alignHorizontal?: number;
  146972. alignVertical?: number;
  146973. faceUV?: Vector4[];
  146974. faceColors?: Color4[];
  146975. sideOrientation?: number;
  146976. updatable?: boolean;
  146977. }, scene?: Nullable<Scene>): Mesh;
  146978. }
  146979. }
  146980. declare module BABYLON {
  146981. /**
  146982. * Class containing static functions to help procedurally build meshes
  146983. */
  146984. export class TorusKnotBuilder {
  146985. /**
  146986. * Creates a torus knot mesh
  146987. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146988. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146989. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146990. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146991. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146992. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146994. * @param name defines the name of the mesh
  146995. * @param options defines the options used to create the mesh
  146996. * @param scene defines the hosting scene
  146997. * @returns the torus knot mesh
  146998. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146999. */
  147000. static CreateTorusKnot(name: string, options: {
  147001. radius?: number;
  147002. tube?: number;
  147003. radialSegments?: number;
  147004. tubularSegments?: number;
  147005. p?: number;
  147006. q?: number;
  147007. updatable?: boolean;
  147008. sideOrientation?: number;
  147009. frontUVs?: Vector4;
  147010. backUVs?: Vector4;
  147011. }, scene: any): Mesh;
  147012. }
  147013. }
  147014. declare module BABYLON {
  147015. /**
  147016. * Polygon
  147017. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  147018. */
  147019. export class Polygon {
  147020. /**
  147021. * Creates a rectangle
  147022. * @param xmin bottom X coord
  147023. * @param ymin bottom Y coord
  147024. * @param xmax top X coord
  147025. * @param ymax top Y coord
  147026. * @returns points that make the resulting rectation
  147027. */
  147028. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  147029. /**
  147030. * Creates a circle
  147031. * @param radius radius of circle
  147032. * @param cx scale in x
  147033. * @param cy scale in y
  147034. * @param numberOfSides number of sides that make up the circle
  147035. * @returns points that make the resulting circle
  147036. */
  147037. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  147038. /**
  147039. * Creates a polygon from input string
  147040. * @param input Input polygon data
  147041. * @returns the parsed points
  147042. */
  147043. static Parse(input: string): Vector2[];
  147044. /**
  147045. * Starts building a polygon from x and y coordinates
  147046. * @param x x coordinate
  147047. * @param y y coordinate
  147048. * @returns the started path2
  147049. */
  147050. static StartingAt(x: number, y: number): Path2;
  147051. }
  147052. /**
  147053. * Builds a polygon
  147054. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  147055. */
  147056. export class PolygonMeshBuilder {
  147057. private _points;
  147058. private _outlinepoints;
  147059. private _holes;
  147060. private _name;
  147061. private _scene;
  147062. private _epoints;
  147063. private _eholes;
  147064. private _addToepoint;
  147065. /**
  147066. * Babylon reference to the earcut plugin.
  147067. */
  147068. bjsEarcut: any;
  147069. /**
  147070. * Creates a PolygonMeshBuilder
  147071. * @param name name of the builder
  147072. * @param contours Path of the polygon
  147073. * @param scene scene to add to when creating the mesh
  147074. * @param earcutInjection can be used to inject your own earcut reference
  147075. */
  147076. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  147077. /**
  147078. * Adds a whole within the polygon
  147079. * @param hole Array of points defining the hole
  147080. * @returns this
  147081. */
  147082. addHole(hole: Vector2[]): PolygonMeshBuilder;
  147083. /**
  147084. * Creates the polygon
  147085. * @param updatable If the mesh should be updatable
  147086. * @param depth The depth of the mesh created
  147087. * @returns the created mesh
  147088. */
  147089. build(updatable?: boolean, depth?: number): Mesh;
  147090. /**
  147091. * Creates the polygon
  147092. * @param depth The depth of the mesh created
  147093. * @returns the created VertexData
  147094. */
  147095. buildVertexData(depth?: number): VertexData;
  147096. /**
  147097. * Adds a side to the polygon
  147098. * @param positions points that make the polygon
  147099. * @param normals normals of the polygon
  147100. * @param uvs uvs of the polygon
  147101. * @param indices indices of the polygon
  147102. * @param bounds bounds of the polygon
  147103. * @param points points of the polygon
  147104. * @param depth depth of the polygon
  147105. * @param flip flip of the polygon
  147106. */
  147107. private addSide;
  147108. }
  147109. }
  147110. declare module BABYLON {
  147111. /**
  147112. * Class containing static functions to help procedurally build meshes
  147113. */
  147114. export class PolygonBuilder {
  147115. /**
  147116. * Creates a polygon mesh
  147117. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  147118. * * 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
  147119. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147121. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  147122. * * Remember you can only change the shape positions, not their number when updating a polygon
  147123. * @param name defines the name of the mesh
  147124. * @param options defines the options used to create the mesh
  147125. * @param scene defines the hosting scene
  147126. * @param earcutInjection can be used to inject your own earcut reference
  147127. * @returns the polygon mesh
  147128. */
  147129. static CreatePolygon(name: string, options: {
  147130. shape: Vector3[];
  147131. holes?: Vector3[][];
  147132. depth?: number;
  147133. faceUV?: Vector4[];
  147134. faceColors?: Color4[];
  147135. updatable?: boolean;
  147136. sideOrientation?: number;
  147137. frontUVs?: Vector4;
  147138. backUVs?: Vector4;
  147139. wrap?: boolean;
  147140. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147141. /**
  147142. * Creates an extruded polygon mesh, with depth in the Y direction.
  147143. * * 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)
  147144. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147145. * @param name defines the name of the mesh
  147146. * @param options defines the options used to create the mesh
  147147. * @param scene defines the hosting scene
  147148. * @param earcutInjection can be used to inject your own earcut reference
  147149. * @returns the polygon mesh
  147150. */
  147151. static ExtrudePolygon(name: string, options: {
  147152. shape: Vector3[];
  147153. holes?: Vector3[][];
  147154. depth?: number;
  147155. faceUV?: Vector4[];
  147156. faceColors?: Color4[];
  147157. updatable?: boolean;
  147158. sideOrientation?: number;
  147159. frontUVs?: Vector4;
  147160. backUVs?: Vector4;
  147161. wrap?: boolean;
  147162. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147163. }
  147164. }
  147165. declare module BABYLON {
  147166. /**
  147167. * Class containing static functions to help procedurally build meshes
  147168. */
  147169. export class LatheBuilder {
  147170. /**
  147171. * Creates lathe mesh.
  147172. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  147173. * * 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
  147174. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  147175. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  147176. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  147177. * * 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
  147178. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  147179. * * 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
  147180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147181. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147182. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147184. * @param name defines the name of the mesh
  147185. * @param options defines the options used to create the mesh
  147186. * @param scene defines the hosting scene
  147187. * @returns the lathe mesh
  147188. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  147189. */
  147190. static CreateLathe(name: string, options: {
  147191. shape: Vector3[];
  147192. radius?: number;
  147193. tessellation?: number;
  147194. clip?: number;
  147195. arc?: number;
  147196. closed?: boolean;
  147197. updatable?: boolean;
  147198. sideOrientation?: number;
  147199. frontUVs?: Vector4;
  147200. backUVs?: Vector4;
  147201. cap?: number;
  147202. invertUV?: boolean;
  147203. }, scene?: Nullable<Scene>): Mesh;
  147204. }
  147205. }
  147206. declare module BABYLON {
  147207. /**
  147208. * Class containing static functions to help procedurally build meshes
  147209. */
  147210. export class TiledPlaneBuilder {
  147211. /**
  147212. * Creates a tiled plane mesh
  147213. * * The parameter `pattern` will, depending on value, do nothing or
  147214. * * * flip (reflect about central vertical) alternate tiles across and up
  147215. * * * flip every tile on alternate rows
  147216. * * * rotate (180 degs) alternate tiles across and up
  147217. * * * rotate every tile on alternate rows
  147218. * * * flip and rotate alternate tiles across and up
  147219. * * * flip and rotate every tile on alternate rows
  147220. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  147221. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  147222. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147223. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147224. * * 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)
  147225. * * 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)
  147226. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  147227. * @param name defines the name of the mesh
  147228. * @param options defines the options used to create the mesh
  147229. * @param scene defines the hosting scene
  147230. * @returns the box mesh
  147231. */
  147232. static CreateTiledPlane(name: string, options: {
  147233. pattern?: number;
  147234. tileSize?: number;
  147235. tileWidth?: number;
  147236. tileHeight?: number;
  147237. size?: number;
  147238. width?: number;
  147239. height?: number;
  147240. alignHorizontal?: number;
  147241. alignVertical?: number;
  147242. sideOrientation?: number;
  147243. frontUVs?: Vector4;
  147244. backUVs?: Vector4;
  147245. updatable?: boolean;
  147246. }, scene?: Nullable<Scene>): Mesh;
  147247. }
  147248. }
  147249. declare module BABYLON {
  147250. /**
  147251. * Class containing static functions to help procedurally build meshes
  147252. */
  147253. export class TubeBuilder {
  147254. /**
  147255. * Creates a tube mesh.
  147256. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147257. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  147258. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  147259. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  147260. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147261. * * 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)
  147262. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147263. * * 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
  147264. * * 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
  147265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147266. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147267. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147269. * @param name defines the name of the mesh
  147270. * @param options defines the options used to create the mesh
  147271. * @param scene defines the hosting scene
  147272. * @returns the tube mesh
  147273. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147274. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  147275. */
  147276. static CreateTube(name: string, options: {
  147277. path: Vector3[];
  147278. radius?: number;
  147279. tessellation?: number;
  147280. radiusFunction?: {
  147281. (i: number, distance: number): number;
  147282. };
  147283. cap?: number;
  147284. arc?: number;
  147285. updatable?: boolean;
  147286. sideOrientation?: number;
  147287. frontUVs?: Vector4;
  147288. backUVs?: Vector4;
  147289. instance?: Mesh;
  147290. invertUV?: boolean;
  147291. }, scene?: Nullable<Scene>): Mesh;
  147292. }
  147293. }
  147294. declare module BABYLON {
  147295. /**
  147296. * Class containing static functions to help procedurally build meshes
  147297. */
  147298. export class IcoSphereBuilder {
  147299. /**
  147300. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  147301. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  147302. * * 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`)
  147303. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  147304. * * 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
  147305. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147306. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147308. * @param name defines the name of the mesh
  147309. * @param options defines the options used to create the mesh
  147310. * @param scene defines the hosting scene
  147311. * @returns the icosahedron mesh
  147312. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  147313. */
  147314. static CreateIcoSphere(name: string, options: {
  147315. radius?: number;
  147316. radiusX?: number;
  147317. radiusY?: number;
  147318. radiusZ?: number;
  147319. flat?: boolean;
  147320. subdivisions?: number;
  147321. sideOrientation?: number;
  147322. frontUVs?: Vector4;
  147323. backUVs?: Vector4;
  147324. updatable?: boolean;
  147325. }, scene?: Nullable<Scene>): Mesh;
  147326. }
  147327. }
  147328. declare module BABYLON {
  147329. /**
  147330. * Class containing static functions to help procedurally build meshes
  147331. */
  147332. export class DecalBuilder {
  147333. /**
  147334. * Creates a decal mesh.
  147335. * 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
  147336. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  147337. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  147338. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  147339. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  147340. * @param name defines the name of the mesh
  147341. * @param sourceMesh defines the mesh where the decal must be applied
  147342. * @param options defines the options used to create the mesh
  147343. * @param scene defines the hosting scene
  147344. * @returns the decal mesh
  147345. * @see https://doc.babylonjs.com/how_to/decals
  147346. */
  147347. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  147348. position?: Vector3;
  147349. normal?: Vector3;
  147350. size?: Vector3;
  147351. angle?: number;
  147352. }): Mesh;
  147353. }
  147354. }
  147355. declare module BABYLON {
  147356. /**
  147357. * Class containing static functions to help procedurally build meshes
  147358. */
  147359. export class MeshBuilder {
  147360. /**
  147361. * Creates a box mesh
  147362. * * The parameter `size` sets the size (float) of each box side (default 1)
  147363. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  147364. * * 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)
  147365. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147367. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147369. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  147370. * @param name defines the name of the mesh
  147371. * @param options defines the options used to create the mesh
  147372. * @param scene defines the hosting scene
  147373. * @returns the box mesh
  147374. */
  147375. static CreateBox(name: string, options: {
  147376. size?: number;
  147377. width?: number;
  147378. height?: number;
  147379. depth?: number;
  147380. faceUV?: Vector4[];
  147381. faceColors?: Color4[];
  147382. sideOrientation?: number;
  147383. frontUVs?: Vector4;
  147384. backUVs?: Vector4;
  147385. wrap?: boolean;
  147386. topBaseAt?: number;
  147387. bottomBaseAt?: number;
  147388. updatable?: boolean;
  147389. }, scene?: Nullable<Scene>): Mesh;
  147390. /**
  147391. * Creates a tiled box mesh
  147392. * * faceTiles sets the pattern, tile size and number of tiles for a face
  147393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147394. * @param name defines the name of the mesh
  147395. * @param options defines the options used to create the mesh
  147396. * @param scene defines the hosting scene
  147397. * @returns the tiled box mesh
  147398. */
  147399. static CreateTiledBox(name: string, options: {
  147400. pattern?: number;
  147401. size?: number;
  147402. width?: number;
  147403. height?: number;
  147404. depth: number;
  147405. tileSize?: number;
  147406. tileWidth?: number;
  147407. tileHeight?: number;
  147408. faceUV?: Vector4[];
  147409. faceColors?: Color4[];
  147410. alignHorizontal?: number;
  147411. alignVertical?: number;
  147412. sideOrientation?: number;
  147413. updatable?: boolean;
  147414. }, scene?: Nullable<Scene>): Mesh;
  147415. /**
  147416. * Creates a sphere mesh
  147417. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  147418. * * 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`)
  147419. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  147420. * * 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
  147421. * * 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)
  147422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147423. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147425. * @param name defines the name of the mesh
  147426. * @param options defines the options used to create the mesh
  147427. * @param scene defines the hosting scene
  147428. * @returns the sphere mesh
  147429. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  147430. */
  147431. static CreateSphere(name: string, options: {
  147432. segments?: number;
  147433. diameter?: number;
  147434. diameterX?: number;
  147435. diameterY?: number;
  147436. diameterZ?: number;
  147437. arc?: number;
  147438. slice?: number;
  147439. sideOrientation?: number;
  147440. frontUVs?: Vector4;
  147441. backUVs?: Vector4;
  147442. updatable?: boolean;
  147443. }, scene?: Nullable<Scene>): Mesh;
  147444. /**
  147445. * Creates a plane polygonal mesh. By default, this is a disc
  147446. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  147447. * * 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
  147448. * * 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
  147449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147452. * @param name defines the name of the mesh
  147453. * @param options defines the options used to create the mesh
  147454. * @param scene defines the hosting scene
  147455. * @returns the plane polygonal mesh
  147456. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  147457. */
  147458. static CreateDisc(name: string, options: {
  147459. radius?: number;
  147460. tessellation?: number;
  147461. arc?: number;
  147462. updatable?: boolean;
  147463. sideOrientation?: number;
  147464. frontUVs?: Vector4;
  147465. backUVs?: Vector4;
  147466. }, scene?: Nullable<Scene>): Mesh;
  147467. /**
  147468. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  147469. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  147470. * * 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`)
  147471. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  147472. * * 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
  147473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147474. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147476. * @param name defines the name of the mesh
  147477. * @param options defines the options used to create the mesh
  147478. * @param scene defines the hosting scene
  147479. * @returns the icosahedron mesh
  147480. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  147481. */
  147482. static CreateIcoSphere(name: string, options: {
  147483. radius?: number;
  147484. radiusX?: number;
  147485. radiusY?: number;
  147486. radiusZ?: number;
  147487. flat?: boolean;
  147488. subdivisions?: number;
  147489. sideOrientation?: number;
  147490. frontUVs?: Vector4;
  147491. backUVs?: Vector4;
  147492. updatable?: boolean;
  147493. }, scene?: Nullable<Scene>): Mesh;
  147494. /**
  147495. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147496. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  147497. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  147498. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  147499. * * 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
  147500. * * 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
  147501. * * 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
  147502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147503. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147504. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147505. * * 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
  147506. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  147507. * * 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
  147508. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  147509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147510. * @param name defines the name of the mesh
  147511. * @param options defines the options used to create the mesh
  147512. * @param scene defines the hosting scene
  147513. * @returns the ribbon mesh
  147514. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  147515. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147516. */
  147517. static CreateRibbon(name: string, options: {
  147518. pathArray: Vector3[][];
  147519. closeArray?: boolean;
  147520. closePath?: boolean;
  147521. offset?: number;
  147522. updatable?: boolean;
  147523. sideOrientation?: number;
  147524. frontUVs?: Vector4;
  147525. backUVs?: Vector4;
  147526. instance?: Mesh;
  147527. invertUV?: boolean;
  147528. uvs?: Vector2[];
  147529. colors?: Color4[];
  147530. }, scene?: Nullable<Scene>): Mesh;
  147531. /**
  147532. * Creates a cylinder or a cone mesh
  147533. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  147534. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  147535. * * 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.
  147536. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  147537. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  147538. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  147539. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  147540. * * 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).
  147541. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  147542. * * 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).
  147543. * * 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
  147544. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  147545. * * 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
  147546. * * 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.
  147547. * * If `enclose` is false, a ring surface is one element.
  147548. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  147549. * * 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
  147550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147551. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147553. * @param name defines the name of the mesh
  147554. * @param options defines the options used to create the mesh
  147555. * @param scene defines the hosting scene
  147556. * @returns the cylinder mesh
  147557. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  147558. */
  147559. static CreateCylinder(name: string, options: {
  147560. height?: number;
  147561. diameterTop?: number;
  147562. diameterBottom?: number;
  147563. diameter?: number;
  147564. tessellation?: number;
  147565. subdivisions?: number;
  147566. arc?: number;
  147567. faceColors?: Color4[];
  147568. faceUV?: Vector4[];
  147569. updatable?: boolean;
  147570. hasRings?: boolean;
  147571. enclose?: boolean;
  147572. cap?: number;
  147573. sideOrientation?: number;
  147574. frontUVs?: Vector4;
  147575. backUVs?: Vector4;
  147576. }, scene?: Nullable<Scene>): Mesh;
  147577. /**
  147578. * Creates a torus mesh
  147579. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  147580. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  147581. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  147582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147583. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147585. * @param name defines the name of the mesh
  147586. * @param options defines the options used to create the mesh
  147587. * @param scene defines the hosting scene
  147588. * @returns the torus mesh
  147589. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  147590. */
  147591. static CreateTorus(name: string, options: {
  147592. diameter?: number;
  147593. thickness?: number;
  147594. tessellation?: number;
  147595. updatable?: boolean;
  147596. sideOrientation?: number;
  147597. frontUVs?: Vector4;
  147598. backUVs?: Vector4;
  147599. }, scene?: Nullable<Scene>): Mesh;
  147600. /**
  147601. * Creates a torus knot mesh
  147602. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  147603. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  147604. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  147605. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  147606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147607. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147609. * @param name defines the name of the mesh
  147610. * @param options defines the options used to create the mesh
  147611. * @param scene defines the hosting scene
  147612. * @returns the torus knot mesh
  147613. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  147614. */
  147615. static CreateTorusKnot(name: string, options: {
  147616. radius?: number;
  147617. tube?: number;
  147618. radialSegments?: number;
  147619. tubularSegments?: number;
  147620. p?: number;
  147621. q?: number;
  147622. updatable?: boolean;
  147623. sideOrientation?: number;
  147624. frontUVs?: Vector4;
  147625. backUVs?: Vector4;
  147626. }, scene?: Nullable<Scene>): Mesh;
  147627. /**
  147628. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  147629. * * 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
  147630. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  147631. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  147632. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  147633. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  147634. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  147635. * * 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
  147636. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  147637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147638. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  147639. * @param name defines the name of the new line system
  147640. * @param options defines the options used to create the line system
  147641. * @param scene defines the hosting scene
  147642. * @returns a new line system mesh
  147643. */
  147644. static CreateLineSystem(name: string, options: {
  147645. lines: Vector3[][];
  147646. updatable?: boolean;
  147647. instance?: Nullable<LinesMesh>;
  147648. colors?: Nullable<Color4[][]>;
  147649. useVertexAlpha?: boolean;
  147650. }, scene: Nullable<Scene>): LinesMesh;
  147651. /**
  147652. * Creates a line mesh
  147653. * 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
  147654. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  147655. * * The parameter `points` is an array successive Vector3
  147656. * * 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
  147657. * * The optional parameter `colors` is an array of successive Color4, one per line point
  147658. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  147659. * * When updating an instance, remember that only point positions can change, not the number of points
  147660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147661. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  147662. * @param name defines the name of the new line system
  147663. * @param options defines the options used to create the line system
  147664. * @param scene defines the hosting scene
  147665. * @returns a new line mesh
  147666. */
  147667. static CreateLines(name: string, options: {
  147668. points: Vector3[];
  147669. updatable?: boolean;
  147670. instance?: Nullable<LinesMesh>;
  147671. colors?: Color4[];
  147672. useVertexAlpha?: boolean;
  147673. }, scene?: Nullable<Scene>): LinesMesh;
  147674. /**
  147675. * Creates a dashed line mesh
  147676. * * 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
  147677. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  147678. * * The parameter `points` is an array successive Vector3
  147679. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  147680. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  147681. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  147682. * * 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
  147683. * * When updating an instance, remember that only point positions can change, not the number of points
  147684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147685. * @param name defines the name of the mesh
  147686. * @param options defines the options used to create the mesh
  147687. * @param scene defines the hosting scene
  147688. * @returns the dashed line mesh
  147689. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  147690. */
  147691. static CreateDashedLines(name: string, options: {
  147692. points: Vector3[];
  147693. dashSize?: number;
  147694. gapSize?: number;
  147695. dashNb?: number;
  147696. updatable?: boolean;
  147697. instance?: LinesMesh;
  147698. }, scene?: Nullable<Scene>): LinesMesh;
  147699. /**
  147700. * 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.
  147701. * * 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.
  147702. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  147703. * * 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.
  147704. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  147705. * * 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
  147706. * * 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
  147707. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  147708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147709. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147710. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  147711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147712. * @param name defines the name of the mesh
  147713. * @param options defines the options used to create the mesh
  147714. * @param scene defines the hosting scene
  147715. * @returns the extruded shape mesh
  147716. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147717. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  147718. */
  147719. static ExtrudeShape(name: string, options: {
  147720. shape: Vector3[];
  147721. path: Vector3[];
  147722. scale?: number;
  147723. rotation?: number;
  147724. cap?: number;
  147725. updatable?: boolean;
  147726. sideOrientation?: number;
  147727. frontUVs?: Vector4;
  147728. backUVs?: Vector4;
  147729. instance?: Mesh;
  147730. invertUV?: boolean;
  147731. }, scene?: Nullable<Scene>): Mesh;
  147732. /**
  147733. * Creates an custom extruded shape mesh.
  147734. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  147735. * * 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.
  147736. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  147737. * * 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
  147738. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  147739. * * 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
  147740. * * It must returns a float value that will be the scale value applied to the shape on each path point
  147741. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  147742. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  147743. * * 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
  147744. * * 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
  147745. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  147746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147747. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147748. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147750. * @param name defines the name of the mesh
  147751. * @param options defines the options used to create the mesh
  147752. * @param scene defines the hosting scene
  147753. * @returns the custom extruded shape mesh
  147754. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  147755. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147756. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  147757. */
  147758. static ExtrudeShapeCustom(name: string, options: {
  147759. shape: Vector3[];
  147760. path: Vector3[];
  147761. scaleFunction?: any;
  147762. rotationFunction?: any;
  147763. ribbonCloseArray?: boolean;
  147764. ribbonClosePath?: boolean;
  147765. cap?: number;
  147766. updatable?: boolean;
  147767. sideOrientation?: number;
  147768. frontUVs?: Vector4;
  147769. backUVs?: Vector4;
  147770. instance?: Mesh;
  147771. invertUV?: boolean;
  147772. }, scene?: Nullable<Scene>): Mesh;
  147773. /**
  147774. * Creates lathe mesh.
  147775. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  147776. * * 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
  147777. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  147778. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  147779. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  147780. * * 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
  147781. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  147782. * * 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
  147783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147784. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147785. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147787. * @param name defines the name of the mesh
  147788. * @param options defines the options used to create the mesh
  147789. * @param scene defines the hosting scene
  147790. * @returns the lathe mesh
  147791. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  147792. */
  147793. static CreateLathe(name: string, options: {
  147794. shape: Vector3[];
  147795. radius?: number;
  147796. tessellation?: number;
  147797. clip?: number;
  147798. arc?: number;
  147799. closed?: boolean;
  147800. updatable?: boolean;
  147801. sideOrientation?: number;
  147802. frontUVs?: Vector4;
  147803. backUVs?: Vector4;
  147804. cap?: number;
  147805. invertUV?: boolean;
  147806. }, scene?: Nullable<Scene>): Mesh;
  147807. /**
  147808. * Creates a tiled plane mesh
  147809. * * You can set a limited pattern arrangement with the tiles
  147810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147811. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147813. * @param name defines the name of the mesh
  147814. * @param options defines the options used to create the mesh
  147815. * @param scene defines the hosting scene
  147816. * @returns the plane mesh
  147817. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  147818. */
  147819. static CreateTiledPlane(name: string, options: {
  147820. pattern?: number;
  147821. tileSize?: number;
  147822. tileWidth?: number;
  147823. tileHeight?: number;
  147824. size?: number;
  147825. width?: number;
  147826. height?: number;
  147827. alignHorizontal?: number;
  147828. alignVertical?: number;
  147829. sideOrientation?: number;
  147830. frontUVs?: Vector4;
  147831. backUVs?: Vector4;
  147832. updatable?: boolean;
  147833. }, scene?: Nullable<Scene>): Mesh;
  147834. /**
  147835. * Creates a plane mesh
  147836. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  147837. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  147838. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  147839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147840. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147842. * @param name defines the name of the mesh
  147843. * @param options defines the options used to create the mesh
  147844. * @param scene defines the hosting scene
  147845. * @returns the plane mesh
  147846. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  147847. */
  147848. static CreatePlane(name: string, options: {
  147849. size?: number;
  147850. width?: number;
  147851. height?: number;
  147852. sideOrientation?: number;
  147853. frontUVs?: Vector4;
  147854. backUVs?: Vector4;
  147855. updatable?: boolean;
  147856. sourcePlane?: Plane;
  147857. }, scene?: Nullable<Scene>): Mesh;
  147858. /**
  147859. * Creates a ground mesh
  147860. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  147861. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  147862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147863. * @param name defines the name of the mesh
  147864. * @param options defines the options used to create the mesh
  147865. * @param scene defines the hosting scene
  147866. * @returns the ground mesh
  147867. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  147868. */
  147869. static CreateGround(name: string, options: {
  147870. width?: number;
  147871. height?: number;
  147872. subdivisions?: number;
  147873. subdivisionsX?: number;
  147874. subdivisionsY?: number;
  147875. updatable?: boolean;
  147876. }, scene?: Nullable<Scene>): Mesh;
  147877. /**
  147878. * Creates a tiled ground mesh
  147879. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  147880. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  147881. * * 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
  147882. * * 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
  147883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147884. * @param name defines the name of the mesh
  147885. * @param options defines the options used to create the mesh
  147886. * @param scene defines the hosting scene
  147887. * @returns the tiled ground mesh
  147888. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  147889. */
  147890. static CreateTiledGround(name: string, options: {
  147891. xmin: number;
  147892. zmin: number;
  147893. xmax: number;
  147894. zmax: number;
  147895. subdivisions?: {
  147896. w: number;
  147897. h: number;
  147898. };
  147899. precision?: {
  147900. w: number;
  147901. h: number;
  147902. };
  147903. updatable?: boolean;
  147904. }, scene?: Nullable<Scene>): Mesh;
  147905. /**
  147906. * Creates a ground mesh from a height map
  147907. * * The parameter `url` sets the URL of the height map image resource.
  147908. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  147909. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  147910. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  147911. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  147912. * * 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.
  147913. * * 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).
  147914. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  147915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147916. * @param name defines the name of the mesh
  147917. * @param url defines the url to the height map
  147918. * @param options defines the options used to create the mesh
  147919. * @param scene defines the hosting scene
  147920. * @returns the ground mesh
  147921. * @see https://doc.babylonjs.com/babylon101/height_map
  147922. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  147923. */
  147924. static CreateGroundFromHeightMap(name: string, url: string, options: {
  147925. width?: number;
  147926. height?: number;
  147927. subdivisions?: number;
  147928. minHeight?: number;
  147929. maxHeight?: number;
  147930. colorFilter?: Color3;
  147931. alphaFilter?: number;
  147932. updatable?: boolean;
  147933. onReady?: (mesh: GroundMesh) => void;
  147934. }, scene?: Nullable<Scene>): GroundMesh;
  147935. /**
  147936. * Creates a polygon mesh
  147937. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  147938. * * 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
  147939. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147941. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  147942. * * Remember you can only change the shape positions, not their number when updating a polygon
  147943. * @param name defines the name of the mesh
  147944. * @param options defines the options used to create the mesh
  147945. * @param scene defines the hosting scene
  147946. * @param earcutInjection can be used to inject your own earcut reference
  147947. * @returns the polygon mesh
  147948. */
  147949. static CreatePolygon(name: string, options: {
  147950. shape: Vector3[];
  147951. holes?: Vector3[][];
  147952. depth?: number;
  147953. faceUV?: Vector4[];
  147954. faceColors?: Color4[];
  147955. updatable?: boolean;
  147956. sideOrientation?: number;
  147957. frontUVs?: Vector4;
  147958. backUVs?: Vector4;
  147959. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147960. /**
  147961. * Creates an extruded polygon mesh, with depth in the Y direction.
  147962. * * 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)
  147963. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147964. * @param name defines the name of the mesh
  147965. * @param options defines the options used to create the mesh
  147966. * @param scene defines the hosting scene
  147967. * @param earcutInjection can be used to inject your own earcut reference
  147968. * @returns the polygon mesh
  147969. */
  147970. static ExtrudePolygon(name: string, options: {
  147971. shape: Vector3[];
  147972. holes?: Vector3[][];
  147973. depth?: number;
  147974. faceUV?: Vector4[];
  147975. faceColors?: Color4[];
  147976. updatable?: boolean;
  147977. sideOrientation?: number;
  147978. frontUVs?: Vector4;
  147979. backUVs?: Vector4;
  147980. wrap?: boolean;
  147981. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147982. /**
  147983. * Creates a tube mesh.
  147984. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147985. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  147986. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  147987. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  147988. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147989. * * 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)
  147990. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147991. * * 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
  147992. * * 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
  147993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147994. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147995. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147997. * @param name defines the name of the mesh
  147998. * @param options defines the options used to create the mesh
  147999. * @param scene defines the hosting scene
  148000. * @returns the tube mesh
  148001. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148002. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  148003. */
  148004. static CreateTube(name: string, options: {
  148005. path: Vector3[];
  148006. radius?: number;
  148007. tessellation?: number;
  148008. radiusFunction?: {
  148009. (i: number, distance: number): number;
  148010. };
  148011. cap?: number;
  148012. arc?: number;
  148013. updatable?: boolean;
  148014. sideOrientation?: number;
  148015. frontUVs?: Vector4;
  148016. backUVs?: Vector4;
  148017. instance?: Mesh;
  148018. invertUV?: boolean;
  148019. }, scene?: Nullable<Scene>): Mesh;
  148020. /**
  148021. * Creates a polyhedron mesh
  148022. * * 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
  148023. * * The parameter `size` (positive float, default 1) sets the polygon size
  148024. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  148025. * * 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`
  148026. * * 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
  148027. * * 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)`)
  148028. * * 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
  148029. * * 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
  148030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148031. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148033. * @param name defines the name of the mesh
  148034. * @param options defines the options used to create the mesh
  148035. * @param scene defines the hosting scene
  148036. * @returns the polyhedron mesh
  148037. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  148038. */
  148039. static CreatePolyhedron(name: string, options: {
  148040. type?: number;
  148041. size?: number;
  148042. sizeX?: number;
  148043. sizeY?: number;
  148044. sizeZ?: number;
  148045. custom?: any;
  148046. faceUV?: Vector4[];
  148047. faceColors?: Color4[];
  148048. flat?: boolean;
  148049. updatable?: boolean;
  148050. sideOrientation?: number;
  148051. frontUVs?: Vector4;
  148052. backUVs?: Vector4;
  148053. }, scene?: Nullable<Scene>): Mesh;
  148054. /**
  148055. * Creates a decal mesh.
  148056. * 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
  148057. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  148058. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  148059. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  148060. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  148061. * @param name defines the name of the mesh
  148062. * @param sourceMesh defines the mesh where the decal must be applied
  148063. * @param options defines the options used to create the mesh
  148064. * @param scene defines the hosting scene
  148065. * @returns the decal mesh
  148066. * @see https://doc.babylonjs.com/how_to/decals
  148067. */
  148068. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  148069. position?: Vector3;
  148070. normal?: Vector3;
  148071. size?: Vector3;
  148072. angle?: number;
  148073. }): Mesh;
  148074. /**
  148075. * Creates a Capsule Mesh
  148076. * @param name defines the name of the mesh.
  148077. * @param options the constructors options used to shape the mesh.
  148078. * @param scene defines the scene the mesh is scoped to.
  148079. * @returns the capsule mesh
  148080. * @see https://doc.babylonjs.com/how_to/capsule_shape
  148081. */
  148082. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  148083. }
  148084. }
  148085. declare module BABYLON {
  148086. /**
  148087. * A simplifier interface for future simplification implementations
  148088. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148089. */
  148090. export interface ISimplifier {
  148091. /**
  148092. * Simplification of a given mesh according to the given settings.
  148093. * Since this requires computation, it is assumed that the function runs async.
  148094. * @param settings The settings of the simplification, including quality and distance
  148095. * @param successCallback A callback that will be called after the mesh was simplified.
  148096. * @param errorCallback in case of an error, this callback will be called. optional.
  148097. */
  148098. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  148099. }
  148100. /**
  148101. * Expected simplification settings.
  148102. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  148103. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148104. */
  148105. export interface ISimplificationSettings {
  148106. /**
  148107. * Gets or sets the expected quality
  148108. */
  148109. quality: number;
  148110. /**
  148111. * Gets or sets the distance when this optimized version should be used
  148112. */
  148113. distance: number;
  148114. /**
  148115. * Gets an already optimized mesh
  148116. */
  148117. optimizeMesh?: boolean;
  148118. }
  148119. /**
  148120. * Class used to specify simplification options
  148121. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148122. */
  148123. export class SimplificationSettings implements ISimplificationSettings {
  148124. /** expected quality */
  148125. quality: number;
  148126. /** distance when this optimized version should be used */
  148127. distance: number;
  148128. /** already optimized mesh */
  148129. optimizeMesh?: boolean | undefined;
  148130. /**
  148131. * Creates a SimplificationSettings
  148132. * @param quality expected quality
  148133. * @param distance distance when this optimized version should be used
  148134. * @param optimizeMesh already optimized mesh
  148135. */
  148136. constructor(
  148137. /** expected quality */
  148138. quality: number,
  148139. /** distance when this optimized version should be used */
  148140. distance: number,
  148141. /** already optimized mesh */
  148142. optimizeMesh?: boolean | undefined);
  148143. }
  148144. /**
  148145. * Interface used to define a simplification task
  148146. */
  148147. export interface ISimplificationTask {
  148148. /**
  148149. * Array of settings
  148150. */
  148151. settings: Array<ISimplificationSettings>;
  148152. /**
  148153. * Simplification type
  148154. */
  148155. simplificationType: SimplificationType;
  148156. /**
  148157. * Mesh to simplify
  148158. */
  148159. mesh: Mesh;
  148160. /**
  148161. * Callback called on success
  148162. */
  148163. successCallback?: () => void;
  148164. /**
  148165. * Defines if parallel processing can be used
  148166. */
  148167. parallelProcessing: boolean;
  148168. }
  148169. /**
  148170. * Queue used to order the simplification tasks
  148171. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148172. */
  148173. export class SimplificationQueue {
  148174. private _simplificationArray;
  148175. /**
  148176. * Gets a boolean indicating that the process is still running
  148177. */
  148178. running: boolean;
  148179. /**
  148180. * Creates a new queue
  148181. */
  148182. constructor();
  148183. /**
  148184. * Adds a new simplification task
  148185. * @param task defines a task to add
  148186. */
  148187. addTask(task: ISimplificationTask): void;
  148188. /**
  148189. * Execute next task
  148190. */
  148191. executeNext(): void;
  148192. /**
  148193. * Execute a simplification task
  148194. * @param task defines the task to run
  148195. */
  148196. runSimplification(task: ISimplificationTask): void;
  148197. private getSimplifier;
  148198. }
  148199. /**
  148200. * The implemented types of simplification
  148201. * At the moment only Quadratic Error Decimation is implemented
  148202. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148203. */
  148204. export enum SimplificationType {
  148205. /** Quadratic error decimation */
  148206. QUADRATIC = 0
  148207. }
  148208. /**
  148209. * An implementation of the Quadratic Error simplification algorithm.
  148210. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  148211. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  148212. * @author RaananW
  148213. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148214. */
  148215. export class QuadraticErrorSimplification implements ISimplifier {
  148216. private _mesh;
  148217. private triangles;
  148218. private vertices;
  148219. private references;
  148220. private _reconstructedMesh;
  148221. /** Gets or sets the number pf sync interations */
  148222. syncIterations: number;
  148223. /** Gets or sets the aggressiveness of the simplifier */
  148224. aggressiveness: number;
  148225. /** Gets or sets the number of allowed iterations for decimation */
  148226. decimationIterations: number;
  148227. /** Gets or sets the espilon to use for bounding box computation */
  148228. boundingBoxEpsilon: number;
  148229. /**
  148230. * Creates a new QuadraticErrorSimplification
  148231. * @param _mesh defines the target mesh
  148232. */
  148233. constructor(_mesh: Mesh);
  148234. /**
  148235. * Simplification of a given mesh according to the given settings.
  148236. * Since this requires computation, it is assumed that the function runs async.
  148237. * @param settings The settings of the simplification, including quality and distance
  148238. * @param successCallback A callback that will be called after the mesh was simplified.
  148239. */
  148240. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  148241. private runDecimation;
  148242. private initWithMesh;
  148243. private init;
  148244. private reconstructMesh;
  148245. private initDecimatedMesh;
  148246. private isFlipped;
  148247. private updateTriangles;
  148248. private identifyBorder;
  148249. private updateMesh;
  148250. private vertexError;
  148251. private calculateError;
  148252. }
  148253. }
  148254. declare module BABYLON {
  148255. interface Scene {
  148256. /** @hidden (Backing field) */
  148257. _simplificationQueue: SimplificationQueue;
  148258. /**
  148259. * Gets or sets the simplification queue attached to the scene
  148260. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148261. */
  148262. simplificationQueue: SimplificationQueue;
  148263. }
  148264. interface Mesh {
  148265. /**
  148266. * Simplify the mesh according to the given array of settings.
  148267. * Function will return immediately and will simplify async
  148268. * @param settings a collection of simplification settings
  148269. * @param parallelProcessing should all levels calculate parallel or one after the other
  148270. * @param simplificationType the type of simplification to run
  148271. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  148272. * @returns the current mesh
  148273. */
  148274. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  148275. }
  148276. /**
  148277. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  148278. * created in a scene
  148279. */
  148280. export class SimplicationQueueSceneComponent implements ISceneComponent {
  148281. /**
  148282. * The component name helpfull to identify the component in the list of scene components.
  148283. */
  148284. readonly name: string;
  148285. /**
  148286. * The scene the component belongs to.
  148287. */
  148288. scene: Scene;
  148289. /**
  148290. * Creates a new instance of the component for the given scene
  148291. * @param scene Defines the scene to register the component in
  148292. */
  148293. constructor(scene: Scene);
  148294. /**
  148295. * Registers the component in a given scene
  148296. */
  148297. register(): void;
  148298. /**
  148299. * Rebuilds the elements related to this component in case of
  148300. * context lost for instance.
  148301. */
  148302. rebuild(): void;
  148303. /**
  148304. * Disposes the component and the associated ressources
  148305. */
  148306. dispose(): void;
  148307. private _beforeCameraUpdate;
  148308. }
  148309. }
  148310. declare module BABYLON {
  148311. interface Mesh {
  148312. /**
  148313. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  148314. */
  148315. thinInstanceEnablePicking: boolean;
  148316. /**
  148317. * Creates a new thin instance
  148318. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  148319. * @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
  148320. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  148321. */
  148322. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  148323. /**
  148324. * Adds the transformation (matrix) of the current mesh as a thin instance
  148325. * @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
  148326. * @returns the thin instance index number
  148327. */
  148328. thinInstanceAddSelf(refresh: boolean): number;
  148329. /**
  148330. * Registers a custom attribute to be used with thin instances
  148331. * @param kind name of the attribute
  148332. * @param stride size in floats of the attribute
  148333. */
  148334. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  148335. /**
  148336. * Sets the matrix of a thin instance
  148337. * @param index index of the thin instance
  148338. * @param matrix matrix to set
  148339. * @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
  148340. */
  148341. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  148342. /**
  148343. * Sets the value of a custom attribute for a thin instance
  148344. * @param kind name of the attribute
  148345. * @param index index of the thin instance
  148346. * @param value value to set
  148347. * @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
  148348. */
  148349. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  148350. /**
  148351. * 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.
  148352. */
  148353. thinInstanceCount: number;
  148354. /**
  148355. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  148356. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  148357. * @param buffer buffer to set
  148358. * @param stride size in floats of each value of the buffer
  148359. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  148360. */
  148361. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  148362. /**
  148363. * Gets the list of world matrices
  148364. * @return an array containing all the world matrices from the thin instances
  148365. */
  148366. thinInstanceGetWorldMatrices(): Matrix[];
  148367. /**
  148368. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  148369. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  148370. */
  148371. thinInstanceBufferUpdated(kind: string): void;
  148372. /**
  148373. * Applies a partial update to a buffer directly on the GPU
  148374. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  148375. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  148376. * @param data the data to set in the GPU buffer
  148377. * @param offset the offset in the GPU buffer where to update the data
  148378. */
  148379. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  148380. /**
  148381. * Refreshes the bounding info, taking into account all the thin instances defined
  148382. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  148383. */
  148384. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  148385. /** @hidden */
  148386. _thinInstanceInitializeUserStorage(): void;
  148387. /** @hidden */
  148388. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  148389. /** @hidden */
  148390. _userThinInstanceBuffersStorage: {
  148391. data: {
  148392. [key: string]: Float32Array;
  148393. };
  148394. sizes: {
  148395. [key: string]: number;
  148396. };
  148397. vertexBuffers: {
  148398. [key: string]: Nullable<VertexBuffer>;
  148399. };
  148400. strides: {
  148401. [key: string]: number;
  148402. };
  148403. };
  148404. }
  148405. }
  148406. declare module BABYLON {
  148407. /**
  148408. * Navigation plugin interface to add navigation constrained by a navigation mesh
  148409. */
  148410. export interface INavigationEnginePlugin {
  148411. /**
  148412. * plugin name
  148413. */
  148414. name: string;
  148415. /**
  148416. * Creates a navigation mesh
  148417. * @param meshes array of all the geometry used to compute the navigatio mesh
  148418. * @param parameters bunch of parameters used to filter geometry
  148419. */
  148420. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  148421. /**
  148422. * Create a navigation mesh debug mesh
  148423. * @param scene is where the mesh will be added
  148424. * @returns debug display mesh
  148425. */
  148426. createDebugNavMesh(scene: Scene): Mesh;
  148427. /**
  148428. * Get a navigation mesh constrained position, closest to the parameter position
  148429. * @param position world position
  148430. * @returns the closest point to position constrained by the navigation mesh
  148431. */
  148432. getClosestPoint(position: Vector3): Vector3;
  148433. /**
  148434. * Get a navigation mesh constrained position, closest to the parameter position
  148435. * @param position world position
  148436. * @param result output the closest point to position constrained by the navigation mesh
  148437. */
  148438. getClosestPointToRef(position: Vector3, result: Vector3): void;
  148439. /**
  148440. * Get a navigation mesh constrained position, within a particular radius
  148441. * @param position world position
  148442. * @param maxRadius the maximum distance to the constrained world position
  148443. * @returns the closest point to position constrained by the navigation mesh
  148444. */
  148445. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  148446. /**
  148447. * Get a navigation mesh constrained position, within a particular radius
  148448. * @param position world position
  148449. * @param maxRadius the maximum distance to the constrained world position
  148450. * @param result output the closest point to position constrained by the navigation mesh
  148451. */
  148452. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  148453. /**
  148454. * Compute the final position from a segment made of destination-position
  148455. * @param position world position
  148456. * @param destination world position
  148457. * @returns the resulting point along the navmesh
  148458. */
  148459. moveAlong(position: Vector3, destination: Vector3): Vector3;
  148460. /**
  148461. * Compute the final position from a segment made of destination-position
  148462. * @param position world position
  148463. * @param destination world position
  148464. * @param result output the resulting point along the navmesh
  148465. */
  148466. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  148467. /**
  148468. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  148469. * @param start world position
  148470. * @param end world position
  148471. * @returns array containing world position composing the path
  148472. */
  148473. computePath(start: Vector3, end: Vector3): Vector3[];
  148474. /**
  148475. * If this plugin is supported
  148476. * @returns true if plugin is supported
  148477. */
  148478. isSupported(): boolean;
  148479. /**
  148480. * Create a new Crowd so you can add agents
  148481. * @param maxAgents the maximum agent count in the crowd
  148482. * @param maxAgentRadius the maximum radius an agent can have
  148483. * @param scene to attach the crowd to
  148484. * @returns the crowd you can add agents to
  148485. */
  148486. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  148487. /**
  148488. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148489. * The queries will try to find a solution within those bounds
  148490. * default is (1,1,1)
  148491. * @param extent x,y,z value that define the extent around the queries point of reference
  148492. */
  148493. setDefaultQueryExtent(extent: Vector3): void;
  148494. /**
  148495. * Get the Bounding box extent specified by setDefaultQueryExtent
  148496. * @returns the box extent values
  148497. */
  148498. getDefaultQueryExtent(): Vector3;
  148499. /**
  148500. * build the navmesh from a previously saved state using getNavmeshData
  148501. * @param data the Uint8Array returned by getNavmeshData
  148502. */
  148503. buildFromNavmeshData(data: Uint8Array): void;
  148504. /**
  148505. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  148506. * @returns data the Uint8Array that can be saved and reused
  148507. */
  148508. getNavmeshData(): Uint8Array;
  148509. /**
  148510. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148511. * @param result output the box extent values
  148512. */
  148513. getDefaultQueryExtentToRef(result: Vector3): void;
  148514. /**
  148515. * Release all resources
  148516. */
  148517. dispose(): void;
  148518. }
  148519. /**
  148520. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  148521. */
  148522. export interface ICrowd {
  148523. /**
  148524. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  148525. * You can attach anything to that node. The node position is updated in the scene update tick.
  148526. * @param pos world position that will be constrained by the navigation mesh
  148527. * @param parameters agent parameters
  148528. * @param transform hooked to the agent that will be update by the scene
  148529. * @returns agent index
  148530. */
  148531. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  148532. /**
  148533. * Returns the agent position in world space
  148534. * @param index agent index returned by addAgent
  148535. * @returns world space position
  148536. */
  148537. getAgentPosition(index: number): Vector3;
  148538. /**
  148539. * Gets the agent position result in world space
  148540. * @param index agent index returned by addAgent
  148541. * @param result output world space position
  148542. */
  148543. getAgentPositionToRef(index: number, result: Vector3): void;
  148544. /**
  148545. * Gets the agent velocity in world space
  148546. * @param index agent index returned by addAgent
  148547. * @returns world space velocity
  148548. */
  148549. getAgentVelocity(index: number): Vector3;
  148550. /**
  148551. * Gets the agent velocity result in world space
  148552. * @param index agent index returned by addAgent
  148553. * @param result output world space velocity
  148554. */
  148555. getAgentVelocityToRef(index: number, result: Vector3): void;
  148556. /**
  148557. * remove a particular agent previously created
  148558. * @param index agent index returned by addAgent
  148559. */
  148560. removeAgent(index: number): void;
  148561. /**
  148562. * get the list of all agents attached to this crowd
  148563. * @returns list of agent indices
  148564. */
  148565. getAgents(): number[];
  148566. /**
  148567. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  148568. * @param deltaTime in seconds
  148569. */
  148570. update(deltaTime: number): void;
  148571. /**
  148572. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  148573. * @param index agent index returned by addAgent
  148574. * @param destination targeted world position
  148575. */
  148576. agentGoto(index: number, destination: Vector3): void;
  148577. /**
  148578. * Teleport the agent to a new position
  148579. * @param index agent index returned by addAgent
  148580. * @param destination targeted world position
  148581. */
  148582. agentTeleport(index: number, destination: Vector3): void;
  148583. /**
  148584. * Update agent parameters
  148585. * @param index agent index returned by addAgent
  148586. * @param parameters agent parameters
  148587. */
  148588. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  148589. /**
  148590. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148591. * The queries will try to find a solution within those bounds
  148592. * default is (1,1,1)
  148593. * @param extent x,y,z value that define the extent around the queries point of reference
  148594. */
  148595. setDefaultQueryExtent(extent: Vector3): void;
  148596. /**
  148597. * Get the Bounding box extent specified by setDefaultQueryExtent
  148598. * @returns the box extent values
  148599. */
  148600. getDefaultQueryExtent(): Vector3;
  148601. /**
  148602. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148603. * @param result output the box extent values
  148604. */
  148605. getDefaultQueryExtentToRef(result: Vector3): void;
  148606. /**
  148607. * Release all resources
  148608. */
  148609. dispose(): void;
  148610. }
  148611. /**
  148612. * Configures an agent
  148613. */
  148614. export interface IAgentParameters {
  148615. /**
  148616. * Agent radius. [Limit: >= 0]
  148617. */
  148618. radius: number;
  148619. /**
  148620. * Agent height. [Limit: > 0]
  148621. */
  148622. height: number;
  148623. /**
  148624. * Maximum allowed acceleration. [Limit: >= 0]
  148625. */
  148626. maxAcceleration: number;
  148627. /**
  148628. * Maximum allowed speed. [Limit: >= 0]
  148629. */
  148630. maxSpeed: number;
  148631. /**
  148632. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  148633. */
  148634. collisionQueryRange: number;
  148635. /**
  148636. * The path visibility optimization range. [Limit: > 0]
  148637. */
  148638. pathOptimizationRange: number;
  148639. /**
  148640. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  148641. */
  148642. separationWeight: number;
  148643. }
  148644. /**
  148645. * Configures the navigation mesh creation
  148646. */
  148647. export interface INavMeshParameters {
  148648. /**
  148649. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  148650. */
  148651. cs: number;
  148652. /**
  148653. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  148654. */
  148655. ch: number;
  148656. /**
  148657. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  148658. */
  148659. walkableSlopeAngle: number;
  148660. /**
  148661. * Minimum floor to 'ceiling' height that will still allow the floor area to
  148662. * be considered walkable. [Limit: >= 3] [Units: vx]
  148663. */
  148664. walkableHeight: number;
  148665. /**
  148666. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  148667. */
  148668. walkableClimb: number;
  148669. /**
  148670. * The distance to erode/shrink the walkable area of the heightfield away from
  148671. * obstructions. [Limit: >=0] [Units: vx]
  148672. */
  148673. walkableRadius: number;
  148674. /**
  148675. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  148676. */
  148677. maxEdgeLen: number;
  148678. /**
  148679. * The maximum distance a simplfied contour's border edges should deviate
  148680. * the original raw contour. [Limit: >=0] [Units: vx]
  148681. */
  148682. maxSimplificationError: number;
  148683. /**
  148684. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  148685. */
  148686. minRegionArea: number;
  148687. /**
  148688. * Any regions with a span count smaller than this value will, if possible,
  148689. * be merged with larger regions. [Limit: >=0] [Units: vx]
  148690. */
  148691. mergeRegionArea: number;
  148692. /**
  148693. * The maximum number of vertices allowed for polygons generated during the
  148694. * contour to polygon conversion process. [Limit: >= 3]
  148695. */
  148696. maxVertsPerPoly: number;
  148697. /**
  148698. * Sets the sampling distance to use when generating the detail mesh.
  148699. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  148700. */
  148701. detailSampleDist: number;
  148702. /**
  148703. * The maximum distance the detail mesh surface should deviate from heightfield
  148704. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  148705. */
  148706. detailSampleMaxError: number;
  148707. }
  148708. }
  148709. declare module BABYLON {
  148710. /**
  148711. * RecastJS navigation plugin
  148712. */
  148713. export class RecastJSPlugin implements INavigationEnginePlugin {
  148714. /**
  148715. * Reference to the Recast library
  148716. */
  148717. bjsRECAST: any;
  148718. /**
  148719. * plugin name
  148720. */
  148721. name: string;
  148722. /**
  148723. * the first navmesh created. We might extend this to support multiple navmeshes
  148724. */
  148725. navMesh: any;
  148726. /**
  148727. * Initializes the recastJS plugin
  148728. * @param recastInjection can be used to inject your own recast reference
  148729. */
  148730. constructor(recastInjection?: any);
  148731. /**
  148732. * Creates a navigation mesh
  148733. * @param meshes array of all the geometry used to compute the navigatio mesh
  148734. * @param parameters bunch of parameters used to filter geometry
  148735. */
  148736. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  148737. /**
  148738. * Create a navigation mesh debug mesh
  148739. * @param scene is where the mesh will be added
  148740. * @returns debug display mesh
  148741. */
  148742. createDebugNavMesh(scene: Scene): Mesh;
  148743. /**
  148744. * Get a navigation mesh constrained position, closest to the parameter position
  148745. * @param position world position
  148746. * @returns the closest point to position constrained by the navigation mesh
  148747. */
  148748. getClosestPoint(position: Vector3): Vector3;
  148749. /**
  148750. * Get a navigation mesh constrained position, closest to the parameter position
  148751. * @param position world position
  148752. * @param result output the closest point to position constrained by the navigation mesh
  148753. */
  148754. getClosestPointToRef(position: Vector3, result: Vector3): void;
  148755. /**
  148756. * Get a navigation mesh constrained position, within a particular radius
  148757. * @param position world position
  148758. * @param maxRadius the maximum distance to the constrained world position
  148759. * @returns the closest point to position constrained by the navigation mesh
  148760. */
  148761. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  148762. /**
  148763. * Get a navigation mesh constrained position, within a particular radius
  148764. * @param position world position
  148765. * @param maxRadius the maximum distance to the constrained world position
  148766. * @param result output the closest point to position constrained by the navigation mesh
  148767. */
  148768. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  148769. /**
  148770. * Compute the final position from a segment made of destination-position
  148771. * @param position world position
  148772. * @param destination world position
  148773. * @returns the resulting point along the navmesh
  148774. */
  148775. moveAlong(position: Vector3, destination: Vector3): Vector3;
  148776. /**
  148777. * Compute the final position from a segment made of destination-position
  148778. * @param position world position
  148779. * @param destination world position
  148780. * @param result output the resulting point along the navmesh
  148781. */
  148782. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  148783. /**
  148784. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  148785. * @param start world position
  148786. * @param end world position
  148787. * @returns array containing world position composing the path
  148788. */
  148789. computePath(start: Vector3, end: Vector3): Vector3[];
  148790. /**
  148791. * Create a new Crowd so you can add agents
  148792. * @param maxAgents the maximum agent count in the crowd
  148793. * @param maxAgentRadius the maximum radius an agent can have
  148794. * @param scene to attach the crowd to
  148795. * @returns the crowd you can add agents to
  148796. */
  148797. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  148798. /**
  148799. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148800. * The queries will try to find a solution within those bounds
  148801. * default is (1,1,1)
  148802. * @param extent x,y,z value that define the extent around the queries point of reference
  148803. */
  148804. setDefaultQueryExtent(extent: Vector3): void;
  148805. /**
  148806. * Get the Bounding box extent specified by setDefaultQueryExtent
  148807. * @returns the box extent values
  148808. */
  148809. getDefaultQueryExtent(): Vector3;
  148810. /**
  148811. * build the navmesh from a previously saved state using getNavmeshData
  148812. * @param data the Uint8Array returned by getNavmeshData
  148813. */
  148814. buildFromNavmeshData(data: Uint8Array): void;
  148815. /**
  148816. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  148817. * @returns data the Uint8Array that can be saved and reused
  148818. */
  148819. getNavmeshData(): Uint8Array;
  148820. /**
  148821. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148822. * @param result output the box extent values
  148823. */
  148824. getDefaultQueryExtentToRef(result: Vector3): void;
  148825. /**
  148826. * Disposes
  148827. */
  148828. dispose(): void;
  148829. /**
  148830. * If this plugin is supported
  148831. * @returns true if plugin is supported
  148832. */
  148833. isSupported(): boolean;
  148834. }
  148835. /**
  148836. * Recast detour crowd implementation
  148837. */
  148838. export class RecastJSCrowd implements ICrowd {
  148839. /**
  148840. * Recast/detour plugin
  148841. */
  148842. bjsRECASTPlugin: RecastJSPlugin;
  148843. /**
  148844. * Link to the detour crowd
  148845. */
  148846. recastCrowd: any;
  148847. /**
  148848. * One transform per agent
  148849. */
  148850. transforms: TransformNode[];
  148851. /**
  148852. * All agents created
  148853. */
  148854. agents: number[];
  148855. /**
  148856. * Link to the scene is kept to unregister the crowd from the scene
  148857. */
  148858. private _scene;
  148859. /**
  148860. * Observer for crowd updates
  148861. */
  148862. private _onBeforeAnimationsObserver;
  148863. /**
  148864. * Constructor
  148865. * @param plugin recastJS plugin
  148866. * @param maxAgents the maximum agent count in the crowd
  148867. * @param maxAgentRadius the maximum radius an agent can have
  148868. * @param scene to attach the crowd to
  148869. * @returns the crowd you can add agents to
  148870. */
  148871. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  148872. /**
  148873. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  148874. * You can attach anything to that node. The node position is updated in the scene update tick.
  148875. * @param pos world position that will be constrained by the navigation mesh
  148876. * @param parameters agent parameters
  148877. * @param transform hooked to the agent that will be update by the scene
  148878. * @returns agent index
  148879. */
  148880. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  148881. /**
  148882. * Returns the agent position in world space
  148883. * @param index agent index returned by addAgent
  148884. * @returns world space position
  148885. */
  148886. getAgentPosition(index: number): Vector3;
  148887. /**
  148888. * Returns the agent position result in world space
  148889. * @param index agent index returned by addAgent
  148890. * @param result output world space position
  148891. */
  148892. getAgentPositionToRef(index: number, result: Vector3): void;
  148893. /**
  148894. * Returns the agent velocity in world space
  148895. * @param index agent index returned by addAgent
  148896. * @returns world space velocity
  148897. */
  148898. getAgentVelocity(index: number): Vector3;
  148899. /**
  148900. * Returns the agent velocity result in world space
  148901. * @param index agent index returned by addAgent
  148902. * @param result output world space velocity
  148903. */
  148904. getAgentVelocityToRef(index: number, result: Vector3): void;
  148905. /**
  148906. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  148907. * @param index agent index returned by addAgent
  148908. * @param destination targeted world position
  148909. */
  148910. agentGoto(index: number, destination: Vector3): void;
  148911. /**
  148912. * Teleport the agent to a new position
  148913. * @param index agent index returned by addAgent
  148914. * @param destination targeted world position
  148915. */
  148916. agentTeleport(index: number, destination: Vector3): void;
  148917. /**
  148918. * Update agent parameters
  148919. * @param index agent index returned by addAgent
  148920. * @param parameters agent parameters
  148921. */
  148922. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  148923. /**
  148924. * remove a particular agent previously created
  148925. * @param index agent index returned by addAgent
  148926. */
  148927. removeAgent(index: number): void;
  148928. /**
  148929. * get the list of all agents attached to this crowd
  148930. * @returns list of agent indices
  148931. */
  148932. getAgents(): number[];
  148933. /**
  148934. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  148935. * @param deltaTime in seconds
  148936. */
  148937. update(deltaTime: number): void;
  148938. /**
  148939. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148940. * The queries will try to find a solution within those bounds
  148941. * default is (1,1,1)
  148942. * @param extent x,y,z value that define the extent around the queries point of reference
  148943. */
  148944. setDefaultQueryExtent(extent: Vector3): void;
  148945. /**
  148946. * Get the Bounding box extent specified by setDefaultQueryExtent
  148947. * @returns the box extent values
  148948. */
  148949. getDefaultQueryExtent(): Vector3;
  148950. /**
  148951. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148952. * @param result output the box extent values
  148953. */
  148954. getDefaultQueryExtentToRef(result: Vector3): void;
  148955. /**
  148956. * Release all resources
  148957. */
  148958. dispose(): void;
  148959. }
  148960. }
  148961. declare module BABYLON {
  148962. /**
  148963. * Class used to enable access to IndexedDB
  148964. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  148965. */
  148966. export class Database implements IOfflineProvider {
  148967. private _callbackManifestChecked;
  148968. private _currentSceneUrl;
  148969. private _db;
  148970. private _enableSceneOffline;
  148971. private _enableTexturesOffline;
  148972. private _manifestVersionFound;
  148973. private _mustUpdateRessources;
  148974. private _hasReachedQuota;
  148975. private _isSupported;
  148976. private _idbFactory;
  148977. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  148978. private static IsUASupportingBlobStorage;
  148979. /**
  148980. * Gets a boolean indicating if Database storate is enabled (off by default)
  148981. */
  148982. static IDBStorageEnabled: boolean;
  148983. /**
  148984. * Gets a boolean indicating if scene must be saved in the database
  148985. */
  148986. get enableSceneOffline(): boolean;
  148987. /**
  148988. * Gets a boolean indicating if textures must be saved in the database
  148989. */
  148990. get enableTexturesOffline(): boolean;
  148991. /**
  148992. * Creates a new Database
  148993. * @param urlToScene defines the url to load the scene
  148994. * @param callbackManifestChecked defines the callback to use when manifest is checked
  148995. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  148996. */
  148997. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  148998. private static _ParseURL;
  148999. private static _ReturnFullUrlLocation;
  149000. private _checkManifestFile;
  149001. /**
  149002. * Open the database and make it available
  149003. * @param successCallback defines the callback to call on success
  149004. * @param errorCallback defines the callback to call on error
  149005. */
  149006. open(successCallback: () => void, errorCallback: () => void): void;
  149007. /**
  149008. * Loads an image from the database
  149009. * @param url defines the url to load from
  149010. * @param image defines the target DOM image
  149011. */
  149012. loadImage(url: string, image: HTMLImageElement): void;
  149013. private _loadImageFromDBAsync;
  149014. private _saveImageIntoDBAsync;
  149015. private _checkVersionFromDB;
  149016. private _loadVersionFromDBAsync;
  149017. private _saveVersionIntoDBAsync;
  149018. /**
  149019. * Loads a file from database
  149020. * @param url defines the URL to load from
  149021. * @param sceneLoaded defines a callback to call on success
  149022. * @param progressCallBack defines a callback to call when progress changed
  149023. * @param errorCallback defines a callback to call on error
  149024. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  149025. */
  149026. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  149027. private _loadFileAsync;
  149028. private _saveFileAsync;
  149029. /**
  149030. * Validates if xhr data is correct
  149031. * @param xhr defines the request to validate
  149032. * @param dataType defines the expected data type
  149033. * @returns true if data is correct
  149034. */
  149035. private static _ValidateXHRData;
  149036. }
  149037. }
  149038. declare module BABYLON {
  149039. /** @hidden */
  149040. export var gpuUpdateParticlesPixelShader: {
  149041. name: string;
  149042. shader: string;
  149043. };
  149044. }
  149045. declare module BABYLON {
  149046. /** @hidden */
  149047. export var gpuUpdateParticlesVertexShader: {
  149048. name: string;
  149049. shader: string;
  149050. };
  149051. }
  149052. declare module BABYLON {
  149053. /** @hidden */
  149054. export var clipPlaneFragmentDeclaration2: {
  149055. name: string;
  149056. shader: string;
  149057. };
  149058. }
  149059. declare module BABYLON {
  149060. /** @hidden */
  149061. export var gpuRenderParticlesPixelShader: {
  149062. name: string;
  149063. shader: string;
  149064. };
  149065. }
  149066. declare module BABYLON {
  149067. /** @hidden */
  149068. export var clipPlaneVertexDeclaration2: {
  149069. name: string;
  149070. shader: string;
  149071. };
  149072. }
  149073. declare module BABYLON {
  149074. /** @hidden */
  149075. export var gpuRenderParticlesVertexShader: {
  149076. name: string;
  149077. shader: string;
  149078. };
  149079. }
  149080. declare module BABYLON {
  149081. /**
  149082. * This represents a GPU particle system in Babylon
  149083. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  149084. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  149085. */
  149086. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  149087. /**
  149088. * The layer mask we are rendering the particles through.
  149089. */
  149090. layerMask: number;
  149091. private _capacity;
  149092. private _activeCount;
  149093. private _currentActiveCount;
  149094. private _accumulatedCount;
  149095. private _renderEffect;
  149096. private _updateEffect;
  149097. private _buffer0;
  149098. private _buffer1;
  149099. private _spriteBuffer;
  149100. private _updateVAO;
  149101. private _renderVAO;
  149102. private _targetIndex;
  149103. private _sourceBuffer;
  149104. private _targetBuffer;
  149105. private _currentRenderId;
  149106. private _started;
  149107. private _stopped;
  149108. private _timeDelta;
  149109. private _randomTexture;
  149110. private _randomTexture2;
  149111. private _attributesStrideSize;
  149112. private _updateEffectOptions;
  149113. private _randomTextureSize;
  149114. private _actualFrame;
  149115. private _customEffect;
  149116. private readonly _rawTextureWidth;
  149117. /**
  149118. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  149119. */
  149120. static get IsSupported(): boolean;
  149121. /**
  149122. * An event triggered when the system is disposed.
  149123. */
  149124. onDisposeObservable: Observable<IParticleSystem>;
  149125. /**
  149126. * An event triggered when the system is stopped
  149127. */
  149128. onStoppedObservable: Observable<IParticleSystem>;
  149129. /**
  149130. * Gets the maximum number of particles active at the same time.
  149131. * @returns The max number of active particles.
  149132. */
  149133. getCapacity(): number;
  149134. /**
  149135. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  149136. * to override the particles.
  149137. */
  149138. forceDepthWrite: boolean;
  149139. /**
  149140. * Gets or set the number of active particles
  149141. */
  149142. get activeParticleCount(): number;
  149143. set activeParticleCount(value: number);
  149144. private _preWarmDone;
  149145. /**
  149146. * Specifies if the particles are updated in emitter local space or world space.
  149147. */
  149148. isLocal: boolean;
  149149. /** Gets or sets a matrix to use to compute projection */
  149150. defaultProjectionMatrix: Matrix;
  149151. /**
  149152. * Is this system ready to be used/rendered
  149153. * @return true if the system is ready
  149154. */
  149155. isReady(): boolean;
  149156. /**
  149157. * Gets if the system has been started. (Note: this will still be true after stop is called)
  149158. * @returns True if it has been started, otherwise false.
  149159. */
  149160. isStarted(): boolean;
  149161. /**
  149162. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  149163. * @returns True if it has been stopped, otherwise false.
  149164. */
  149165. isStopped(): boolean;
  149166. /**
  149167. * Gets a boolean indicating that the system is stopping
  149168. * @returns true if the system is currently stopping
  149169. */
  149170. isStopping(): boolean;
  149171. /**
  149172. * Gets the number of particles active at the same time.
  149173. * @returns The number of active particles.
  149174. */
  149175. getActiveCount(): number;
  149176. /**
  149177. * Starts the particle system and begins to emit
  149178. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  149179. */
  149180. start(delay?: number): void;
  149181. /**
  149182. * Stops the particle system.
  149183. */
  149184. stop(): void;
  149185. /**
  149186. * Remove all active particles
  149187. */
  149188. reset(): void;
  149189. /**
  149190. * Returns the string "GPUParticleSystem"
  149191. * @returns a string containing the class name
  149192. */
  149193. getClassName(): string;
  149194. /**
  149195. * Gets the custom effect used to render the particles
  149196. * @param blendMode Blend mode for which the effect should be retrieved
  149197. * @returns The effect
  149198. */
  149199. getCustomEffect(blendMode?: number): Nullable<Effect>;
  149200. /**
  149201. * Sets the custom effect used to render the particles
  149202. * @param effect The effect to set
  149203. * @param blendMode Blend mode for which the effect should be set
  149204. */
  149205. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  149206. /** @hidden */
  149207. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  149208. /**
  149209. * Observable that will be called just before the particles are drawn
  149210. */
  149211. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  149212. /**
  149213. * Gets the name of the particle vertex shader
  149214. */
  149215. get vertexShaderName(): string;
  149216. private _colorGradientsTexture;
  149217. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  149218. /**
  149219. * Adds a new color gradient
  149220. * @param gradient defines the gradient to use (between 0 and 1)
  149221. * @param color1 defines the color to affect to the specified gradient
  149222. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  149223. * @returns the current particle system
  149224. */
  149225. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  149226. private _refreshColorGradient;
  149227. /** Force the system to rebuild all gradients that need to be resync */
  149228. forceRefreshGradients(): void;
  149229. /**
  149230. * Remove a specific color gradient
  149231. * @param gradient defines the gradient to remove
  149232. * @returns the current particle system
  149233. */
  149234. removeColorGradient(gradient: number): GPUParticleSystem;
  149235. private _angularSpeedGradientsTexture;
  149236. private _sizeGradientsTexture;
  149237. private _velocityGradientsTexture;
  149238. private _limitVelocityGradientsTexture;
  149239. private _dragGradientsTexture;
  149240. private _addFactorGradient;
  149241. /**
  149242. * Adds a new size gradient
  149243. * @param gradient defines the gradient to use (between 0 and 1)
  149244. * @param factor defines the size factor to affect to the specified gradient
  149245. * @returns the current particle system
  149246. */
  149247. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  149248. /**
  149249. * Remove a specific size gradient
  149250. * @param gradient defines the gradient to remove
  149251. * @returns the current particle system
  149252. */
  149253. removeSizeGradient(gradient: number): GPUParticleSystem;
  149254. private _refreshFactorGradient;
  149255. /**
  149256. * Adds a new angular speed gradient
  149257. * @param gradient defines the gradient to use (between 0 and 1)
  149258. * @param factor defines the angular speed to affect to the specified gradient
  149259. * @returns the current particle system
  149260. */
  149261. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  149262. /**
  149263. * Remove a specific angular speed gradient
  149264. * @param gradient defines the gradient to remove
  149265. * @returns the current particle system
  149266. */
  149267. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  149268. /**
  149269. * Adds a new velocity gradient
  149270. * @param gradient defines the gradient to use (between 0 and 1)
  149271. * @param factor defines the velocity to affect to the specified gradient
  149272. * @returns the current particle system
  149273. */
  149274. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  149275. /**
  149276. * Remove a specific velocity gradient
  149277. * @param gradient defines the gradient to remove
  149278. * @returns the current particle system
  149279. */
  149280. removeVelocityGradient(gradient: number): GPUParticleSystem;
  149281. /**
  149282. * Adds a new limit velocity gradient
  149283. * @param gradient defines the gradient to use (between 0 and 1)
  149284. * @param factor defines the limit velocity value to affect to the specified gradient
  149285. * @returns the current particle system
  149286. */
  149287. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  149288. /**
  149289. * Remove a specific limit velocity gradient
  149290. * @param gradient defines the gradient to remove
  149291. * @returns the current particle system
  149292. */
  149293. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  149294. /**
  149295. * Adds a new drag gradient
  149296. * @param gradient defines the gradient to use (between 0 and 1)
  149297. * @param factor defines the drag value to affect to the specified gradient
  149298. * @returns the current particle system
  149299. */
  149300. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  149301. /**
  149302. * Remove a specific drag gradient
  149303. * @param gradient defines the gradient to remove
  149304. * @returns the current particle system
  149305. */
  149306. removeDragGradient(gradient: number): GPUParticleSystem;
  149307. /**
  149308. * Not supported by GPUParticleSystem
  149309. * @param gradient defines the gradient to use (between 0 and 1)
  149310. * @param factor defines the emit rate value to affect to the specified gradient
  149311. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149312. * @returns the current particle system
  149313. */
  149314. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149315. /**
  149316. * Not supported by GPUParticleSystem
  149317. * @param gradient defines the gradient to remove
  149318. * @returns the current particle system
  149319. */
  149320. removeEmitRateGradient(gradient: number): IParticleSystem;
  149321. /**
  149322. * Not supported by GPUParticleSystem
  149323. * @param gradient defines the gradient to use (between 0 and 1)
  149324. * @param factor defines the start size value to affect to the specified gradient
  149325. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149326. * @returns the current particle system
  149327. */
  149328. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149329. /**
  149330. * Not supported by GPUParticleSystem
  149331. * @param gradient defines the gradient to remove
  149332. * @returns the current particle system
  149333. */
  149334. removeStartSizeGradient(gradient: number): IParticleSystem;
  149335. /**
  149336. * Not supported by GPUParticleSystem
  149337. * @param gradient defines the gradient to use (between 0 and 1)
  149338. * @param min defines the color remap minimal range
  149339. * @param max defines the color remap maximal range
  149340. * @returns the current particle system
  149341. */
  149342. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  149343. /**
  149344. * Not supported by GPUParticleSystem
  149345. * @param gradient defines the gradient to remove
  149346. * @returns the current particle system
  149347. */
  149348. removeColorRemapGradient(): IParticleSystem;
  149349. /**
  149350. * Not supported by GPUParticleSystem
  149351. * @param gradient defines the gradient to use (between 0 and 1)
  149352. * @param min defines the alpha remap minimal range
  149353. * @param max defines the alpha remap maximal range
  149354. * @returns the current particle system
  149355. */
  149356. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  149357. /**
  149358. * Not supported by GPUParticleSystem
  149359. * @param gradient defines the gradient to remove
  149360. * @returns the current particle system
  149361. */
  149362. removeAlphaRemapGradient(): IParticleSystem;
  149363. /**
  149364. * Not supported by GPUParticleSystem
  149365. * @param gradient defines the gradient to use (between 0 and 1)
  149366. * @param color defines the color to affect to the specified gradient
  149367. * @returns the current particle system
  149368. */
  149369. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  149370. /**
  149371. * Not supported by GPUParticleSystem
  149372. * @param gradient defines the gradient to remove
  149373. * @returns the current particle system
  149374. */
  149375. removeRampGradient(): IParticleSystem;
  149376. /**
  149377. * Not supported by GPUParticleSystem
  149378. * @returns the list of ramp gradients
  149379. */
  149380. getRampGradients(): Nullable<Array<Color3Gradient>>;
  149381. /**
  149382. * Not supported by GPUParticleSystem
  149383. * Gets or sets a boolean indicating that ramp gradients must be used
  149384. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  149385. */
  149386. get useRampGradients(): boolean;
  149387. set useRampGradients(value: boolean);
  149388. /**
  149389. * Not supported by GPUParticleSystem
  149390. * @param gradient defines the gradient to use (between 0 and 1)
  149391. * @param factor defines the life time factor to affect to the specified gradient
  149392. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149393. * @returns the current particle system
  149394. */
  149395. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149396. /**
  149397. * Not supported by GPUParticleSystem
  149398. * @param gradient defines the gradient to remove
  149399. * @returns the current particle system
  149400. */
  149401. removeLifeTimeGradient(gradient: number): IParticleSystem;
  149402. /**
  149403. * Instantiates a GPU particle system.
  149404. * 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.
  149405. * @param name The name of the particle system
  149406. * @param options The options used to create the system
  149407. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  149408. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  149409. * @param customEffect a custom effect used to change the way particles are rendered by default
  149410. */
  149411. constructor(name: string, options: Partial<{
  149412. capacity: number;
  149413. randomTextureSize: number;
  149414. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  149415. protected _reset(): void;
  149416. private _createUpdateVAO;
  149417. private _createRenderVAO;
  149418. private _initialize;
  149419. /** @hidden */
  149420. _recreateUpdateEffect(): void;
  149421. private _getEffect;
  149422. /**
  149423. * Fill the defines array according to the current settings of the particle system
  149424. * @param defines Array to be updated
  149425. * @param blendMode blend mode to take into account when updating the array
  149426. */
  149427. fillDefines(defines: Array<string>, blendMode?: number): void;
  149428. /**
  149429. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  149430. * @param uniforms Uniforms array to fill
  149431. * @param attributes Attributes array to fill
  149432. * @param samplers Samplers array to fill
  149433. */
  149434. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  149435. /** @hidden */
  149436. _recreateRenderEffect(): Effect;
  149437. /**
  149438. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  149439. * @param preWarm defines if we are in the pre-warmimg phase
  149440. */
  149441. animate(preWarm?: boolean): void;
  149442. private _createFactorGradientTexture;
  149443. private _createSizeGradientTexture;
  149444. private _createAngularSpeedGradientTexture;
  149445. private _createVelocityGradientTexture;
  149446. private _createLimitVelocityGradientTexture;
  149447. private _createDragGradientTexture;
  149448. private _createColorGradientTexture;
  149449. /**
  149450. * Renders the particle system in its current state
  149451. * @param preWarm defines if the system should only update the particles but not render them
  149452. * @returns the current number of particles
  149453. */
  149454. render(preWarm?: boolean): number;
  149455. /**
  149456. * Rebuilds the particle system
  149457. */
  149458. rebuild(): void;
  149459. private _releaseBuffers;
  149460. private _releaseVAOs;
  149461. /**
  149462. * Disposes the particle system and free the associated resources
  149463. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  149464. */
  149465. dispose(disposeTexture?: boolean): void;
  149466. /**
  149467. * Clones the particle system.
  149468. * @param name The name of the cloned object
  149469. * @param newEmitter The new emitter to use
  149470. * @returns the cloned particle system
  149471. */
  149472. clone(name: string, newEmitter: any): GPUParticleSystem;
  149473. /**
  149474. * Serializes the particle system to a JSON object
  149475. * @param serializeTexture defines if the texture must be serialized as well
  149476. * @returns the JSON object
  149477. */
  149478. serialize(serializeTexture?: boolean): any;
  149479. /**
  149480. * Parses a JSON object to create a GPU particle system.
  149481. * @param parsedParticleSystem The JSON object to parse
  149482. * @param sceneOrEngine The scene or the engine to create the particle system in
  149483. * @param rootUrl The root url to use to load external dependencies like texture
  149484. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  149485. * @returns the parsed GPU particle system
  149486. */
  149487. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  149488. }
  149489. }
  149490. declare module BABYLON {
  149491. /**
  149492. * Represents a set of particle systems working together to create a specific effect
  149493. */
  149494. export class ParticleSystemSet implements IDisposable {
  149495. /**
  149496. * Gets or sets base Assets URL
  149497. */
  149498. static BaseAssetsUrl: string;
  149499. private _emitterCreationOptions;
  149500. private _emitterNode;
  149501. /**
  149502. * Gets the particle system list
  149503. */
  149504. systems: IParticleSystem[];
  149505. /**
  149506. * Gets the emitter node used with this set
  149507. */
  149508. get emitterNode(): Nullable<TransformNode>;
  149509. /**
  149510. * Creates a new emitter mesh as a sphere
  149511. * @param options defines the options used to create the sphere
  149512. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  149513. * @param scene defines the hosting scene
  149514. */
  149515. setEmitterAsSphere(options: {
  149516. diameter: number;
  149517. segments: number;
  149518. color: Color3;
  149519. }, renderingGroupId: number, scene: Scene): void;
  149520. /**
  149521. * Starts all particle systems of the set
  149522. * @param emitter defines an optional mesh to use as emitter for the particle systems
  149523. */
  149524. start(emitter?: AbstractMesh): void;
  149525. /**
  149526. * Release all associated resources
  149527. */
  149528. dispose(): void;
  149529. /**
  149530. * Serialize the set into a JSON compatible object
  149531. * @param serializeTexture defines if the texture must be serialized as well
  149532. * @returns a JSON compatible representation of the set
  149533. */
  149534. serialize(serializeTexture?: boolean): any;
  149535. /**
  149536. * Parse a new ParticleSystemSet from a serialized source
  149537. * @param data defines a JSON compatible representation of the set
  149538. * @param scene defines the hosting scene
  149539. * @param gpu defines if we want GPU particles or CPU particles
  149540. * @returns a new ParticleSystemSet
  149541. */
  149542. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  149543. }
  149544. }
  149545. declare module BABYLON {
  149546. /**
  149547. * This class is made for on one-liner static method to help creating particle system set.
  149548. */
  149549. export class ParticleHelper {
  149550. /**
  149551. * Gets or sets base Assets URL
  149552. */
  149553. static BaseAssetsUrl: string;
  149554. /** Define the Url to load snippets */
  149555. static SnippetUrl: string;
  149556. /**
  149557. * Create a default particle system that you can tweak
  149558. * @param emitter defines the emitter to use
  149559. * @param capacity defines the system capacity (default is 500 particles)
  149560. * @param scene defines the hosting scene
  149561. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  149562. * @returns the new Particle system
  149563. */
  149564. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  149565. /**
  149566. * This is the main static method (one-liner) of this helper to create different particle systems
  149567. * @param type This string represents the type to the particle system to create
  149568. * @param scene The scene where the particle system should live
  149569. * @param gpu If the system will use gpu
  149570. * @returns the ParticleSystemSet created
  149571. */
  149572. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  149573. /**
  149574. * Static function used to export a particle system to a ParticleSystemSet variable.
  149575. * Please note that the emitter shape is not exported
  149576. * @param systems defines the particle systems to export
  149577. * @returns the created particle system set
  149578. */
  149579. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  149580. /**
  149581. * Creates a particle system from a snippet saved in a remote file
  149582. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  149583. * @param url defines the url to load from
  149584. * @param scene defines the hosting scene
  149585. * @param gpu If the system will use gpu
  149586. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  149587. * @returns a promise that will resolve to the new particle system
  149588. */
  149589. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  149590. /**
  149591. * Creates a particle system from a snippet saved by the particle system editor
  149592. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  149593. * @param scene defines the hosting scene
  149594. * @param gpu If the system will use gpu
  149595. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  149596. * @returns a promise that will resolve to the new particle system
  149597. */
  149598. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  149599. }
  149600. }
  149601. declare module BABYLON {
  149602. interface Engine {
  149603. /**
  149604. * Create an effect to use with particle systems.
  149605. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  149606. * the particle system for which you want to create a custom effect in the last parameter
  149607. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  149608. * @param uniformsNames defines a list of attribute names
  149609. * @param samplers defines an array of string used to represent textures
  149610. * @param defines defines the string containing the defines to use to compile the shaders
  149611. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  149612. * @param onCompiled defines a function to call when the effect creation is successful
  149613. * @param onError defines a function to call when the effect creation has failed
  149614. * @param particleSystem the particle system you want to create the effect for
  149615. * @returns the new Effect
  149616. */
  149617. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  149618. }
  149619. interface Mesh {
  149620. /**
  149621. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  149622. * @returns an array of IParticleSystem
  149623. */
  149624. getEmittedParticleSystems(): IParticleSystem[];
  149625. /**
  149626. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  149627. * @returns an array of IParticleSystem
  149628. */
  149629. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  149630. }
  149631. }
  149632. declare module BABYLON {
  149633. /** Defines the 4 color options */
  149634. export enum PointColor {
  149635. /** color value */
  149636. Color = 2,
  149637. /** uv value */
  149638. UV = 1,
  149639. /** random value */
  149640. Random = 0,
  149641. /** stated value */
  149642. Stated = 3
  149643. }
  149644. /**
  149645. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  149646. * 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.
  149647. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  149648. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  149649. *
  149650. * Full documentation here : TO BE ENTERED
  149651. */
  149652. export class PointsCloudSystem implements IDisposable {
  149653. /**
  149654. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  149655. * Example : var p = SPS.particles[i];
  149656. */
  149657. particles: CloudPoint[];
  149658. /**
  149659. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  149660. */
  149661. nbParticles: number;
  149662. /**
  149663. * This a counter for your own usage. It's not set by any SPS functions.
  149664. */
  149665. counter: number;
  149666. /**
  149667. * The PCS name. This name is also given to the underlying mesh.
  149668. */
  149669. name: string;
  149670. /**
  149671. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  149672. */
  149673. mesh: Mesh;
  149674. /**
  149675. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  149676. * Please read :
  149677. */
  149678. vars: any;
  149679. /**
  149680. * @hidden
  149681. */
  149682. _size: number;
  149683. private _scene;
  149684. private _promises;
  149685. private _positions;
  149686. private _indices;
  149687. private _normals;
  149688. private _colors;
  149689. private _uvs;
  149690. private _indices32;
  149691. private _positions32;
  149692. private _colors32;
  149693. private _uvs32;
  149694. private _updatable;
  149695. private _isVisibilityBoxLocked;
  149696. private _alwaysVisible;
  149697. private _groups;
  149698. private _groupCounter;
  149699. private _computeParticleColor;
  149700. private _computeParticleTexture;
  149701. private _computeParticleRotation;
  149702. private _computeBoundingBox;
  149703. private _isReady;
  149704. /**
  149705. * Creates a PCS (Points Cloud System) object
  149706. * @param name (String) is the PCS name, this will be the underlying mesh name
  149707. * @param pointSize (number) is the size for each point
  149708. * @param scene (Scene) is the scene in which the PCS is added
  149709. * @param options defines the options of the PCS e.g.
  149710. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  149711. */
  149712. constructor(name: string, pointSize: number, scene: Scene, options?: {
  149713. updatable?: boolean;
  149714. });
  149715. /**
  149716. * Builds the PCS underlying mesh. Returns a standard Mesh.
  149717. * If no points were added to the PCS, the returned mesh is just a single point.
  149718. * @returns a promise for the created mesh
  149719. */
  149720. buildMeshAsync(): Promise<Mesh>;
  149721. /**
  149722. * @hidden
  149723. */
  149724. private _buildMesh;
  149725. private _addParticle;
  149726. private _randomUnitVector;
  149727. private _getColorIndicesForCoord;
  149728. private _setPointsColorOrUV;
  149729. private _colorFromTexture;
  149730. private _calculateDensity;
  149731. /**
  149732. * Adds points to the PCS in random positions within a unit sphere
  149733. * @param nb (positive integer) the number of particles to be created from this model
  149734. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  149735. * @returns the number of groups in the system
  149736. */
  149737. addPoints(nb: number, pointFunction?: any): number;
  149738. /**
  149739. * Adds points to the PCS from the surface of the model shape
  149740. * @param mesh is any Mesh object that will be used as a surface model for the points
  149741. * @param nb (positive integer) the number of particles to be created from this model
  149742. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  149743. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  149744. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  149745. * @returns the number of groups in the system
  149746. */
  149747. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  149748. /**
  149749. * Adds points to the PCS inside the model shape
  149750. * @param mesh is any Mesh object that will be used as a surface model for the points
  149751. * @param nb (positive integer) the number of particles to be created from this model
  149752. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  149753. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  149754. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  149755. * @returns the number of groups in the system
  149756. */
  149757. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  149758. /**
  149759. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  149760. * This method calls `updateParticle()` for each particle of the SPS.
  149761. * For an animated SPS, it is usually called within the render loop.
  149762. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  149763. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  149764. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  149765. * @returns the PCS.
  149766. */
  149767. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  149768. /**
  149769. * Disposes the PCS.
  149770. */
  149771. dispose(): void;
  149772. /**
  149773. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  149774. * doc :
  149775. * @returns the PCS.
  149776. */
  149777. refreshVisibleSize(): PointsCloudSystem;
  149778. /**
  149779. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  149780. * @param size the size (float) of the visibility box
  149781. * note : this doesn't lock the PCS mesh bounding box.
  149782. * doc :
  149783. */
  149784. setVisibilityBox(size: number): void;
  149785. /**
  149786. * Gets whether the PCS is always visible or not
  149787. * doc :
  149788. */
  149789. get isAlwaysVisible(): boolean;
  149790. /**
  149791. * Sets the PCS as always visible or not
  149792. * doc :
  149793. */
  149794. set isAlwaysVisible(val: boolean);
  149795. /**
  149796. * Tells to `setParticles()` to compute the particle rotations or not
  149797. * Default value : false. The PCS is faster when it's set to false
  149798. * Note : particle rotations are only applied to parent particles
  149799. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  149800. */
  149801. set computeParticleRotation(val: boolean);
  149802. /**
  149803. * Tells to `setParticles()` to compute the particle colors or not.
  149804. * Default value : true. The PCS is faster when it's set to false.
  149805. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  149806. */
  149807. set computeParticleColor(val: boolean);
  149808. set computeParticleTexture(val: boolean);
  149809. /**
  149810. * Gets if `setParticles()` computes the particle colors or not.
  149811. * Default value : false. The PCS is faster when it's set to false.
  149812. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  149813. */
  149814. get computeParticleColor(): boolean;
  149815. /**
  149816. * Gets if `setParticles()` computes the particle textures or not.
  149817. * Default value : false. The PCS is faster when it's set to false.
  149818. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  149819. */
  149820. get computeParticleTexture(): boolean;
  149821. /**
  149822. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  149823. */
  149824. set computeBoundingBox(val: boolean);
  149825. /**
  149826. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  149827. */
  149828. get computeBoundingBox(): boolean;
  149829. /**
  149830. * This function does nothing. It may be overwritten to set all the particle first values.
  149831. * The PCS doesn't call this function, you may have to call it by your own.
  149832. * doc :
  149833. */
  149834. initParticles(): void;
  149835. /**
  149836. * This function does nothing. It may be overwritten to recycle a particle
  149837. * The PCS doesn't call this function, you can to call it
  149838. * doc :
  149839. * @param particle The particle to recycle
  149840. * @returns the recycled particle
  149841. */
  149842. recycleParticle(particle: CloudPoint): CloudPoint;
  149843. /**
  149844. * Updates a particle : this function should be overwritten by the user.
  149845. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  149846. * doc :
  149847. * @example : just set a particle position or velocity and recycle conditions
  149848. * @param particle The particle to update
  149849. * @returns the updated particle
  149850. */
  149851. updateParticle(particle: CloudPoint): CloudPoint;
  149852. /**
  149853. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  149854. * This does nothing and may be overwritten by the user.
  149855. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149856. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149857. * @param update the boolean update value actually passed to setParticles()
  149858. */
  149859. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149860. /**
  149861. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  149862. * This will be passed three parameters.
  149863. * This does nothing and may be overwritten by the user.
  149864. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149865. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149866. * @param update the boolean update value actually passed to setParticles()
  149867. */
  149868. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149869. }
  149870. }
  149871. declare module BABYLON {
  149872. /**
  149873. * Represents one particle of a points cloud system.
  149874. */
  149875. export class CloudPoint {
  149876. /**
  149877. * particle global index
  149878. */
  149879. idx: number;
  149880. /**
  149881. * The color of the particle
  149882. */
  149883. color: Nullable<Color4>;
  149884. /**
  149885. * The world space position of the particle.
  149886. */
  149887. position: Vector3;
  149888. /**
  149889. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  149890. */
  149891. rotation: Vector3;
  149892. /**
  149893. * The world space rotation quaternion of the particle.
  149894. */
  149895. rotationQuaternion: Nullable<Quaternion>;
  149896. /**
  149897. * The uv of the particle.
  149898. */
  149899. uv: Nullable<Vector2>;
  149900. /**
  149901. * The current speed of the particle.
  149902. */
  149903. velocity: Vector3;
  149904. /**
  149905. * The pivot point in the particle local space.
  149906. */
  149907. pivot: Vector3;
  149908. /**
  149909. * Must the particle be translated from its pivot point in its local space ?
  149910. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  149911. * Default : false
  149912. */
  149913. translateFromPivot: boolean;
  149914. /**
  149915. * Index of this particle in the global "positions" array (Internal use)
  149916. * @hidden
  149917. */
  149918. _pos: number;
  149919. /**
  149920. * @hidden Index of this particle in the global "indices" array (Internal use)
  149921. */
  149922. _ind: number;
  149923. /**
  149924. * Group this particle belongs to
  149925. */
  149926. _group: PointsGroup;
  149927. /**
  149928. * Group id of this particle
  149929. */
  149930. groupId: number;
  149931. /**
  149932. * Index of the particle in its group id (Internal use)
  149933. */
  149934. idxInGroup: number;
  149935. /**
  149936. * @hidden Particle BoundingInfo object (Internal use)
  149937. */
  149938. _boundingInfo: BoundingInfo;
  149939. /**
  149940. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  149941. */
  149942. _pcs: PointsCloudSystem;
  149943. /**
  149944. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  149945. */
  149946. _stillInvisible: boolean;
  149947. /**
  149948. * @hidden Last computed particle rotation matrix
  149949. */
  149950. _rotationMatrix: number[];
  149951. /**
  149952. * Parent particle Id, if any.
  149953. * Default null.
  149954. */
  149955. parentId: Nullable<number>;
  149956. /**
  149957. * @hidden Internal global position in the PCS.
  149958. */
  149959. _globalPosition: Vector3;
  149960. /**
  149961. * Creates a Point Cloud object.
  149962. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  149963. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  149964. * @param group (PointsGroup) is the group the particle belongs to
  149965. * @param groupId (integer) is the group identifier in the PCS.
  149966. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  149967. * @param pcs defines the PCS it is associated to
  149968. */
  149969. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  149970. /**
  149971. * get point size
  149972. */
  149973. get size(): Vector3;
  149974. /**
  149975. * Set point size
  149976. */
  149977. set size(scale: Vector3);
  149978. /**
  149979. * Legacy support, changed quaternion to rotationQuaternion
  149980. */
  149981. get quaternion(): Nullable<Quaternion>;
  149982. /**
  149983. * Legacy support, changed quaternion to rotationQuaternion
  149984. */
  149985. set quaternion(q: Nullable<Quaternion>);
  149986. /**
  149987. * Returns a boolean. True if the particle intersects a mesh, else false
  149988. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  149989. * @param target is the object (point or mesh) what the intersection is computed against
  149990. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  149991. * @returns true if it intersects
  149992. */
  149993. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  149994. /**
  149995. * get the rotation matrix of the particle
  149996. * @hidden
  149997. */
  149998. getRotationMatrix(m: Matrix): void;
  149999. }
  150000. /**
  150001. * Represents a group of points in a points cloud system
  150002. * * PCS internal tool, don't use it manually.
  150003. */
  150004. export class PointsGroup {
  150005. /**
  150006. * The group id
  150007. * @hidden
  150008. */
  150009. groupID: number;
  150010. /**
  150011. * image data for group (internal use)
  150012. * @hidden
  150013. */
  150014. _groupImageData: Nullable<ArrayBufferView>;
  150015. /**
  150016. * Image Width (internal use)
  150017. * @hidden
  150018. */
  150019. _groupImgWidth: number;
  150020. /**
  150021. * Image Height (internal use)
  150022. * @hidden
  150023. */
  150024. _groupImgHeight: number;
  150025. /**
  150026. * Custom position function (internal use)
  150027. * @hidden
  150028. */
  150029. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  150030. /**
  150031. * density per facet for surface points
  150032. * @hidden
  150033. */
  150034. _groupDensity: number[];
  150035. /**
  150036. * Only when points are colored by texture carries pointer to texture list array
  150037. * @hidden
  150038. */
  150039. _textureNb: number;
  150040. /**
  150041. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  150042. * PCS internal tool, don't use it manually.
  150043. * @hidden
  150044. */
  150045. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  150046. }
  150047. }
  150048. declare module BABYLON {
  150049. interface Scene {
  150050. /** @hidden (Backing field) */
  150051. _physicsEngine: Nullable<IPhysicsEngine>;
  150052. /** @hidden */
  150053. _physicsTimeAccumulator: number;
  150054. /**
  150055. * Gets the current physics engine
  150056. * @returns a IPhysicsEngine or null if none attached
  150057. */
  150058. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  150059. /**
  150060. * Enables physics to the current scene
  150061. * @param gravity defines the scene's gravity for the physics engine
  150062. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  150063. * @return a boolean indicating if the physics engine was initialized
  150064. */
  150065. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  150066. /**
  150067. * Disables and disposes the physics engine associated with the scene
  150068. */
  150069. disablePhysicsEngine(): void;
  150070. /**
  150071. * Gets a boolean indicating if there is an active physics engine
  150072. * @returns a boolean indicating if there is an active physics engine
  150073. */
  150074. isPhysicsEnabled(): boolean;
  150075. /**
  150076. * Deletes a physics compound impostor
  150077. * @param compound defines the compound to delete
  150078. */
  150079. deleteCompoundImpostor(compound: any): void;
  150080. /**
  150081. * An event triggered when physic simulation is about to be run
  150082. */
  150083. onBeforePhysicsObservable: Observable<Scene>;
  150084. /**
  150085. * An event triggered when physic simulation has been done
  150086. */
  150087. onAfterPhysicsObservable: Observable<Scene>;
  150088. }
  150089. interface AbstractMesh {
  150090. /** @hidden */
  150091. _physicsImpostor: Nullable<PhysicsImpostor>;
  150092. /**
  150093. * Gets or sets impostor used for physic simulation
  150094. * @see https://doc.babylonjs.com/features/physics_engine
  150095. */
  150096. physicsImpostor: Nullable<PhysicsImpostor>;
  150097. /**
  150098. * Gets the current physics impostor
  150099. * @see https://doc.babylonjs.com/features/physics_engine
  150100. * @returns a physics impostor or null
  150101. */
  150102. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  150103. /** Apply a physic impulse to the mesh
  150104. * @param force defines the force to apply
  150105. * @param contactPoint defines where to apply the force
  150106. * @returns the current mesh
  150107. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  150108. */
  150109. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  150110. /**
  150111. * Creates a physic joint between two meshes
  150112. * @param otherMesh defines the other mesh to use
  150113. * @param pivot1 defines the pivot to use on this mesh
  150114. * @param pivot2 defines the pivot to use on the other mesh
  150115. * @param options defines additional options (can be plugin dependent)
  150116. * @returns the current mesh
  150117. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  150118. */
  150119. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  150120. /** @hidden */
  150121. _disposePhysicsObserver: Nullable<Observer<Node>>;
  150122. }
  150123. /**
  150124. * Defines the physics engine scene component responsible to manage a physics engine
  150125. */
  150126. export class PhysicsEngineSceneComponent implements ISceneComponent {
  150127. /**
  150128. * The component name helpful to identify the component in the list of scene components.
  150129. */
  150130. readonly name: string;
  150131. /**
  150132. * The scene the component belongs to.
  150133. */
  150134. scene: Scene;
  150135. /**
  150136. * Creates a new instance of the component for the given scene
  150137. * @param scene Defines the scene to register the component in
  150138. */
  150139. constructor(scene: Scene);
  150140. /**
  150141. * Registers the component in a given scene
  150142. */
  150143. register(): void;
  150144. /**
  150145. * Rebuilds the elements related to this component in case of
  150146. * context lost for instance.
  150147. */
  150148. rebuild(): void;
  150149. /**
  150150. * Disposes the component and the associated ressources
  150151. */
  150152. dispose(): void;
  150153. }
  150154. }
  150155. declare module BABYLON {
  150156. /**
  150157. * A helper for physics simulations
  150158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150159. */
  150160. export class PhysicsHelper {
  150161. private _scene;
  150162. private _physicsEngine;
  150163. /**
  150164. * Initializes the Physics helper
  150165. * @param scene Babylon.js scene
  150166. */
  150167. constructor(scene: Scene);
  150168. /**
  150169. * Applies a radial explosion impulse
  150170. * @param origin the origin of the explosion
  150171. * @param radiusOrEventOptions the radius or the options of radial explosion
  150172. * @param strength the explosion strength
  150173. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150174. * @returns A physics radial explosion event, or null
  150175. */
  150176. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  150177. /**
  150178. * Applies a radial explosion force
  150179. * @param origin the origin of the explosion
  150180. * @param radiusOrEventOptions the radius or the options of radial explosion
  150181. * @param strength the explosion strength
  150182. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150183. * @returns A physics radial explosion event, or null
  150184. */
  150185. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  150186. /**
  150187. * Creates a gravitational field
  150188. * @param origin the origin of the explosion
  150189. * @param radiusOrEventOptions the radius or the options of radial explosion
  150190. * @param strength the explosion strength
  150191. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150192. * @returns A physics gravitational field event, or null
  150193. */
  150194. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  150195. /**
  150196. * Creates a physics updraft event
  150197. * @param origin the origin of the updraft
  150198. * @param radiusOrEventOptions the radius or the options of the updraft
  150199. * @param strength the strength of the updraft
  150200. * @param height the height of the updraft
  150201. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  150202. * @returns A physics updraft event, or null
  150203. */
  150204. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  150205. /**
  150206. * Creates a physics vortex event
  150207. * @param origin the of the vortex
  150208. * @param radiusOrEventOptions the radius or the options of the vortex
  150209. * @param strength the strength of the vortex
  150210. * @param height the height of the vortex
  150211. * @returns a Physics vortex event, or null
  150212. * A physics vortex event or null
  150213. */
  150214. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  150215. }
  150216. /**
  150217. * Represents a physics radial explosion event
  150218. */
  150219. class PhysicsRadialExplosionEvent {
  150220. private _scene;
  150221. private _options;
  150222. private _sphere;
  150223. private _dataFetched;
  150224. /**
  150225. * Initializes a radial explosioin event
  150226. * @param _scene BabylonJS scene
  150227. * @param _options The options for the vortex event
  150228. */
  150229. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  150230. /**
  150231. * Returns the data related to the radial explosion event (sphere).
  150232. * @returns The radial explosion event data
  150233. */
  150234. getData(): PhysicsRadialExplosionEventData;
  150235. /**
  150236. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  150237. * @param impostor A physics imposter
  150238. * @param origin the origin of the explosion
  150239. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  150240. */
  150241. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  150242. /**
  150243. * Triggers affecterd impostors callbacks
  150244. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  150245. */
  150246. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  150247. /**
  150248. * Disposes the sphere.
  150249. * @param force Specifies if the sphere should be disposed by force
  150250. */
  150251. dispose(force?: boolean): void;
  150252. /*** Helpers ***/
  150253. private _prepareSphere;
  150254. private _intersectsWithSphere;
  150255. }
  150256. /**
  150257. * Represents a gravitational field event
  150258. */
  150259. class PhysicsGravitationalFieldEvent {
  150260. private _physicsHelper;
  150261. private _scene;
  150262. private _origin;
  150263. private _options;
  150264. private _tickCallback;
  150265. private _sphere;
  150266. private _dataFetched;
  150267. /**
  150268. * Initializes the physics gravitational field event
  150269. * @param _physicsHelper A physics helper
  150270. * @param _scene BabylonJS scene
  150271. * @param _origin The origin position of the gravitational field event
  150272. * @param _options The options for the vortex event
  150273. */
  150274. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  150275. /**
  150276. * Returns the data related to the gravitational field event (sphere).
  150277. * @returns A gravitational field event
  150278. */
  150279. getData(): PhysicsGravitationalFieldEventData;
  150280. /**
  150281. * Enables the gravitational field.
  150282. */
  150283. enable(): void;
  150284. /**
  150285. * Disables the gravitational field.
  150286. */
  150287. disable(): void;
  150288. /**
  150289. * Disposes the sphere.
  150290. * @param force The force to dispose from the gravitational field event
  150291. */
  150292. dispose(force?: boolean): void;
  150293. private _tick;
  150294. }
  150295. /**
  150296. * Represents a physics updraft event
  150297. */
  150298. class PhysicsUpdraftEvent {
  150299. private _scene;
  150300. private _origin;
  150301. private _options;
  150302. private _physicsEngine;
  150303. private _originTop;
  150304. private _originDirection;
  150305. private _tickCallback;
  150306. private _cylinder;
  150307. private _cylinderPosition;
  150308. private _dataFetched;
  150309. /**
  150310. * Initializes the physics updraft event
  150311. * @param _scene BabylonJS scene
  150312. * @param _origin The origin position of the updraft
  150313. * @param _options The options for the updraft event
  150314. */
  150315. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  150316. /**
  150317. * Returns the data related to the updraft event (cylinder).
  150318. * @returns A physics updraft event
  150319. */
  150320. getData(): PhysicsUpdraftEventData;
  150321. /**
  150322. * Enables the updraft.
  150323. */
  150324. enable(): void;
  150325. /**
  150326. * Disables the updraft.
  150327. */
  150328. disable(): void;
  150329. /**
  150330. * Disposes the cylinder.
  150331. * @param force Specifies if the updraft should be disposed by force
  150332. */
  150333. dispose(force?: boolean): void;
  150334. private getImpostorHitData;
  150335. private _tick;
  150336. /*** Helpers ***/
  150337. private _prepareCylinder;
  150338. private _intersectsWithCylinder;
  150339. }
  150340. /**
  150341. * Represents a physics vortex event
  150342. */
  150343. class PhysicsVortexEvent {
  150344. private _scene;
  150345. private _origin;
  150346. private _options;
  150347. private _physicsEngine;
  150348. private _originTop;
  150349. private _tickCallback;
  150350. private _cylinder;
  150351. private _cylinderPosition;
  150352. private _dataFetched;
  150353. /**
  150354. * Initializes the physics vortex event
  150355. * @param _scene The BabylonJS scene
  150356. * @param _origin The origin position of the vortex
  150357. * @param _options The options for the vortex event
  150358. */
  150359. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  150360. /**
  150361. * Returns the data related to the vortex event (cylinder).
  150362. * @returns The physics vortex event data
  150363. */
  150364. getData(): PhysicsVortexEventData;
  150365. /**
  150366. * Enables the vortex.
  150367. */
  150368. enable(): void;
  150369. /**
  150370. * Disables the cortex.
  150371. */
  150372. disable(): void;
  150373. /**
  150374. * Disposes the sphere.
  150375. * @param force
  150376. */
  150377. dispose(force?: boolean): void;
  150378. private getImpostorHitData;
  150379. private _tick;
  150380. /*** Helpers ***/
  150381. private _prepareCylinder;
  150382. private _intersectsWithCylinder;
  150383. }
  150384. /**
  150385. * Options fot the radial explosion event
  150386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150387. */
  150388. export class PhysicsRadialExplosionEventOptions {
  150389. /**
  150390. * The radius of the sphere for the radial explosion.
  150391. */
  150392. radius: number;
  150393. /**
  150394. * The strenth of the explosion.
  150395. */
  150396. strength: number;
  150397. /**
  150398. * The strenght of the force in correspondence to the distance of the affected object
  150399. */
  150400. falloff: PhysicsRadialImpulseFalloff;
  150401. /**
  150402. * Sphere options for the radial explosion.
  150403. */
  150404. sphere: {
  150405. segments: number;
  150406. diameter: number;
  150407. };
  150408. /**
  150409. * Sphere options for the radial explosion.
  150410. */
  150411. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  150412. }
  150413. /**
  150414. * Options fot the updraft event
  150415. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150416. */
  150417. export class PhysicsUpdraftEventOptions {
  150418. /**
  150419. * The radius of the cylinder for the vortex
  150420. */
  150421. radius: number;
  150422. /**
  150423. * The strenth of the updraft.
  150424. */
  150425. strength: number;
  150426. /**
  150427. * The height of the cylinder for the updraft.
  150428. */
  150429. height: number;
  150430. /**
  150431. * The mode for the the updraft.
  150432. */
  150433. updraftMode: PhysicsUpdraftMode;
  150434. }
  150435. /**
  150436. * Options fot the vortex event
  150437. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150438. */
  150439. export class PhysicsVortexEventOptions {
  150440. /**
  150441. * The radius of the cylinder for the vortex
  150442. */
  150443. radius: number;
  150444. /**
  150445. * The strenth of the vortex.
  150446. */
  150447. strength: number;
  150448. /**
  150449. * The height of the cylinder for the vortex.
  150450. */
  150451. height: number;
  150452. /**
  150453. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  150454. */
  150455. centripetalForceThreshold: number;
  150456. /**
  150457. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  150458. */
  150459. centripetalForceMultiplier: number;
  150460. /**
  150461. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  150462. */
  150463. centrifugalForceMultiplier: number;
  150464. /**
  150465. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  150466. */
  150467. updraftForceMultiplier: number;
  150468. }
  150469. /**
  150470. * The strenght of the force in correspondence to the distance of the affected object
  150471. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150472. */
  150473. export enum PhysicsRadialImpulseFalloff {
  150474. /** Defines that impulse is constant in strength across it's whole radius */
  150475. Constant = 0,
  150476. /** Defines that impulse gets weaker if it's further from the origin */
  150477. Linear = 1
  150478. }
  150479. /**
  150480. * The strength of the force in correspondence to the distance of the affected object
  150481. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150482. */
  150483. export enum PhysicsUpdraftMode {
  150484. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  150485. Center = 0,
  150486. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  150487. Perpendicular = 1
  150488. }
  150489. /**
  150490. * Interface for a physics hit data
  150491. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150492. */
  150493. export interface PhysicsHitData {
  150494. /**
  150495. * The force applied at the contact point
  150496. */
  150497. force: Vector3;
  150498. /**
  150499. * The contact point
  150500. */
  150501. contactPoint: Vector3;
  150502. /**
  150503. * The distance from the origin to the contact point
  150504. */
  150505. distanceFromOrigin: number;
  150506. }
  150507. /**
  150508. * Interface for radial explosion event data
  150509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150510. */
  150511. export interface PhysicsRadialExplosionEventData {
  150512. /**
  150513. * A sphere used for the radial explosion event
  150514. */
  150515. sphere: Mesh;
  150516. }
  150517. /**
  150518. * Interface for gravitational field event data
  150519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150520. */
  150521. export interface PhysicsGravitationalFieldEventData {
  150522. /**
  150523. * A sphere mesh used for the gravitational field event
  150524. */
  150525. sphere: Mesh;
  150526. }
  150527. /**
  150528. * Interface for updraft event data
  150529. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150530. */
  150531. export interface PhysicsUpdraftEventData {
  150532. /**
  150533. * A cylinder used for the updraft event
  150534. */
  150535. cylinder: Mesh;
  150536. }
  150537. /**
  150538. * Interface for vortex event data
  150539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150540. */
  150541. export interface PhysicsVortexEventData {
  150542. /**
  150543. * A cylinder used for the vortex event
  150544. */
  150545. cylinder: Mesh;
  150546. }
  150547. /**
  150548. * Interface for an affected physics impostor
  150549. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150550. */
  150551. export interface PhysicsAffectedImpostorWithData {
  150552. /**
  150553. * The impostor affected by the effect
  150554. */
  150555. impostor: PhysicsImpostor;
  150556. /**
  150557. * The data about the hit/horce from the explosion
  150558. */
  150559. hitData: PhysicsHitData;
  150560. }
  150561. }
  150562. declare module BABYLON {
  150563. /** @hidden */
  150564. export var blackAndWhitePixelShader: {
  150565. name: string;
  150566. shader: string;
  150567. };
  150568. }
  150569. declare module BABYLON {
  150570. /**
  150571. * Post process used to render in black and white
  150572. */
  150573. export class BlackAndWhitePostProcess extends PostProcess {
  150574. /**
  150575. * Linear about to convert he result to black and white (default: 1)
  150576. */
  150577. degree: number;
  150578. /**
  150579. * Gets a string identifying the name of the class
  150580. * @returns "BlackAndWhitePostProcess" string
  150581. */
  150582. getClassName(): string;
  150583. /**
  150584. * Creates a black and white post process
  150585. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  150586. * @param name The name of the effect.
  150587. * @param options The required width/height ratio to downsize to before computing the render pass.
  150588. * @param camera The camera to apply the render pass to.
  150589. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150590. * @param engine The engine which the post process will be applied. (default: current engine)
  150591. * @param reusable If the post process can be reused on the same frame. (default: false)
  150592. */
  150593. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150594. /** @hidden */
  150595. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  150596. }
  150597. }
  150598. declare module BABYLON {
  150599. /**
  150600. * This represents a set of one or more post processes in Babylon.
  150601. * A post process can be used to apply a shader to a texture after it is rendered.
  150602. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150603. */
  150604. export class PostProcessRenderEffect {
  150605. private _postProcesses;
  150606. private _getPostProcesses;
  150607. private _singleInstance;
  150608. private _cameras;
  150609. private _indicesForCamera;
  150610. /**
  150611. * Name of the effect
  150612. * @hidden
  150613. */
  150614. _name: string;
  150615. /**
  150616. * Instantiates a post process render effect.
  150617. * A post process can be used to apply a shader to a texture after it is rendered.
  150618. * @param engine The engine the effect is tied to
  150619. * @param name The name of the effect
  150620. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  150621. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  150622. */
  150623. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  150624. /**
  150625. * Checks if all the post processes in the effect are supported.
  150626. */
  150627. get isSupported(): boolean;
  150628. /**
  150629. * Updates the current state of the effect
  150630. * @hidden
  150631. */
  150632. _update(): void;
  150633. /**
  150634. * Attaches the effect on cameras
  150635. * @param cameras The camera to attach to.
  150636. * @hidden
  150637. */
  150638. _attachCameras(cameras: Camera): void;
  150639. /**
  150640. * Attaches the effect on cameras
  150641. * @param cameras The camera to attach to.
  150642. * @hidden
  150643. */
  150644. _attachCameras(cameras: Camera[]): void;
  150645. /**
  150646. * Detaches the effect on cameras
  150647. * @param cameras The camera to detatch from.
  150648. * @hidden
  150649. */
  150650. _detachCameras(cameras: Camera): void;
  150651. /**
  150652. * Detatches the effect on cameras
  150653. * @param cameras The camera to detatch from.
  150654. * @hidden
  150655. */
  150656. _detachCameras(cameras: Camera[]): void;
  150657. /**
  150658. * Enables the effect on given cameras
  150659. * @param cameras The camera to enable.
  150660. * @hidden
  150661. */
  150662. _enable(cameras: Camera): void;
  150663. /**
  150664. * Enables the effect on given cameras
  150665. * @param cameras The camera to enable.
  150666. * @hidden
  150667. */
  150668. _enable(cameras: Nullable<Camera[]>): void;
  150669. /**
  150670. * Disables the effect on the given cameras
  150671. * @param cameras The camera to disable.
  150672. * @hidden
  150673. */
  150674. _disable(cameras: Camera): void;
  150675. /**
  150676. * Disables the effect on the given cameras
  150677. * @param cameras The camera to disable.
  150678. * @hidden
  150679. */
  150680. _disable(cameras: Nullable<Camera[]>): void;
  150681. /**
  150682. * Gets a list of the post processes contained in the effect.
  150683. * @param camera The camera to get the post processes on.
  150684. * @returns The list of the post processes in the effect.
  150685. */
  150686. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  150687. }
  150688. }
  150689. declare module BABYLON {
  150690. /** @hidden */
  150691. export var extractHighlightsPixelShader: {
  150692. name: string;
  150693. shader: string;
  150694. };
  150695. }
  150696. declare module BABYLON {
  150697. /**
  150698. * 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.
  150699. */
  150700. export class ExtractHighlightsPostProcess extends PostProcess {
  150701. /**
  150702. * The luminance threshold, pixels below this value will be set to black.
  150703. */
  150704. threshold: number;
  150705. /** @hidden */
  150706. _exposure: number;
  150707. /**
  150708. * Post process which has the input texture to be used when performing highlight extraction
  150709. * @hidden
  150710. */
  150711. _inputPostProcess: Nullable<PostProcess>;
  150712. /**
  150713. * Gets a string identifying the name of the class
  150714. * @returns "ExtractHighlightsPostProcess" string
  150715. */
  150716. getClassName(): string;
  150717. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150718. }
  150719. }
  150720. declare module BABYLON {
  150721. /** @hidden */
  150722. export var bloomMergePixelShader: {
  150723. name: string;
  150724. shader: string;
  150725. };
  150726. }
  150727. declare module BABYLON {
  150728. /**
  150729. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  150730. */
  150731. export class BloomMergePostProcess extends PostProcess {
  150732. /** Weight of the bloom to be added to the original input. */
  150733. weight: number;
  150734. /**
  150735. * Gets a string identifying the name of the class
  150736. * @returns "BloomMergePostProcess" string
  150737. */
  150738. getClassName(): string;
  150739. /**
  150740. * Creates a new instance of @see BloomMergePostProcess
  150741. * @param name The name of the effect.
  150742. * @param originalFromInput Post process which's input will be used for the merge.
  150743. * @param blurred Blurred highlights post process which's output will be used.
  150744. * @param weight Weight of the bloom to be added to the original input.
  150745. * @param options The required width/height ratio to downsize to before computing the render pass.
  150746. * @param camera The camera to apply the render pass to.
  150747. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150748. * @param engine The engine which the post process will be applied. (default: current engine)
  150749. * @param reusable If the post process can be reused on the same frame. (default: false)
  150750. * @param textureType Type of textures used when performing the post process. (default: 0)
  150751. * @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)
  150752. */
  150753. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  150754. /** Weight of the bloom to be added to the original input. */
  150755. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150756. }
  150757. }
  150758. declare module BABYLON {
  150759. /**
  150760. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  150761. */
  150762. export class BloomEffect extends PostProcessRenderEffect {
  150763. private bloomScale;
  150764. /**
  150765. * @hidden Internal
  150766. */
  150767. _effects: Array<PostProcess>;
  150768. /**
  150769. * @hidden Internal
  150770. */
  150771. _downscale: ExtractHighlightsPostProcess;
  150772. private _blurX;
  150773. private _blurY;
  150774. private _merge;
  150775. /**
  150776. * The luminance threshold to find bright areas of the image to bloom.
  150777. */
  150778. get threshold(): number;
  150779. set threshold(value: number);
  150780. /**
  150781. * The strength of the bloom.
  150782. */
  150783. get weight(): number;
  150784. set weight(value: number);
  150785. /**
  150786. * Specifies the size of the bloom blur kernel, relative to the final output size
  150787. */
  150788. get kernel(): number;
  150789. set kernel(value: number);
  150790. /**
  150791. * Creates a new instance of @see BloomEffect
  150792. * @param scene The scene the effect belongs to.
  150793. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  150794. * @param bloomKernel The size of the kernel to be used when applying the blur.
  150795. * @param bloomWeight The the strength of bloom.
  150796. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  150797. * @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)
  150798. */
  150799. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  150800. /**
  150801. * Disposes each of the internal effects for a given camera.
  150802. * @param camera The camera to dispose the effect on.
  150803. */
  150804. disposeEffects(camera: Camera): void;
  150805. /**
  150806. * @hidden Internal
  150807. */
  150808. _updateEffects(): void;
  150809. /**
  150810. * Internal
  150811. * @returns if all the contained post processes are ready.
  150812. * @hidden
  150813. */
  150814. _isReady(): boolean;
  150815. }
  150816. }
  150817. declare module BABYLON {
  150818. /** @hidden */
  150819. export var chromaticAberrationPixelShader: {
  150820. name: string;
  150821. shader: string;
  150822. };
  150823. }
  150824. declare module BABYLON {
  150825. /**
  150826. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  150827. */
  150828. export class ChromaticAberrationPostProcess extends PostProcess {
  150829. /**
  150830. * The amount of seperation of rgb channels (default: 30)
  150831. */
  150832. aberrationAmount: number;
  150833. /**
  150834. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  150835. */
  150836. radialIntensity: number;
  150837. /**
  150838. * 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))
  150839. */
  150840. direction: Vector2;
  150841. /**
  150842. * 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))
  150843. */
  150844. centerPosition: Vector2;
  150845. /** The width of the screen to apply the effect on */
  150846. screenWidth: number;
  150847. /** The height of the screen to apply the effect on */
  150848. screenHeight: number;
  150849. /**
  150850. * Gets a string identifying the name of the class
  150851. * @returns "ChromaticAberrationPostProcess" string
  150852. */
  150853. getClassName(): string;
  150854. /**
  150855. * Creates a new instance ChromaticAberrationPostProcess
  150856. * @param name The name of the effect.
  150857. * @param screenWidth The width of the screen to apply the effect on.
  150858. * @param screenHeight The height of the screen to apply the effect on.
  150859. * @param options The required width/height ratio to downsize to before computing the render pass.
  150860. * @param camera The camera to apply the render pass to.
  150861. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150862. * @param engine The engine which the post process will be applied. (default: current engine)
  150863. * @param reusable If the post process can be reused on the same frame. (default: false)
  150864. * @param textureType Type of textures used when performing the post process. (default: 0)
  150865. * @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)
  150866. */
  150867. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150868. /** @hidden */
  150869. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  150870. }
  150871. }
  150872. declare module BABYLON {
  150873. /** @hidden */
  150874. export var circleOfConfusionPixelShader: {
  150875. name: string;
  150876. shader: string;
  150877. };
  150878. }
  150879. declare module BABYLON {
  150880. /**
  150881. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  150882. */
  150883. export class CircleOfConfusionPostProcess extends PostProcess {
  150884. /**
  150885. * 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.
  150886. */
  150887. lensSize: number;
  150888. /**
  150889. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  150890. */
  150891. fStop: number;
  150892. /**
  150893. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  150894. */
  150895. focusDistance: number;
  150896. /**
  150897. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  150898. */
  150899. focalLength: number;
  150900. /**
  150901. * Gets a string identifying the name of the class
  150902. * @returns "CircleOfConfusionPostProcess" string
  150903. */
  150904. getClassName(): string;
  150905. private _depthTexture;
  150906. /**
  150907. * Creates a new instance CircleOfConfusionPostProcess
  150908. * @param name The name of the effect.
  150909. * @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.
  150910. * @param options The required width/height ratio to downsize to before computing the render pass.
  150911. * @param camera The camera to apply the render pass to.
  150912. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150913. * @param engine The engine which the post process will be applied. (default: current engine)
  150914. * @param reusable If the post process can be reused on the same frame. (default: false)
  150915. * @param textureType Type of textures used when performing the post process. (default: 0)
  150916. * @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)
  150917. */
  150918. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150919. /**
  150920. * 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.
  150921. */
  150922. set depthTexture(value: RenderTargetTexture);
  150923. }
  150924. }
  150925. declare module BABYLON {
  150926. /** @hidden */
  150927. export var colorCorrectionPixelShader: {
  150928. name: string;
  150929. shader: string;
  150930. };
  150931. }
  150932. declare module BABYLON {
  150933. /**
  150934. *
  150935. * This post-process allows the modification of rendered colors by using
  150936. * a 'look-up table' (LUT). This effect is also called Color Grading.
  150937. *
  150938. * The object needs to be provided an url to a texture containing the color
  150939. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  150940. * Use an image editing software to tweak the LUT to match your needs.
  150941. *
  150942. * For an example of a color LUT, see here:
  150943. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  150944. * For explanations on color grading, see here:
  150945. * @see http://udn.epicgames.com/Three/ColorGrading.html
  150946. *
  150947. */
  150948. export class ColorCorrectionPostProcess extends PostProcess {
  150949. private _colorTableTexture;
  150950. /**
  150951. * Gets the color table url used to create the LUT texture
  150952. */
  150953. colorTableUrl: string;
  150954. /**
  150955. * Gets a string identifying the name of the class
  150956. * @returns "ColorCorrectionPostProcess" string
  150957. */
  150958. getClassName(): string;
  150959. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150960. /** @hidden */
  150961. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  150962. }
  150963. }
  150964. declare module BABYLON {
  150965. /** @hidden */
  150966. export var convolutionPixelShader: {
  150967. name: string;
  150968. shader: string;
  150969. };
  150970. }
  150971. declare module BABYLON {
  150972. /**
  150973. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  150974. * input texture to perform effects such as edge detection or sharpening
  150975. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150976. */
  150977. export class ConvolutionPostProcess extends PostProcess {
  150978. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  150979. kernel: number[];
  150980. /**
  150981. * Gets a string identifying the name of the class
  150982. * @returns "ConvolutionPostProcess" string
  150983. */
  150984. getClassName(): string;
  150985. /**
  150986. * Creates a new instance ConvolutionPostProcess
  150987. * @param name The name of the effect.
  150988. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  150989. * @param options The required width/height ratio to downsize to before computing the render pass.
  150990. * @param camera The camera to apply the render pass to.
  150991. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150992. * @param engine The engine which the post process will be applied. (default: current engine)
  150993. * @param reusable If the post process can be reused on the same frame. (default: false)
  150994. * @param textureType Type of textures used when performing the post process. (default: 0)
  150995. */
  150996. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150997. /** @hidden */
  150998. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  150999. /**
  151000. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151001. */
  151002. static EdgeDetect0Kernel: number[];
  151003. /**
  151004. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151005. */
  151006. static EdgeDetect1Kernel: number[];
  151007. /**
  151008. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151009. */
  151010. static EdgeDetect2Kernel: number[];
  151011. /**
  151012. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151013. */
  151014. static SharpenKernel: number[];
  151015. /**
  151016. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151017. */
  151018. static EmbossKernel: number[];
  151019. /**
  151020. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151021. */
  151022. static GaussianKernel: number[];
  151023. }
  151024. }
  151025. declare module BABYLON {
  151026. /**
  151027. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  151028. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  151029. * based on samples that have a large difference in distance than the center pixel.
  151030. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  151031. */
  151032. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  151033. /**
  151034. * The direction the blur should be applied
  151035. */
  151036. direction: Vector2;
  151037. /**
  151038. * Gets a string identifying the name of the class
  151039. * @returns "DepthOfFieldBlurPostProcess" string
  151040. */
  151041. getClassName(): string;
  151042. /**
  151043. * Creates a new instance CircleOfConfusionPostProcess
  151044. * @param name The name of the effect.
  151045. * @param scene The scene the effect belongs to.
  151046. * @param direction The direction the blur should be applied.
  151047. * @param kernel The size of the kernel used to blur.
  151048. * @param options The required width/height ratio to downsize to before computing the render pass.
  151049. * @param camera The camera to apply the render pass to.
  151050. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  151051. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  151052. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151053. * @param engine The engine which the post process will be applied. (default: current engine)
  151054. * @param reusable If the post process can be reused on the same frame. (default: false)
  151055. * @param textureType Type of textures used when performing the post process. (default: 0)
  151056. * @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)
  151057. */
  151058. 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);
  151059. }
  151060. }
  151061. declare module BABYLON {
  151062. /** @hidden */
  151063. export var depthOfFieldMergePixelShader: {
  151064. name: string;
  151065. shader: string;
  151066. };
  151067. }
  151068. declare module BABYLON {
  151069. /**
  151070. * Options to be set when merging outputs from the default pipeline.
  151071. */
  151072. export class DepthOfFieldMergePostProcessOptions {
  151073. /**
  151074. * The original image to merge on top of
  151075. */
  151076. originalFromInput: PostProcess;
  151077. /**
  151078. * Parameters to perform the merge of the depth of field effect
  151079. */
  151080. depthOfField?: {
  151081. circleOfConfusion: PostProcess;
  151082. blurSteps: Array<PostProcess>;
  151083. };
  151084. /**
  151085. * Parameters to perform the merge of bloom effect
  151086. */
  151087. bloom?: {
  151088. blurred: PostProcess;
  151089. weight: number;
  151090. };
  151091. }
  151092. /**
  151093. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  151094. */
  151095. export class DepthOfFieldMergePostProcess extends PostProcess {
  151096. private blurSteps;
  151097. /**
  151098. * Gets a string identifying the name of the class
  151099. * @returns "DepthOfFieldMergePostProcess" string
  151100. */
  151101. getClassName(): string;
  151102. /**
  151103. * Creates a new instance of DepthOfFieldMergePostProcess
  151104. * @param name The name of the effect.
  151105. * @param originalFromInput Post process which's input will be used for the merge.
  151106. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  151107. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  151108. * @param options The required width/height ratio to downsize to before computing the render pass.
  151109. * @param camera The camera to apply the render pass to.
  151110. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151111. * @param engine The engine which the post process will be applied. (default: current engine)
  151112. * @param reusable If the post process can be reused on the same frame. (default: false)
  151113. * @param textureType Type of textures used when performing the post process. (default: 0)
  151114. * @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)
  151115. */
  151116. 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);
  151117. /**
  151118. * Updates the effect with the current post process compile time values and recompiles the shader.
  151119. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  151120. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  151121. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  151122. * @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
  151123. * @param onCompiled Called when the shader has been compiled.
  151124. * @param onError Called if there is an error when compiling a shader.
  151125. */
  151126. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  151127. }
  151128. }
  151129. declare module BABYLON {
  151130. /**
  151131. * Specifies the level of max blur that should be applied when using the depth of field effect
  151132. */
  151133. export enum DepthOfFieldEffectBlurLevel {
  151134. /**
  151135. * Subtle blur
  151136. */
  151137. Low = 0,
  151138. /**
  151139. * Medium blur
  151140. */
  151141. Medium = 1,
  151142. /**
  151143. * Large blur
  151144. */
  151145. High = 2
  151146. }
  151147. /**
  151148. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  151149. */
  151150. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  151151. private _circleOfConfusion;
  151152. /**
  151153. * @hidden Internal, blurs from high to low
  151154. */
  151155. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  151156. private _depthOfFieldBlurY;
  151157. private _dofMerge;
  151158. /**
  151159. * @hidden Internal post processes in depth of field effect
  151160. */
  151161. _effects: Array<PostProcess>;
  151162. /**
  151163. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  151164. */
  151165. set focalLength(value: number);
  151166. get focalLength(): number;
  151167. /**
  151168. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  151169. */
  151170. set fStop(value: number);
  151171. get fStop(): number;
  151172. /**
  151173. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  151174. */
  151175. set focusDistance(value: number);
  151176. get focusDistance(): number;
  151177. /**
  151178. * 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.
  151179. */
  151180. set lensSize(value: number);
  151181. get lensSize(): number;
  151182. /**
  151183. * Creates a new instance DepthOfFieldEffect
  151184. * @param scene The scene the effect belongs to.
  151185. * @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.
  151186. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  151187. * @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)
  151188. */
  151189. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  151190. /**
  151191. * Get the current class name of the current effet
  151192. * @returns "DepthOfFieldEffect"
  151193. */
  151194. getClassName(): string;
  151195. /**
  151196. * 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.
  151197. */
  151198. set depthTexture(value: RenderTargetTexture);
  151199. /**
  151200. * Disposes each of the internal effects for a given camera.
  151201. * @param camera The camera to dispose the effect on.
  151202. */
  151203. disposeEffects(camera: Camera): void;
  151204. /**
  151205. * @hidden Internal
  151206. */
  151207. _updateEffects(): void;
  151208. /**
  151209. * Internal
  151210. * @returns if all the contained post processes are ready.
  151211. * @hidden
  151212. */
  151213. _isReady(): boolean;
  151214. }
  151215. }
  151216. declare module BABYLON {
  151217. /** @hidden */
  151218. export var displayPassPixelShader: {
  151219. name: string;
  151220. shader: string;
  151221. };
  151222. }
  151223. declare module BABYLON {
  151224. /**
  151225. * DisplayPassPostProcess which produces an output the same as it's input
  151226. */
  151227. export class DisplayPassPostProcess extends PostProcess {
  151228. /**
  151229. * Gets a string identifying the name of the class
  151230. * @returns "DisplayPassPostProcess" string
  151231. */
  151232. getClassName(): string;
  151233. /**
  151234. * Creates the DisplayPassPostProcess
  151235. * @param name The name of the effect.
  151236. * @param options The required width/height ratio to downsize to before computing the render pass.
  151237. * @param camera The camera to apply the render pass to.
  151238. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151239. * @param engine The engine which the post process will be applied. (default: current engine)
  151240. * @param reusable If the post process can be reused on the same frame. (default: false)
  151241. */
  151242. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151243. /** @hidden */
  151244. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  151245. }
  151246. }
  151247. declare module BABYLON {
  151248. /** @hidden */
  151249. export var filterPixelShader: {
  151250. name: string;
  151251. shader: string;
  151252. };
  151253. }
  151254. declare module BABYLON {
  151255. /**
  151256. * Applies a kernel filter to the image
  151257. */
  151258. export class FilterPostProcess extends PostProcess {
  151259. /** The matrix to be applied to the image */
  151260. kernelMatrix: Matrix;
  151261. /**
  151262. * Gets a string identifying the name of the class
  151263. * @returns "FilterPostProcess" string
  151264. */
  151265. getClassName(): string;
  151266. /**
  151267. *
  151268. * @param name The name of the effect.
  151269. * @param kernelMatrix The matrix to be applied to the image
  151270. * @param options The required width/height ratio to downsize to before computing the render pass.
  151271. * @param camera The camera to apply the render pass to.
  151272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151273. * @param engine The engine which the post process will be applied. (default: current engine)
  151274. * @param reusable If the post process can be reused on the same frame. (default: false)
  151275. */
  151276. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151277. /** @hidden */
  151278. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  151279. }
  151280. }
  151281. declare module BABYLON {
  151282. /** @hidden */
  151283. export var fxaaPixelShader: {
  151284. name: string;
  151285. shader: string;
  151286. };
  151287. }
  151288. declare module BABYLON {
  151289. /** @hidden */
  151290. export var fxaaVertexShader: {
  151291. name: string;
  151292. shader: string;
  151293. };
  151294. }
  151295. declare module BABYLON {
  151296. /**
  151297. * Fxaa post process
  151298. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  151299. */
  151300. export class FxaaPostProcess extends PostProcess {
  151301. /**
  151302. * Gets a string identifying the name of the class
  151303. * @returns "FxaaPostProcess" string
  151304. */
  151305. getClassName(): string;
  151306. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  151307. private _getDefines;
  151308. /** @hidden */
  151309. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  151310. }
  151311. }
  151312. declare module BABYLON {
  151313. /** @hidden */
  151314. export var grainPixelShader: {
  151315. name: string;
  151316. shader: string;
  151317. };
  151318. }
  151319. declare module BABYLON {
  151320. /**
  151321. * The GrainPostProcess adds noise to the image at mid luminance levels
  151322. */
  151323. export class GrainPostProcess extends PostProcess {
  151324. /**
  151325. * The intensity of the grain added (default: 30)
  151326. */
  151327. intensity: number;
  151328. /**
  151329. * If the grain should be randomized on every frame
  151330. */
  151331. animated: boolean;
  151332. /**
  151333. * Gets a string identifying the name of the class
  151334. * @returns "GrainPostProcess" string
  151335. */
  151336. getClassName(): string;
  151337. /**
  151338. * Creates a new instance of @see GrainPostProcess
  151339. * @param name The name of the effect.
  151340. * @param options The required width/height ratio to downsize to before computing the render pass.
  151341. * @param camera The camera to apply the render pass to.
  151342. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151343. * @param engine The engine which the post process will be applied. (default: current engine)
  151344. * @param reusable If the post process can be reused on the same frame. (default: false)
  151345. * @param textureType Type of textures used when performing the post process. (default: 0)
  151346. * @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)
  151347. */
  151348. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151349. /** @hidden */
  151350. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  151351. }
  151352. }
  151353. declare module BABYLON {
  151354. /** @hidden */
  151355. export var highlightsPixelShader: {
  151356. name: string;
  151357. shader: string;
  151358. };
  151359. }
  151360. declare module BABYLON {
  151361. /**
  151362. * Extracts highlights from the image
  151363. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  151364. */
  151365. export class HighlightsPostProcess extends PostProcess {
  151366. /**
  151367. * Gets a string identifying the name of the class
  151368. * @returns "HighlightsPostProcess" string
  151369. */
  151370. getClassName(): string;
  151371. /**
  151372. * Extracts highlights from the image
  151373. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  151374. * @param name The name of the effect.
  151375. * @param options The required width/height ratio to downsize to before computing the render pass.
  151376. * @param camera The camera to apply the render pass to.
  151377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151378. * @param engine The engine which the post process will be applied. (default: current engine)
  151379. * @param reusable If the post process can be reused on the same frame. (default: false)
  151380. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  151381. */
  151382. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  151383. }
  151384. }
  151385. declare module BABYLON {
  151386. /**
  151387. * Contains all parameters needed for the prepass to perform
  151388. * motion blur
  151389. */
  151390. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  151391. /**
  151392. * Is motion blur enabled
  151393. */
  151394. enabled: boolean;
  151395. /**
  151396. * Name of the configuration
  151397. */
  151398. name: string;
  151399. /**
  151400. * Textures that should be present in the MRT for this effect to work
  151401. */
  151402. readonly texturesRequired: number[];
  151403. }
  151404. }
  151405. declare module BABYLON {
  151406. interface Scene {
  151407. /** @hidden (Backing field) */
  151408. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  151409. /**
  151410. * Gets or Sets the current geometry buffer associated to the scene.
  151411. */
  151412. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  151413. /**
  151414. * Enables a GeometryBufferRender and associates it with the scene
  151415. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  151416. * @returns the GeometryBufferRenderer
  151417. */
  151418. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  151419. /**
  151420. * Disables the GeometryBufferRender associated with the scene
  151421. */
  151422. disableGeometryBufferRenderer(): void;
  151423. }
  151424. /**
  151425. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  151426. * in several rendering techniques.
  151427. */
  151428. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  151429. /**
  151430. * The component name helpful to identify the component in the list of scene components.
  151431. */
  151432. readonly name: string;
  151433. /**
  151434. * The scene the component belongs to.
  151435. */
  151436. scene: Scene;
  151437. /**
  151438. * Creates a new instance of the component for the given scene
  151439. * @param scene Defines the scene to register the component in
  151440. */
  151441. constructor(scene: Scene);
  151442. /**
  151443. * Registers the component in a given scene
  151444. */
  151445. register(): void;
  151446. /**
  151447. * Rebuilds the elements related to this component in case of
  151448. * context lost for instance.
  151449. */
  151450. rebuild(): void;
  151451. /**
  151452. * Disposes the component and the associated ressources
  151453. */
  151454. dispose(): void;
  151455. private _gatherRenderTargets;
  151456. }
  151457. }
  151458. declare module BABYLON {
  151459. /** @hidden */
  151460. export var motionBlurPixelShader: {
  151461. name: string;
  151462. shader: string;
  151463. };
  151464. }
  151465. declare module BABYLON {
  151466. /**
  151467. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  151468. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  151469. * As an example, all you have to do is to create the post-process:
  151470. * var mb = new BABYLON.MotionBlurPostProcess(
  151471. * 'mb', // The name of the effect.
  151472. * scene, // The scene containing the objects to blur according to their velocity.
  151473. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  151474. * camera // The camera to apply the render pass to.
  151475. * );
  151476. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  151477. */
  151478. export class MotionBlurPostProcess extends PostProcess {
  151479. /**
  151480. * Defines how much the image is blurred by the movement. Default value is equal to 1
  151481. */
  151482. motionStrength: number;
  151483. /**
  151484. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  151485. */
  151486. get motionBlurSamples(): number;
  151487. /**
  151488. * Sets the number of iterations to be used for motion blur quality
  151489. */
  151490. set motionBlurSamples(samples: number);
  151491. private _motionBlurSamples;
  151492. private _forceGeometryBuffer;
  151493. private _geometryBufferRenderer;
  151494. private _prePassRenderer;
  151495. /**
  151496. * Gets a string identifying the name of the class
  151497. * @returns "MotionBlurPostProcess" string
  151498. */
  151499. getClassName(): string;
  151500. /**
  151501. * Creates a new instance MotionBlurPostProcess
  151502. * @param name The name of the effect.
  151503. * @param scene The scene containing the objects to blur according to their velocity.
  151504. * @param options The required width/height ratio to downsize to before computing the render pass.
  151505. * @param camera The camera to apply the render pass to.
  151506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151507. * @param engine The engine which the post process will be applied. (default: current engine)
  151508. * @param reusable If the post process can be reused on the same frame. (default: false)
  151509. * @param textureType Type of textures used when performing the post process. (default: 0)
  151510. * @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)
  151511. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  151512. */
  151513. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  151514. /**
  151515. * Excludes the given skinned mesh from computing bones velocities.
  151516. * 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.
  151517. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  151518. */
  151519. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  151520. /**
  151521. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  151522. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  151523. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  151524. */
  151525. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  151526. /**
  151527. * Disposes the post process.
  151528. * @param camera The camera to dispose the post process on.
  151529. */
  151530. dispose(camera?: Camera): void;
  151531. /** @hidden */
  151532. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  151533. }
  151534. }
  151535. declare module BABYLON {
  151536. /** @hidden */
  151537. export var refractionPixelShader: {
  151538. name: string;
  151539. shader: string;
  151540. };
  151541. }
  151542. declare module BABYLON {
  151543. /**
  151544. * Post process which applies a refractin texture
  151545. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  151546. */
  151547. export class RefractionPostProcess extends PostProcess {
  151548. private _refTexture;
  151549. private _ownRefractionTexture;
  151550. /** the base color of the refraction (used to taint the rendering) */
  151551. color: Color3;
  151552. /** simulated refraction depth */
  151553. depth: number;
  151554. /** the coefficient of the base color (0 to remove base color tainting) */
  151555. colorLevel: number;
  151556. /** Gets the url used to load the refraction texture */
  151557. refractionTextureUrl: string;
  151558. /**
  151559. * Gets or sets the refraction texture
  151560. * Please note that you are responsible for disposing the texture if you set it manually
  151561. */
  151562. get refractionTexture(): Texture;
  151563. set refractionTexture(value: Texture);
  151564. /**
  151565. * Gets a string identifying the name of the class
  151566. * @returns "RefractionPostProcess" string
  151567. */
  151568. getClassName(): string;
  151569. /**
  151570. * Initializes the RefractionPostProcess
  151571. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  151572. * @param name The name of the effect.
  151573. * @param refractionTextureUrl Url of the refraction texture to use
  151574. * @param color the base color of the refraction (used to taint the rendering)
  151575. * @param depth simulated refraction depth
  151576. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  151577. * @param camera The camera to apply the render pass to.
  151578. * @param options The required width/height ratio to downsize to before computing the render pass.
  151579. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151580. * @param engine The engine which the post process will be applied. (default: current engine)
  151581. * @param reusable If the post process can be reused on the same frame. (default: false)
  151582. */
  151583. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151584. /**
  151585. * Disposes of the post process
  151586. * @param camera Camera to dispose post process on
  151587. */
  151588. dispose(camera: Camera): void;
  151589. /** @hidden */
  151590. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  151591. }
  151592. }
  151593. declare module BABYLON {
  151594. /** @hidden */
  151595. export var sharpenPixelShader: {
  151596. name: string;
  151597. shader: string;
  151598. };
  151599. }
  151600. declare module BABYLON {
  151601. /**
  151602. * The SharpenPostProcess applies a sharpen kernel to every pixel
  151603. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  151604. */
  151605. export class SharpenPostProcess extends PostProcess {
  151606. /**
  151607. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  151608. */
  151609. colorAmount: number;
  151610. /**
  151611. * How much sharpness should be applied (default: 0.3)
  151612. */
  151613. edgeAmount: number;
  151614. /**
  151615. * Gets a string identifying the name of the class
  151616. * @returns "SharpenPostProcess" string
  151617. */
  151618. getClassName(): string;
  151619. /**
  151620. * Creates a new instance ConvolutionPostProcess
  151621. * @param name The name of the effect.
  151622. * @param options The required width/height ratio to downsize to before computing the render pass.
  151623. * @param camera The camera to apply the render pass to.
  151624. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151625. * @param engine The engine which the post process will be applied. (default: current engine)
  151626. * @param reusable If the post process can be reused on the same frame. (default: false)
  151627. * @param textureType Type of textures used when performing the post process. (default: 0)
  151628. * @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)
  151629. */
  151630. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151631. /** @hidden */
  151632. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  151633. }
  151634. }
  151635. declare module BABYLON {
  151636. /**
  151637. * PostProcessRenderPipeline
  151638. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151639. */
  151640. export class PostProcessRenderPipeline {
  151641. private engine;
  151642. private _renderEffects;
  151643. private _renderEffectsForIsolatedPass;
  151644. /**
  151645. * List of inspectable custom properties (used by the Inspector)
  151646. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  151647. */
  151648. inspectableCustomProperties: IInspectable[];
  151649. /**
  151650. * @hidden
  151651. */
  151652. protected _cameras: Camera[];
  151653. /** @hidden */
  151654. _name: string;
  151655. /**
  151656. * Gets pipeline name
  151657. */
  151658. get name(): string;
  151659. /** Gets the list of attached cameras */
  151660. get cameras(): Camera[];
  151661. /**
  151662. * Initializes a PostProcessRenderPipeline
  151663. * @param engine engine to add the pipeline to
  151664. * @param name name of the pipeline
  151665. */
  151666. constructor(engine: Engine, name: string);
  151667. /**
  151668. * Gets the class name
  151669. * @returns "PostProcessRenderPipeline"
  151670. */
  151671. getClassName(): string;
  151672. /**
  151673. * If all the render effects in the pipeline are supported
  151674. */
  151675. get isSupported(): boolean;
  151676. /**
  151677. * Adds an effect to the pipeline
  151678. * @param renderEffect the effect to add
  151679. */
  151680. addEffect(renderEffect: PostProcessRenderEffect): void;
  151681. /** @hidden */
  151682. _rebuild(): void;
  151683. /** @hidden */
  151684. _enableEffect(renderEffectName: string, cameras: Camera): void;
  151685. /** @hidden */
  151686. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  151687. /** @hidden */
  151688. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151689. /** @hidden */
  151690. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151691. /** @hidden */
  151692. _attachCameras(cameras: Camera, unique: boolean): void;
  151693. /** @hidden */
  151694. _attachCameras(cameras: Camera[], unique: boolean): void;
  151695. /** @hidden */
  151696. _detachCameras(cameras: Camera): void;
  151697. /** @hidden */
  151698. _detachCameras(cameras: Nullable<Camera[]>): void;
  151699. /** @hidden */
  151700. _update(): void;
  151701. /** @hidden */
  151702. _reset(): void;
  151703. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  151704. /**
  151705. * Sets the required values to the prepass renderer.
  151706. * @param prePassRenderer defines the prepass renderer to setup.
  151707. * @returns true if the pre pass is needed.
  151708. */
  151709. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  151710. /**
  151711. * Disposes of the pipeline
  151712. */
  151713. dispose(): void;
  151714. }
  151715. }
  151716. declare module BABYLON {
  151717. /**
  151718. * PostProcessRenderPipelineManager class
  151719. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151720. */
  151721. export class PostProcessRenderPipelineManager {
  151722. private _renderPipelines;
  151723. /**
  151724. * Initializes a PostProcessRenderPipelineManager
  151725. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151726. */
  151727. constructor();
  151728. /**
  151729. * Gets the list of supported render pipelines
  151730. */
  151731. get supportedPipelines(): PostProcessRenderPipeline[];
  151732. /**
  151733. * Adds a pipeline to the manager
  151734. * @param renderPipeline The pipeline to add
  151735. */
  151736. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  151737. /**
  151738. * Attaches a camera to the pipeline
  151739. * @param renderPipelineName The name of the pipeline to attach to
  151740. * @param cameras the camera to attach
  151741. * @param unique if the camera can be attached multiple times to the pipeline
  151742. */
  151743. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  151744. /**
  151745. * Detaches a camera from the pipeline
  151746. * @param renderPipelineName The name of the pipeline to detach from
  151747. * @param cameras the camera to detach
  151748. */
  151749. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  151750. /**
  151751. * Enables an effect by name on a pipeline
  151752. * @param renderPipelineName the name of the pipeline to enable the effect in
  151753. * @param renderEffectName the name of the effect to enable
  151754. * @param cameras the cameras that the effect should be enabled on
  151755. */
  151756. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151757. /**
  151758. * Disables an effect by name on a pipeline
  151759. * @param renderPipelineName the name of the pipeline to disable the effect in
  151760. * @param renderEffectName the name of the effect to disable
  151761. * @param cameras the cameras that the effect should be disabled on
  151762. */
  151763. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151764. /**
  151765. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  151766. */
  151767. update(): void;
  151768. /** @hidden */
  151769. _rebuild(): void;
  151770. /**
  151771. * Disposes of the manager and pipelines
  151772. */
  151773. dispose(): void;
  151774. }
  151775. }
  151776. declare module BABYLON {
  151777. interface Scene {
  151778. /** @hidden (Backing field) */
  151779. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151780. /**
  151781. * Gets the postprocess render pipeline manager
  151782. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151783. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151784. */
  151785. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151786. }
  151787. /**
  151788. * Defines the Render Pipeline scene component responsible to rendering pipelines
  151789. */
  151790. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  151791. /**
  151792. * The component name helpfull to identify the component in the list of scene components.
  151793. */
  151794. readonly name: string;
  151795. /**
  151796. * The scene the component belongs to.
  151797. */
  151798. scene: Scene;
  151799. /**
  151800. * Creates a new instance of the component for the given scene
  151801. * @param scene Defines the scene to register the component in
  151802. */
  151803. constructor(scene: Scene);
  151804. /**
  151805. * Registers the component in a given scene
  151806. */
  151807. register(): void;
  151808. /**
  151809. * Rebuilds the elements related to this component in case of
  151810. * context lost for instance.
  151811. */
  151812. rebuild(): void;
  151813. /**
  151814. * Disposes the component and the associated ressources
  151815. */
  151816. dispose(): void;
  151817. private _gatherRenderTargets;
  151818. }
  151819. }
  151820. declare module BABYLON {
  151821. /**
  151822. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  151823. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151824. */
  151825. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151826. private _scene;
  151827. private _camerasToBeAttached;
  151828. /**
  151829. * ID of the sharpen post process,
  151830. */
  151831. private readonly SharpenPostProcessId;
  151832. /**
  151833. * @ignore
  151834. * ID of the image processing post process;
  151835. */
  151836. readonly ImageProcessingPostProcessId: string;
  151837. /**
  151838. * @ignore
  151839. * ID of the Fast Approximate Anti-Aliasing post process;
  151840. */
  151841. readonly FxaaPostProcessId: string;
  151842. /**
  151843. * ID of the chromatic aberration post process,
  151844. */
  151845. private readonly ChromaticAberrationPostProcessId;
  151846. /**
  151847. * ID of the grain post process
  151848. */
  151849. private readonly GrainPostProcessId;
  151850. /**
  151851. * Sharpen post process which will apply a sharpen convolution to enhance edges
  151852. */
  151853. sharpen: SharpenPostProcess;
  151854. private _sharpenEffect;
  151855. private bloom;
  151856. /**
  151857. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  151858. */
  151859. depthOfField: DepthOfFieldEffect;
  151860. /**
  151861. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151862. */
  151863. fxaa: FxaaPostProcess;
  151864. /**
  151865. * Image post processing pass used to perform operations such as tone mapping or color grading.
  151866. */
  151867. imageProcessing: ImageProcessingPostProcess;
  151868. /**
  151869. * Chromatic aberration post process which will shift rgb colors in the image
  151870. */
  151871. chromaticAberration: ChromaticAberrationPostProcess;
  151872. private _chromaticAberrationEffect;
  151873. /**
  151874. * Grain post process which add noise to the image
  151875. */
  151876. grain: GrainPostProcess;
  151877. private _grainEffect;
  151878. /**
  151879. * Glow post process which adds a glow to emissive areas of the image
  151880. */
  151881. private _glowLayer;
  151882. /**
  151883. * Animations which can be used to tweak settings over a period of time
  151884. */
  151885. animations: Animation[];
  151886. private _imageProcessingConfigurationObserver;
  151887. private _sharpenEnabled;
  151888. private _bloomEnabled;
  151889. private _depthOfFieldEnabled;
  151890. private _depthOfFieldBlurLevel;
  151891. private _fxaaEnabled;
  151892. private _imageProcessingEnabled;
  151893. private _defaultPipelineTextureType;
  151894. private _bloomScale;
  151895. private _chromaticAberrationEnabled;
  151896. private _grainEnabled;
  151897. private _buildAllowed;
  151898. /**
  151899. * Gets active scene
  151900. */
  151901. get scene(): Scene;
  151902. /**
  151903. * Enable or disable the sharpen process from the pipeline
  151904. */
  151905. set sharpenEnabled(enabled: boolean);
  151906. get sharpenEnabled(): boolean;
  151907. private _resizeObserver;
  151908. private _hardwareScaleLevel;
  151909. private _bloomKernel;
  151910. /**
  151911. * Specifies the size of the bloom blur kernel, relative to the final output size
  151912. */
  151913. get bloomKernel(): number;
  151914. set bloomKernel(value: number);
  151915. /**
  151916. * Specifies the weight of the bloom in the final rendering
  151917. */
  151918. private _bloomWeight;
  151919. /**
  151920. * Specifies the luma threshold for the area that will be blurred by the bloom
  151921. */
  151922. private _bloomThreshold;
  151923. private _hdr;
  151924. /**
  151925. * The strength of the bloom.
  151926. */
  151927. set bloomWeight(value: number);
  151928. get bloomWeight(): number;
  151929. /**
  151930. * The strength of the bloom.
  151931. */
  151932. set bloomThreshold(value: number);
  151933. get bloomThreshold(): number;
  151934. /**
  151935. * The scale of the bloom, lower value will provide better performance.
  151936. */
  151937. set bloomScale(value: number);
  151938. get bloomScale(): number;
  151939. /**
  151940. * Enable or disable the bloom from the pipeline
  151941. */
  151942. set bloomEnabled(enabled: boolean);
  151943. get bloomEnabled(): boolean;
  151944. private _rebuildBloom;
  151945. /**
  151946. * If the depth of field is enabled.
  151947. */
  151948. get depthOfFieldEnabled(): boolean;
  151949. set depthOfFieldEnabled(enabled: boolean);
  151950. /**
  151951. * Blur level of the depth of field effect. (Higher blur will effect performance)
  151952. */
  151953. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  151954. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  151955. /**
  151956. * If the anti aliasing is enabled.
  151957. */
  151958. set fxaaEnabled(enabled: boolean);
  151959. get fxaaEnabled(): boolean;
  151960. private _samples;
  151961. /**
  151962. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151963. */
  151964. set samples(sampleCount: number);
  151965. get samples(): number;
  151966. /**
  151967. * If image processing is enabled.
  151968. */
  151969. set imageProcessingEnabled(enabled: boolean);
  151970. get imageProcessingEnabled(): boolean;
  151971. /**
  151972. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  151973. */
  151974. set glowLayerEnabled(enabled: boolean);
  151975. get glowLayerEnabled(): boolean;
  151976. /**
  151977. * Gets the glow layer (or null if not defined)
  151978. */
  151979. get glowLayer(): Nullable<GlowLayer>;
  151980. /**
  151981. * Enable or disable the chromaticAberration process from the pipeline
  151982. */
  151983. set chromaticAberrationEnabled(enabled: boolean);
  151984. get chromaticAberrationEnabled(): boolean;
  151985. /**
  151986. * Enable or disable the grain process from the pipeline
  151987. */
  151988. set grainEnabled(enabled: boolean);
  151989. get grainEnabled(): boolean;
  151990. /**
  151991. * @constructor
  151992. * @param name - The rendering pipeline name (default: "")
  151993. * @param hdr - If high dynamic range textures should be used (default: true)
  151994. * @param scene - The scene linked to this pipeline (default: the last created scene)
  151995. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  151996. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  151997. */
  151998. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  151999. /**
  152000. * Get the class name
  152001. * @returns "DefaultRenderingPipeline"
  152002. */
  152003. getClassName(): string;
  152004. /**
  152005. * Force the compilation of the entire pipeline.
  152006. */
  152007. prepare(): void;
  152008. private _hasCleared;
  152009. private _prevPostProcess;
  152010. private _prevPrevPostProcess;
  152011. private _setAutoClearAndTextureSharing;
  152012. private _depthOfFieldSceneObserver;
  152013. private _buildPipeline;
  152014. private _disposePostProcesses;
  152015. /**
  152016. * Adds a camera to the pipeline
  152017. * @param camera the camera to be added
  152018. */
  152019. addCamera(camera: Camera): void;
  152020. /**
  152021. * Removes a camera from the pipeline
  152022. * @param camera the camera to remove
  152023. */
  152024. removeCamera(camera: Camera): void;
  152025. /**
  152026. * Dispose of the pipeline and stop all post processes
  152027. */
  152028. dispose(): void;
  152029. /**
  152030. * Serialize the rendering pipeline (Used when exporting)
  152031. * @returns the serialized object
  152032. */
  152033. serialize(): any;
  152034. /**
  152035. * Parse the serialized pipeline
  152036. * @param source Source pipeline.
  152037. * @param scene The scene to load the pipeline to.
  152038. * @param rootUrl The URL of the serialized pipeline.
  152039. * @returns An instantiated pipeline from the serialized object.
  152040. */
  152041. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  152042. }
  152043. }
  152044. declare module BABYLON {
  152045. /** @hidden */
  152046. export var lensHighlightsPixelShader: {
  152047. name: string;
  152048. shader: string;
  152049. };
  152050. }
  152051. declare module BABYLON {
  152052. /** @hidden */
  152053. export var depthOfFieldPixelShader: {
  152054. name: string;
  152055. shader: string;
  152056. };
  152057. }
  152058. declare module BABYLON {
  152059. /**
  152060. * BABYLON.JS Chromatic Aberration GLSL Shader
  152061. * Author: Olivier Guyot
  152062. * Separates very slightly R, G and B colors on the edges of the screen
  152063. * Inspired by Francois Tarlier & Martins Upitis
  152064. */
  152065. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  152066. /**
  152067. * @ignore
  152068. * The chromatic aberration PostProcess id in the pipeline
  152069. */
  152070. LensChromaticAberrationEffect: string;
  152071. /**
  152072. * @ignore
  152073. * The highlights enhancing PostProcess id in the pipeline
  152074. */
  152075. HighlightsEnhancingEffect: string;
  152076. /**
  152077. * @ignore
  152078. * The depth-of-field PostProcess id in the pipeline
  152079. */
  152080. LensDepthOfFieldEffect: string;
  152081. private _scene;
  152082. private _depthTexture;
  152083. private _grainTexture;
  152084. private _chromaticAberrationPostProcess;
  152085. private _highlightsPostProcess;
  152086. private _depthOfFieldPostProcess;
  152087. private _edgeBlur;
  152088. private _grainAmount;
  152089. private _chromaticAberration;
  152090. private _distortion;
  152091. private _highlightsGain;
  152092. private _highlightsThreshold;
  152093. private _dofDistance;
  152094. private _dofAperture;
  152095. private _dofDarken;
  152096. private _dofPentagon;
  152097. private _blurNoise;
  152098. /**
  152099. * @constructor
  152100. *
  152101. * Effect parameters are as follow:
  152102. * {
  152103. * chromatic_aberration: number; // from 0 to x (1 for realism)
  152104. * edge_blur: number; // from 0 to x (1 for realism)
  152105. * distortion: number; // from 0 to x (1 for realism)
  152106. * grain_amount: number; // from 0 to 1
  152107. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  152108. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  152109. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  152110. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  152111. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  152112. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  152113. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  152114. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  152115. * }
  152116. * Note: if an effect parameter is unset, effect is disabled
  152117. *
  152118. * @param name The rendering pipeline name
  152119. * @param parameters - An object containing all parameters (see above)
  152120. * @param scene The scene linked to this pipeline
  152121. * @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)
  152122. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152123. */
  152124. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  152125. /**
  152126. * Get the class name
  152127. * @returns "LensRenderingPipeline"
  152128. */
  152129. getClassName(): string;
  152130. /**
  152131. * Gets associated scene
  152132. */
  152133. get scene(): Scene;
  152134. /**
  152135. * Gets or sets the edge blur
  152136. */
  152137. get edgeBlur(): number;
  152138. set edgeBlur(value: number);
  152139. /**
  152140. * Gets or sets the grain amount
  152141. */
  152142. get grainAmount(): number;
  152143. set grainAmount(value: number);
  152144. /**
  152145. * Gets or sets the chromatic aberration amount
  152146. */
  152147. get chromaticAberration(): number;
  152148. set chromaticAberration(value: number);
  152149. /**
  152150. * Gets or sets the depth of field aperture
  152151. */
  152152. get dofAperture(): number;
  152153. set dofAperture(value: number);
  152154. /**
  152155. * Gets or sets the edge distortion
  152156. */
  152157. get edgeDistortion(): number;
  152158. set edgeDistortion(value: number);
  152159. /**
  152160. * Gets or sets the depth of field distortion
  152161. */
  152162. get dofDistortion(): number;
  152163. set dofDistortion(value: number);
  152164. /**
  152165. * Gets or sets the darken out of focus amount
  152166. */
  152167. get darkenOutOfFocus(): number;
  152168. set darkenOutOfFocus(value: number);
  152169. /**
  152170. * Gets or sets a boolean indicating if blur noise is enabled
  152171. */
  152172. get blurNoise(): boolean;
  152173. set blurNoise(value: boolean);
  152174. /**
  152175. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  152176. */
  152177. get pentagonBokeh(): boolean;
  152178. set pentagonBokeh(value: boolean);
  152179. /**
  152180. * Gets or sets the highlight grain amount
  152181. */
  152182. get highlightsGain(): number;
  152183. set highlightsGain(value: number);
  152184. /**
  152185. * Gets or sets the highlight threshold
  152186. */
  152187. get highlightsThreshold(): number;
  152188. set highlightsThreshold(value: number);
  152189. /**
  152190. * Sets the amount of blur at the edges
  152191. * @param amount blur amount
  152192. */
  152193. setEdgeBlur(amount: number): void;
  152194. /**
  152195. * Sets edge blur to 0
  152196. */
  152197. disableEdgeBlur(): void;
  152198. /**
  152199. * Sets the amout of grain
  152200. * @param amount Amount of grain
  152201. */
  152202. setGrainAmount(amount: number): void;
  152203. /**
  152204. * Set grain amount to 0
  152205. */
  152206. disableGrain(): void;
  152207. /**
  152208. * Sets the chromatic aberration amount
  152209. * @param amount amount of chromatic aberration
  152210. */
  152211. setChromaticAberration(amount: number): void;
  152212. /**
  152213. * Sets chromatic aberration amount to 0
  152214. */
  152215. disableChromaticAberration(): void;
  152216. /**
  152217. * Sets the EdgeDistortion amount
  152218. * @param amount amount of EdgeDistortion
  152219. */
  152220. setEdgeDistortion(amount: number): void;
  152221. /**
  152222. * Sets edge distortion to 0
  152223. */
  152224. disableEdgeDistortion(): void;
  152225. /**
  152226. * Sets the FocusDistance amount
  152227. * @param amount amount of FocusDistance
  152228. */
  152229. setFocusDistance(amount: number): void;
  152230. /**
  152231. * Disables depth of field
  152232. */
  152233. disableDepthOfField(): void;
  152234. /**
  152235. * Sets the Aperture amount
  152236. * @param amount amount of Aperture
  152237. */
  152238. setAperture(amount: number): void;
  152239. /**
  152240. * Sets the DarkenOutOfFocus amount
  152241. * @param amount amount of DarkenOutOfFocus
  152242. */
  152243. setDarkenOutOfFocus(amount: number): void;
  152244. private _pentagonBokehIsEnabled;
  152245. /**
  152246. * Creates a pentagon bokeh effect
  152247. */
  152248. enablePentagonBokeh(): void;
  152249. /**
  152250. * Disables the pentagon bokeh effect
  152251. */
  152252. disablePentagonBokeh(): void;
  152253. /**
  152254. * Enables noise blur
  152255. */
  152256. enableNoiseBlur(): void;
  152257. /**
  152258. * Disables noise blur
  152259. */
  152260. disableNoiseBlur(): void;
  152261. /**
  152262. * Sets the HighlightsGain amount
  152263. * @param amount amount of HighlightsGain
  152264. */
  152265. setHighlightsGain(amount: number): void;
  152266. /**
  152267. * Sets the HighlightsThreshold amount
  152268. * @param amount amount of HighlightsThreshold
  152269. */
  152270. setHighlightsThreshold(amount: number): void;
  152271. /**
  152272. * Disables highlights
  152273. */
  152274. disableHighlights(): void;
  152275. /**
  152276. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  152277. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  152278. */
  152279. dispose(disableDepthRender?: boolean): void;
  152280. private _createChromaticAberrationPostProcess;
  152281. private _createHighlightsPostProcess;
  152282. private _createDepthOfFieldPostProcess;
  152283. private _createGrainTexture;
  152284. }
  152285. }
  152286. declare module BABYLON {
  152287. /**
  152288. * Contains all parameters needed for the prepass to perform
  152289. * screen space subsurface scattering
  152290. */
  152291. export class SSAO2Configuration implements PrePassEffectConfiguration {
  152292. /**
  152293. * Is subsurface enabled
  152294. */
  152295. enabled: boolean;
  152296. /**
  152297. * Name of the configuration
  152298. */
  152299. name: string;
  152300. /**
  152301. * Textures that should be present in the MRT for this effect to work
  152302. */
  152303. readonly texturesRequired: number[];
  152304. }
  152305. }
  152306. declare module BABYLON {
  152307. /** @hidden */
  152308. export var ssao2PixelShader: {
  152309. name: string;
  152310. shader: string;
  152311. };
  152312. }
  152313. declare module BABYLON {
  152314. /** @hidden */
  152315. export var ssaoCombinePixelShader: {
  152316. name: string;
  152317. shader: string;
  152318. };
  152319. }
  152320. declare module BABYLON {
  152321. /**
  152322. * Render pipeline to produce ssao effect
  152323. */
  152324. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  152325. /**
  152326. * @ignore
  152327. * The PassPostProcess id in the pipeline that contains the original scene color
  152328. */
  152329. SSAOOriginalSceneColorEffect: string;
  152330. /**
  152331. * @ignore
  152332. * The SSAO PostProcess id in the pipeline
  152333. */
  152334. SSAORenderEffect: string;
  152335. /**
  152336. * @ignore
  152337. * The horizontal blur PostProcess id in the pipeline
  152338. */
  152339. SSAOBlurHRenderEffect: string;
  152340. /**
  152341. * @ignore
  152342. * The vertical blur PostProcess id in the pipeline
  152343. */
  152344. SSAOBlurVRenderEffect: string;
  152345. /**
  152346. * @ignore
  152347. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  152348. */
  152349. SSAOCombineRenderEffect: string;
  152350. /**
  152351. * The output strength of the SSAO post-process. Default value is 1.0.
  152352. */
  152353. totalStrength: number;
  152354. /**
  152355. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  152356. */
  152357. maxZ: number;
  152358. /**
  152359. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  152360. */
  152361. minZAspect: number;
  152362. private _samples;
  152363. /**
  152364. * Number of samples used for the SSAO calculations. Default value is 8
  152365. */
  152366. set samples(n: number);
  152367. get samples(): number;
  152368. private _textureSamples;
  152369. /**
  152370. * Number of samples to use for antialiasing
  152371. */
  152372. set textureSamples(n: number);
  152373. get textureSamples(): number;
  152374. /**
  152375. * Force rendering the geometry through geometry buffer
  152376. */
  152377. private _forceGeometryBuffer;
  152378. /**
  152379. * Ratio object used for SSAO ratio and blur ratio
  152380. */
  152381. private _ratio;
  152382. /**
  152383. * Dynamically generated sphere sampler.
  152384. */
  152385. private _sampleSphere;
  152386. /**
  152387. * Blur filter offsets
  152388. */
  152389. private _samplerOffsets;
  152390. private _expensiveBlur;
  152391. /**
  152392. * If bilateral blur should be used
  152393. */
  152394. set expensiveBlur(b: boolean);
  152395. get expensiveBlur(): boolean;
  152396. /**
  152397. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  152398. */
  152399. radius: number;
  152400. /**
  152401. * The base color of the SSAO post-process
  152402. * The final result is "base + ssao" between [0, 1]
  152403. */
  152404. base: number;
  152405. /**
  152406. * Support test.
  152407. */
  152408. static get IsSupported(): boolean;
  152409. private _scene;
  152410. private _randomTexture;
  152411. private _originalColorPostProcess;
  152412. private _ssaoPostProcess;
  152413. private _blurHPostProcess;
  152414. private _blurVPostProcess;
  152415. private _ssaoCombinePostProcess;
  152416. private _prePassRenderer;
  152417. /**
  152418. * Gets active scene
  152419. */
  152420. get scene(): Scene;
  152421. /**
  152422. * @constructor
  152423. * @param name The rendering pipeline name
  152424. * @param scene The scene linked to this pipeline
  152425. * @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 }
  152426. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152427. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  152428. */
  152429. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  152430. /**
  152431. * Get the class name
  152432. * @returns "SSAO2RenderingPipeline"
  152433. */
  152434. getClassName(): string;
  152435. /**
  152436. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  152437. */
  152438. dispose(disableGeometryBufferRenderer?: boolean): void;
  152439. private _createBlurPostProcess;
  152440. /** @hidden */
  152441. _rebuild(): void;
  152442. private _bits;
  152443. private _radicalInverse_VdC;
  152444. private _hammersley;
  152445. private _hemisphereSample_uniform;
  152446. private _generateHemisphere;
  152447. private _getDefinesForSSAO;
  152448. private _createSSAOPostProcess;
  152449. private _createSSAOCombinePostProcess;
  152450. private _createRandomTexture;
  152451. /**
  152452. * Serialize the rendering pipeline (Used when exporting)
  152453. * @returns the serialized object
  152454. */
  152455. serialize(): any;
  152456. /**
  152457. * Parse the serialized pipeline
  152458. * @param source Source pipeline.
  152459. * @param scene The scene to load the pipeline to.
  152460. * @param rootUrl The URL of the serialized pipeline.
  152461. * @returns An instantiated pipeline from the serialized object.
  152462. */
  152463. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  152464. }
  152465. }
  152466. declare module BABYLON {
  152467. /** @hidden */
  152468. export var ssaoPixelShader: {
  152469. name: string;
  152470. shader: string;
  152471. };
  152472. }
  152473. declare module BABYLON {
  152474. /**
  152475. * Render pipeline to produce ssao effect
  152476. */
  152477. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  152478. /**
  152479. * @ignore
  152480. * The PassPostProcess id in the pipeline that contains the original scene color
  152481. */
  152482. SSAOOriginalSceneColorEffect: string;
  152483. /**
  152484. * @ignore
  152485. * The SSAO PostProcess id in the pipeline
  152486. */
  152487. SSAORenderEffect: string;
  152488. /**
  152489. * @ignore
  152490. * The horizontal blur PostProcess id in the pipeline
  152491. */
  152492. SSAOBlurHRenderEffect: string;
  152493. /**
  152494. * @ignore
  152495. * The vertical blur PostProcess id in the pipeline
  152496. */
  152497. SSAOBlurVRenderEffect: string;
  152498. /**
  152499. * @ignore
  152500. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  152501. */
  152502. SSAOCombineRenderEffect: string;
  152503. /**
  152504. * The output strength of the SSAO post-process. Default value is 1.0.
  152505. */
  152506. totalStrength: number;
  152507. /**
  152508. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  152509. */
  152510. radius: number;
  152511. /**
  152512. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  152513. * Must not be equal to fallOff and superior to fallOff.
  152514. * Default value is 0.0075
  152515. */
  152516. area: number;
  152517. /**
  152518. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  152519. * Must not be equal to area and inferior to area.
  152520. * Default value is 0.000001
  152521. */
  152522. fallOff: number;
  152523. /**
  152524. * The base color of the SSAO post-process
  152525. * The final result is "base + ssao" between [0, 1]
  152526. */
  152527. base: number;
  152528. private _scene;
  152529. private _depthTexture;
  152530. private _randomTexture;
  152531. private _originalColorPostProcess;
  152532. private _ssaoPostProcess;
  152533. private _blurHPostProcess;
  152534. private _blurVPostProcess;
  152535. private _ssaoCombinePostProcess;
  152536. private _firstUpdate;
  152537. /**
  152538. * Gets active scene
  152539. */
  152540. get scene(): Scene;
  152541. /**
  152542. * @constructor
  152543. * @param name - The rendering pipeline name
  152544. * @param scene - The scene linked to this pipeline
  152545. * @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 }
  152546. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  152547. */
  152548. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  152549. /**
  152550. * Get the class name
  152551. * @returns "SSAORenderingPipeline"
  152552. */
  152553. getClassName(): string;
  152554. /**
  152555. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  152556. */
  152557. dispose(disableDepthRender?: boolean): void;
  152558. private _createBlurPostProcess;
  152559. /** @hidden */
  152560. _rebuild(): void;
  152561. private _createSSAOPostProcess;
  152562. private _createSSAOCombinePostProcess;
  152563. private _createRandomTexture;
  152564. }
  152565. }
  152566. declare module BABYLON {
  152567. /**
  152568. * Contains all parameters needed for the prepass to perform
  152569. * screen space reflections
  152570. */
  152571. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  152572. /**
  152573. * Is ssr enabled
  152574. */
  152575. enabled: boolean;
  152576. /**
  152577. * Name of the configuration
  152578. */
  152579. name: string;
  152580. /**
  152581. * Textures that should be present in the MRT for this effect to work
  152582. */
  152583. readonly texturesRequired: number[];
  152584. }
  152585. }
  152586. declare module BABYLON {
  152587. /** @hidden */
  152588. export var screenSpaceReflectionPixelShader: {
  152589. name: string;
  152590. shader: string;
  152591. };
  152592. }
  152593. declare module BABYLON {
  152594. /**
  152595. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  152596. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  152597. */
  152598. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  152599. /**
  152600. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  152601. */
  152602. threshold: number;
  152603. /**
  152604. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  152605. */
  152606. strength: number;
  152607. /**
  152608. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  152609. */
  152610. reflectionSpecularFalloffExponent: number;
  152611. /**
  152612. * 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]
  152613. */
  152614. step: number;
  152615. /**
  152616. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  152617. */
  152618. roughnessFactor: number;
  152619. private _forceGeometryBuffer;
  152620. private _geometryBufferRenderer;
  152621. private _prePassRenderer;
  152622. private _enableSmoothReflections;
  152623. private _reflectionSamples;
  152624. private _smoothSteps;
  152625. /**
  152626. * Gets a string identifying the name of the class
  152627. * @returns "ScreenSpaceReflectionPostProcess" string
  152628. */
  152629. getClassName(): string;
  152630. /**
  152631. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  152632. * @param name The name of the effect.
  152633. * @param scene The scene containing the objects to calculate reflections.
  152634. * @param options The required width/height ratio to downsize to before computing the render pass.
  152635. * @param camera The camera to apply the render pass to.
  152636. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152637. * @param engine The engine which the post process will be applied. (default: current engine)
  152638. * @param reusable If the post process can be reused on the same frame. (default: false)
  152639. * @param textureType Type of textures used when performing the post process. (default: 0)
  152640. * @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)
  152641. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  152642. */
  152643. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  152644. /**
  152645. * Gets wether or not smoothing reflections is enabled.
  152646. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  152647. */
  152648. get enableSmoothReflections(): boolean;
  152649. /**
  152650. * Sets wether or not smoothing reflections is enabled.
  152651. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  152652. */
  152653. set enableSmoothReflections(enabled: boolean);
  152654. /**
  152655. * Gets the number of samples taken while computing reflections. More samples count is high,
  152656. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  152657. */
  152658. get reflectionSamples(): number;
  152659. /**
  152660. * Sets the number of samples taken while computing reflections. More samples count is high,
  152661. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  152662. */
  152663. set reflectionSamples(samples: number);
  152664. /**
  152665. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  152666. * more the post-process will require GPU power and can generate a drop in FPS.
  152667. * Default value (5.0) work pretty well in all cases but can be adjusted.
  152668. */
  152669. get smoothSteps(): number;
  152670. set smoothSteps(steps: number);
  152671. private _updateEffectDefines;
  152672. /** @hidden */
  152673. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  152674. }
  152675. }
  152676. declare module BABYLON {
  152677. /** @hidden */
  152678. export var standardPixelShader: {
  152679. name: string;
  152680. shader: string;
  152681. };
  152682. }
  152683. declare module BABYLON {
  152684. /**
  152685. * Standard rendering pipeline
  152686. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152687. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  152688. */
  152689. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  152690. /**
  152691. * Public members
  152692. */
  152693. /**
  152694. * Post-process which contains the original scene color before the pipeline applies all the effects
  152695. */
  152696. originalPostProcess: Nullable<PostProcess>;
  152697. /**
  152698. * Post-process used to down scale an image x4
  152699. */
  152700. downSampleX4PostProcess: Nullable<PostProcess>;
  152701. /**
  152702. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  152703. */
  152704. brightPassPostProcess: Nullable<PostProcess>;
  152705. /**
  152706. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  152707. */
  152708. blurHPostProcesses: PostProcess[];
  152709. /**
  152710. * Post-process array storing all the vertical blur post-processes used by the pipeline
  152711. */
  152712. blurVPostProcesses: PostProcess[];
  152713. /**
  152714. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  152715. */
  152716. textureAdderPostProcess: Nullable<PostProcess>;
  152717. /**
  152718. * Post-process used to create volumetric lighting effect
  152719. */
  152720. volumetricLightPostProcess: Nullable<PostProcess>;
  152721. /**
  152722. * Post-process used to smooth the previous volumetric light post-process on the X axis
  152723. */
  152724. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  152725. /**
  152726. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  152727. */
  152728. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  152729. /**
  152730. * Post-process used to merge the volumetric light effect and the real scene color
  152731. */
  152732. volumetricLightMergePostProces: Nullable<PostProcess>;
  152733. /**
  152734. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  152735. */
  152736. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  152737. /**
  152738. * Base post-process used to calculate the average luminance of the final image for HDR
  152739. */
  152740. luminancePostProcess: Nullable<PostProcess>;
  152741. /**
  152742. * Post-processes used to create down sample post-processes in order to get
  152743. * the average luminance of the final image for HDR
  152744. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  152745. */
  152746. luminanceDownSamplePostProcesses: PostProcess[];
  152747. /**
  152748. * Post-process used to create a HDR effect (light adaptation)
  152749. */
  152750. hdrPostProcess: Nullable<PostProcess>;
  152751. /**
  152752. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  152753. */
  152754. textureAdderFinalPostProcess: Nullable<PostProcess>;
  152755. /**
  152756. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  152757. */
  152758. lensFlareFinalPostProcess: Nullable<PostProcess>;
  152759. /**
  152760. * Post-process used to merge the final HDR post-process and the real scene color
  152761. */
  152762. hdrFinalPostProcess: Nullable<PostProcess>;
  152763. /**
  152764. * Post-process used to create a lens flare effect
  152765. */
  152766. lensFlarePostProcess: Nullable<PostProcess>;
  152767. /**
  152768. * Post-process that merges the result of the lens flare post-process and the real scene color
  152769. */
  152770. lensFlareComposePostProcess: Nullable<PostProcess>;
  152771. /**
  152772. * Post-process used to create a motion blur effect
  152773. */
  152774. motionBlurPostProcess: Nullable<PostProcess>;
  152775. /**
  152776. * Post-process used to create a depth of field effect
  152777. */
  152778. depthOfFieldPostProcess: Nullable<PostProcess>;
  152779. /**
  152780. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  152781. */
  152782. fxaaPostProcess: Nullable<FxaaPostProcess>;
  152783. /**
  152784. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  152785. */
  152786. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  152787. /**
  152788. * Represents the brightness threshold in order to configure the illuminated surfaces
  152789. */
  152790. brightThreshold: number;
  152791. /**
  152792. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  152793. */
  152794. blurWidth: number;
  152795. /**
  152796. * Sets if the blur for highlighted surfaces must be only horizontal
  152797. */
  152798. horizontalBlur: boolean;
  152799. /**
  152800. * Gets the overall exposure used by the pipeline
  152801. */
  152802. get exposure(): number;
  152803. /**
  152804. * Sets the overall exposure used by the pipeline
  152805. */
  152806. set exposure(value: number);
  152807. /**
  152808. * Texture used typically to simulate "dirty" on camera lens
  152809. */
  152810. lensTexture: Nullable<Texture>;
  152811. /**
  152812. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  152813. */
  152814. volumetricLightCoefficient: number;
  152815. /**
  152816. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  152817. */
  152818. volumetricLightPower: number;
  152819. /**
  152820. * Used the set the blur intensity to smooth the volumetric lights
  152821. */
  152822. volumetricLightBlurScale: number;
  152823. /**
  152824. * Light (spot or directional) used to generate the volumetric lights rays
  152825. * The source light must have a shadow generate so the pipeline can get its
  152826. * depth map
  152827. */
  152828. sourceLight: Nullable<SpotLight | DirectionalLight>;
  152829. /**
  152830. * For eye adaptation, represents the minimum luminance the eye can see
  152831. */
  152832. hdrMinimumLuminance: number;
  152833. /**
  152834. * For eye adaptation, represents the decrease luminance speed
  152835. */
  152836. hdrDecreaseRate: number;
  152837. /**
  152838. * For eye adaptation, represents the increase luminance speed
  152839. */
  152840. hdrIncreaseRate: number;
  152841. /**
  152842. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152843. */
  152844. get hdrAutoExposure(): boolean;
  152845. /**
  152846. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152847. */
  152848. set hdrAutoExposure(value: boolean);
  152849. /**
  152850. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  152851. */
  152852. lensColorTexture: Nullable<Texture>;
  152853. /**
  152854. * The overall strengh for the lens flare effect
  152855. */
  152856. lensFlareStrength: number;
  152857. /**
  152858. * Dispersion coefficient for lens flare ghosts
  152859. */
  152860. lensFlareGhostDispersal: number;
  152861. /**
  152862. * Main lens flare halo width
  152863. */
  152864. lensFlareHaloWidth: number;
  152865. /**
  152866. * Based on the lens distortion effect, defines how much the lens flare result
  152867. * is distorted
  152868. */
  152869. lensFlareDistortionStrength: number;
  152870. /**
  152871. * Configures the blur intensity used for for lens flare (halo)
  152872. */
  152873. lensFlareBlurWidth: number;
  152874. /**
  152875. * Lens star texture must be used to simulate rays on the flares and is available
  152876. * in the documentation
  152877. */
  152878. lensStarTexture: Nullable<Texture>;
  152879. /**
  152880. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  152881. * flare effect by taking account of the dirt texture
  152882. */
  152883. lensFlareDirtTexture: Nullable<Texture>;
  152884. /**
  152885. * Represents the focal length for the depth of field effect
  152886. */
  152887. depthOfFieldDistance: number;
  152888. /**
  152889. * Represents the blur intensity for the blurred part of the depth of field effect
  152890. */
  152891. depthOfFieldBlurWidth: number;
  152892. /**
  152893. * Gets how much the image is blurred by the movement while using the motion blur post-process
  152894. */
  152895. get motionStrength(): number;
  152896. /**
  152897. * Sets how much the image is blurred by the movement while using the motion blur post-process
  152898. */
  152899. set motionStrength(strength: number);
  152900. /**
  152901. * Gets wether or not the motion blur post-process is object based or screen based.
  152902. */
  152903. get objectBasedMotionBlur(): boolean;
  152904. /**
  152905. * Sets wether or not the motion blur post-process should be object based or screen based
  152906. */
  152907. set objectBasedMotionBlur(value: boolean);
  152908. /**
  152909. * List of animations for the pipeline (IAnimatable implementation)
  152910. */
  152911. animations: Animation[];
  152912. /**
  152913. * Private members
  152914. */
  152915. private _scene;
  152916. private _currentDepthOfFieldSource;
  152917. private _basePostProcess;
  152918. private _fixedExposure;
  152919. private _currentExposure;
  152920. private _hdrAutoExposure;
  152921. private _hdrCurrentLuminance;
  152922. private _motionStrength;
  152923. private _isObjectBasedMotionBlur;
  152924. private _floatTextureType;
  152925. private _camerasToBeAttached;
  152926. private _ratio;
  152927. private _bloomEnabled;
  152928. private _depthOfFieldEnabled;
  152929. private _vlsEnabled;
  152930. private _lensFlareEnabled;
  152931. private _hdrEnabled;
  152932. private _motionBlurEnabled;
  152933. private _fxaaEnabled;
  152934. private _screenSpaceReflectionsEnabled;
  152935. private _motionBlurSamples;
  152936. private _volumetricLightStepsCount;
  152937. private _samples;
  152938. /**
  152939. * @ignore
  152940. * Specifies if the bloom pipeline is enabled
  152941. */
  152942. get BloomEnabled(): boolean;
  152943. set BloomEnabled(enabled: boolean);
  152944. /**
  152945. * @ignore
  152946. * Specifies if the depth of field pipeline is enabed
  152947. */
  152948. get DepthOfFieldEnabled(): boolean;
  152949. set DepthOfFieldEnabled(enabled: boolean);
  152950. /**
  152951. * @ignore
  152952. * Specifies if the lens flare pipeline is enabed
  152953. */
  152954. get LensFlareEnabled(): boolean;
  152955. set LensFlareEnabled(enabled: boolean);
  152956. /**
  152957. * @ignore
  152958. * Specifies if the HDR pipeline is enabled
  152959. */
  152960. get HDREnabled(): boolean;
  152961. set HDREnabled(enabled: boolean);
  152962. /**
  152963. * @ignore
  152964. * Specifies if the volumetric lights scattering effect is enabled
  152965. */
  152966. get VLSEnabled(): boolean;
  152967. set VLSEnabled(enabled: boolean);
  152968. /**
  152969. * @ignore
  152970. * Specifies if the motion blur effect is enabled
  152971. */
  152972. get MotionBlurEnabled(): boolean;
  152973. set MotionBlurEnabled(enabled: boolean);
  152974. /**
  152975. * Specifies if anti-aliasing is enabled
  152976. */
  152977. get fxaaEnabled(): boolean;
  152978. set fxaaEnabled(enabled: boolean);
  152979. /**
  152980. * Specifies if screen space reflections are enabled.
  152981. */
  152982. get screenSpaceReflectionsEnabled(): boolean;
  152983. set screenSpaceReflectionsEnabled(enabled: boolean);
  152984. /**
  152985. * Specifies the number of steps used to calculate the volumetric lights
  152986. * Typically in interval [50, 200]
  152987. */
  152988. get volumetricLightStepsCount(): number;
  152989. set volumetricLightStepsCount(count: number);
  152990. /**
  152991. * Specifies the number of samples used for the motion blur effect
  152992. * Typically in interval [16, 64]
  152993. */
  152994. get motionBlurSamples(): number;
  152995. set motionBlurSamples(samples: number);
  152996. /**
  152997. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  152998. */
  152999. get samples(): number;
  153000. set samples(sampleCount: number);
  153001. /**
  153002. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  153003. * @constructor
  153004. * @param name The rendering pipeline name
  153005. * @param scene The scene linked to this pipeline
  153006. * @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)
  153007. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  153008. * @param cameras The array of cameras that the rendering pipeline will be attached to
  153009. */
  153010. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  153011. private _buildPipeline;
  153012. private _createDownSampleX4PostProcess;
  153013. private _createBrightPassPostProcess;
  153014. private _createBlurPostProcesses;
  153015. private _createTextureAdderPostProcess;
  153016. private _createVolumetricLightPostProcess;
  153017. private _createLuminancePostProcesses;
  153018. private _createHdrPostProcess;
  153019. private _createLensFlarePostProcess;
  153020. private _createDepthOfFieldPostProcess;
  153021. private _createMotionBlurPostProcess;
  153022. private _getDepthTexture;
  153023. private _disposePostProcesses;
  153024. /**
  153025. * Dispose of the pipeline and stop all post processes
  153026. */
  153027. dispose(): void;
  153028. /**
  153029. * Serialize the rendering pipeline (Used when exporting)
  153030. * @returns the serialized object
  153031. */
  153032. serialize(): any;
  153033. /**
  153034. * Parse the serialized pipeline
  153035. * @param source Source pipeline.
  153036. * @param scene The scene to load the pipeline to.
  153037. * @param rootUrl The URL of the serialized pipeline.
  153038. * @returns An instantiated pipeline from the serialized object.
  153039. */
  153040. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  153041. /**
  153042. * Luminance steps
  153043. */
  153044. static LuminanceSteps: number;
  153045. }
  153046. }
  153047. declare module BABYLON {
  153048. /** @hidden */
  153049. export var stereoscopicInterlacePixelShader: {
  153050. name: string;
  153051. shader: string;
  153052. };
  153053. }
  153054. declare module BABYLON {
  153055. /**
  153056. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  153057. */
  153058. export class StereoscopicInterlacePostProcessI extends PostProcess {
  153059. private _stepSize;
  153060. private _passedProcess;
  153061. /**
  153062. * Gets a string identifying the name of the class
  153063. * @returns "StereoscopicInterlacePostProcessI" string
  153064. */
  153065. getClassName(): string;
  153066. /**
  153067. * Initializes a StereoscopicInterlacePostProcessI
  153068. * @param name The name of the effect.
  153069. * @param rigCameras The rig cameras to be appled to the post process
  153070. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  153071. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  153072. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153073. * @param engine The engine which the post process will be applied. (default: current engine)
  153074. * @param reusable If the post process can be reused on the same frame. (default: false)
  153075. */
  153076. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  153077. }
  153078. /**
  153079. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  153080. */
  153081. export class StereoscopicInterlacePostProcess extends PostProcess {
  153082. private _stepSize;
  153083. private _passedProcess;
  153084. /**
  153085. * Gets a string identifying the name of the class
  153086. * @returns "StereoscopicInterlacePostProcess" string
  153087. */
  153088. getClassName(): string;
  153089. /**
  153090. * Initializes a StereoscopicInterlacePostProcess
  153091. * @param name The name of the effect.
  153092. * @param rigCameras The rig cameras to be appled to the post process
  153093. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  153094. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153095. * @param engine The engine which the post process will be applied. (default: current engine)
  153096. * @param reusable If the post process can be reused on the same frame. (default: false)
  153097. */
  153098. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  153099. }
  153100. }
  153101. declare module BABYLON {
  153102. /** @hidden */
  153103. export var tonemapPixelShader: {
  153104. name: string;
  153105. shader: string;
  153106. };
  153107. }
  153108. declare module BABYLON {
  153109. /** Defines operator used for tonemapping */
  153110. export enum TonemappingOperator {
  153111. /** Hable */
  153112. Hable = 0,
  153113. /** Reinhard */
  153114. Reinhard = 1,
  153115. /** HejiDawson */
  153116. HejiDawson = 2,
  153117. /** Photographic */
  153118. Photographic = 3
  153119. }
  153120. /**
  153121. * Defines a post process to apply tone mapping
  153122. */
  153123. export class TonemapPostProcess extends PostProcess {
  153124. private _operator;
  153125. /** Defines the required exposure adjustement */
  153126. exposureAdjustment: number;
  153127. /**
  153128. * Gets a string identifying the name of the class
  153129. * @returns "TonemapPostProcess" string
  153130. */
  153131. getClassName(): string;
  153132. /**
  153133. * Creates a new TonemapPostProcess
  153134. * @param name defines the name of the postprocess
  153135. * @param _operator defines the operator to use
  153136. * @param exposureAdjustment defines the required exposure adjustement
  153137. * @param camera defines the camera to use (can be null)
  153138. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  153139. * @param engine defines the hosting engine (can be ignore if camera is set)
  153140. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  153141. */
  153142. constructor(name: string, _operator: TonemappingOperator,
  153143. /** Defines the required exposure adjustement */
  153144. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  153145. }
  153146. }
  153147. declare module BABYLON {
  153148. /** @hidden */
  153149. export var volumetricLightScatteringPixelShader: {
  153150. name: string;
  153151. shader: string;
  153152. };
  153153. }
  153154. declare module BABYLON {
  153155. /** @hidden */
  153156. export var volumetricLightScatteringPassVertexShader: {
  153157. name: string;
  153158. shader: string;
  153159. };
  153160. }
  153161. declare module BABYLON {
  153162. /** @hidden */
  153163. export var volumetricLightScatteringPassPixelShader: {
  153164. name: string;
  153165. shader: string;
  153166. };
  153167. }
  153168. declare module BABYLON {
  153169. /**
  153170. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  153171. */
  153172. export class VolumetricLightScatteringPostProcess extends PostProcess {
  153173. private _volumetricLightScatteringPass;
  153174. private _volumetricLightScatteringRTT;
  153175. private _viewPort;
  153176. private _screenCoordinates;
  153177. private _cachedDefines;
  153178. /**
  153179. * If not undefined, the mesh position is computed from the attached node position
  153180. */
  153181. attachedNode: {
  153182. position: Vector3;
  153183. };
  153184. /**
  153185. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  153186. */
  153187. customMeshPosition: Vector3;
  153188. /**
  153189. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  153190. */
  153191. useCustomMeshPosition: boolean;
  153192. /**
  153193. * If the post-process should inverse the light scattering direction
  153194. */
  153195. invert: boolean;
  153196. /**
  153197. * The internal mesh used by the post-process
  153198. */
  153199. mesh: Mesh;
  153200. /**
  153201. * @hidden
  153202. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  153203. */
  153204. get useDiffuseColor(): boolean;
  153205. set useDiffuseColor(useDiffuseColor: boolean);
  153206. /**
  153207. * Array containing the excluded meshes not rendered in the internal pass
  153208. */
  153209. excludedMeshes: AbstractMesh[];
  153210. /**
  153211. * Controls the overall intensity of the post-process
  153212. */
  153213. exposure: number;
  153214. /**
  153215. * Dissipates each sample's contribution in range [0, 1]
  153216. */
  153217. decay: number;
  153218. /**
  153219. * Controls the overall intensity of each sample
  153220. */
  153221. weight: number;
  153222. /**
  153223. * Controls the density of each sample
  153224. */
  153225. density: number;
  153226. /**
  153227. * @constructor
  153228. * @param name The post-process name
  153229. * @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)
  153230. * @param camera The camera that the post-process will be attached to
  153231. * @param mesh The mesh used to create the light scattering
  153232. * @param samples The post-process quality, default 100
  153233. * @param samplingModeThe post-process filtering mode
  153234. * @param engine The babylon engine
  153235. * @param reusable If the post-process is reusable
  153236. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  153237. */
  153238. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  153239. /**
  153240. * Returns the string "VolumetricLightScatteringPostProcess"
  153241. * @returns "VolumetricLightScatteringPostProcess"
  153242. */
  153243. getClassName(): string;
  153244. private _isReady;
  153245. /**
  153246. * Sets the new light position for light scattering effect
  153247. * @param position The new custom light position
  153248. */
  153249. setCustomMeshPosition(position: Vector3): void;
  153250. /**
  153251. * Returns the light position for light scattering effect
  153252. * @return Vector3 The custom light position
  153253. */
  153254. getCustomMeshPosition(): Vector3;
  153255. /**
  153256. * Disposes the internal assets and detaches the post-process from the camera
  153257. */
  153258. dispose(camera: Camera): void;
  153259. /**
  153260. * Returns the render target texture used by the post-process
  153261. * @return the render target texture used by the post-process
  153262. */
  153263. getPass(): RenderTargetTexture;
  153264. private _meshExcluded;
  153265. private _createPass;
  153266. private _updateMeshScreenCoordinates;
  153267. /**
  153268. * Creates a default mesh for the Volumeric Light Scattering post-process
  153269. * @param name The mesh name
  153270. * @param scene The scene where to create the mesh
  153271. * @return the default mesh
  153272. */
  153273. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  153274. }
  153275. }
  153276. declare module BABYLON {
  153277. /** @hidden */
  153278. export var screenSpaceCurvaturePixelShader: {
  153279. name: string;
  153280. shader: string;
  153281. };
  153282. }
  153283. declare module BABYLON {
  153284. /**
  153285. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  153286. */
  153287. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  153288. /**
  153289. * Defines how much ridge the curvature effect displays.
  153290. */
  153291. ridge: number;
  153292. /**
  153293. * Defines how much valley the curvature effect displays.
  153294. */
  153295. valley: number;
  153296. private _geometryBufferRenderer;
  153297. /**
  153298. * Gets a string identifying the name of the class
  153299. * @returns "ScreenSpaceCurvaturePostProcess" string
  153300. */
  153301. getClassName(): string;
  153302. /**
  153303. * Creates a new instance ScreenSpaceCurvaturePostProcess
  153304. * @param name The name of the effect.
  153305. * @param scene The scene containing the objects to blur according to their velocity.
  153306. * @param options The required width/height ratio to downsize to before computing the render pass.
  153307. * @param camera The camera to apply the render pass to.
  153308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153309. * @param engine The engine which the post process will be applied. (default: current engine)
  153310. * @param reusable If the post process can be reused on the same frame. (default: false)
  153311. * @param textureType Type of textures used when performing the post process. (default: 0)
  153312. * @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)
  153313. */
  153314. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  153315. /**
  153316. * Support test.
  153317. */
  153318. static get IsSupported(): boolean;
  153319. /** @hidden */
  153320. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  153321. }
  153322. }
  153323. declare module BABYLON {
  153324. interface Scene {
  153325. /** @hidden (Backing field) */
  153326. _boundingBoxRenderer: BoundingBoxRenderer;
  153327. /** @hidden (Backing field) */
  153328. _forceShowBoundingBoxes: boolean;
  153329. /**
  153330. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  153331. */
  153332. forceShowBoundingBoxes: boolean;
  153333. /**
  153334. * Gets the bounding box renderer associated with the scene
  153335. * @returns a BoundingBoxRenderer
  153336. */
  153337. getBoundingBoxRenderer(): BoundingBoxRenderer;
  153338. }
  153339. interface AbstractMesh {
  153340. /** @hidden (Backing field) */
  153341. _showBoundingBox: boolean;
  153342. /**
  153343. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  153344. */
  153345. showBoundingBox: boolean;
  153346. }
  153347. /**
  153348. * Component responsible of rendering the bounding box of the meshes in a scene.
  153349. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  153350. */
  153351. export class BoundingBoxRenderer implements ISceneComponent {
  153352. /**
  153353. * The component name helpfull to identify the component in the list of scene components.
  153354. */
  153355. readonly name: string;
  153356. /**
  153357. * The scene the component belongs to.
  153358. */
  153359. scene: Scene;
  153360. /**
  153361. * Color of the bounding box lines placed in front of an object
  153362. */
  153363. frontColor: Color3;
  153364. /**
  153365. * Color of the bounding box lines placed behind an object
  153366. */
  153367. backColor: Color3;
  153368. /**
  153369. * Defines if the renderer should show the back lines or not
  153370. */
  153371. showBackLines: boolean;
  153372. /**
  153373. * Observable raised before rendering a bounding box
  153374. */
  153375. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  153376. /**
  153377. * Observable raised after rendering a bounding box
  153378. */
  153379. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  153380. /**
  153381. * When false, no bounding boxes will be rendered
  153382. */
  153383. enabled: boolean;
  153384. /**
  153385. * @hidden
  153386. */
  153387. renderList: SmartArray<BoundingBox>;
  153388. private _colorShader;
  153389. private _vertexBuffers;
  153390. private _indexBuffer;
  153391. private _fillIndexBuffer;
  153392. private _fillIndexData;
  153393. /**
  153394. * Instantiates a new bounding box renderer in a scene.
  153395. * @param scene the scene the renderer renders in
  153396. */
  153397. constructor(scene: Scene);
  153398. /**
  153399. * Registers the component in a given scene
  153400. */
  153401. register(): void;
  153402. private _evaluateSubMesh;
  153403. private _preActiveMesh;
  153404. private _prepareRessources;
  153405. private _createIndexBuffer;
  153406. /**
  153407. * Rebuilds the elements related to this component in case of
  153408. * context lost for instance.
  153409. */
  153410. rebuild(): void;
  153411. /**
  153412. * @hidden
  153413. */
  153414. reset(): void;
  153415. /**
  153416. * Render the bounding boxes of a specific rendering group
  153417. * @param renderingGroupId defines the rendering group to render
  153418. */
  153419. render(renderingGroupId: number): void;
  153420. /**
  153421. * In case of occlusion queries, we can render the occlusion bounding box through this method
  153422. * @param mesh Define the mesh to render the occlusion bounding box for
  153423. */
  153424. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  153425. /**
  153426. * Dispose and release the resources attached to this renderer.
  153427. */
  153428. dispose(): void;
  153429. }
  153430. }
  153431. declare module BABYLON {
  153432. interface Scene {
  153433. /** @hidden (Backing field) */
  153434. _depthRenderer: {
  153435. [id: string]: DepthRenderer;
  153436. };
  153437. /**
  153438. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  153439. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  153440. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  153441. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  153442. * @returns the created depth renderer
  153443. */
  153444. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  153445. /**
  153446. * Disables a depth renderer for a given camera
  153447. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  153448. */
  153449. disableDepthRenderer(camera?: Nullable<Camera>): void;
  153450. }
  153451. /**
  153452. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  153453. * in several rendering techniques.
  153454. */
  153455. export class DepthRendererSceneComponent implements ISceneComponent {
  153456. /**
  153457. * The component name helpfull to identify the component in the list of scene components.
  153458. */
  153459. readonly name: string;
  153460. /**
  153461. * The scene the component belongs to.
  153462. */
  153463. scene: Scene;
  153464. /**
  153465. * Creates a new instance of the component for the given scene
  153466. * @param scene Defines the scene to register the component in
  153467. */
  153468. constructor(scene: Scene);
  153469. /**
  153470. * Registers the component in a given scene
  153471. */
  153472. register(): void;
  153473. /**
  153474. * Rebuilds the elements related to this component in case of
  153475. * context lost for instance.
  153476. */
  153477. rebuild(): void;
  153478. /**
  153479. * Disposes the component and the associated ressources
  153480. */
  153481. dispose(): void;
  153482. private _gatherRenderTargets;
  153483. private _gatherActiveCameraRenderTargets;
  153484. }
  153485. }
  153486. declare module BABYLON {
  153487. interface AbstractScene {
  153488. /** @hidden (Backing field) */
  153489. _prePassRenderer: Nullable<PrePassRenderer>;
  153490. /**
  153491. * Gets or Sets the current prepass renderer associated to the scene.
  153492. */
  153493. prePassRenderer: Nullable<PrePassRenderer>;
  153494. /**
  153495. * Enables the prepass and associates it with the scene
  153496. * @returns the PrePassRenderer
  153497. */
  153498. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  153499. /**
  153500. * Disables the prepass associated with the scene
  153501. */
  153502. disablePrePassRenderer(): void;
  153503. }
  153504. /**
  153505. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153506. * in several rendering techniques.
  153507. */
  153508. export class PrePassRendererSceneComponent implements ISceneComponent {
  153509. /**
  153510. * The component name helpful to identify the component in the list of scene components.
  153511. */
  153512. readonly name: string;
  153513. /**
  153514. * The scene the component belongs to.
  153515. */
  153516. scene: Scene;
  153517. /**
  153518. * Creates a new instance of the component for the given scene
  153519. * @param scene Defines the scene to register the component in
  153520. */
  153521. constructor(scene: Scene);
  153522. /**
  153523. * Registers the component in a given scene
  153524. */
  153525. register(): void;
  153526. private _beforeCameraDraw;
  153527. private _afterCameraDraw;
  153528. private _beforeClearStage;
  153529. /**
  153530. * Rebuilds the elements related to this component in case of
  153531. * context lost for instance.
  153532. */
  153533. rebuild(): void;
  153534. /**
  153535. * Disposes the component and the associated ressources
  153536. */
  153537. dispose(): void;
  153538. }
  153539. }
  153540. declare module BABYLON {
  153541. /** @hidden */
  153542. export var fibonacci: {
  153543. name: string;
  153544. shader: string;
  153545. };
  153546. }
  153547. declare module BABYLON {
  153548. /** @hidden */
  153549. export var diffusionProfile: {
  153550. name: string;
  153551. shader: string;
  153552. };
  153553. }
  153554. declare module BABYLON {
  153555. /** @hidden */
  153556. export var subSurfaceScatteringPixelShader: {
  153557. name: string;
  153558. shader: string;
  153559. };
  153560. }
  153561. declare module BABYLON {
  153562. /**
  153563. * Sub surface scattering post process
  153564. */
  153565. export class SubSurfaceScatteringPostProcess extends PostProcess {
  153566. /**
  153567. * Gets a string identifying the name of the class
  153568. * @returns "SubSurfaceScatteringPostProcess" string
  153569. */
  153570. getClassName(): string;
  153571. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  153572. }
  153573. }
  153574. declare module BABYLON {
  153575. /**
  153576. * Contains all parameters needed for the prepass to perform
  153577. * screen space subsurface scattering
  153578. */
  153579. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  153580. /** @hidden */
  153581. static _SceneComponentInitialization: (scene: Scene) => void;
  153582. private _ssDiffusionS;
  153583. private _ssFilterRadii;
  153584. private _ssDiffusionD;
  153585. /**
  153586. * Post process to attach for screen space subsurface scattering
  153587. */
  153588. postProcess: SubSurfaceScatteringPostProcess;
  153589. /**
  153590. * Diffusion profile color for subsurface scattering
  153591. */
  153592. get ssDiffusionS(): number[];
  153593. /**
  153594. * Diffusion profile max color channel value for subsurface scattering
  153595. */
  153596. get ssDiffusionD(): number[];
  153597. /**
  153598. * Diffusion profile filter radius for subsurface scattering
  153599. */
  153600. get ssFilterRadii(): number[];
  153601. /**
  153602. * Is subsurface enabled
  153603. */
  153604. enabled: boolean;
  153605. /**
  153606. * Name of the configuration
  153607. */
  153608. name: string;
  153609. /**
  153610. * Diffusion profile colors for subsurface scattering
  153611. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  153612. * See ...
  153613. * Note that you can only store up to 5 of them
  153614. */
  153615. ssDiffusionProfileColors: Color3[];
  153616. /**
  153617. * Defines the ratio real world => scene units.
  153618. * Used for subsurface scattering
  153619. */
  153620. metersPerUnit: number;
  153621. /**
  153622. * Textures that should be present in the MRT for this effect to work
  153623. */
  153624. readonly texturesRequired: number[];
  153625. private _scene;
  153626. /**
  153627. * Builds a subsurface configuration object
  153628. * @param scene The scene
  153629. */
  153630. constructor(scene: Scene);
  153631. /**
  153632. * Adds a new diffusion profile.
  153633. * Useful for more realistic subsurface scattering on diverse materials.
  153634. * @param color The color of the diffusion profile. Should be the average color of the material.
  153635. * @return The index of the diffusion profile for the material subsurface configuration
  153636. */
  153637. addDiffusionProfile(color: Color3): number;
  153638. /**
  153639. * Creates the sss post process
  153640. * @return The created post process
  153641. */
  153642. createPostProcess(): SubSurfaceScatteringPostProcess;
  153643. /**
  153644. * Deletes all diffusion profiles.
  153645. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  153646. */
  153647. clearAllDiffusionProfiles(): void;
  153648. /**
  153649. * Disposes this object
  153650. */
  153651. dispose(): void;
  153652. /**
  153653. * @hidden
  153654. * https://zero-radiance.github.io/post/sampling-diffusion/
  153655. *
  153656. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  153657. * ------------------------------------------------------------------------------------
  153658. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  153659. * PDF[r, phi, s] = r * R[r, phi, s]
  153660. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  153661. * ------------------------------------------------------------------------------------
  153662. * We importance sample the color channel with the widest scattering distance.
  153663. */
  153664. getDiffusionProfileParameters(color: Color3): number;
  153665. /**
  153666. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  153667. * 'u' is the random number (the value of the CDF): [0, 1).
  153668. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  153669. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  153670. */
  153671. private _sampleBurleyDiffusionProfile;
  153672. }
  153673. }
  153674. declare module BABYLON {
  153675. interface AbstractScene {
  153676. /** @hidden (Backing field) */
  153677. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  153678. /**
  153679. * Gets or Sets the current prepass renderer associated to the scene.
  153680. */
  153681. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  153682. /**
  153683. * Enables the subsurface effect for prepass
  153684. * @returns the SubSurfaceConfiguration
  153685. */
  153686. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  153687. /**
  153688. * Disables the subsurface effect for prepass
  153689. */
  153690. disableSubSurfaceForPrePass(): void;
  153691. }
  153692. /**
  153693. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153694. * in several rendering techniques.
  153695. */
  153696. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  153697. /**
  153698. * The component name helpful to identify the component in the list of scene components.
  153699. */
  153700. readonly name: string;
  153701. /**
  153702. * The scene the component belongs to.
  153703. */
  153704. scene: Scene;
  153705. /**
  153706. * Creates a new instance of the component for the given scene
  153707. * @param scene Defines the scene to register the component in
  153708. */
  153709. constructor(scene: Scene);
  153710. /**
  153711. * Registers the component in a given scene
  153712. */
  153713. register(): void;
  153714. /**
  153715. * Serializes the component data to the specified json object
  153716. * @param serializationObject The object to serialize to
  153717. */
  153718. serialize(serializationObject: any): void;
  153719. /**
  153720. * Adds all the elements from the container to the scene
  153721. * @param container the container holding the elements
  153722. */
  153723. addFromContainer(container: AbstractScene): void;
  153724. /**
  153725. * Removes all the elements in the container from the scene
  153726. * @param container contains the elements to remove
  153727. * @param dispose if the removed element should be disposed (default: false)
  153728. */
  153729. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  153730. /**
  153731. * Rebuilds the elements related to this component in case of
  153732. * context lost for instance.
  153733. */
  153734. rebuild(): void;
  153735. /**
  153736. * Disposes the component and the associated ressources
  153737. */
  153738. dispose(): void;
  153739. }
  153740. }
  153741. declare module BABYLON {
  153742. /** @hidden */
  153743. export var outlinePixelShader: {
  153744. name: string;
  153745. shader: string;
  153746. };
  153747. }
  153748. declare module BABYLON {
  153749. /** @hidden */
  153750. export var outlineVertexShader: {
  153751. name: string;
  153752. shader: string;
  153753. };
  153754. }
  153755. declare module BABYLON {
  153756. interface Scene {
  153757. /** @hidden */
  153758. _outlineRenderer: OutlineRenderer;
  153759. /**
  153760. * Gets the outline renderer associated with the scene
  153761. * @returns a OutlineRenderer
  153762. */
  153763. getOutlineRenderer(): OutlineRenderer;
  153764. }
  153765. interface AbstractMesh {
  153766. /** @hidden (Backing field) */
  153767. _renderOutline: boolean;
  153768. /**
  153769. * Gets or sets a boolean indicating if the outline must be rendered as well
  153770. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  153771. */
  153772. renderOutline: boolean;
  153773. /** @hidden (Backing field) */
  153774. _renderOverlay: boolean;
  153775. /**
  153776. * Gets or sets a boolean indicating if the overlay must be rendered as well
  153777. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  153778. */
  153779. renderOverlay: boolean;
  153780. }
  153781. /**
  153782. * This class is responsible to draw bothe outline/overlay of meshes.
  153783. * It should not be used directly but through the available method on mesh.
  153784. */
  153785. export class OutlineRenderer implements ISceneComponent {
  153786. /**
  153787. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  153788. */
  153789. private static _StencilReference;
  153790. /**
  153791. * The name of the component. Each component must have a unique name.
  153792. */
  153793. name: string;
  153794. /**
  153795. * The scene the component belongs to.
  153796. */
  153797. scene: Scene;
  153798. /**
  153799. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  153800. */
  153801. zOffset: number;
  153802. private _engine;
  153803. private _effect;
  153804. private _cachedDefines;
  153805. private _savedDepthWrite;
  153806. /**
  153807. * Instantiates a new outline renderer. (There could be only one per scene).
  153808. * @param scene Defines the scene it belongs to
  153809. */
  153810. constructor(scene: Scene);
  153811. /**
  153812. * Register the component to one instance of a scene.
  153813. */
  153814. register(): void;
  153815. /**
  153816. * Rebuilds the elements related to this component in case of
  153817. * context lost for instance.
  153818. */
  153819. rebuild(): void;
  153820. /**
  153821. * Disposes the component and the associated ressources.
  153822. */
  153823. dispose(): void;
  153824. /**
  153825. * Renders the outline in the canvas.
  153826. * @param subMesh Defines the sumesh to render
  153827. * @param batch Defines the batch of meshes in case of instances
  153828. * @param useOverlay Defines if the rendering is for the overlay or the outline
  153829. */
  153830. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  153831. /**
  153832. * Returns whether or not the outline renderer is ready for a given submesh.
  153833. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  153834. * @param subMesh Defines the submesh to check readyness for
  153835. * @param useInstances Defines wheter wee are trying to render instances or not
  153836. * @returns true if ready otherwise false
  153837. */
  153838. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  153839. private _beforeRenderingMesh;
  153840. private _afterRenderingMesh;
  153841. }
  153842. }
  153843. declare module BABYLON {
  153844. /**
  153845. * Defines the basic options interface of a Sprite Frame Source Size.
  153846. */
  153847. export interface ISpriteJSONSpriteSourceSize {
  153848. /**
  153849. * number of the original width of the Frame
  153850. */
  153851. w: number;
  153852. /**
  153853. * number of the original height of the Frame
  153854. */
  153855. h: number;
  153856. }
  153857. /**
  153858. * Defines the basic options interface of a Sprite Frame Data.
  153859. */
  153860. export interface ISpriteJSONSpriteFrameData {
  153861. /**
  153862. * number of the x offset of the Frame
  153863. */
  153864. x: number;
  153865. /**
  153866. * number of the y offset of the Frame
  153867. */
  153868. y: number;
  153869. /**
  153870. * number of the width of the Frame
  153871. */
  153872. w: number;
  153873. /**
  153874. * number of the height of the Frame
  153875. */
  153876. h: number;
  153877. }
  153878. /**
  153879. * Defines the basic options interface of a JSON Sprite.
  153880. */
  153881. export interface ISpriteJSONSprite {
  153882. /**
  153883. * string name of the Frame
  153884. */
  153885. filename: string;
  153886. /**
  153887. * ISpriteJSONSpriteFrame basic object of the frame data
  153888. */
  153889. frame: ISpriteJSONSpriteFrameData;
  153890. /**
  153891. * boolean to flag is the frame was rotated.
  153892. */
  153893. rotated: boolean;
  153894. /**
  153895. * boolean to flag is the frame was trimmed.
  153896. */
  153897. trimmed: boolean;
  153898. /**
  153899. * ISpriteJSONSpriteFrame basic object of the source data
  153900. */
  153901. spriteSourceSize: ISpriteJSONSpriteFrameData;
  153902. /**
  153903. * ISpriteJSONSpriteFrame basic object of the source data
  153904. */
  153905. sourceSize: ISpriteJSONSpriteSourceSize;
  153906. }
  153907. /**
  153908. * Defines the basic options interface of a JSON atlas.
  153909. */
  153910. export interface ISpriteJSONAtlas {
  153911. /**
  153912. * Array of objects that contain the frame data.
  153913. */
  153914. frames: Array<ISpriteJSONSprite>;
  153915. /**
  153916. * object basic object containing the sprite meta data.
  153917. */
  153918. meta?: object;
  153919. }
  153920. }
  153921. declare module BABYLON {
  153922. /** @hidden */
  153923. export var spriteMapPixelShader: {
  153924. name: string;
  153925. shader: string;
  153926. };
  153927. }
  153928. declare module BABYLON {
  153929. /** @hidden */
  153930. export var spriteMapVertexShader: {
  153931. name: string;
  153932. shader: string;
  153933. };
  153934. }
  153935. declare module BABYLON {
  153936. /**
  153937. * Defines the basic options interface of a SpriteMap
  153938. */
  153939. export interface ISpriteMapOptions {
  153940. /**
  153941. * Vector2 of the number of cells in the grid.
  153942. */
  153943. stageSize?: Vector2;
  153944. /**
  153945. * Vector2 of the size of the output plane in World Units.
  153946. */
  153947. outputSize?: Vector2;
  153948. /**
  153949. * Vector3 of the position of the output plane in World Units.
  153950. */
  153951. outputPosition?: Vector3;
  153952. /**
  153953. * Vector3 of the rotation of the output plane.
  153954. */
  153955. outputRotation?: Vector3;
  153956. /**
  153957. * number of layers that the system will reserve in resources.
  153958. */
  153959. layerCount?: number;
  153960. /**
  153961. * number of max animation frames a single cell will reserve in resources.
  153962. */
  153963. maxAnimationFrames?: number;
  153964. /**
  153965. * number cell index of the base tile when the system compiles.
  153966. */
  153967. baseTile?: number;
  153968. /**
  153969. * boolean flip the sprite after its been repositioned by the framing data.
  153970. */
  153971. flipU?: boolean;
  153972. /**
  153973. * Vector3 scalar of the global RGB values of the SpriteMap.
  153974. */
  153975. colorMultiply?: Vector3;
  153976. }
  153977. /**
  153978. * Defines the IDisposable interface in order to be cleanable from resources.
  153979. */
  153980. export interface ISpriteMap extends IDisposable {
  153981. /**
  153982. * String name of the SpriteMap.
  153983. */
  153984. name: string;
  153985. /**
  153986. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  153987. */
  153988. atlasJSON: ISpriteJSONAtlas;
  153989. /**
  153990. * Texture of the SpriteMap.
  153991. */
  153992. spriteSheet: Texture;
  153993. /**
  153994. * The parameters to initialize the SpriteMap with.
  153995. */
  153996. options: ISpriteMapOptions;
  153997. }
  153998. /**
  153999. * Class used to manage a grid restricted sprite deployment on an Output plane.
  154000. */
  154001. export class SpriteMap implements ISpriteMap {
  154002. /** The Name of the spriteMap */
  154003. name: string;
  154004. /** The JSON file with the frame and meta data */
  154005. atlasJSON: ISpriteJSONAtlas;
  154006. /** The systems Sprite Sheet Texture */
  154007. spriteSheet: Texture;
  154008. /** Arguments passed with the Constructor */
  154009. options: ISpriteMapOptions;
  154010. /** Public Sprite Storage array, parsed from atlasJSON */
  154011. sprites: Array<ISpriteJSONSprite>;
  154012. /** Returns the Number of Sprites in the System */
  154013. get spriteCount(): number;
  154014. /** Returns the Position of Output Plane*/
  154015. get position(): Vector3;
  154016. /** Returns the Position of Output Plane*/
  154017. set position(v: Vector3);
  154018. /** Returns the Rotation of Output Plane*/
  154019. get rotation(): Vector3;
  154020. /** Returns the Rotation of Output Plane*/
  154021. set rotation(v: Vector3);
  154022. /** Sets the AnimationMap*/
  154023. get animationMap(): RawTexture;
  154024. /** Sets the AnimationMap*/
  154025. set animationMap(v: RawTexture);
  154026. /** Scene that the SpriteMap was created in */
  154027. private _scene;
  154028. /** Texture Buffer of Float32 that holds tile frame data*/
  154029. private _frameMap;
  154030. /** Texture Buffers of Float32 that holds tileMap data*/
  154031. private _tileMaps;
  154032. /** Texture Buffer of Float32 that holds Animation Data*/
  154033. private _animationMap;
  154034. /** Custom ShaderMaterial Central to the System*/
  154035. private _material;
  154036. /** Custom ShaderMaterial Central to the System*/
  154037. private _output;
  154038. /** Systems Time Ticker*/
  154039. private _time;
  154040. /**
  154041. * Creates a new SpriteMap
  154042. * @param name defines the SpriteMaps Name
  154043. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  154044. * @param spriteSheet is the Texture that the Sprites are on.
  154045. * @param options a basic deployment configuration
  154046. * @param scene The Scene that the map is deployed on
  154047. */
  154048. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  154049. /**
  154050. * Returns tileID location
  154051. * @returns Vector2 the cell position ID
  154052. */
  154053. getTileID(): Vector2;
  154054. /**
  154055. * Gets the UV location of the mouse over the SpriteMap.
  154056. * @returns Vector2 the UV position of the mouse interaction
  154057. */
  154058. getMousePosition(): Vector2;
  154059. /**
  154060. * Creates the "frame" texture Buffer
  154061. * -------------------------------------
  154062. * Structure of frames
  154063. * "filename": "Falling-Water-2.png",
  154064. * "frame": {"x":69,"y":103,"w":24,"h":32},
  154065. * "rotated": true,
  154066. * "trimmed": true,
  154067. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  154068. * "sourceSize": {"w":32,"h":32}
  154069. * @returns RawTexture of the frameMap
  154070. */
  154071. private _createFrameBuffer;
  154072. /**
  154073. * Creates the tileMap texture Buffer
  154074. * @param buffer normally and array of numbers, or a false to generate from scratch
  154075. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  154076. * @returns RawTexture of the tileMap
  154077. */
  154078. private _createTileBuffer;
  154079. /**
  154080. * Modifies the data of the tileMaps
  154081. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  154082. * @param pos is the iVector2 Coordinates of the Tile
  154083. * @param tile The SpriteIndex of the new Tile
  154084. */
  154085. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  154086. /**
  154087. * Creates the animationMap texture Buffer
  154088. * @param buffer normally and array of numbers, or a false to generate from scratch
  154089. * @returns RawTexture of the animationMap
  154090. */
  154091. private _createTileAnimationBuffer;
  154092. /**
  154093. * Modifies the data of the animationMap
  154094. * @param cellID is the Index of the Sprite
  154095. * @param _frame is the target Animation frame
  154096. * @param toCell is the Target Index of the next frame of the animation
  154097. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  154098. * @param speed is a global scalar of the time variable on the map.
  154099. */
  154100. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  154101. /**
  154102. * Exports the .tilemaps file
  154103. */
  154104. saveTileMaps(): void;
  154105. /**
  154106. * Imports the .tilemaps file
  154107. * @param url of the .tilemaps file
  154108. */
  154109. loadTileMaps(url: string): void;
  154110. /**
  154111. * Release associated resources
  154112. */
  154113. dispose(): void;
  154114. }
  154115. }
  154116. declare module BABYLON {
  154117. /**
  154118. * Class used to manage multiple sprites of different sizes on the same spritesheet
  154119. * @see https://doc.babylonjs.com/babylon101/sprites
  154120. */
  154121. export class SpritePackedManager extends SpriteManager {
  154122. /** defines the packed manager's name */
  154123. name: string;
  154124. /**
  154125. * Creates a new sprite manager from a packed sprite sheet
  154126. * @param name defines the manager's name
  154127. * @param imgUrl defines the sprite sheet url
  154128. * @param capacity defines the maximum allowed number of sprites
  154129. * @param scene defines the hosting scene
  154130. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  154131. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  154132. * @param samplingMode defines the smapling mode to use with spritesheet
  154133. * @param fromPacked set to true; do not alter
  154134. */
  154135. constructor(
  154136. /** defines the packed manager's name */
  154137. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  154138. }
  154139. }
  154140. declare module BABYLON {
  154141. /**
  154142. * Defines the list of states available for a task inside a AssetsManager
  154143. */
  154144. export enum AssetTaskState {
  154145. /**
  154146. * Initialization
  154147. */
  154148. INIT = 0,
  154149. /**
  154150. * Running
  154151. */
  154152. RUNNING = 1,
  154153. /**
  154154. * Done
  154155. */
  154156. DONE = 2,
  154157. /**
  154158. * Error
  154159. */
  154160. ERROR = 3
  154161. }
  154162. /**
  154163. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  154164. */
  154165. export abstract class AbstractAssetTask {
  154166. /**
  154167. * Task name
  154168. */ name: string;
  154169. /**
  154170. * Callback called when the task is successful
  154171. */
  154172. onSuccess: (task: any) => void;
  154173. /**
  154174. * Callback called when the task is not successful
  154175. */
  154176. onError: (task: any, message?: string, exception?: any) => void;
  154177. /**
  154178. * Creates a new AssetsManager
  154179. * @param name defines the name of the task
  154180. */
  154181. constructor(
  154182. /**
  154183. * Task name
  154184. */ name: string);
  154185. private _isCompleted;
  154186. private _taskState;
  154187. private _errorObject;
  154188. /**
  154189. * Get if the task is completed
  154190. */
  154191. get isCompleted(): boolean;
  154192. /**
  154193. * Gets the current state of the task
  154194. */
  154195. get taskState(): AssetTaskState;
  154196. /**
  154197. * Gets the current error object (if task is in error)
  154198. */
  154199. get errorObject(): {
  154200. message?: string;
  154201. exception?: any;
  154202. };
  154203. /**
  154204. * Internal only
  154205. * @hidden
  154206. */
  154207. _setErrorObject(message?: string, exception?: any): void;
  154208. /**
  154209. * Execute the current task
  154210. * @param scene defines the scene where you want your assets to be loaded
  154211. * @param onSuccess is a callback called when the task is successfully executed
  154212. * @param onError is a callback called if an error occurs
  154213. */
  154214. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154215. /**
  154216. * Execute the current task
  154217. * @param scene defines the scene where you want your assets to be loaded
  154218. * @param onSuccess is a callback called when the task is successfully executed
  154219. * @param onError is a callback called if an error occurs
  154220. */
  154221. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154222. /**
  154223. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  154224. * This can be used with failed tasks that have the reason for failure fixed.
  154225. */
  154226. reset(): void;
  154227. private onErrorCallback;
  154228. private onDoneCallback;
  154229. }
  154230. /**
  154231. * Define the interface used by progress events raised during assets loading
  154232. */
  154233. export interface IAssetsProgressEvent {
  154234. /**
  154235. * Defines the number of remaining tasks to process
  154236. */
  154237. remainingCount: number;
  154238. /**
  154239. * Defines the total number of tasks
  154240. */
  154241. totalCount: number;
  154242. /**
  154243. * Defines the task that was just processed
  154244. */
  154245. task: AbstractAssetTask;
  154246. }
  154247. /**
  154248. * Class used to share progress information about assets loading
  154249. */
  154250. export class AssetsProgressEvent implements IAssetsProgressEvent {
  154251. /**
  154252. * Defines the number of remaining tasks to process
  154253. */
  154254. remainingCount: number;
  154255. /**
  154256. * Defines the total number of tasks
  154257. */
  154258. totalCount: number;
  154259. /**
  154260. * Defines the task that was just processed
  154261. */
  154262. task: AbstractAssetTask;
  154263. /**
  154264. * Creates a AssetsProgressEvent
  154265. * @param remainingCount defines the number of remaining tasks to process
  154266. * @param totalCount defines the total number of tasks
  154267. * @param task defines the task that was just processed
  154268. */
  154269. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  154270. }
  154271. /**
  154272. * Define a task used by AssetsManager to load assets into a container
  154273. */
  154274. export class ContainerAssetTask extends AbstractAssetTask {
  154275. /**
  154276. * Defines the name of the task
  154277. */
  154278. name: string;
  154279. /**
  154280. * Defines the list of mesh's names you want to load
  154281. */
  154282. meshesNames: any;
  154283. /**
  154284. * Defines the root url to use as a base to load your meshes and associated resources
  154285. */
  154286. rootUrl: string;
  154287. /**
  154288. * Defines the filename or File of the scene to load from
  154289. */
  154290. sceneFilename: string | File;
  154291. /**
  154292. * Get the loaded asset container
  154293. */
  154294. loadedContainer: AssetContainer;
  154295. /**
  154296. * Gets the list of loaded meshes
  154297. */
  154298. loadedMeshes: Array<AbstractMesh>;
  154299. /**
  154300. * Gets the list of loaded particle systems
  154301. */
  154302. loadedParticleSystems: Array<IParticleSystem>;
  154303. /**
  154304. * Gets the list of loaded skeletons
  154305. */
  154306. loadedSkeletons: Array<Skeleton>;
  154307. /**
  154308. * Gets the list of loaded animation groups
  154309. */
  154310. loadedAnimationGroups: Array<AnimationGroup>;
  154311. /**
  154312. * Callback called when the task is successful
  154313. */
  154314. onSuccess: (task: ContainerAssetTask) => void;
  154315. /**
  154316. * Callback called when the task is successful
  154317. */
  154318. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  154319. /**
  154320. * Creates a new ContainerAssetTask
  154321. * @param name defines the name of the task
  154322. * @param meshesNames defines the list of mesh's names you want to load
  154323. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  154324. * @param sceneFilename defines the filename or File of the scene to load from
  154325. */
  154326. constructor(
  154327. /**
  154328. * Defines the name of the task
  154329. */
  154330. name: string,
  154331. /**
  154332. * Defines the list of mesh's names you want to load
  154333. */
  154334. meshesNames: any,
  154335. /**
  154336. * Defines the root url to use as a base to load your meshes and associated resources
  154337. */
  154338. rootUrl: string,
  154339. /**
  154340. * Defines the filename or File of the scene to load from
  154341. */
  154342. sceneFilename: string | File);
  154343. /**
  154344. * Execute the current task
  154345. * @param scene defines the scene where you want your assets to be loaded
  154346. * @param onSuccess is a callback called when the task is successfully executed
  154347. * @param onError is a callback called if an error occurs
  154348. */
  154349. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154350. }
  154351. /**
  154352. * Define a task used by AssetsManager to load meshes
  154353. */
  154354. export class MeshAssetTask extends AbstractAssetTask {
  154355. /**
  154356. * Defines the name of the task
  154357. */
  154358. name: string;
  154359. /**
  154360. * Defines the list of mesh's names you want to load
  154361. */
  154362. meshesNames: any;
  154363. /**
  154364. * Defines the root url to use as a base to load your meshes and associated resources
  154365. */
  154366. rootUrl: string;
  154367. /**
  154368. * Defines the filename or File of the scene to load from
  154369. */
  154370. sceneFilename: string | File;
  154371. /**
  154372. * Gets the list of loaded meshes
  154373. */
  154374. loadedMeshes: Array<AbstractMesh>;
  154375. /**
  154376. * Gets the list of loaded particle systems
  154377. */
  154378. loadedParticleSystems: Array<IParticleSystem>;
  154379. /**
  154380. * Gets the list of loaded skeletons
  154381. */
  154382. loadedSkeletons: Array<Skeleton>;
  154383. /**
  154384. * Gets the list of loaded animation groups
  154385. */
  154386. loadedAnimationGroups: Array<AnimationGroup>;
  154387. /**
  154388. * Callback called when the task is successful
  154389. */
  154390. onSuccess: (task: MeshAssetTask) => void;
  154391. /**
  154392. * Callback called when the task is successful
  154393. */
  154394. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  154395. /**
  154396. * Creates a new MeshAssetTask
  154397. * @param name defines the name of the task
  154398. * @param meshesNames defines the list of mesh's names you want to load
  154399. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  154400. * @param sceneFilename defines the filename or File of the scene to load from
  154401. */
  154402. constructor(
  154403. /**
  154404. * Defines the name of the task
  154405. */
  154406. name: string,
  154407. /**
  154408. * Defines the list of mesh's names you want to load
  154409. */
  154410. meshesNames: any,
  154411. /**
  154412. * Defines the root url to use as a base to load your meshes and associated resources
  154413. */
  154414. rootUrl: string,
  154415. /**
  154416. * Defines the filename or File of the scene to load from
  154417. */
  154418. sceneFilename: string | File);
  154419. /**
  154420. * Execute the current task
  154421. * @param scene defines the scene where you want your assets to be loaded
  154422. * @param onSuccess is a callback called when the task is successfully executed
  154423. * @param onError is a callback called if an error occurs
  154424. */
  154425. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154426. }
  154427. /**
  154428. * Define a task used by AssetsManager to load text content
  154429. */
  154430. export class TextFileAssetTask extends AbstractAssetTask {
  154431. /**
  154432. * Defines the name of the task
  154433. */
  154434. name: string;
  154435. /**
  154436. * Defines the location of the file to load
  154437. */
  154438. url: string;
  154439. /**
  154440. * Gets the loaded text string
  154441. */
  154442. text: string;
  154443. /**
  154444. * Callback called when the task is successful
  154445. */
  154446. onSuccess: (task: TextFileAssetTask) => void;
  154447. /**
  154448. * Callback called when the task is successful
  154449. */
  154450. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  154451. /**
  154452. * Creates a new TextFileAssetTask object
  154453. * @param name defines the name of the task
  154454. * @param url defines the location of the file to load
  154455. */
  154456. constructor(
  154457. /**
  154458. * Defines the name of the task
  154459. */
  154460. name: string,
  154461. /**
  154462. * Defines the location of the file to load
  154463. */
  154464. url: string);
  154465. /**
  154466. * Execute the current task
  154467. * @param scene defines the scene where you want your assets to be loaded
  154468. * @param onSuccess is a callback called when the task is successfully executed
  154469. * @param onError is a callback called if an error occurs
  154470. */
  154471. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154472. }
  154473. /**
  154474. * Define a task used by AssetsManager to load binary data
  154475. */
  154476. export class BinaryFileAssetTask extends AbstractAssetTask {
  154477. /**
  154478. * Defines the name of the task
  154479. */
  154480. name: string;
  154481. /**
  154482. * Defines the location of the file to load
  154483. */
  154484. url: string;
  154485. /**
  154486. * Gets the lodaded data (as an array buffer)
  154487. */
  154488. data: ArrayBuffer;
  154489. /**
  154490. * Callback called when the task is successful
  154491. */
  154492. onSuccess: (task: BinaryFileAssetTask) => void;
  154493. /**
  154494. * Callback called when the task is successful
  154495. */
  154496. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  154497. /**
  154498. * Creates a new BinaryFileAssetTask object
  154499. * @param name defines the name of the new task
  154500. * @param url defines the location of the file to load
  154501. */
  154502. constructor(
  154503. /**
  154504. * Defines the name of the task
  154505. */
  154506. name: string,
  154507. /**
  154508. * Defines the location of the file to load
  154509. */
  154510. url: string);
  154511. /**
  154512. * Execute the current task
  154513. * @param scene defines the scene where you want your assets to be loaded
  154514. * @param onSuccess is a callback called when the task is successfully executed
  154515. * @param onError is a callback called if an error occurs
  154516. */
  154517. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154518. }
  154519. /**
  154520. * Define a task used by AssetsManager to load images
  154521. */
  154522. export class ImageAssetTask extends AbstractAssetTask {
  154523. /**
  154524. * Defines the name of the task
  154525. */
  154526. name: string;
  154527. /**
  154528. * Defines the location of the image to load
  154529. */
  154530. url: string;
  154531. /**
  154532. * Gets the loaded images
  154533. */
  154534. image: HTMLImageElement;
  154535. /**
  154536. * Callback called when the task is successful
  154537. */
  154538. onSuccess: (task: ImageAssetTask) => void;
  154539. /**
  154540. * Callback called when the task is successful
  154541. */
  154542. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  154543. /**
  154544. * Creates a new ImageAssetTask
  154545. * @param name defines the name of the task
  154546. * @param url defines the location of the image to load
  154547. */
  154548. constructor(
  154549. /**
  154550. * Defines the name of the task
  154551. */
  154552. name: string,
  154553. /**
  154554. * Defines the location of the image to load
  154555. */
  154556. url: string);
  154557. /**
  154558. * Execute the current task
  154559. * @param scene defines the scene where you want your assets to be loaded
  154560. * @param onSuccess is a callback called when the task is successfully executed
  154561. * @param onError is a callback called if an error occurs
  154562. */
  154563. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154564. }
  154565. /**
  154566. * Defines the interface used by texture loading tasks
  154567. */
  154568. export interface ITextureAssetTask<TEX extends BaseTexture> {
  154569. /**
  154570. * Gets the loaded texture
  154571. */
  154572. texture: TEX;
  154573. }
  154574. /**
  154575. * Define a task used by AssetsManager to load 2D textures
  154576. */
  154577. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  154578. /**
  154579. * Defines the name of the task
  154580. */
  154581. name: string;
  154582. /**
  154583. * Defines the location of the file to load
  154584. */
  154585. url: string;
  154586. /**
  154587. * Defines if mipmap should not be generated (default is false)
  154588. */
  154589. noMipmap?: boolean | undefined;
  154590. /**
  154591. * Defines if texture must be inverted on Y axis (default is true)
  154592. */
  154593. invertY: boolean;
  154594. /**
  154595. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154596. */
  154597. samplingMode: number;
  154598. /**
  154599. * Gets the loaded texture
  154600. */
  154601. texture: Texture;
  154602. /**
  154603. * Callback called when the task is successful
  154604. */
  154605. onSuccess: (task: TextureAssetTask) => void;
  154606. /**
  154607. * Callback called when the task is successful
  154608. */
  154609. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  154610. /**
  154611. * Creates a new TextureAssetTask object
  154612. * @param name defines the name of the task
  154613. * @param url defines the location of the file to load
  154614. * @param noMipmap defines if mipmap should not be generated (default is false)
  154615. * @param invertY defines if texture must be inverted on Y axis (default is true)
  154616. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154617. */
  154618. constructor(
  154619. /**
  154620. * Defines the name of the task
  154621. */
  154622. name: string,
  154623. /**
  154624. * Defines the location of the file to load
  154625. */
  154626. url: string,
  154627. /**
  154628. * Defines if mipmap should not be generated (default is false)
  154629. */
  154630. noMipmap?: boolean | undefined,
  154631. /**
  154632. * Defines if texture must be inverted on Y axis (default is true)
  154633. */
  154634. invertY?: boolean,
  154635. /**
  154636. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154637. */
  154638. samplingMode?: number);
  154639. /**
  154640. * Execute the current task
  154641. * @param scene defines the scene where you want your assets to be loaded
  154642. * @param onSuccess is a callback called when the task is successfully executed
  154643. * @param onError is a callback called if an error occurs
  154644. */
  154645. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154646. }
  154647. /**
  154648. * Define a task used by AssetsManager to load cube textures
  154649. */
  154650. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  154651. /**
  154652. * Defines the name of the task
  154653. */
  154654. name: string;
  154655. /**
  154656. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154657. */
  154658. url: string;
  154659. /**
  154660. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154661. */
  154662. extensions?: string[] | undefined;
  154663. /**
  154664. * Defines if mipmaps should not be generated (default is false)
  154665. */
  154666. noMipmap?: boolean | undefined;
  154667. /**
  154668. * Defines the explicit list of files (undefined by default)
  154669. */
  154670. files?: string[] | undefined;
  154671. /**
  154672. * Gets the loaded texture
  154673. */
  154674. texture: CubeTexture;
  154675. /**
  154676. * Callback called when the task is successful
  154677. */
  154678. onSuccess: (task: CubeTextureAssetTask) => void;
  154679. /**
  154680. * Callback called when the task is successful
  154681. */
  154682. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  154683. /**
  154684. * Creates a new CubeTextureAssetTask
  154685. * @param name defines the name of the task
  154686. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154687. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154688. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154689. * @param files defines the explicit list of files (undefined by default)
  154690. */
  154691. constructor(
  154692. /**
  154693. * Defines the name of the task
  154694. */
  154695. name: string,
  154696. /**
  154697. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154698. */
  154699. url: string,
  154700. /**
  154701. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154702. */
  154703. extensions?: string[] | undefined,
  154704. /**
  154705. * Defines if mipmaps should not be generated (default is false)
  154706. */
  154707. noMipmap?: boolean | undefined,
  154708. /**
  154709. * Defines the explicit list of files (undefined by default)
  154710. */
  154711. files?: string[] | undefined);
  154712. /**
  154713. * Execute the current task
  154714. * @param scene defines the scene where you want your assets to be loaded
  154715. * @param onSuccess is a callback called when the task is successfully executed
  154716. * @param onError is a callback called if an error occurs
  154717. */
  154718. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154719. }
  154720. /**
  154721. * Define a task used by AssetsManager to load HDR cube textures
  154722. */
  154723. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  154724. /**
  154725. * Defines the name of the task
  154726. */
  154727. name: string;
  154728. /**
  154729. * Defines the location of the file to load
  154730. */
  154731. url: string;
  154732. /**
  154733. * Defines the desired size (the more it increases the longer the generation will be)
  154734. */
  154735. size: number;
  154736. /**
  154737. * Defines if mipmaps should not be generated (default is false)
  154738. */
  154739. noMipmap: boolean;
  154740. /**
  154741. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154742. */
  154743. generateHarmonics: boolean;
  154744. /**
  154745. * 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)
  154746. */
  154747. gammaSpace: boolean;
  154748. /**
  154749. * Internal Use Only
  154750. */
  154751. reserved: boolean;
  154752. /**
  154753. * Gets the loaded texture
  154754. */
  154755. texture: HDRCubeTexture;
  154756. /**
  154757. * Callback called when the task is successful
  154758. */
  154759. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  154760. /**
  154761. * Callback called when the task is successful
  154762. */
  154763. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  154764. /**
  154765. * Creates a new HDRCubeTextureAssetTask object
  154766. * @param name defines the name of the task
  154767. * @param url defines the location of the file to load
  154768. * @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.
  154769. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154770. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154771. * @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)
  154772. * @param reserved Internal use only
  154773. */
  154774. constructor(
  154775. /**
  154776. * Defines the name of the task
  154777. */
  154778. name: string,
  154779. /**
  154780. * Defines the location of the file to load
  154781. */
  154782. url: string,
  154783. /**
  154784. * Defines the desired size (the more it increases the longer the generation will be)
  154785. */
  154786. size: number,
  154787. /**
  154788. * Defines if mipmaps should not be generated (default is false)
  154789. */
  154790. noMipmap?: boolean,
  154791. /**
  154792. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154793. */
  154794. generateHarmonics?: boolean,
  154795. /**
  154796. * 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)
  154797. */
  154798. gammaSpace?: boolean,
  154799. /**
  154800. * Internal Use Only
  154801. */
  154802. reserved?: boolean);
  154803. /**
  154804. * Execute the current task
  154805. * @param scene defines the scene where you want your assets to be loaded
  154806. * @param onSuccess is a callback called when the task is successfully executed
  154807. * @param onError is a callback called if an error occurs
  154808. */
  154809. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154810. }
  154811. /**
  154812. * Define a task used by AssetsManager to load Equirectangular cube textures
  154813. */
  154814. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  154815. /**
  154816. * Defines the name of the task
  154817. */
  154818. name: string;
  154819. /**
  154820. * Defines the location of the file to load
  154821. */
  154822. url: string;
  154823. /**
  154824. * Defines the desired size (the more it increases the longer the generation will be)
  154825. */
  154826. size: number;
  154827. /**
  154828. * Defines if mipmaps should not be generated (default is false)
  154829. */
  154830. noMipmap: boolean;
  154831. /**
  154832. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154833. * but the standard material would require them in Gamma space) (default is true)
  154834. */
  154835. gammaSpace: boolean;
  154836. /**
  154837. * Gets the loaded texture
  154838. */
  154839. texture: EquiRectangularCubeTexture;
  154840. /**
  154841. * Callback called when the task is successful
  154842. */
  154843. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  154844. /**
  154845. * Callback called when the task is successful
  154846. */
  154847. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  154848. /**
  154849. * Creates a new EquiRectangularCubeTextureAssetTask object
  154850. * @param name defines the name of the task
  154851. * @param url defines the location of the file to load
  154852. * @param size defines the desired size (the more it increases the longer the generation will be)
  154853. * If the size is omitted this implies you are using a preprocessed cubemap.
  154854. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154855. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  154856. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  154857. * (default is true)
  154858. */
  154859. constructor(
  154860. /**
  154861. * Defines the name of the task
  154862. */
  154863. name: string,
  154864. /**
  154865. * Defines the location of the file to load
  154866. */
  154867. url: string,
  154868. /**
  154869. * Defines the desired size (the more it increases the longer the generation will be)
  154870. */
  154871. size: number,
  154872. /**
  154873. * Defines if mipmaps should not be generated (default is false)
  154874. */
  154875. noMipmap?: boolean,
  154876. /**
  154877. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154878. * but the standard material would require them in Gamma space) (default is true)
  154879. */
  154880. gammaSpace?: boolean);
  154881. /**
  154882. * Execute the current task
  154883. * @param scene defines the scene where you want your assets to be loaded
  154884. * @param onSuccess is a callback called when the task is successfully executed
  154885. * @param onError is a callback called if an error occurs
  154886. */
  154887. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154888. }
  154889. /**
  154890. * This class can be used to easily import assets into a scene
  154891. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  154892. */
  154893. export class AssetsManager {
  154894. private _scene;
  154895. private _isLoading;
  154896. protected _tasks: AbstractAssetTask[];
  154897. protected _waitingTasksCount: number;
  154898. protected _totalTasksCount: number;
  154899. /**
  154900. * Callback called when all tasks are processed
  154901. */
  154902. onFinish: (tasks: AbstractAssetTask[]) => void;
  154903. /**
  154904. * Callback called when a task is successful
  154905. */
  154906. onTaskSuccess: (task: AbstractAssetTask) => void;
  154907. /**
  154908. * Callback called when a task had an error
  154909. */
  154910. onTaskError: (task: AbstractAssetTask) => void;
  154911. /**
  154912. * Callback called when a task is done (whatever the result is)
  154913. */
  154914. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  154915. /**
  154916. * Observable called when all tasks are processed
  154917. */
  154918. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  154919. /**
  154920. * Observable called when a task had an error
  154921. */
  154922. onTaskErrorObservable: Observable<AbstractAssetTask>;
  154923. /**
  154924. * Observable called when all tasks were executed
  154925. */
  154926. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  154927. /**
  154928. * Observable called when a task is done (whatever the result is)
  154929. */
  154930. onProgressObservable: Observable<IAssetsProgressEvent>;
  154931. /**
  154932. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  154933. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  154934. */
  154935. useDefaultLoadingScreen: boolean;
  154936. /**
  154937. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  154938. * when all assets have been downloaded.
  154939. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  154940. */
  154941. autoHideLoadingUI: boolean;
  154942. /**
  154943. * Creates a new AssetsManager
  154944. * @param scene defines the scene to work on
  154945. */
  154946. constructor(scene: Scene);
  154947. /**
  154948. * Add a ContainerAssetTask to the list of active tasks
  154949. * @param taskName defines the name of the new task
  154950. * @param meshesNames defines the name of meshes to load
  154951. * @param rootUrl defines the root url to use to locate files
  154952. * @param sceneFilename defines the filename of the scene file
  154953. * @returns a new ContainerAssetTask object
  154954. */
  154955. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  154956. /**
  154957. * Add a MeshAssetTask to the list of active tasks
  154958. * @param taskName defines the name of the new task
  154959. * @param meshesNames defines the name of meshes to load
  154960. * @param rootUrl defines the root url to use to locate files
  154961. * @param sceneFilename defines the filename of the scene file
  154962. * @returns a new MeshAssetTask object
  154963. */
  154964. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  154965. /**
  154966. * Add a TextFileAssetTask to the list of active tasks
  154967. * @param taskName defines the name of the new task
  154968. * @param url defines the url of the file to load
  154969. * @returns a new TextFileAssetTask object
  154970. */
  154971. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  154972. /**
  154973. * Add a BinaryFileAssetTask to the list of active tasks
  154974. * @param taskName defines the name of the new task
  154975. * @param url defines the url of the file to load
  154976. * @returns a new BinaryFileAssetTask object
  154977. */
  154978. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  154979. /**
  154980. * Add a ImageAssetTask to the list of active tasks
  154981. * @param taskName defines the name of the new task
  154982. * @param url defines the url of the file to load
  154983. * @returns a new ImageAssetTask object
  154984. */
  154985. addImageTask(taskName: string, url: string): ImageAssetTask;
  154986. /**
  154987. * Add a TextureAssetTask to the list of active tasks
  154988. * @param taskName defines the name of the new task
  154989. * @param url defines the url of the file to load
  154990. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154991. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  154992. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  154993. * @returns a new TextureAssetTask object
  154994. */
  154995. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  154996. /**
  154997. * Add a CubeTextureAssetTask to the list of active tasks
  154998. * @param taskName defines the name of the new task
  154999. * @param url defines the url of the file to load
  155000. * @param extensions defines the extension to use to load the cube map (can be null)
  155001. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  155002. * @param files defines the list of files to load (can be null)
  155003. * @returns a new CubeTextureAssetTask object
  155004. */
  155005. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  155006. /**
  155007. *
  155008. * Add a HDRCubeTextureAssetTask to the list of active tasks
  155009. * @param taskName defines the name of the new task
  155010. * @param url defines the url of the file to load
  155011. * @param size defines the size you want for the cubemap (can be null)
  155012. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  155013. * @param generateHarmonics defines if you want to automatically generate (true by default)
  155014. * @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)
  155015. * @param reserved Internal use only
  155016. * @returns a new HDRCubeTextureAssetTask object
  155017. */
  155018. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  155019. /**
  155020. *
  155021. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  155022. * @param taskName defines the name of the new task
  155023. * @param url defines the url of the file to load
  155024. * @param size defines the size you want for the cubemap (can be null)
  155025. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  155026. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  155027. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  155028. * @returns a new EquiRectangularCubeTextureAssetTask object
  155029. */
  155030. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  155031. /**
  155032. * Remove a task from the assets manager.
  155033. * @param task the task to remove
  155034. */
  155035. removeTask(task: AbstractAssetTask): void;
  155036. private _decreaseWaitingTasksCount;
  155037. private _runTask;
  155038. /**
  155039. * Reset the AssetsManager and remove all tasks
  155040. * @return the current instance of the AssetsManager
  155041. */
  155042. reset(): AssetsManager;
  155043. /**
  155044. * Start the loading process
  155045. * @return the current instance of the AssetsManager
  155046. */
  155047. load(): AssetsManager;
  155048. /**
  155049. * Start the loading process as an async operation
  155050. * @return a promise returning the list of failed tasks
  155051. */
  155052. loadAsync(): Promise<void>;
  155053. }
  155054. }
  155055. declare module BABYLON {
  155056. /**
  155057. * Wrapper class for promise with external resolve and reject.
  155058. */
  155059. export class Deferred<T> {
  155060. /**
  155061. * The promise associated with this deferred object.
  155062. */
  155063. readonly promise: Promise<T>;
  155064. private _resolve;
  155065. private _reject;
  155066. /**
  155067. * The resolve method of the promise associated with this deferred object.
  155068. */
  155069. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  155070. /**
  155071. * The reject method of the promise associated with this deferred object.
  155072. */
  155073. get reject(): (reason?: any) => void;
  155074. /**
  155075. * Constructor for this deferred object.
  155076. */
  155077. constructor();
  155078. }
  155079. }
  155080. declare module BABYLON {
  155081. /**
  155082. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  155083. */
  155084. export class MeshExploder {
  155085. private _centerMesh;
  155086. private _meshes;
  155087. private _meshesOrigins;
  155088. private _toCenterVectors;
  155089. private _scaledDirection;
  155090. private _newPosition;
  155091. private _centerPosition;
  155092. /**
  155093. * Explodes meshes from a center mesh.
  155094. * @param meshes The meshes to explode.
  155095. * @param centerMesh The mesh to be center of explosion.
  155096. */
  155097. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  155098. private _setCenterMesh;
  155099. /**
  155100. * Get class name
  155101. * @returns "MeshExploder"
  155102. */
  155103. getClassName(): string;
  155104. /**
  155105. * "Exploded meshes"
  155106. * @returns Array of meshes with the centerMesh at index 0.
  155107. */
  155108. getMeshes(): Array<Mesh>;
  155109. /**
  155110. * Explodes meshes giving a specific direction
  155111. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  155112. */
  155113. explode(direction?: number): void;
  155114. }
  155115. }
  155116. declare module BABYLON {
  155117. /**
  155118. * Class used to help managing file picking and drag'n'drop
  155119. */
  155120. export class FilesInput {
  155121. /**
  155122. * List of files ready to be loaded
  155123. */
  155124. static get FilesToLoad(): {
  155125. [key: string]: File;
  155126. };
  155127. /**
  155128. * Callback called when a file is processed
  155129. */
  155130. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  155131. private _engine;
  155132. private _currentScene;
  155133. private _sceneLoadedCallback;
  155134. private _progressCallback;
  155135. private _additionalRenderLoopLogicCallback;
  155136. private _textureLoadingCallback;
  155137. private _startingProcessingFilesCallback;
  155138. private _onReloadCallback;
  155139. private _errorCallback;
  155140. private _elementToMonitor;
  155141. private _sceneFileToLoad;
  155142. private _filesToLoad;
  155143. /**
  155144. * Creates a new FilesInput
  155145. * @param engine defines the rendering engine
  155146. * @param scene defines the hosting scene
  155147. * @param sceneLoadedCallback callback called when scene is loaded
  155148. * @param progressCallback callback called to track progress
  155149. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  155150. * @param textureLoadingCallback callback called when a texture is loading
  155151. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  155152. * @param onReloadCallback callback called when a reload is requested
  155153. * @param errorCallback callback call if an error occurs
  155154. */
  155155. 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>);
  155156. private _dragEnterHandler;
  155157. private _dragOverHandler;
  155158. private _dropHandler;
  155159. /**
  155160. * Calls this function to listen to drag'n'drop events on a specific DOM element
  155161. * @param elementToMonitor defines the DOM element to track
  155162. */
  155163. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  155164. /** Gets the current list of files to load */
  155165. get filesToLoad(): File[];
  155166. /**
  155167. * Release all associated resources
  155168. */
  155169. dispose(): void;
  155170. private renderFunction;
  155171. private drag;
  155172. private drop;
  155173. private _traverseFolder;
  155174. private _processFiles;
  155175. /**
  155176. * Load files from a drop event
  155177. * @param event defines the drop event to use as source
  155178. */
  155179. loadFiles(event: any): void;
  155180. private _processReload;
  155181. /**
  155182. * Reload the current scene from the loaded files
  155183. */
  155184. reload(): void;
  155185. }
  155186. }
  155187. declare module BABYLON {
  155188. /**
  155189. * Defines the root class used to create scene optimization to use with SceneOptimizer
  155190. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155191. */
  155192. export class SceneOptimization {
  155193. /**
  155194. * Defines the priority of this optimization (0 by default which means first in the list)
  155195. */
  155196. priority: number;
  155197. /**
  155198. * Gets a string describing the action executed by the current optimization
  155199. * @returns description string
  155200. */
  155201. getDescription(): string;
  155202. /**
  155203. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155204. * @param scene defines the current scene where to apply this optimization
  155205. * @param optimizer defines the current optimizer
  155206. * @returns true if everything that can be done was applied
  155207. */
  155208. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155209. /**
  155210. * Creates the SceneOptimization object
  155211. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155212. * @param desc defines the description associated with the optimization
  155213. */
  155214. constructor(
  155215. /**
  155216. * Defines the priority of this optimization (0 by default which means first in the list)
  155217. */
  155218. priority?: number);
  155219. }
  155220. /**
  155221. * Defines an optimization used to reduce the size of render target textures
  155222. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155223. */
  155224. export class TextureOptimization extends SceneOptimization {
  155225. /**
  155226. * Defines the priority of this optimization (0 by default which means first in the list)
  155227. */
  155228. priority: number;
  155229. /**
  155230. * 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
  155231. */
  155232. maximumSize: number;
  155233. /**
  155234. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155235. */
  155236. step: number;
  155237. /**
  155238. * Gets a string describing the action executed by the current optimization
  155239. * @returns description string
  155240. */
  155241. getDescription(): string;
  155242. /**
  155243. * Creates the TextureOptimization object
  155244. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155245. * @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
  155246. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155247. */
  155248. constructor(
  155249. /**
  155250. * Defines the priority of this optimization (0 by default which means first in the list)
  155251. */
  155252. priority?: number,
  155253. /**
  155254. * 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
  155255. */
  155256. maximumSize?: number,
  155257. /**
  155258. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155259. */
  155260. step?: number);
  155261. /**
  155262. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155263. * @param scene defines the current scene where to apply this optimization
  155264. * @param optimizer defines the current optimizer
  155265. * @returns true if everything that can be done was applied
  155266. */
  155267. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155268. }
  155269. /**
  155270. * Defines an optimization used to increase or decrease the rendering resolution
  155271. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155272. */
  155273. export class HardwareScalingOptimization extends SceneOptimization {
  155274. /**
  155275. * Defines the priority of this optimization (0 by default which means first in the list)
  155276. */
  155277. priority: number;
  155278. /**
  155279. * Defines the maximum scale to use (2 by default)
  155280. */
  155281. maximumScale: number;
  155282. /**
  155283. * Defines the step to use between two passes (0.5 by default)
  155284. */
  155285. step: number;
  155286. private _currentScale;
  155287. private _directionOffset;
  155288. /**
  155289. * Gets a string describing the action executed by the current optimization
  155290. * @return description string
  155291. */
  155292. getDescription(): string;
  155293. /**
  155294. * Creates the HardwareScalingOptimization object
  155295. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155296. * @param maximumScale defines the maximum scale to use (2 by default)
  155297. * @param step defines the step to use between two passes (0.5 by default)
  155298. */
  155299. constructor(
  155300. /**
  155301. * Defines the priority of this optimization (0 by default which means first in the list)
  155302. */
  155303. priority?: number,
  155304. /**
  155305. * Defines the maximum scale to use (2 by default)
  155306. */
  155307. maximumScale?: number,
  155308. /**
  155309. * Defines the step to use between two passes (0.5 by default)
  155310. */
  155311. step?: number);
  155312. /**
  155313. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155314. * @param scene defines the current scene where to apply this optimization
  155315. * @param optimizer defines the current optimizer
  155316. * @returns true if everything that can be done was applied
  155317. */
  155318. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155319. }
  155320. /**
  155321. * Defines an optimization used to remove shadows
  155322. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155323. */
  155324. export class ShadowsOptimization extends SceneOptimization {
  155325. /**
  155326. * Gets a string describing the action executed by the current optimization
  155327. * @return description string
  155328. */
  155329. getDescription(): string;
  155330. /**
  155331. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155332. * @param scene defines the current scene where to apply this optimization
  155333. * @param optimizer defines the current optimizer
  155334. * @returns true if everything that can be done was applied
  155335. */
  155336. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155337. }
  155338. /**
  155339. * Defines an optimization used to turn post-processes off
  155340. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155341. */
  155342. export class PostProcessesOptimization extends SceneOptimization {
  155343. /**
  155344. * Gets a string describing the action executed by the current optimization
  155345. * @return description string
  155346. */
  155347. getDescription(): string;
  155348. /**
  155349. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155350. * @param scene defines the current scene where to apply this optimization
  155351. * @param optimizer defines the current optimizer
  155352. * @returns true if everything that can be done was applied
  155353. */
  155354. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155355. }
  155356. /**
  155357. * Defines an optimization used to turn lens flares off
  155358. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155359. */
  155360. export class LensFlaresOptimization extends SceneOptimization {
  155361. /**
  155362. * Gets a string describing the action executed by the current optimization
  155363. * @return description string
  155364. */
  155365. getDescription(): string;
  155366. /**
  155367. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155368. * @param scene defines the current scene where to apply this optimization
  155369. * @param optimizer defines the current optimizer
  155370. * @returns true if everything that can be done was applied
  155371. */
  155372. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155373. }
  155374. /**
  155375. * Defines an optimization based on user defined callback.
  155376. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155377. */
  155378. export class CustomOptimization extends SceneOptimization {
  155379. /**
  155380. * Callback called to apply the custom optimization.
  155381. */
  155382. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  155383. /**
  155384. * Callback called to get custom description
  155385. */
  155386. onGetDescription: () => string;
  155387. /**
  155388. * Gets a string describing the action executed by the current optimization
  155389. * @returns description string
  155390. */
  155391. getDescription(): string;
  155392. /**
  155393. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155394. * @param scene defines the current scene where to apply this optimization
  155395. * @param optimizer defines the current optimizer
  155396. * @returns true if everything that can be done was applied
  155397. */
  155398. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155399. }
  155400. /**
  155401. * Defines an optimization used to turn particles off
  155402. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155403. */
  155404. export class ParticlesOptimization extends SceneOptimization {
  155405. /**
  155406. * Gets a string describing the action executed by the current optimization
  155407. * @return description string
  155408. */
  155409. getDescription(): string;
  155410. /**
  155411. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155412. * @param scene defines the current scene where to apply this optimization
  155413. * @param optimizer defines the current optimizer
  155414. * @returns true if everything that can be done was applied
  155415. */
  155416. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155417. }
  155418. /**
  155419. * Defines an optimization used to turn render targets off
  155420. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155421. */
  155422. export class RenderTargetsOptimization extends SceneOptimization {
  155423. /**
  155424. * Gets a string describing the action executed by the current optimization
  155425. * @return description string
  155426. */
  155427. getDescription(): string;
  155428. /**
  155429. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155430. * @param scene defines the current scene where to apply this optimization
  155431. * @param optimizer defines the current optimizer
  155432. * @returns true if everything that can be done was applied
  155433. */
  155434. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155435. }
  155436. /**
  155437. * Defines an optimization used to merge meshes with compatible materials
  155438. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155439. */
  155440. export class MergeMeshesOptimization extends SceneOptimization {
  155441. private static _UpdateSelectionTree;
  155442. /**
  155443. * Gets or sets a boolean which defines if optimization octree has to be updated
  155444. */
  155445. static get UpdateSelectionTree(): boolean;
  155446. /**
  155447. * Gets or sets a boolean which defines if optimization octree has to be updated
  155448. */
  155449. static set UpdateSelectionTree(value: boolean);
  155450. /**
  155451. * Gets a string describing the action executed by the current optimization
  155452. * @return description string
  155453. */
  155454. getDescription(): string;
  155455. private _canBeMerged;
  155456. /**
  155457. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155458. * @param scene defines the current scene where to apply this optimization
  155459. * @param optimizer defines the current optimizer
  155460. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  155461. * @returns true if everything that can be done was applied
  155462. */
  155463. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  155464. }
  155465. /**
  155466. * Defines a list of options used by SceneOptimizer
  155467. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155468. */
  155469. export class SceneOptimizerOptions {
  155470. /**
  155471. * Defines the target frame rate to reach (60 by default)
  155472. */
  155473. targetFrameRate: number;
  155474. /**
  155475. * Defines the interval between two checkes (2000ms by default)
  155476. */
  155477. trackerDuration: number;
  155478. /**
  155479. * Gets the list of optimizations to apply
  155480. */
  155481. optimizations: SceneOptimization[];
  155482. /**
  155483. * Creates a new list of options used by SceneOptimizer
  155484. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  155485. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  155486. */
  155487. constructor(
  155488. /**
  155489. * Defines the target frame rate to reach (60 by default)
  155490. */
  155491. targetFrameRate?: number,
  155492. /**
  155493. * Defines the interval between two checkes (2000ms by default)
  155494. */
  155495. trackerDuration?: number);
  155496. /**
  155497. * Add a new optimization
  155498. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  155499. * @returns the current SceneOptimizerOptions
  155500. */
  155501. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  155502. /**
  155503. * Add a new custom optimization
  155504. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  155505. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  155506. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155507. * @returns the current SceneOptimizerOptions
  155508. */
  155509. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  155510. /**
  155511. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  155512. * @param targetFrameRate defines the target frame rate (60 by default)
  155513. * @returns a SceneOptimizerOptions object
  155514. */
  155515. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155516. /**
  155517. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  155518. * @param targetFrameRate defines the target frame rate (60 by default)
  155519. * @returns a SceneOptimizerOptions object
  155520. */
  155521. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155522. /**
  155523. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  155524. * @param targetFrameRate defines the target frame rate (60 by default)
  155525. * @returns a SceneOptimizerOptions object
  155526. */
  155527. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155528. }
  155529. /**
  155530. * Class used to run optimizations in order to reach a target frame rate
  155531. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155532. */
  155533. export class SceneOptimizer implements IDisposable {
  155534. private _isRunning;
  155535. private _options;
  155536. private _scene;
  155537. private _currentPriorityLevel;
  155538. private _targetFrameRate;
  155539. private _trackerDuration;
  155540. private _currentFrameRate;
  155541. private _sceneDisposeObserver;
  155542. private _improvementMode;
  155543. /**
  155544. * Defines an observable called when the optimizer reaches the target frame rate
  155545. */
  155546. onSuccessObservable: Observable<SceneOptimizer>;
  155547. /**
  155548. * Defines an observable called when the optimizer enables an optimization
  155549. */
  155550. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  155551. /**
  155552. * Defines an observable called when the optimizer is not able to reach the target frame rate
  155553. */
  155554. onFailureObservable: Observable<SceneOptimizer>;
  155555. /**
  155556. * Gets a boolean indicating if the optimizer is in improvement mode
  155557. */
  155558. get isInImprovementMode(): boolean;
  155559. /**
  155560. * Gets the current priority level (0 at start)
  155561. */
  155562. get currentPriorityLevel(): number;
  155563. /**
  155564. * Gets the current frame rate checked by the SceneOptimizer
  155565. */
  155566. get currentFrameRate(): number;
  155567. /**
  155568. * Gets or sets the current target frame rate (60 by default)
  155569. */
  155570. get targetFrameRate(): number;
  155571. /**
  155572. * Gets or sets the current target frame rate (60 by default)
  155573. */
  155574. set targetFrameRate(value: number);
  155575. /**
  155576. * Gets or sets the current interval between two checks (every 2000ms by default)
  155577. */
  155578. get trackerDuration(): number;
  155579. /**
  155580. * Gets or sets the current interval between two checks (every 2000ms by default)
  155581. */
  155582. set trackerDuration(value: number);
  155583. /**
  155584. * Gets the list of active optimizations
  155585. */
  155586. get optimizations(): SceneOptimization[];
  155587. /**
  155588. * Creates a new SceneOptimizer
  155589. * @param scene defines the scene to work on
  155590. * @param options defines the options to use with the SceneOptimizer
  155591. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  155592. * @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)
  155593. */
  155594. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  155595. /**
  155596. * Stops the current optimizer
  155597. */
  155598. stop(): void;
  155599. /**
  155600. * Reset the optimizer to initial step (current priority level = 0)
  155601. */
  155602. reset(): void;
  155603. /**
  155604. * Start the optimizer. By default it will try to reach a specific framerate
  155605. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  155606. */
  155607. start(): void;
  155608. private _checkCurrentState;
  155609. /**
  155610. * Release all resources
  155611. */
  155612. dispose(): void;
  155613. /**
  155614. * Helper function to create a SceneOptimizer with one single line of code
  155615. * @param scene defines the scene to work on
  155616. * @param options defines the options to use with the SceneOptimizer
  155617. * @param onSuccess defines a callback to call on success
  155618. * @param onFailure defines a callback to call on failure
  155619. * @returns the new SceneOptimizer object
  155620. */
  155621. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  155622. }
  155623. }
  155624. declare module BABYLON {
  155625. /**
  155626. * Class used to serialize a scene into a string
  155627. */
  155628. export class SceneSerializer {
  155629. /**
  155630. * Clear cache used by a previous serialization
  155631. */
  155632. static ClearCache(): void;
  155633. /**
  155634. * Serialize a scene into a JSON compatible object
  155635. * @param scene defines the scene to serialize
  155636. * @returns a JSON compatible object
  155637. */
  155638. static Serialize(scene: Scene): any;
  155639. /**
  155640. * Serialize a mesh into a JSON compatible object
  155641. * @param toSerialize defines the mesh to serialize
  155642. * @param withParents defines if parents must be serialized as well
  155643. * @param withChildren defines if children must be serialized as well
  155644. * @returns a JSON compatible object
  155645. */
  155646. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  155647. }
  155648. }
  155649. declare module BABYLON {
  155650. /**
  155651. * Class used to host texture specific utilities
  155652. */
  155653. export class TextureTools {
  155654. /**
  155655. * Uses the GPU to create a copy texture rescaled at a given size
  155656. * @param texture Texture to copy from
  155657. * @param width defines the desired width
  155658. * @param height defines the desired height
  155659. * @param useBilinearMode defines if bilinear mode has to be used
  155660. * @return the generated texture
  155661. */
  155662. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  155663. }
  155664. }
  155665. declare module BABYLON {
  155666. /**
  155667. * This represents the different options available for the video capture.
  155668. */
  155669. export interface VideoRecorderOptions {
  155670. /** Defines the mime type of the video. */
  155671. mimeType: string;
  155672. /** Defines the FPS the video should be recorded at. */
  155673. fps: number;
  155674. /** Defines the chunk size for the recording data. */
  155675. recordChunckSize: number;
  155676. /** The audio tracks to attach to the recording. */
  155677. audioTracks?: MediaStreamTrack[];
  155678. }
  155679. /**
  155680. * This can help with recording videos from BabylonJS.
  155681. * This is based on the available WebRTC functionalities of the browser.
  155682. *
  155683. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  155684. */
  155685. export class VideoRecorder {
  155686. private static readonly _defaultOptions;
  155687. /**
  155688. * Returns whether or not the VideoRecorder is available in your browser.
  155689. * @param engine Defines the Babylon Engine.
  155690. * @returns true if supported otherwise false.
  155691. */
  155692. static IsSupported(engine: Engine): boolean;
  155693. private readonly _options;
  155694. private _canvas;
  155695. private _mediaRecorder;
  155696. private _recordedChunks;
  155697. private _fileName;
  155698. private _resolve;
  155699. private _reject;
  155700. /**
  155701. * True when a recording is already in progress.
  155702. */
  155703. get isRecording(): boolean;
  155704. /**
  155705. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  155706. * @param engine Defines the BabylonJS Engine you wish to record.
  155707. * @param options Defines options that can be used to customize the capture.
  155708. */
  155709. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  155710. /**
  155711. * Stops the current recording before the default capture timeout passed in the startRecording function.
  155712. */
  155713. stopRecording(): void;
  155714. /**
  155715. * Starts recording the canvas for a max duration specified in parameters.
  155716. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  155717. * If null no automatic download will start and you can rely on the promise to get the data back.
  155718. * @param maxDuration Defines the maximum recording time in seconds.
  155719. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  155720. * @return A promise callback at the end of the recording with the video data in Blob.
  155721. */
  155722. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  155723. /**
  155724. * Releases internal resources used during the recording.
  155725. */
  155726. dispose(): void;
  155727. private _handleDataAvailable;
  155728. private _handleError;
  155729. private _handleStop;
  155730. }
  155731. }
  155732. declare module BABYLON {
  155733. /**
  155734. * Class containing a set of static utilities functions for screenshots
  155735. */
  155736. export class ScreenshotTools {
  155737. /**
  155738. * Captures a screenshot of the current rendering
  155739. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155740. * @param engine defines the rendering engine
  155741. * @param camera defines the source camera
  155742. * @param size This parameter can be set to a single number or to an object with the
  155743. * following (optional) properties: precision, width, height. If a single number is passed,
  155744. * it will be used for both width and height. If an object is passed, the screenshot size
  155745. * will be derived from the parameters. The precision property is a multiplier allowing
  155746. * rendering at a higher or lower resolution
  155747. * @param successCallback defines the callback receives a single parameter which contains the
  155748. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155749. * src parameter of an <img> to display it
  155750. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155751. * Check your browser for supported MIME types
  155752. */
  155753. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  155754. /**
  155755. * Captures a screenshot of the current rendering
  155756. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155757. * @param engine defines the rendering engine
  155758. * @param camera defines the source camera
  155759. * @param size This parameter can be set to a single number or to an object with the
  155760. * following (optional) properties: precision, width, height. If a single number is passed,
  155761. * it will be used for both width and height. If an object is passed, the screenshot size
  155762. * will be derived from the parameters. The precision property is a multiplier allowing
  155763. * rendering at a higher or lower resolution
  155764. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155765. * Check your browser for supported MIME types
  155766. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155767. * to the src parameter of an <img> to display it
  155768. */
  155769. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  155770. /**
  155771. * Generates an image screenshot from the specified camera.
  155772. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155773. * @param engine The engine to use for rendering
  155774. * @param camera The camera to use for rendering
  155775. * @param size This parameter can be set to a single number or to an object with the
  155776. * following (optional) properties: precision, width, height. If a single number is passed,
  155777. * it will be used for both width and height. If an object is passed, the screenshot size
  155778. * will be derived from the parameters. The precision property is a multiplier allowing
  155779. * rendering at a higher or lower resolution
  155780. * @param successCallback The callback receives a single parameter which contains the
  155781. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155782. * src parameter of an <img> to display it
  155783. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155784. * Check your browser for supported MIME types
  155785. * @param samples Texture samples (default: 1)
  155786. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155787. * @param fileName A name for for the downloaded file.
  155788. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155789. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  155790. */
  155791. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  155792. /**
  155793. * Generates an image screenshot from the specified camera.
  155794. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155795. * @param engine The engine to use for rendering
  155796. * @param camera The camera to use for rendering
  155797. * @param size This parameter can be set to a single number or to an object with the
  155798. * following (optional) properties: precision, width, height. If a single number is passed,
  155799. * it will be used for both width and height. If an object is passed, the screenshot size
  155800. * will be derived from the parameters. The precision property is a multiplier allowing
  155801. * rendering at a higher or lower resolution
  155802. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155803. * Check your browser for supported MIME types
  155804. * @param samples Texture samples (default: 1)
  155805. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155806. * @param fileName A name for for the downloaded file.
  155807. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155808. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155809. * to the src parameter of an <img> to display it
  155810. */
  155811. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  155812. /**
  155813. * Gets height and width for screenshot size
  155814. * @private
  155815. */
  155816. private static _getScreenshotSize;
  155817. }
  155818. }
  155819. declare module BABYLON {
  155820. /**
  155821. * Interface for a data buffer
  155822. */
  155823. export interface IDataBuffer {
  155824. /**
  155825. * Reads bytes from the data buffer.
  155826. * @param byteOffset The byte offset to read
  155827. * @param byteLength The byte length to read
  155828. * @returns A promise that resolves when the bytes are read
  155829. */
  155830. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  155831. /**
  155832. * The byte length of the buffer.
  155833. */
  155834. readonly byteLength: number;
  155835. }
  155836. /**
  155837. * Utility class for reading from a data buffer
  155838. */
  155839. export class DataReader {
  155840. /**
  155841. * The data buffer associated with this data reader.
  155842. */
  155843. readonly buffer: IDataBuffer;
  155844. /**
  155845. * The current byte offset from the beginning of the data buffer.
  155846. */
  155847. byteOffset: number;
  155848. private _dataView;
  155849. private _dataByteOffset;
  155850. /**
  155851. * Constructor
  155852. * @param buffer The buffer to read
  155853. */
  155854. constructor(buffer: IDataBuffer);
  155855. /**
  155856. * Loads the given byte length.
  155857. * @param byteLength The byte length to load
  155858. * @returns A promise that resolves when the load is complete
  155859. */
  155860. loadAsync(byteLength: number): Promise<void>;
  155861. /**
  155862. * Read a unsigned 32-bit integer from the currently loaded data range.
  155863. * @returns The 32-bit integer read
  155864. */
  155865. readUint32(): number;
  155866. /**
  155867. * Read a byte array from the currently loaded data range.
  155868. * @param byteLength The byte length to read
  155869. * @returns The byte array read
  155870. */
  155871. readUint8Array(byteLength: number): Uint8Array;
  155872. /**
  155873. * Read a string from the currently loaded data range.
  155874. * @param byteLength The byte length to read
  155875. * @returns The string read
  155876. */
  155877. readString(byteLength: number): string;
  155878. /**
  155879. * Skips the given byte length the currently loaded data range.
  155880. * @param byteLength The byte length to skip
  155881. */
  155882. skipBytes(byteLength: number): void;
  155883. }
  155884. }
  155885. declare module BABYLON {
  155886. /**
  155887. * Class for storing data to local storage if available or in-memory storage otherwise
  155888. */
  155889. export class DataStorage {
  155890. private static _Storage;
  155891. private static _GetStorage;
  155892. /**
  155893. * Reads a string from the data storage
  155894. * @param key The key to read
  155895. * @param defaultValue The value if the key doesn't exist
  155896. * @returns The string value
  155897. */
  155898. static ReadString(key: string, defaultValue: string): string;
  155899. /**
  155900. * Writes a string to the data storage
  155901. * @param key The key to write
  155902. * @param value The value to write
  155903. */
  155904. static WriteString(key: string, value: string): void;
  155905. /**
  155906. * Reads a boolean from the data storage
  155907. * @param key The key to read
  155908. * @param defaultValue The value if the key doesn't exist
  155909. * @returns The boolean value
  155910. */
  155911. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  155912. /**
  155913. * Writes a boolean to the data storage
  155914. * @param key The key to write
  155915. * @param value The value to write
  155916. */
  155917. static WriteBoolean(key: string, value: boolean): void;
  155918. /**
  155919. * Reads a number from the data storage
  155920. * @param key The key to read
  155921. * @param defaultValue The value if the key doesn't exist
  155922. * @returns The number value
  155923. */
  155924. static ReadNumber(key: string, defaultValue: number): number;
  155925. /**
  155926. * Writes a number to the data storage
  155927. * @param key The key to write
  155928. * @param value The value to write
  155929. */
  155930. static WriteNumber(key: string, value: number): void;
  155931. }
  155932. }
  155933. declare module BABYLON {
  155934. /**
  155935. * Class used to record delta files between 2 scene states
  155936. */
  155937. export class SceneRecorder {
  155938. private _trackedScene;
  155939. private _savedJSON;
  155940. /**
  155941. * Track a given scene. This means the current scene state will be considered the original state
  155942. * @param scene defines the scene to track
  155943. */
  155944. track(scene: Scene): void;
  155945. /**
  155946. * Get the delta between current state and original state
  155947. * @returns a string containing the delta
  155948. */
  155949. getDelta(): any;
  155950. private _compareArray;
  155951. private _compareObjects;
  155952. private _compareCollections;
  155953. private static GetShadowGeneratorById;
  155954. /**
  155955. * Apply a given delta to a given scene
  155956. * @param deltaJSON defines the JSON containing the delta
  155957. * @param scene defines the scene to apply the delta to
  155958. */
  155959. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  155960. private static _ApplyPropertiesToEntity;
  155961. private static _ApplyDeltaForEntity;
  155962. }
  155963. }
  155964. declare module BABYLON {
  155965. /**
  155966. * A 3D trajectory consisting of an order list of vectors describing a
  155967. * path of motion through 3D space.
  155968. */
  155969. export class Trajectory {
  155970. private _points;
  155971. private readonly _segmentLength;
  155972. /**
  155973. * Serialize to JSON.
  155974. * @returns serialized JSON string
  155975. */
  155976. serialize(): string;
  155977. /**
  155978. * Deserialize from JSON.
  155979. * @param json serialized JSON string
  155980. * @returns deserialized Trajectory
  155981. */
  155982. static Deserialize(json: string): Trajectory;
  155983. /**
  155984. * Create a new empty Trajectory.
  155985. * @param segmentLength radius of discretization for Trajectory points
  155986. */
  155987. constructor(segmentLength?: number);
  155988. /**
  155989. * Get the length of the Trajectory.
  155990. * @returns length of the Trajectory
  155991. */
  155992. getLength(): number;
  155993. /**
  155994. * Append a new point to the Trajectory.
  155995. * NOTE: This implementation has many allocations.
  155996. * @param point point to append to the Trajectory
  155997. */
  155998. add(point: DeepImmutable<Vector3>): void;
  155999. /**
  156000. * Create a new Trajectory with a segment length chosen to make it
  156001. * probable that the new Trajectory will have a specified number of
  156002. * segments. This operation is imprecise.
  156003. * @param targetResolution number of segments desired
  156004. * @returns new Trajectory with approximately the requested number of segments
  156005. */
  156006. resampleAtTargetResolution(targetResolution: number): Trajectory;
  156007. /**
  156008. * Convert Trajectory segments into tokenized representation. This
  156009. * representation is an array of numbers where each nth number is the
  156010. * index of the token which is most similar to the nth segment of the
  156011. * Trajectory.
  156012. * @param tokens list of vectors which serve as discrete tokens
  156013. * @returns list of indices of most similar token per segment
  156014. */
  156015. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  156016. private static _forwardDir;
  156017. private static _inverseFromVec;
  156018. private static _upDir;
  156019. private static _fromToVec;
  156020. private static _lookMatrix;
  156021. /**
  156022. * Transform the rotation (i.e., direction) of a segment to isolate
  156023. * the relative transformation represented by the segment. This operation
  156024. * may or may not succeed due to singularities in the equations that define
  156025. * motion relativity in this context.
  156026. * @param priorVec the origin of the prior segment
  156027. * @param fromVec the origin of the current segment
  156028. * @param toVec the destination of the current segment
  156029. * @param result reference to output variable
  156030. * @returns whether or not transformation was successful
  156031. */
  156032. private static _transformSegmentDirToRef;
  156033. private static _bestMatch;
  156034. private static _score;
  156035. private static _bestScore;
  156036. /**
  156037. * Determine which token vector is most similar to the
  156038. * segment vector.
  156039. * @param segment segment vector
  156040. * @param tokens token vector list
  156041. * @returns index of the most similar token to the segment
  156042. */
  156043. private static _tokenizeSegment;
  156044. }
  156045. /**
  156046. * Class representing a set of known, named trajectories to which Trajectories can be
  156047. * added and using which Trajectories can be recognized.
  156048. */
  156049. export class TrajectoryClassifier {
  156050. private _maximumAllowableMatchCost;
  156051. private _vector3Alphabet;
  156052. private _levenshteinAlphabet;
  156053. private _nameToDescribedTrajectory;
  156054. /**
  156055. * Serialize to JSON.
  156056. * @returns JSON serialization
  156057. */
  156058. serialize(): string;
  156059. /**
  156060. * Deserialize from JSON.
  156061. * @param json JSON serialization
  156062. * @returns deserialized TrajectorySet
  156063. */
  156064. static Deserialize(json: string): TrajectoryClassifier;
  156065. /**
  156066. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  156067. * VERY naive, need to be generating these things from known
  156068. * sets. Better version later, probably eliminating this one.
  156069. * @returns auto-generated TrajectorySet
  156070. */
  156071. static Generate(): TrajectoryClassifier;
  156072. private constructor();
  156073. /**
  156074. * Add a new Trajectory to the set with a given name.
  156075. * @param trajectory new Trajectory to be added
  156076. * @param classification name to which to add the Trajectory
  156077. */
  156078. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  156079. /**
  156080. * Remove a known named trajectory and all Trajectories associated with it.
  156081. * @param classification name to remove
  156082. * @returns whether anything was removed
  156083. */
  156084. deleteClassification(classification: string): boolean;
  156085. /**
  156086. * Attempt to recognize a Trajectory from among all the classifications
  156087. * already known to the classifier.
  156088. * @param trajectory Trajectory to be recognized
  156089. * @returns classification of Trajectory if recognized, null otherwise
  156090. */
  156091. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  156092. }
  156093. }
  156094. declare module BABYLON {
  156095. /**
  156096. * An interface for all Hit test features
  156097. */
  156098. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  156099. /**
  156100. * Triggered when new babylon (transformed) hit test results are available
  156101. */
  156102. onHitTestResultObservable: Observable<T[]>;
  156103. }
  156104. /**
  156105. * Options used for hit testing
  156106. */
  156107. export interface IWebXRLegacyHitTestOptions {
  156108. /**
  156109. * Only test when user interacted with the scene. Default - hit test every frame
  156110. */
  156111. testOnPointerDownOnly?: boolean;
  156112. /**
  156113. * The node to use to transform the local results to world coordinates
  156114. */
  156115. worldParentNode?: TransformNode;
  156116. }
  156117. /**
  156118. * Interface defining the babylon result of raycasting/hit-test
  156119. */
  156120. export interface IWebXRLegacyHitResult {
  156121. /**
  156122. * Transformation matrix that can be applied to a node that will put it in the hit point location
  156123. */
  156124. transformationMatrix: Matrix;
  156125. /**
  156126. * The native hit test result
  156127. */
  156128. xrHitResult: XRHitResult | XRHitTestResult;
  156129. }
  156130. /**
  156131. * The currently-working hit-test module.
  156132. * Hit test (or Ray-casting) is used to interact with the real world.
  156133. * For further information read here - https://github.com/immersive-web/hit-test
  156134. */
  156135. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  156136. /**
  156137. * options to use when constructing this feature
  156138. */
  156139. readonly options: IWebXRLegacyHitTestOptions;
  156140. private _direction;
  156141. private _mat;
  156142. private _onSelectEnabled;
  156143. private _origin;
  156144. /**
  156145. * The module's name
  156146. */
  156147. static readonly Name: string;
  156148. /**
  156149. * The (Babylon) version of this module.
  156150. * This is an integer representing the implementation version.
  156151. * This number does not correspond to the WebXR specs version
  156152. */
  156153. static readonly Version: number;
  156154. /**
  156155. * Populated with the last native XR Hit Results
  156156. */
  156157. lastNativeXRHitResults: XRHitResult[];
  156158. /**
  156159. * Triggered when new babylon (transformed) hit test results are available
  156160. */
  156161. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  156162. /**
  156163. * Creates a new instance of the (legacy version) hit test feature
  156164. * @param _xrSessionManager an instance of WebXRSessionManager
  156165. * @param options options to use when constructing this feature
  156166. */
  156167. constructor(_xrSessionManager: WebXRSessionManager,
  156168. /**
  156169. * options to use when constructing this feature
  156170. */
  156171. options?: IWebXRLegacyHitTestOptions);
  156172. /**
  156173. * execute a hit test with an XR Ray
  156174. *
  156175. * @param xrSession a native xrSession that will execute this hit test
  156176. * @param xrRay the ray (position and direction) to use for ray-casting
  156177. * @param referenceSpace native XR reference space to use for the hit-test
  156178. * @param filter filter function that will filter the results
  156179. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  156180. */
  156181. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  156182. /**
  156183. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  156184. * @param event the (select) event to use to select with
  156185. * @param referenceSpace the reference space to use for this hit test
  156186. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  156187. */
  156188. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  156189. /**
  156190. * attach this feature
  156191. * Will usually be called by the features manager
  156192. *
  156193. * @returns true if successful.
  156194. */
  156195. attach(): boolean;
  156196. /**
  156197. * detach this feature.
  156198. * Will usually be called by the features manager
  156199. *
  156200. * @returns true if successful.
  156201. */
  156202. detach(): boolean;
  156203. /**
  156204. * Dispose this feature and all of the resources attached
  156205. */
  156206. dispose(): void;
  156207. protected _onXRFrame(frame: XRFrame): void;
  156208. private _onHitTestResults;
  156209. private _onSelect;
  156210. }
  156211. }
  156212. declare module BABYLON {
  156213. /**
  156214. * Options used for hit testing (version 2)
  156215. */
  156216. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  156217. /**
  156218. * Do not create a permanent hit test. Will usually be used when only
  156219. * transient inputs are needed.
  156220. */
  156221. disablePermanentHitTest?: boolean;
  156222. /**
  156223. * Enable transient (for example touch-based) hit test inspections
  156224. */
  156225. enableTransientHitTest?: boolean;
  156226. /**
  156227. * Offset ray for the permanent hit test
  156228. */
  156229. offsetRay?: Vector3;
  156230. /**
  156231. * Offset ray for the transient hit test
  156232. */
  156233. transientOffsetRay?: Vector3;
  156234. /**
  156235. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  156236. */
  156237. useReferenceSpace?: boolean;
  156238. /**
  156239. * Override the default entity type(s) of the hit-test result
  156240. */
  156241. entityTypes?: XRHitTestTrackableType[];
  156242. }
  156243. /**
  156244. * Interface defining the babylon result of hit-test
  156245. */
  156246. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  156247. /**
  156248. * The input source that generated this hit test (if transient)
  156249. */
  156250. inputSource?: XRInputSource;
  156251. /**
  156252. * Is this a transient hit test
  156253. */
  156254. isTransient?: boolean;
  156255. /**
  156256. * Position of the hit test result
  156257. */
  156258. position: Vector3;
  156259. /**
  156260. * Rotation of the hit test result
  156261. */
  156262. rotationQuaternion: Quaternion;
  156263. /**
  156264. * The native hit test result
  156265. */
  156266. xrHitResult: XRHitTestResult;
  156267. }
  156268. /**
  156269. * The currently-working hit-test module.
  156270. * Hit test (or Ray-casting) is used to interact with the real world.
  156271. * For further information read here - https://github.com/immersive-web/hit-test
  156272. *
  156273. * Tested on chrome (mobile) 80.
  156274. */
  156275. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  156276. /**
  156277. * options to use when constructing this feature
  156278. */
  156279. readonly options: IWebXRHitTestOptions;
  156280. private _tmpMat;
  156281. private _tmpPos;
  156282. private _tmpQuat;
  156283. private _transientXrHitTestSource;
  156284. private _xrHitTestSource;
  156285. private initHitTestSource;
  156286. /**
  156287. * The module's name
  156288. */
  156289. static readonly Name: string;
  156290. /**
  156291. * The (Babylon) version of this module.
  156292. * This is an integer representing the implementation version.
  156293. * This number does not correspond to the WebXR specs version
  156294. */
  156295. static readonly Version: number;
  156296. /**
  156297. * When set to true, each hit test will have its own position/rotation objects
  156298. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  156299. * the developers will clone them or copy them as they see fit.
  156300. */
  156301. autoCloneTransformation: boolean;
  156302. /**
  156303. * Triggered when new babylon (transformed) hit test results are available
  156304. * Note - this will be called when results come back from the device. It can be an empty array!!
  156305. */
  156306. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  156307. /**
  156308. * Use this to temporarily pause hit test checks.
  156309. */
  156310. paused: boolean;
  156311. /**
  156312. * Creates a new instance of the hit test feature
  156313. * @param _xrSessionManager an instance of WebXRSessionManager
  156314. * @param options options to use when constructing this feature
  156315. */
  156316. constructor(_xrSessionManager: WebXRSessionManager,
  156317. /**
  156318. * options to use when constructing this feature
  156319. */
  156320. options?: IWebXRHitTestOptions);
  156321. /**
  156322. * attach this feature
  156323. * Will usually be called by the features manager
  156324. *
  156325. * @returns true if successful.
  156326. */
  156327. attach(): boolean;
  156328. /**
  156329. * detach this feature.
  156330. * Will usually be called by the features manager
  156331. *
  156332. * @returns true if successful.
  156333. */
  156334. detach(): boolean;
  156335. /**
  156336. * Dispose this feature and all of the resources attached
  156337. */
  156338. dispose(): void;
  156339. protected _onXRFrame(frame: XRFrame): void;
  156340. private _processWebXRHitTestResult;
  156341. }
  156342. }
  156343. declare module BABYLON {
  156344. /**
  156345. * Configuration options of the anchor system
  156346. */
  156347. export interface IWebXRAnchorSystemOptions {
  156348. /**
  156349. * a node that will be used to convert local to world coordinates
  156350. */
  156351. worldParentNode?: TransformNode;
  156352. /**
  156353. * If set to true a reference of the created anchors will be kept until the next session starts
  156354. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  156355. */
  156356. doNotRemoveAnchorsOnSessionEnded?: boolean;
  156357. }
  156358. /**
  156359. * A babylon container for an XR Anchor
  156360. */
  156361. export interface IWebXRAnchor {
  156362. /**
  156363. * A babylon-assigned ID for this anchor
  156364. */
  156365. id: number;
  156366. /**
  156367. * Transformation matrix to apply to an object attached to this anchor
  156368. */
  156369. transformationMatrix: Matrix;
  156370. /**
  156371. * The native anchor object
  156372. */
  156373. xrAnchor: XRAnchor;
  156374. /**
  156375. * if defined, this object will be constantly updated by the anchor's position and rotation
  156376. */
  156377. attachedNode?: TransformNode;
  156378. }
  156379. /**
  156380. * An implementation of the anchor system for WebXR.
  156381. * For further information see https://github.com/immersive-web/anchors/
  156382. */
  156383. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  156384. private _options;
  156385. private _lastFrameDetected;
  156386. private _trackedAnchors;
  156387. private _referenceSpaceForFrameAnchors;
  156388. private _futureAnchors;
  156389. /**
  156390. * The module's name
  156391. */
  156392. static readonly Name: string;
  156393. /**
  156394. * The (Babylon) version of this module.
  156395. * This is an integer representing the implementation version.
  156396. * This number does not correspond to the WebXR specs version
  156397. */
  156398. static readonly Version: number;
  156399. /**
  156400. * Observers registered here will be executed when a new anchor was added to the session
  156401. */
  156402. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  156403. /**
  156404. * Observers registered here will be executed when an anchor was removed from the session
  156405. */
  156406. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  156407. /**
  156408. * Observers registered here will be executed when an existing anchor updates
  156409. * This can execute N times every frame
  156410. */
  156411. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  156412. /**
  156413. * Set the reference space to use for anchor creation, when not using a hit test.
  156414. * Will default to the session's reference space if not defined
  156415. */
  156416. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  156417. /**
  156418. * constructs a new anchor system
  156419. * @param _xrSessionManager an instance of WebXRSessionManager
  156420. * @param _options configuration object for this feature
  156421. */
  156422. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  156423. private _tmpVector;
  156424. private _tmpQuaternion;
  156425. private _populateTmpTransformation;
  156426. /**
  156427. * Create a new anchor point using a hit test result at a specific point in the scene
  156428. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  156429. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  156430. *
  156431. * @param hitTestResult The hit test result to use for this anchor creation
  156432. * @param position an optional position offset for this anchor
  156433. * @param rotationQuaternion an optional rotation offset for this anchor
  156434. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  156435. */
  156436. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  156437. /**
  156438. * Add a new anchor at a specific position and rotation
  156439. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  156440. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  156441. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  156442. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  156443. *
  156444. * @param position the position in which to add an anchor
  156445. * @param rotationQuaternion an optional rotation for the anchor transformation
  156446. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  156447. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  156448. */
  156449. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  156450. /**
  156451. * detach this feature.
  156452. * Will usually be called by the features manager
  156453. *
  156454. * @returns true if successful.
  156455. */
  156456. detach(): boolean;
  156457. /**
  156458. * Dispose this feature and all of the resources attached
  156459. */
  156460. dispose(): void;
  156461. protected _onXRFrame(frame: XRFrame): void;
  156462. /**
  156463. * avoiding using Array.find for global support.
  156464. * @param xrAnchor the plane to find in the array
  156465. */
  156466. private _findIndexInAnchorArray;
  156467. private _updateAnchorWithXRFrame;
  156468. private _createAnchorAtTransformation;
  156469. }
  156470. }
  156471. declare module BABYLON {
  156472. /**
  156473. * Options used in the plane detector module
  156474. */
  156475. export interface IWebXRPlaneDetectorOptions {
  156476. /**
  156477. * The node to use to transform the local results to world coordinates
  156478. */
  156479. worldParentNode?: TransformNode;
  156480. /**
  156481. * If set to true a reference of the created planes will be kept until the next session starts
  156482. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  156483. */
  156484. doNotRemovePlanesOnSessionEnded?: boolean;
  156485. }
  156486. /**
  156487. * A babylon interface for a WebXR plane.
  156488. * A Plane is actually a polygon, built from N points in space
  156489. *
  156490. * Supported in chrome 79, not supported in canary 81 ATM
  156491. */
  156492. export interface IWebXRPlane {
  156493. /**
  156494. * a babylon-assigned ID for this polygon
  156495. */
  156496. id: number;
  156497. /**
  156498. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  156499. */
  156500. polygonDefinition: Array<Vector3>;
  156501. /**
  156502. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  156503. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  156504. */
  156505. transformationMatrix: Matrix;
  156506. /**
  156507. * the native xr-plane object
  156508. */
  156509. xrPlane: XRPlane;
  156510. }
  156511. /**
  156512. * The plane detector is used to detect planes in the real world when in AR
  156513. * For more information see https://github.com/immersive-web/real-world-geometry/
  156514. */
  156515. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  156516. private _options;
  156517. private _detectedPlanes;
  156518. private _enabled;
  156519. private _lastFrameDetected;
  156520. /**
  156521. * The module's name
  156522. */
  156523. static readonly Name: string;
  156524. /**
  156525. * The (Babylon) version of this module.
  156526. * This is an integer representing the implementation version.
  156527. * This number does not correspond to the WebXR specs version
  156528. */
  156529. static readonly Version: number;
  156530. /**
  156531. * Observers registered here will be executed when a new plane was added to the session
  156532. */
  156533. onPlaneAddedObservable: Observable<IWebXRPlane>;
  156534. /**
  156535. * Observers registered here will be executed when a plane is no longer detected in the session
  156536. */
  156537. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  156538. /**
  156539. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  156540. * This can execute N times every frame
  156541. */
  156542. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  156543. /**
  156544. * construct a new Plane Detector
  156545. * @param _xrSessionManager an instance of xr Session manager
  156546. * @param _options configuration to use when constructing this feature
  156547. */
  156548. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  156549. /**
  156550. * detach this feature.
  156551. * Will usually be called by the features manager
  156552. *
  156553. * @returns true if successful.
  156554. */
  156555. detach(): boolean;
  156556. /**
  156557. * Dispose this feature and all of the resources attached
  156558. */
  156559. dispose(): void;
  156560. protected _onXRFrame(frame: XRFrame): void;
  156561. private _init;
  156562. private _updatePlaneWithXRPlane;
  156563. /**
  156564. * avoiding using Array.find for global support.
  156565. * @param xrPlane the plane to find in the array
  156566. */
  156567. private findIndexInPlaneArray;
  156568. }
  156569. }
  156570. declare module BABYLON {
  156571. /**
  156572. * Options interface for the background remover plugin
  156573. */
  156574. export interface IWebXRBackgroundRemoverOptions {
  156575. /**
  156576. * Further background meshes to disable when entering AR
  156577. */
  156578. backgroundMeshes?: AbstractMesh[];
  156579. /**
  156580. * flags to configure the removal of the environment helper.
  156581. * If not set, the entire background will be removed. If set, flags should be set as well.
  156582. */
  156583. environmentHelperRemovalFlags?: {
  156584. /**
  156585. * Should the skybox be removed (default false)
  156586. */
  156587. skyBox?: boolean;
  156588. /**
  156589. * Should the ground be removed (default false)
  156590. */
  156591. ground?: boolean;
  156592. };
  156593. /**
  156594. * don't disable the environment helper
  156595. */
  156596. ignoreEnvironmentHelper?: boolean;
  156597. }
  156598. /**
  156599. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  156600. */
  156601. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  156602. /**
  156603. * read-only options to be used in this module
  156604. */
  156605. readonly options: IWebXRBackgroundRemoverOptions;
  156606. /**
  156607. * The module's name
  156608. */
  156609. static readonly Name: string;
  156610. /**
  156611. * The (Babylon) version of this module.
  156612. * This is an integer representing the implementation version.
  156613. * This number does not correspond to the WebXR specs version
  156614. */
  156615. static readonly Version: number;
  156616. /**
  156617. * registered observers will be triggered when the background state changes
  156618. */
  156619. onBackgroundStateChangedObservable: Observable<boolean>;
  156620. /**
  156621. * constructs a new background remover module
  156622. * @param _xrSessionManager the session manager for this module
  156623. * @param options read-only options to be used in this module
  156624. */
  156625. constructor(_xrSessionManager: WebXRSessionManager,
  156626. /**
  156627. * read-only options to be used in this module
  156628. */
  156629. options?: IWebXRBackgroundRemoverOptions);
  156630. /**
  156631. * attach this feature
  156632. * Will usually be called by the features manager
  156633. *
  156634. * @returns true if successful.
  156635. */
  156636. attach(): boolean;
  156637. /**
  156638. * detach this feature.
  156639. * Will usually be called by the features manager
  156640. *
  156641. * @returns true if successful.
  156642. */
  156643. detach(): boolean;
  156644. /**
  156645. * Dispose this feature and all of the resources attached
  156646. */
  156647. dispose(): void;
  156648. protected _onXRFrame(_xrFrame: XRFrame): void;
  156649. private _setBackgroundState;
  156650. }
  156651. }
  156652. declare module BABYLON {
  156653. /**
  156654. * Options for the controller physics feature
  156655. */
  156656. export class IWebXRControllerPhysicsOptions {
  156657. /**
  156658. * Should the headset get its own impostor
  156659. */
  156660. enableHeadsetImpostor?: boolean;
  156661. /**
  156662. * Optional parameters for the headset impostor
  156663. */
  156664. headsetImpostorParams?: {
  156665. /**
  156666. * The type of impostor to create. Default is sphere
  156667. */
  156668. impostorType: number;
  156669. /**
  156670. * the size of the impostor. Defaults to 10cm
  156671. */
  156672. impostorSize?: number | {
  156673. width: number;
  156674. height: number;
  156675. depth: number;
  156676. };
  156677. /**
  156678. * Friction definitions
  156679. */
  156680. friction?: number;
  156681. /**
  156682. * Restitution
  156683. */
  156684. restitution?: number;
  156685. };
  156686. /**
  156687. * The physics properties of the future impostors
  156688. */
  156689. physicsProperties?: {
  156690. /**
  156691. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  156692. * Note that this requires a physics engine that supports mesh impostors!
  156693. */
  156694. useControllerMesh?: boolean;
  156695. /**
  156696. * The type of impostor to create. Default is sphere
  156697. */
  156698. impostorType?: number;
  156699. /**
  156700. * the size of the impostor. Defaults to 10cm
  156701. */
  156702. impostorSize?: number | {
  156703. width: number;
  156704. height: number;
  156705. depth: number;
  156706. };
  156707. /**
  156708. * Friction definitions
  156709. */
  156710. friction?: number;
  156711. /**
  156712. * Restitution
  156713. */
  156714. restitution?: number;
  156715. };
  156716. /**
  156717. * the xr input to use with this pointer selection
  156718. */
  156719. xrInput: WebXRInput;
  156720. }
  156721. /**
  156722. * Add physics impostor to your webxr controllers,
  156723. * including naive calculation of their linear and angular velocity
  156724. */
  156725. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  156726. private readonly _options;
  156727. private _attachController;
  156728. private _controllers;
  156729. private _debugMode;
  156730. private _delta;
  156731. private _headsetImpostor?;
  156732. private _headsetMesh?;
  156733. private _lastTimestamp;
  156734. private _tmpQuaternion;
  156735. private _tmpVector;
  156736. /**
  156737. * The module's name
  156738. */
  156739. static readonly Name: string;
  156740. /**
  156741. * The (Babylon) version of this module.
  156742. * This is an integer representing the implementation version.
  156743. * This number does not correspond to the webxr specs version
  156744. */
  156745. static readonly Version: number;
  156746. /**
  156747. * Construct a new Controller Physics Feature
  156748. * @param _xrSessionManager the corresponding xr session manager
  156749. * @param _options options to create this feature with
  156750. */
  156751. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  156752. /**
  156753. * @hidden
  156754. * enable debugging - will show console outputs and the impostor mesh
  156755. */
  156756. _enablePhysicsDebug(): void;
  156757. /**
  156758. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  156759. * @param xrController the controller to add
  156760. */
  156761. addController(xrController: WebXRInputSource): void;
  156762. /**
  156763. * attach this feature
  156764. * Will usually be called by the features manager
  156765. *
  156766. * @returns true if successful.
  156767. */
  156768. attach(): boolean;
  156769. /**
  156770. * detach this feature.
  156771. * Will usually be called by the features manager
  156772. *
  156773. * @returns true if successful.
  156774. */
  156775. detach(): boolean;
  156776. /**
  156777. * Get the headset impostor, if enabled
  156778. * @returns the impostor
  156779. */
  156780. getHeadsetImpostor(): PhysicsImpostor | undefined;
  156781. /**
  156782. * Get the physics impostor of a specific controller.
  156783. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  156784. * @param controller the controller or the controller id of which to get the impostor
  156785. * @returns the impostor or null
  156786. */
  156787. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  156788. /**
  156789. * Update the physics properties provided in the constructor
  156790. * @param newProperties the new properties object
  156791. */
  156792. setPhysicsProperties(newProperties: {
  156793. impostorType?: number;
  156794. impostorSize?: number | {
  156795. width: number;
  156796. height: number;
  156797. depth: number;
  156798. };
  156799. friction?: number;
  156800. restitution?: number;
  156801. }): void;
  156802. protected _onXRFrame(_xrFrame: any): void;
  156803. private _detachController;
  156804. }
  156805. }
  156806. declare module BABYLON {
  156807. /**
  156808. * A babylon interface for a "WebXR" feature point.
  156809. * Represents the position and confidence value of a given feature point.
  156810. */
  156811. export interface IWebXRFeaturePoint {
  156812. /**
  156813. * Represents the position of the feature point in world space.
  156814. */
  156815. position: Vector3;
  156816. /**
  156817. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  156818. */
  156819. confidenceValue: number;
  156820. }
  156821. /**
  156822. * The feature point system is used to detect feature points from real world geometry.
  156823. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  156824. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  156825. */
  156826. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  156827. private _enabled;
  156828. private _featurePointCloud;
  156829. /**
  156830. * The module's name
  156831. */
  156832. static readonly Name: string;
  156833. /**
  156834. * The (Babylon) version of this module.
  156835. * This is an integer representing the implementation version.
  156836. * This number does not correspond to the WebXR specs version
  156837. */
  156838. static readonly Version: number;
  156839. /**
  156840. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  156841. * Will notify the observers about which feature points have been added.
  156842. */
  156843. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  156844. /**
  156845. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  156846. * Will notify the observers about which feature points have been updated.
  156847. */
  156848. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  156849. /**
  156850. * The current feature point cloud maintained across frames.
  156851. */
  156852. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  156853. /**
  156854. * construct the feature point system
  156855. * @param _xrSessionManager an instance of xr Session manager
  156856. */
  156857. constructor(_xrSessionManager: WebXRSessionManager);
  156858. /**
  156859. * Detach this feature.
  156860. * Will usually be called by the features manager
  156861. *
  156862. * @returns true if successful.
  156863. */
  156864. detach(): boolean;
  156865. /**
  156866. * Dispose this feature and all of the resources attached
  156867. */
  156868. dispose(): void;
  156869. /**
  156870. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  156871. */
  156872. protected _onXRFrame(frame: XRFrame): void;
  156873. /**
  156874. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  156875. */
  156876. private _init;
  156877. }
  156878. }
  156879. declare module BABYLON {
  156880. /**
  156881. * Configuration interface for the hand tracking feature
  156882. */
  156883. export interface IWebXRHandTrackingOptions {
  156884. /**
  156885. * The xrInput that will be used as source for new hands
  156886. */
  156887. xrInput: WebXRInput;
  156888. /**
  156889. * Configuration object for the joint meshes
  156890. */
  156891. jointMeshes?: {
  156892. /**
  156893. * Should the meshes created be invisible (defaults to false)
  156894. */
  156895. invisible?: boolean;
  156896. /**
  156897. * A source mesh to be used to create instances. Defaults to a sphere.
  156898. * This mesh will be the source for all other (25) meshes.
  156899. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  156900. */
  156901. sourceMesh?: Mesh;
  156902. /**
  156903. * This function will be called after a mesh was created for a specific joint.
  156904. * Using this function you can either manipulate the instance or return a new mesh.
  156905. * When returning a new mesh the instance created before will be disposed
  156906. */
  156907. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  156908. /**
  156909. * Should the source mesh stay visible. Defaults to false
  156910. */
  156911. keepOriginalVisible?: boolean;
  156912. /**
  156913. * Scale factor for all instances (defaults to 2)
  156914. */
  156915. scaleFactor?: number;
  156916. /**
  156917. * Should each instance have its own physics impostor
  156918. */
  156919. enablePhysics?: boolean;
  156920. /**
  156921. * If enabled, override default physics properties
  156922. */
  156923. physicsProps?: {
  156924. friction?: number;
  156925. restitution?: number;
  156926. impostorType?: number;
  156927. };
  156928. /**
  156929. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  156930. */
  156931. handMesh?: AbstractMesh;
  156932. };
  156933. }
  156934. /**
  156935. * Parts of the hands divided to writs and finger names
  156936. */
  156937. export const enum HandPart {
  156938. /**
  156939. * HandPart - Wrist
  156940. */
  156941. WRIST = "wrist",
  156942. /**
  156943. * HandPart - The THumb
  156944. */
  156945. THUMB = "thumb",
  156946. /**
  156947. * HandPart - Index finger
  156948. */
  156949. INDEX = "index",
  156950. /**
  156951. * HandPart - Middle finger
  156952. */
  156953. MIDDLE = "middle",
  156954. /**
  156955. * HandPart - Ring finger
  156956. */
  156957. RING = "ring",
  156958. /**
  156959. * HandPart - Little finger
  156960. */
  156961. LITTLE = "little"
  156962. }
  156963. /**
  156964. * Representing a single hand (with its corresponding native XRHand object)
  156965. */
  156966. export class WebXRHand implements IDisposable {
  156967. /** the controller to which the hand correlates */
  156968. readonly xrController: WebXRInputSource;
  156969. /** the meshes to be used to track the hand joints */
  156970. readonly trackedMeshes: AbstractMesh[];
  156971. /**
  156972. * Hand-parts definition (key is HandPart)
  156973. */
  156974. handPartsDefinition: {
  156975. [key: string]: number[];
  156976. };
  156977. /**
  156978. * Populate the HandPartsDefinition object.
  156979. * This is called as a side effect since certain browsers don't have XRHand defined.
  156980. */
  156981. private generateHandPartsDefinition;
  156982. /**
  156983. * Construct a new hand object
  156984. * @param xrController the controller to which the hand correlates
  156985. * @param trackedMeshes the meshes to be used to track the hand joints
  156986. */
  156987. constructor(
  156988. /** the controller to which the hand correlates */
  156989. xrController: WebXRInputSource,
  156990. /** the meshes to be used to track the hand joints */
  156991. trackedMeshes: AbstractMesh[]);
  156992. /**
  156993. * Update this hand from the latest xr frame
  156994. * @param xrFrame xrFrame to update from
  156995. * @param referenceSpace The current viewer reference space
  156996. * @param scaleFactor optional scale factor for the meshes
  156997. */
  156998. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  156999. /**
  157000. * Get meshes of part of the hand
  157001. * @param part the part of hand to get
  157002. * @returns An array of meshes that correlate to the hand part requested
  157003. */
  157004. getHandPartMeshes(part: HandPart): AbstractMesh[];
  157005. /**
  157006. * Dispose this Hand object
  157007. */
  157008. dispose(): void;
  157009. }
  157010. /**
  157011. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  157012. */
  157013. export class WebXRHandTracking extends WebXRAbstractFeature {
  157014. /**
  157015. * options to use when constructing this feature
  157016. */
  157017. readonly options: IWebXRHandTrackingOptions;
  157018. private static _idCounter;
  157019. /**
  157020. * The module's name
  157021. */
  157022. static readonly Name: string;
  157023. /**
  157024. * The (Babylon) version of this module.
  157025. * This is an integer representing the implementation version.
  157026. * This number does not correspond to the WebXR specs version
  157027. */
  157028. static readonly Version: number;
  157029. /**
  157030. * This observable will notify registered observers when a new hand object was added and initialized
  157031. */
  157032. onHandAddedObservable: Observable<WebXRHand>;
  157033. /**
  157034. * This observable will notify its observers right before the hand object is disposed
  157035. */
  157036. onHandRemovedObservable: Observable<WebXRHand>;
  157037. private _hands;
  157038. /**
  157039. * Creates a new instance of the hit test feature
  157040. * @param _xrSessionManager an instance of WebXRSessionManager
  157041. * @param options options to use when constructing this feature
  157042. */
  157043. constructor(_xrSessionManager: WebXRSessionManager,
  157044. /**
  157045. * options to use when constructing this feature
  157046. */
  157047. options: IWebXRHandTrackingOptions);
  157048. /**
  157049. * Check if the needed objects are defined.
  157050. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  157051. */
  157052. isCompatible(): boolean;
  157053. /**
  157054. * attach this feature
  157055. * Will usually be called by the features manager
  157056. *
  157057. * @returns true if successful.
  157058. */
  157059. attach(): boolean;
  157060. /**
  157061. * detach this feature.
  157062. * Will usually be called by the features manager
  157063. *
  157064. * @returns true if successful.
  157065. */
  157066. detach(): boolean;
  157067. /**
  157068. * Dispose this feature and all of the resources attached
  157069. */
  157070. dispose(): void;
  157071. /**
  157072. * Get the hand object according to the controller id
  157073. * @param controllerId the controller id to which we want to get the hand
  157074. * @returns null if not found or the WebXRHand object if found
  157075. */
  157076. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  157077. /**
  157078. * Get a hand object according to the requested handedness
  157079. * @param handedness the handedness to request
  157080. * @returns null if not found or the WebXRHand object if found
  157081. */
  157082. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  157083. protected _onXRFrame(_xrFrame: XRFrame): void;
  157084. private _attachHand;
  157085. private _detachHand;
  157086. }
  157087. }
  157088. declare module BABYLON {
  157089. /**
  157090. * The motion controller class for all microsoft mixed reality controllers
  157091. */
  157092. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  157093. protected readonly _mapping: {
  157094. defaultButton: {
  157095. valueNodeName: string;
  157096. unpressedNodeName: string;
  157097. pressedNodeName: string;
  157098. };
  157099. defaultAxis: {
  157100. valueNodeName: string;
  157101. minNodeName: string;
  157102. maxNodeName: string;
  157103. };
  157104. buttons: {
  157105. "xr-standard-trigger": {
  157106. rootNodeName: string;
  157107. componentProperty: string;
  157108. states: string[];
  157109. };
  157110. "xr-standard-squeeze": {
  157111. rootNodeName: string;
  157112. componentProperty: string;
  157113. states: string[];
  157114. };
  157115. "xr-standard-touchpad": {
  157116. rootNodeName: string;
  157117. labelAnchorNodeName: string;
  157118. touchPointNodeName: string;
  157119. };
  157120. "xr-standard-thumbstick": {
  157121. rootNodeName: string;
  157122. componentProperty: string;
  157123. states: string[];
  157124. };
  157125. };
  157126. axes: {
  157127. "xr-standard-touchpad": {
  157128. "x-axis": {
  157129. rootNodeName: string;
  157130. };
  157131. "y-axis": {
  157132. rootNodeName: string;
  157133. };
  157134. };
  157135. "xr-standard-thumbstick": {
  157136. "x-axis": {
  157137. rootNodeName: string;
  157138. };
  157139. "y-axis": {
  157140. rootNodeName: string;
  157141. };
  157142. };
  157143. };
  157144. };
  157145. /**
  157146. * The base url used to load the left and right controller models
  157147. */
  157148. static MODEL_BASE_URL: string;
  157149. /**
  157150. * The name of the left controller model file
  157151. */
  157152. static MODEL_LEFT_FILENAME: string;
  157153. /**
  157154. * The name of the right controller model file
  157155. */
  157156. static MODEL_RIGHT_FILENAME: string;
  157157. profileId: string;
  157158. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  157159. protected _getFilenameAndPath(): {
  157160. filename: string;
  157161. path: string;
  157162. };
  157163. protected _getModelLoadingConstraints(): boolean;
  157164. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157165. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157166. protected _updateModel(): void;
  157167. }
  157168. }
  157169. declare module BABYLON {
  157170. /**
  157171. * The motion controller class for oculus touch (quest, rift).
  157172. * This class supports legacy mapping as well the standard xr mapping
  157173. */
  157174. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  157175. private _forceLegacyControllers;
  157176. private _modelRootNode;
  157177. /**
  157178. * The base url used to load the left and right controller models
  157179. */
  157180. static MODEL_BASE_URL: string;
  157181. /**
  157182. * The name of the left controller model file
  157183. */
  157184. static MODEL_LEFT_FILENAME: string;
  157185. /**
  157186. * The name of the right controller model file
  157187. */
  157188. static MODEL_RIGHT_FILENAME: string;
  157189. /**
  157190. * Base Url for the Quest controller model.
  157191. */
  157192. static QUEST_MODEL_BASE_URL: string;
  157193. profileId: string;
  157194. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  157195. protected _getFilenameAndPath(): {
  157196. filename: string;
  157197. path: string;
  157198. };
  157199. protected _getModelLoadingConstraints(): boolean;
  157200. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157201. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157202. protected _updateModel(): void;
  157203. /**
  157204. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  157205. * between the touch and touch 2.
  157206. */
  157207. private _isQuest;
  157208. }
  157209. }
  157210. declare module BABYLON {
  157211. /**
  157212. * The motion controller class for the standard HTC-Vive controllers
  157213. */
  157214. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  157215. private _modelRootNode;
  157216. /**
  157217. * The base url used to load the left and right controller models
  157218. */
  157219. static MODEL_BASE_URL: string;
  157220. /**
  157221. * File name for the controller model.
  157222. */
  157223. static MODEL_FILENAME: string;
  157224. profileId: string;
  157225. /**
  157226. * Create a new Vive motion controller object
  157227. * @param scene the scene to use to create this controller
  157228. * @param gamepadObject the corresponding gamepad object
  157229. * @param handedness the handedness of the controller
  157230. */
  157231. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  157232. protected _getFilenameAndPath(): {
  157233. filename: string;
  157234. path: string;
  157235. };
  157236. protected _getModelLoadingConstraints(): boolean;
  157237. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157238. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157239. protected _updateModel(): void;
  157240. }
  157241. }
  157242. declare module BABYLON {
  157243. /**
  157244. * A cursor which tracks a point on a path
  157245. */
  157246. export class PathCursor {
  157247. private path;
  157248. /**
  157249. * Stores path cursor callbacks for when an onchange event is triggered
  157250. */
  157251. private _onchange;
  157252. /**
  157253. * The value of the path cursor
  157254. */
  157255. value: number;
  157256. /**
  157257. * The animation array of the path cursor
  157258. */
  157259. animations: Animation[];
  157260. /**
  157261. * Initializes the path cursor
  157262. * @param path The path to track
  157263. */
  157264. constructor(path: Path2);
  157265. /**
  157266. * Gets the cursor point on the path
  157267. * @returns A point on the path cursor at the cursor location
  157268. */
  157269. getPoint(): Vector3;
  157270. /**
  157271. * Moves the cursor ahead by the step amount
  157272. * @param step The amount to move the cursor forward
  157273. * @returns This path cursor
  157274. */
  157275. moveAhead(step?: number): PathCursor;
  157276. /**
  157277. * Moves the cursor behind by the step amount
  157278. * @param step The amount to move the cursor back
  157279. * @returns This path cursor
  157280. */
  157281. moveBack(step?: number): PathCursor;
  157282. /**
  157283. * Moves the cursor by the step amount
  157284. * If the step amount is greater than one, an exception is thrown
  157285. * @param step The amount to move the cursor
  157286. * @returns This path cursor
  157287. */
  157288. move(step: number): PathCursor;
  157289. /**
  157290. * Ensures that the value is limited between zero and one
  157291. * @returns This path cursor
  157292. */
  157293. private ensureLimits;
  157294. /**
  157295. * Runs onchange callbacks on change (used by the animation engine)
  157296. * @returns This path cursor
  157297. */
  157298. private raiseOnChange;
  157299. /**
  157300. * Executes a function on change
  157301. * @param f A path cursor onchange callback
  157302. * @returns This path cursor
  157303. */
  157304. onchange(f: (cursor: PathCursor) => void): PathCursor;
  157305. }
  157306. }
  157307. declare module BABYLON {
  157308. /** @hidden */
  157309. export var blurPixelShader: {
  157310. name: string;
  157311. shader: string;
  157312. };
  157313. }
  157314. declare module BABYLON {
  157315. /** @hidden */
  157316. export var pointCloudVertexDeclaration: {
  157317. name: string;
  157318. shader: string;
  157319. };
  157320. }
  157321. // Mixins
  157322. interface Window {
  157323. mozIndexedDB: IDBFactory;
  157324. webkitIndexedDB: IDBFactory;
  157325. msIndexedDB: IDBFactory;
  157326. webkitURL: typeof URL;
  157327. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  157328. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  157329. WebGLRenderingContext: WebGLRenderingContext;
  157330. MSGesture: MSGesture;
  157331. CANNON: any;
  157332. AudioContext: AudioContext;
  157333. webkitAudioContext: AudioContext;
  157334. PointerEvent: any;
  157335. Math: Math;
  157336. Uint8Array: Uint8ArrayConstructor;
  157337. Float32Array: Float32ArrayConstructor;
  157338. mozURL: typeof URL;
  157339. msURL: typeof URL;
  157340. VRFrameData: any; // WebVR, from specs 1.1
  157341. DracoDecoderModule: any;
  157342. setImmediate(handler: (...args: any[]) => void): number;
  157343. }
  157344. interface HTMLCanvasElement {
  157345. requestPointerLock(): void;
  157346. msRequestPointerLock?(): void;
  157347. mozRequestPointerLock?(): void;
  157348. webkitRequestPointerLock?(): void;
  157349. /** Track wether a record is in progress */
  157350. isRecording: boolean;
  157351. /** Capture Stream method defined by some browsers */
  157352. captureStream(fps?: number): MediaStream;
  157353. }
  157354. interface CanvasRenderingContext2D {
  157355. msImageSmoothingEnabled: boolean;
  157356. }
  157357. interface MouseEvent {
  157358. mozMovementX: number;
  157359. mozMovementY: number;
  157360. webkitMovementX: number;
  157361. webkitMovementY: number;
  157362. msMovementX: number;
  157363. msMovementY: number;
  157364. }
  157365. interface Navigator {
  157366. mozGetVRDevices: (any: any) => any;
  157367. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157368. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157369. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157370. webkitGetGamepads(): Gamepad[];
  157371. msGetGamepads(): Gamepad[];
  157372. webkitGamepads(): Gamepad[];
  157373. }
  157374. interface HTMLVideoElement {
  157375. mozSrcObject: any;
  157376. }
  157377. interface Math {
  157378. fround(x: number): number;
  157379. imul(a: number, b: number): number;
  157380. }
  157381. interface WebGLRenderingContext {
  157382. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  157383. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  157384. vertexAttribDivisor(index: number, divisor: number): void;
  157385. createVertexArray(): any;
  157386. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  157387. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  157388. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  157389. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  157390. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  157391. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  157392. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  157393. // Queries
  157394. createQuery(): WebGLQuery;
  157395. deleteQuery(query: WebGLQuery): void;
  157396. beginQuery(target: number, query: WebGLQuery): void;
  157397. endQuery(target: number): void;
  157398. getQueryParameter(query: WebGLQuery, pname: number): any;
  157399. getQuery(target: number, pname: number): any;
  157400. MAX_SAMPLES: number;
  157401. RGBA8: number;
  157402. READ_FRAMEBUFFER: number;
  157403. DRAW_FRAMEBUFFER: number;
  157404. UNIFORM_BUFFER: number;
  157405. HALF_FLOAT_OES: number;
  157406. RGBA16F: number;
  157407. RGBA32F: number;
  157408. R32F: number;
  157409. RG32F: number;
  157410. RGB32F: number;
  157411. R16F: number;
  157412. RG16F: number;
  157413. RGB16F: number;
  157414. RED: number;
  157415. RG: number;
  157416. R8: number;
  157417. RG8: number;
  157418. UNSIGNED_INT_24_8: number;
  157419. DEPTH24_STENCIL8: number;
  157420. MIN: number;
  157421. MAX: number;
  157422. /* Multiple Render Targets */
  157423. drawBuffers(buffers: number[]): void;
  157424. readBuffer(src: number): void;
  157425. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  157426. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  157427. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  157428. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  157429. // Occlusion Query
  157430. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  157431. ANY_SAMPLES_PASSED: number;
  157432. QUERY_RESULT_AVAILABLE: number;
  157433. QUERY_RESULT: number;
  157434. }
  157435. interface WebGLProgram {
  157436. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  157437. }
  157438. interface EXT_disjoint_timer_query {
  157439. QUERY_COUNTER_BITS_EXT: number;
  157440. TIME_ELAPSED_EXT: number;
  157441. TIMESTAMP_EXT: number;
  157442. GPU_DISJOINT_EXT: number;
  157443. QUERY_RESULT_EXT: number;
  157444. QUERY_RESULT_AVAILABLE_EXT: number;
  157445. queryCounterEXT(query: WebGLQuery, target: number): void;
  157446. createQueryEXT(): WebGLQuery;
  157447. beginQueryEXT(target: number, query: WebGLQuery): void;
  157448. endQueryEXT(target: number): void;
  157449. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  157450. deleteQueryEXT(query: WebGLQuery): void;
  157451. }
  157452. interface WebGLUniformLocation {
  157453. _currentState: any;
  157454. }
  157455. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  157456. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  157457. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  157458. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  157459. interface WebGLRenderingContext {
  157460. readonly RASTERIZER_DISCARD: number;
  157461. readonly DEPTH_COMPONENT24: number;
  157462. readonly TEXTURE_3D: number;
  157463. readonly TEXTURE_2D_ARRAY: number;
  157464. readonly TEXTURE_COMPARE_FUNC: number;
  157465. readonly TEXTURE_COMPARE_MODE: number;
  157466. readonly COMPARE_REF_TO_TEXTURE: number;
  157467. readonly TEXTURE_WRAP_R: number;
  157468. readonly HALF_FLOAT: number;
  157469. readonly RGB8: number;
  157470. readonly RED_INTEGER: number;
  157471. readonly RG_INTEGER: number;
  157472. readonly RGB_INTEGER: number;
  157473. readonly RGBA_INTEGER: number;
  157474. readonly R8_SNORM: number;
  157475. readonly RG8_SNORM: number;
  157476. readonly RGB8_SNORM: number;
  157477. readonly RGBA8_SNORM: number;
  157478. readonly R8I: number;
  157479. readonly RG8I: number;
  157480. readonly RGB8I: number;
  157481. readonly RGBA8I: number;
  157482. readonly R8UI: number;
  157483. readonly RG8UI: number;
  157484. readonly RGB8UI: number;
  157485. readonly RGBA8UI: number;
  157486. readonly R16I: number;
  157487. readonly RG16I: number;
  157488. readonly RGB16I: number;
  157489. readonly RGBA16I: number;
  157490. readonly R16UI: number;
  157491. readonly RG16UI: number;
  157492. readonly RGB16UI: number;
  157493. readonly RGBA16UI: number;
  157494. readonly R32I: number;
  157495. readonly RG32I: number;
  157496. readonly RGB32I: number;
  157497. readonly RGBA32I: number;
  157498. readonly R32UI: number;
  157499. readonly RG32UI: number;
  157500. readonly RGB32UI: number;
  157501. readonly RGBA32UI: number;
  157502. readonly RGB10_A2UI: number;
  157503. readonly R11F_G11F_B10F: number;
  157504. readonly RGB9_E5: number;
  157505. readonly RGB10_A2: number;
  157506. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  157507. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  157508. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  157509. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  157510. readonly DEPTH_COMPONENT32F: number;
  157511. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  157512. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  157513. 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;
  157514. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  157515. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  157516. readonly TRANSFORM_FEEDBACK: number;
  157517. readonly INTERLEAVED_ATTRIBS: number;
  157518. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  157519. createTransformFeedback(): WebGLTransformFeedback;
  157520. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  157521. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  157522. beginTransformFeedback(primitiveMode: number): void;
  157523. endTransformFeedback(): void;
  157524. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  157525. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157526. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157527. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157528. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  157529. }
  157530. interface ImageBitmap {
  157531. readonly width: number;
  157532. readonly height: number;
  157533. close(): void;
  157534. }
  157535. interface WebGLQuery extends WebGLObject {
  157536. }
  157537. declare var WebGLQuery: {
  157538. prototype: WebGLQuery;
  157539. new(): WebGLQuery;
  157540. };
  157541. interface WebGLSampler extends WebGLObject {
  157542. }
  157543. declare var WebGLSampler: {
  157544. prototype: WebGLSampler;
  157545. new(): WebGLSampler;
  157546. };
  157547. interface WebGLSync extends WebGLObject {
  157548. }
  157549. declare var WebGLSync: {
  157550. prototype: WebGLSync;
  157551. new(): WebGLSync;
  157552. };
  157553. interface WebGLTransformFeedback extends WebGLObject {
  157554. }
  157555. declare var WebGLTransformFeedback: {
  157556. prototype: WebGLTransformFeedback;
  157557. new(): WebGLTransformFeedback;
  157558. };
  157559. interface WebGLVertexArrayObject extends WebGLObject {
  157560. }
  157561. declare var WebGLVertexArrayObject: {
  157562. prototype: WebGLVertexArrayObject;
  157563. new(): WebGLVertexArrayObject;
  157564. };
  157565. // Type definitions for WebVR API
  157566. // Project: https://w3c.github.io/webvr/
  157567. // Definitions by: six a <https://github.com/lostfictions>
  157568. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  157569. interface VRDisplay extends EventTarget {
  157570. /**
  157571. * Dictionary of capabilities describing the VRDisplay.
  157572. */
  157573. readonly capabilities: VRDisplayCapabilities;
  157574. /**
  157575. * z-depth defining the far plane of the eye view frustum
  157576. * enables mapping of values in the render target depth
  157577. * attachment to scene coordinates. Initially set to 10000.0.
  157578. */
  157579. depthFar: number;
  157580. /**
  157581. * z-depth defining the near plane of the eye view frustum
  157582. * enables mapping of values in the render target depth
  157583. * attachment to scene coordinates. Initially set to 0.01.
  157584. */
  157585. depthNear: number;
  157586. /**
  157587. * An identifier for this distinct VRDisplay. Used as an
  157588. * association point in the Gamepad API.
  157589. */
  157590. readonly displayId: number;
  157591. /**
  157592. * A display name, a user-readable name identifying it.
  157593. */
  157594. readonly displayName: string;
  157595. readonly isConnected: boolean;
  157596. readonly isPresenting: boolean;
  157597. /**
  157598. * If this VRDisplay supports room-scale experiences, the optional
  157599. * stage attribute contains details on the room-scale parameters.
  157600. */
  157601. readonly stageParameters: VRStageParameters | null;
  157602. /**
  157603. * Passing the value returned by `requestAnimationFrame` to
  157604. * `cancelAnimationFrame` will unregister the callback.
  157605. * @param handle Define the hanle of the request to cancel
  157606. */
  157607. cancelAnimationFrame(handle: number): void;
  157608. /**
  157609. * Stops presenting to the VRDisplay.
  157610. * @returns a promise to know when it stopped
  157611. */
  157612. exitPresent(): Promise<void>;
  157613. /**
  157614. * Return the current VREyeParameters for the given eye.
  157615. * @param whichEye Define the eye we want the parameter for
  157616. * @returns the eye parameters
  157617. */
  157618. getEyeParameters(whichEye: string): VREyeParameters;
  157619. /**
  157620. * Populates the passed VRFrameData with the information required to render
  157621. * the current frame.
  157622. * @param frameData Define the data structure to populate
  157623. * @returns true if ok otherwise false
  157624. */
  157625. getFrameData(frameData: VRFrameData): boolean;
  157626. /**
  157627. * Get the layers currently being presented.
  157628. * @returns the list of VR layers
  157629. */
  157630. getLayers(): VRLayer[];
  157631. /**
  157632. * Return a VRPose containing the future predicted pose of the VRDisplay
  157633. * when the current frame will be presented. The value returned will not
  157634. * change until JavaScript has returned control to the browser.
  157635. *
  157636. * The VRPose will contain the position, orientation, velocity,
  157637. * and acceleration of each of these properties.
  157638. * @returns the pose object
  157639. */
  157640. getPose(): VRPose;
  157641. /**
  157642. * Return the current instantaneous pose of the VRDisplay, with no
  157643. * prediction applied.
  157644. * @returns the current instantaneous pose
  157645. */
  157646. getImmediatePose(): VRPose;
  157647. /**
  157648. * The callback passed to `requestAnimationFrame` will be called
  157649. * any time a new frame should be rendered. When the VRDisplay is
  157650. * presenting the callback will be called at the native refresh
  157651. * rate of the HMD. When not presenting this function acts
  157652. * identically to how window.requestAnimationFrame acts. Content should
  157653. * make no assumptions of frame rate or vsync behavior as the HMD runs
  157654. * asynchronously from other displays and at differing refresh rates.
  157655. * @param callback Define the eaction to run next frame
  157656. * @returns the request handle it
  157657. */
  157658. requestAnimationFrame(callback: FrameRequestCallback): number;
  157659. /**
  157660. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  157661. * Repeat calls while already presenting will update the VRLayers being displayed.
  157662. * @param layers Define the list of layer to present
  157663. * @returns a promise to know when the request has been fulfilled
  157664. */
  157665. requestPresent(layers: VRLayer[]): Promise<void>;
  157666. /**
  157667. * Reset the pose for this display, treating its current position and
  157668. * orientation as the "origin/zero" values. VRPose.position,
  157669. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  157670. * updated when calling resetPose(). This should be called in only
  157671. * sitting-space experiences.
  157672. */
  157673. resetPose(): void;
  157674. /**
  157675. * The VRLayer provided to the VRDisplay will be captured and presented
  157676. * in the HMD. Calling this function has the same effect on the source
  157677. * canvas as any other operation that uses its source image, and canvases
  157678. * created without preserveDrawingBuffer set to true will be cleared.
  157679. * @param pose Define the pose to submit
  157680. */
  157681. submitFrame(pose?: VRPose): void;
  157682. }
  157683. declare var VRDisplay: {
  157684. prototype: VRDisplay;
  157685. new(): VRDisplay;
  157686. };
  157687. interface VRLayer {
  157688. leftBounds?: number[] | Float32Array | null;
  157689. rightBounds?: number[] | Float32Array | null;
  157690. source?: HTMLCanvasElement | null;
  157691. }
  157692. interface VRDisplayCapabilities {
  157693. readonly canPresent: boolean;
  157694. readonly hasExternalDisplay: boolean;
  157695. readonly hasOrientation: boolean;
  157696. readonly hasPosition: boolean;
  157697. readonly maxLayers: number;
  157698. }
  157699. interface VREyeParameters {
  157700. /** @deprecated */
  157701. readonly fieldOfView: VRFieldOfView;
  157702. readonly offset: Float32Array;
  157703. readonly renderHeight: number;
  157704. readonly renderWidth: number;
  157705. }
  157706. interface VRFieldOfView {
  157707. readonly downDegrees: number;
  157708. readonly leftDegrees: number;
  157709. readonly rightDegrees: number;
  157710. readonly upDegrees: number;
  157711. }
  157712. interface VRFrameData {
  157713. readonly leftProjectionMatrix: Float32Array;
  157714. readonly leftViewMatrix: Float32Array;
  157715. readonly pose: VRPose;
  157716. readonly rightProjectionMatrix: Float32Array;
  157717. readonly rightViewMatrix: Float32Array;
  157718. readonly timestamp: number;
  157719. }
  157720. interface VRPose {
  157721. readonly angularAcceleration: Float32Array | null;
  157722. readonly angularVelocity: Float32Array | null;
  157723. readonly linearAcceleration: Float32Array | null;
  157724. readonly linearVelocity: Float32Array | null;
  157725. readonly orientation: Float32Array | null;
  157726. readonly position: Float32Array | null;
  157727. readonly timestamp: number;
  157728. }
  157729. interface VRStageParameters {
  157730. sittingToStandingTransform?: Float32Array;
  157731. sizeX?: number;
  157732. sizeY?: number;
  157733. }
  157734. interface Navigator {
  157735. getVRDisplays(): Promise<VRDisplay[]>;
  157736. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  157737. }
  157738. interface Window {
  157739. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  157740. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  157741. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  157742. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157743. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157744. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  157745. }
  157746. interface Gamepad {
  157747. readonly displayId: number;
  157748. }
  157749. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  157750. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  157751. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  157752. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  157753. type XRHandedness = "none" | "left" | "right";
  157754. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  157755. type XREye = "none" | "left" | "right";
  157756. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  157757. interface XRSpace extends EventTarget {}
  157758. interface XRRenderState {
  157759. depthNear?: number;
  157760. depthFar?: number;
  157761. inlineVerticalFieldOfView?: number;
  157762. baseLayer?: XRWebGLLayer;
  157763. }
  157764. interface XRInputSource {
  157765. handedness: XRHandedness;
  157766. targetRayMode: XRTargetRayMode;
  157767. targetRaySpace: XRSpace;
  157768. gripSpace: XRSpace | undefined;
  157769. gamepad: Gamepad | undefined;
  157770. profiles: Array<string>;
  157771. hand: XRHand | undefined;
  157772. }
  157773. interface XRSessionInit {
  157774. optionalFeatures?: string[];
  157775. requiredFeatures?: string[];
  157776. }
  157777. interface XRSession {
  157778. addEventListener: Function;
  157779. removeEventListener: Function;
  157780. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  157781. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  157782. requestAnimationFrame: Function;
  157783. end(): Promise<void>;
  157784. renderState: XRRenderState;
  157785. inputSources: Array<XRInputSource>;
  157786. // hit test
  157787. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  157788. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  157789. // legacy AR hit test
  157790. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  157791. // legacy plane detection
  157792. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  157793. }
  157794. interface XRReferenceSpace extends XRSpace {
  157795. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  157796. onreset: any;
  157797. }
  157798. type XRPlaneSet = Set<XRPlane>;
  157799. type XRAnchorSet = Set<XRAnchor>;
  157800. interface XRFrame {
  157801. session: XRSession;
  157802. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  157803. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  157804. // AR
  157805. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  157806. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  157807. // Anchors
  157808. trackedAnchors?: XRAnchorSet;
  157809. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  157810. // Planes
  157811. worldInformation: {
  157812. detectedPlanes?: XRPlaneSet;
  157813. };
  157814. // Hand tracking
  157815. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  157816. }
  157817. interface XRViewerPose extends XRPose {
  157818. views: Array<XRView>;
  157819. }
  157820. interface XRPose {
  157821. transform: XRRigidTransform;
  157822. emulatedPosition: boolean;
  157823. }
  157824. interface XRWebGLLayerOptions {
  157825. antialias?: boolean;
  157826. depth?: boolean;
  157827. stencil?: boolean;
  157828. alpha?: boolean;
  157829. multiview?: boolean;
  157830. framebufferScaleFactor?: number;
  157831. }
  157832. declare var XRWebGLLayer: {
  157833. prototype: XRWebGLLayer;
  157834. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  157835. };
  157836. interface XRWebGLLayer {
  157837. framebuffer: WebGLFramebuffer;
  157838. framebufferWidth: number;
  157839. framebufferHeight: number;
  157840. getViewport: Function;
  157841. }
  157842. declare class XRRigidTransform {
  157843. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  157844. position: DOMPointReadOnly;
  157845. orientation: DOMPointReadOnly;
  157846. matrix: Float32Array;
  157847. inverse: XRRigidTransform;
  157848. }
  157849. interface XRView {
  157850. eye: XREye;
  157851. projectionMatrix: Float32Array;
  157852. transform: XRRigidTransform;
  157853. }
  157854. interface XRInputSourceChangeEvent {
  157855. session: XRSession;
  157856. removed: Array<XRInputSource>;
  157857. added: Array<XRInputSource>;
  157858. }
  157859. interface XRInputSourceEvent extends Event {
  157860. readonly frame: XRFrame;
  157861. readonly inputSource: XRInputSource;
  157862. }
  157863. // Experimental(er) features
  157864. declare class XRRay {
  157865. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  157866. origin: DOMPointReadOnly;
  157867. direction: DOMPointReadOnly;
  157868. matrix: Float32Array;
  157869. }
  157870. declare enum XRHitTestTrackableType {
  157871. "point",
  157872. "plane",
  157873. "mesh",
  157874. }
  157875. interface XRHitResult {
  157876. hitMatrix: Float32Array;
  157877. }
  157878. interface XRTransientInputHitTestResult {
  157879. readonly inputSource: XRInputSource;
  157880. readonly results: Array<XRHitTestResult>;
  157881. }
  157882. interface XRHitTestResult {
  157883. getPose(baseSpace: XRSpace): XRPose | undefined;
  157884. // When anchor system is enabled
  157885. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  157886. }
  157887. interface XRHitTestSource {
  157888. cancel(): void;
  157889. }
  157890. interface XRTransientInputHitTestSource {
  157891. cancel(): void;
  157892. }
  157893. interface XRHitTestOptionsInit {
  157894. space: XRSpace;
  157895. entityTypes?: Array<XRHitTestTrackableType>;
  157896. offsetRay?: XRRay;
  157897. }
  157898. interface XRTransientInputHitTestOptionsInit {
  157899. profile: string;
  157900. entityTypes?: Array<XRHitTestTrackableType>;
  157901. offsetRay?: XRRay;
  157902. }
  157903. interface XRAnchor {
  157904. anchorSpace: XRSpace;
  157905. delete(): void;
  157906. }
  157907. interface XRPlane {
  157908. orientation: "Horizontal" | "Vertical";
  157909. planeSpace: XRSpace;
  157910. polygon: Array<DOMPointReadOnly>;
  157911. lastChangedTime: number;
  157912. }
  157913. interface XRJointSpace extends XRSpace {}
  157914. interface XRJointPose extends XRPose {
  157915. radius: number | undefined;
  157916. }
  157917. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  157918. readonly length: number;
  157919. [index: number]: XRJointSpace;
  157920. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  157921. readonly WRIST: number;
  157922. readonly THUMB_METACARPAL: number;
  157923. readonly THUMB_PHALANX_PROXIMAL: number;
  157924. readonly THUMB_PHALANX_DISTAL: number;
  157925. readonly THUMB_PHALANX_TIP: number;
  157926. readonly INDEX_METACARPAL: number;
  157927. readonly INDEX_PHALANX_PROXIMAL: number;
  157928. readonly INDEX_PHALANX_INTERMEDIATE: number;
  157929. readonly INDEX_PHALANX_DISTAL: number;
  157930. readonly INDEX_PHALANX_TIP: number;
  157931. readonly MIDDLE_METACARPAL: number;
  157932. readonly MIDDLE_PHALANX_PROXIMAL: number;
  157933. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  157934. readonly MIDDLE_PHALANX_DISTAL: number;
  157935. readonly MIDDLE_PHALANX_TIP: number;
  157936. readonly RING_METACARPAL: number;
  157937. readonly RING_PHALANX_PROXIMAL: number;
  157938. readonly RING_PHALANX_INTERMEDIATE: number;
  157939. readonly RING_PHALANX_DISTAL: number;
  157940. readonly RING_PHALANX_TIP: number;
  157941. readonly LITTLE_METACARPAL: number;
  157942. readonly LITTLE_PHALANX_PROXIMAL: number;
  157943. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  157944. readonly LITTLE_PHALANX_DISTAL: number;
  157945. readonly LITTLE_PHALANX_TIP: number;
  157946. }
  157947. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  157948. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  157949. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  157950. interface XRSession {
  157951. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  157952. }
  157953. interface XRFrame {
  157954. featurePointCloud? : Array<number>;
  157955. }